# Username search

> POST /username asks the official public API of each platform whether a username is taken, and returns found, not_found or unknown per platform with the profile URL.

`POST https://api.qelka.com/v1/username`

Find out where a username is taken: the API asks the official public API of 17 developer and social platforms, in parallel, whether an account with that exact name exists. Each platform answers `found`, `not_found` or `unknown`, never a guess. A lookup costs 2 credits when at least one platform answered; when none did, it is free.

## Request

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `username` | string | Yes | none | The username, 1 to 64 letters, digits, dots, underscores or hyphens, with an optional leading `@`. |
| `platforms` | array of strings | No | every platform | Only check these platforms: `github`, `gitlab`, `bitbucket`, `codeberg`, `bluesky`, `mastodon`, `hackernews`, `devto`, `npm`, `dockerhub`, `rubygems`, `huggingface`, `keybase`, `gravatar`, `wikipedia`, `lichess` or `codewars`. The price is the same. |
| `fresh` | boolean | No | `false` | `true` skips the 24-hour result cache and asks every platform again. |

Each platform is asked with a 5-second limit, all at the same time, so every snippet sets a 30-second client timeout.

```bash title="cURL"
curl https://api.qelka.com/v1/username \
  --max-time 30 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"username": "torvalds"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/username', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ username: 'torvalds' }),
  signal: AbortSignal.timeout(30_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/username",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"username": "torvalds"},
    timeout=30,
)
result = response.json()
print(result)
```
```php title="PHP"
<?php
$ch = curl_init('https://api.qelka.com/v1/username');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('QELKA_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode(['username' => 'torvalds']),
    CURLOPT_TIMEOUT => 30,
]);
$result = json_decode(curl_exec($ch), true);
print_r($result);
```
```go title="Go"
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"time"
)

func main() {
	payload, _ := json.Marshal(map[string]any{"username": "torvalds"})
	request, _ := http.NewRequest(http.MethodPost, "https://api.qelka.com/v1/username", bytes.NewReader(payload))
	request.Header.Set("Authorization", "Bearer "+os.Getenv("QELKA_API_KEY"))
	request.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	var result map[string]any
	if err := json.NewDecoder(response.Body).Decode(&result); err != nil {
		panic(err)
	}
	fmt.Println(result)
}
```
```ruby title="Ruby"
require 'json'
require 'net/http'

uri = URI('https://api.qelka.com/v1/username')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{ENV.fetch('QELKA_API_KEY')}"
request['Content-Type'] = 'application/json'
request.body = JSON.generate({ username: 'torvalds' })

response = Net::HTTP.start(uri.host, uri.port, use_ssl: true, read_timeout: 30) do |http|
  http.request(request)
end
result = JSON.parse(response.body)
puts result
```

## Response

Read `status` first: `ok` means at least one platform gave a clear answer. Then read each entry of `platforms`.

| Field | Type | Description |
|---|---|---|
| `id` | string | Identifier of this lookup: `lkp_` followed by 26 characters. |
| `object` | string | Always `username`. |
| `input` | string | The `username` you sent, without surrounding spaces. |
| `username` | string | The username that was checked, without a leading `@`. |
| `status` | string | `ok` when at least one platform answered `found` or `not_found`, `unavailable` when none did. |
| `found` | integer | Number of platforms with an account of this name. |
| `not_found` | integer | Number of platforms without one. |
| `unknown` | integer | Number of platforms that did not answer usefully. |
| `platforms` | array of objects | One entry per platform checked, in the order of the platform list. |
| `platforms.platform` | string | The platform id, such as `github`. |
| `platforms.name` | string | The display name of the platform, such as `GitHub`. |
| `platforms.status` | string | `found`, `not_found` or `unknown`. |
| `platforms.url` | string or null | The public profile URL when `status` is `found`, else `null`. |
| `platforms.reason` | string or null | `invalid_format` when the name breaks the platform's username rules (the platform is not asked and the status is `not_found`); `rate_limited`, `timeout` or `unavailable` when the status is `unknown`; else `null`. |
| `credits_used` | integer | Credits debited for this call: 2 when `status` is `ok` with a live key, else `0`. |
| `cached` | boolean | `true` when the answer came from the 24-hour cache. |

