Username to ID
Numeric user ID for one handle. Smaller response than the full profile.
/username/to/id/{username}Parameters
usernamepath · string · requiredHandle, 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'from twittrapi import TwittrAPI
client = TwittrAPI(api_key="YOUR_API_KEY")
data = client.users.username_to_id("jack")import { TwittrAPI } from "twittrapi";
const client = new TwittrAPI({ apiKey: process.env.TWITTRAPI_API_KEY });
const data = await client.users.usernameToId("jack");curl 'https://twitter-aio.p.rapidapi.com/username/to/id/jack' \
--header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
--header 'x-rapidapi-host: twitter-aio.p.rapidapi.com'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"
}{
"data": {
"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.