🚀 Username Generator API Documentation
Endpoint
POST /generator.php
Available Categories
- gamer
- coder
- music
- anime
- fitness
- scifi
- mind
- finance
- fantasy
- startup
- default
Parameters
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
name | string | User's name (optional) | "" | No |
interest | string | Interest category | random | No |
fav | string | Favorite word to include | "" | No |
min | integer | Minimum username length | 6 | No |
max | integer | Maximum username length | 16 | No |
number | 0 or 1 | Include numbers | 1 | No |
underscore | 0 or 1 | Use underscore separator | 1 | No |
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);