🚀 Username Generator API Documentation

Endpoint

POST /generator.php

Available Categories

Parameters

Parameter Type Description Default Required
namestringUser's name (optional)""No
intereststringInterest categoryrandomNo
favstringFavorite word to include""No
minintegerMinimum username length6No
maxintegerMaximum username length16No
number0 or 1Include numbers1No
underscore0 or 1Use underscore separator1No

Example Usage (PHP)

<?php
$data = http_build_query([
  'name' => 'john',
  'interest' => 'coder',
  'fav' => 'dragon',
  'min' => 6,
  'max' => 20,
  'number' => 0,
  'underscore' => 0
]);
$opts = ['http' => [
  'method'  => 'POST',
  'header'  => 
    "Content-type: application/x-www-form-urlencoded\r\n" .
    "User-Agent: RandomUsernameDocs/1.0 (+https://www.randomusername.net)\r\n",
  'content' => $data
]];
$context = stream_context_create($opts);
$response = file_get_contents('https://www.randomusername.net/generator.php', false, $context);
$result = json_decode($response, true);
print_r($result);
?>

Example Usage (JavaScript)

fetch('https://www.randomusername.net/generator.php', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'User-Agent': 'RandomUsernameDocs/1.0 (+https://www.randomusername.net)'
  },
  body: new URLSearchParams({
    name: 'john',
    interest: 'coder',
    fav: 'dragon',
    min: '6',
    max: '20',
    number: '0',
    underscore: '0'
  })
})
.then(res => res.json())
.then(data => console.log(data))
.catch(console.error);