```json title="Response"
{
  "id": "lkp_01M8CEGA5P3M2FG6WEQPX6BBCC",
  "object": "username",
  "input": "torvalds",
  "username": "torvalds",
  "status": "ok",
  "found": 12,
  "not_found": 5,
  "unknown": 0,
  "platforms": [
    { "platform": "github", "name": "GitHub", "status": "found", "url": "https://github.com/torvalds", "reason": null },
    { "platform": "gitlab", "name": "GitLab", "status": "not_found", "url": null, "reason": null },
    { "platform": "bitbucket", "name": "Bitbucket", "status": "found", "url": "https://bitbucket.org/torvalds/", "reason": null },
    { "platform": "codeberg", "name": "Codeberg", "status": "not_found", "url": null, "reason": null },
    { "platform": "bluesky", "name": "Bluesky", "status": "found", "url": "https://bsky.app/profile/torvalds.bsky.social", "reason": null },
    { "platform": "mastodon", "name": "Mastodon", "status": "found", "url": "https://mastodon.social/@Torvalds", "reason": null },
    { "platform": "hackernews", "name": "Hacker News", "status": "not_found", "url": null, "reason": null },
    { "platform": "devto", "name": "DEV", "status": "not_found", "url": null, "reason": null },
    { "platform": "npm", "name": "npm", "status": "found", "url": "https://www.npmjs.com/~torvalds", "reason": null },
    { "platform": "dockerhub", "name": "Docker Hub", "status": "found", "url": "https://hub.docker.com/u/torvalds", "reason": null },
    { "platform": "rubygems", "name": "RubyGems", "status": "found", "url": "https://rubygems.org/profiles/torvalds", "reason": null },
    { "platform": "huggingface", "name": "Hugging Face", "status": "found", "url": "https://huggingface.co/torvalds", "reason": null },
    { "platform": "keybase", "name": "Keybase", "status": "found", "url": "https://keybase.io/torvalds", "reason": null },
    { "platform": "gravatar", "name": "Gravatar", "status": "not_found", "url": null, "reason": null },
    { "platform": "wikipedia", "name": "Wikipedia", "status": "found", "url": "https://en.wikipedia.org/wiki/User:Torvalds", "reason": null },
    { "platform": "lichess", "name": "Lichess", "status": "found", "url": "https://lichess.org/@/Torvalds", "reason": null },
    { "platform": "codewars", "name": "Codewars", "status": "found", "url": "https://www.codewars.com/users/torvalds", "reason": null }
  ],
  "credits_used": 2,
  "cached": false
}
```

## Act on the status

| `platforms.status` | What it means | What to do |
|---|---|---|
| `found` | The platform's API says an account with this name exists. | Open `url` to see the profile. The same name on two platforms does not prove that one person owns both. |
| `not_found` | The API says no account has this name, or the name breaks the platform's rules (`reason: "invalid_format"`). | The name is probably free there, but platforms can reserve names or keep those of deleted accounts. |
| `unknown` | The platform timed out, rate limited the request or answered something unexpected. | Ask again later with `"fresh": true`. Never read `unknown` as free or taken. |

A lookup with `status` `unavailable` costs 0. Results are cached 24 hours only when every platform answered; a result with an `unknown` entry is never cached, so the next request asks again.

## Which platforms are checked

| Platform | How it is asked |
|---|---|
| GitHub | GitHub REST API, `GET /users/{username}` |
| GitLab | GitLab REST API, `GET /api/v4/users?username=` |
| Bitbucket | Bitbucket Cloud REST API, `GET /2.0/workspaces/{username}` |
| Codeberg | Forgejo API, `GET /api/v1/users/{username}` |
| Bluesky | AppView API `app.bsky.actor.getProfile`, for the handle `{username}.bsky.social` |
| Mastodon | Account lookup API of mastodon.social |
| Hacker News | Hacker News API on Firebase |
| DEV | Forem API, `GET /api/users/by_username` |
| npm | npm registry, packages of the user |
| Docker Hub | Docker Hub API, `GET /v2/users/{username}/` |
| RubyGems | RubyGems API, `GET /api/v1/profiles/{username}.json` |
| Hugging Face | Hugging Face Hub API, `GET /api/users/{username}/overview` |
| Keybase | Keybase API, `user/lookup.json` |
| Gravatar | Gravatar REST API, `GET /v3/profiles/{username}` |
| Wikipedia | MediaWiki API of English Wikipedia, `list=users` |
| Lichess | Lichess API, `GET /api/user/{username}` |
| Codewars | Codewars API, `GET /api/v1/users/{username}` |

