🚀 Username Generator API

API reference for developers using the Random Username Generator. Integrate unique username ideas into your app, onboarding flow, or tools.

Endpoint

POST /api/fetch_username.php

Note: This acts as a proxy to the main generation engine to avoid CORS and rate limits.

Available Categories

gamer coder music anime fitness scifi mind finance fantasy startup default random

Parameters

Parameter Type Description Default
namestringUser's real name (optional)""
intereststringCategory/Interest (see above)random
stylestringSub-style (e.g., cool, kawaii, brandable)""
favstringFavorite word to include""
minintegerMinimum username length6
maxintegerMaximum username length16
number0 or 1Include numbers at the end1
underscore0 or 1Use underscore separators1

Example Usage (JavaScript)

fetch('/api/fetch_username.php', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  body: new URLSearchParams({
    interest: 'coder',
    style: 'tech',
    fav: 'dragon',
    min: '6',
    max: '16',
    number: '0',
    underscore: '1'
  })
})
.then(res => res.json())
.then(data => console.log(data.usernames))
.catch(console.error);

Example Usage (PHP)

<?php
$data = http_build_query([
  'interest' => 'coder',
  'style' => 'tech',
  'fav' => 'dragon',
  'min' => 6,
  'max' => 20,
  'number' => 0,
  'underscore' => 1
]);

$opts = ['http' => [
  'method'  => 'POST',
  'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
  'content' => $data
]];

$context = stream_context_create($opts);
$response = file_get_contents('https://www.randomusername.com/api/fetch_username.php', false, $context);
$result = json_decode($response, true);
print_r($result['usernames']);
?>