Docs
Username to ID

Username to ID

Numeric user ID for one handle. Smaller response than the full profile.

GET/username/to/id/{username}

Parameters

  • usernamepath · string · required

    Handle, with or without a leading @. 2 to 15 characters: letters, digits and underscore.

Example request

curl 'https://api.twittrapi.com/username/to/id/jack' \
  --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: {"userId": "12"}.

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

{
  "userId": "2244994945"
}

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

  • 422The username is invalid, or no user was found (body has errorInfo with X's response).
  • 400The username contains characters X blocks, or X returned an error.

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.