Only official APIs and public endpoints whose terms allow automated access are used. Instagram, X, TikTok, Facebook and LinkedIn are not checked: they offer no public way to look up an account without signing in, and their terms forbid automated access to their pages. The API never signs in, scrapes profile pages or probes sign-up and password reset forms to detect an account.

## What the API keeps

The API asks each platform only whether an account exists and keeps the public profile URL it builds from the answer. The request log keeps the username masked. A username can identify a person: use the results for purposes the people concerned would expect, such as checking a name before you register it.

## Examples

### Check a few platforms with a test key

Test keys return a simulated answer without calling any platform. With a test key in `QELKA_API_KEY`, this request returns:

```bash title="cURL"
curl https://api.qelka.com/v1/username \
  --max-time 30 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"username": "example", "platforms": ["github", "npm", "bluesky"]}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/username', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ username: 'example', platforms: ['github', 'npm', 'bluesky'] }),
  signal: AbortSignal.timeout(30_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/username",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"username": "example", "platforms": ["github", "npm", "bluesky"]},
    timeout=30,
)
result = response.json()
print(result)
```

```json title="Response"
{
  "id": "lkp_01M8CH2QK7V3XDRM9TB4N6WFZA",
  "object": "username",
  "input": "example",
  "username": "example",
  "status": "ok",
  "found": 2,
  "not_found": 1,
  "unknown": 0,
  "platforms": [
    { "platform": "github", "name": "GitHub", "status": "found", "url": "https://github.com/example", "reason": null },
    { "platform": "bluesky", "name": "Bluesky", "status": "found", "url": "https://bsky.app/profile/example.bsky.social", "reason": null },
    { "platform": "npm", "name": "npm", "status": "not_found", "url": null, "reason": null }
  ],
  "credits_used": 0,
  "cached": false
}
```

## Errors

| Status | Type | When |
|---|---|---|
| 400 | [invalid_request](https://qelka.com/docs/errors#invalid_request) | `username` is missing, empty or longer than 64 characters, `platforms` is empty or names an unknown platform, the body is not a JSON object, or it has a field the request table does not list |
| 401 | [invalid_api_key](https://qelka.com/docs/errors#invalid_api_key) | The key is missing, unknown or revoked |
| 402 | [insufficient_credits](https://qelka.com/docs/errors#insufficient_credits) | Your balance is less than 2 credits (live keys only) |
| 403 | [forbidden](https://qelka.com/docs/errors#forbidden) | The key is restricted to other endpoints |
| 405 | [invalid_request](https://qelka.com/docs/errors#invalid_request) | The method is not `POST` |
| 422 | [unprocessable_input](https://qelka.com/docs/errors#unprocessable_input) | `username` has characters other than letters, digits, dots, underscores and hyphens |
| 429 | [rate_limited](https://qelka.com/docs/errors#rate_limited) | Too many requests: wait `Retry-After` seconds |
| 500 | [internal_error](https://qelka.com/docs/errors#internal_error) | Unexpected error on our side: retry with backoff |

No error is billed. A username no platform answered is not an error: it is a `200` with `status` `unavailable` and `credits_used: 0`.

## Related

- [Username search API](https://qelka.com/products/username-search)
- Free tool: [username checker](https://qelka.com/tools/username-checker)
- [Social profile](https://qelka.com/docs/api-reference/social-profile): the full public profile of a GitHub, Bluesky or Mastodon account
- [Batch](https://qelka.com/docs/api-reference/batch): up to 100 usernames in one call, each item with `type: "username"`
- [Bulk](https://qelka.com/docs/api-reference/bulk): a whole column of usernames with `type=username`
- [Caching](https://qelka.com/docs/caching), [Errors](https://qelka.com/docs/errors), [Test mode](https://qelka.com/docs/test-mode)
