Docs
Usernames to IDs

Usernames to IDs

Numeric user IDs for up to 100 handles in one call.

GET/user/usernames/to/ids

Parameters

  • usernamesquery · string (comma-separated) · required

    Handles separated by commas, with or without @. At most 100.

Example request

curl 'https://api.twittrapi.com/user/usernames/to/ids?usernames=jack,XDevelopers' \
  --header 'X-API-KEY: YOUR_API_KEY'

Base URL https://api.twittrapi.com, key in the X-API-KEY header. Python and Node.js use the official SDKs.

Response

Built by the API: {"userIds": {"jack": "12", ...}}. Only resolved handles are keys of userIds. A handle that could not be resolved is left out of userIds and listed in errors: [{"username": "...", "error": "not_found" | "suspended" | "upstream_error", "message": "..."}]. errors is left out when every handle resolved. upstream_error means X could not be asked (retry later), not that the account is missing.

Simple format (?format=simple or X-Response-Format: simple): Unchanged inside {data: ...}: {userIds, errors} is already small, so the simple format only adds the envelope. Schema.

{
  "userIds": {
    "XDevelopers": "2244994945",
    "jack": "12"
  }
}

In the raw format, field names and nesting come from X and can change without notice. See Response format; the simple format keeps a fixed schema.

Errors

  • 400usernames is missing, has more than 100 entries, or a handle contains characters X blocks.
  • 422A handle is not 2 to 15 letters, digits or underscores.

Errors every endpoint can return (401, 402, 403, 404, 408, 409, 429, 5xx), and which of them are charged, are on the Errors page. Calls that fail with 400, 408, 409 or a 5xx error are refunded.