---
title: "Usernames to IDs"
method: GET
path: "/user/usernames/to/ids"
tags: ["Users"]
---

# Usernames to IDs

`GET /user/usernames/to/ids`

## Request

- Base URL: `https://api.twittrapi.com`
- URL: `https://api.twittrapi.com/user/usernames/to/ids`
- Auth: API key in header `X-API-KEY`

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

Reference: https://www.twittrapi.com/docs/reference/user-usernames-to-ids

## Query parameters

- `usernames` string[], required
- `format` 'raw' | 'simple'

## Response `200`

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.

With format=simple: Unchanged inside {data: ...}: {userIds, errors} is already small, so the simple format only adds the envelope.

- union: format=simple: the simple-format schema. Default (raw): X's JSON, passthrough.
  - DataPassthrough: Simple format: the usual (already small) response inside {data: ...}
    - `data` object, required: The usual response, unchanged
  - RawPassthrough: X's own JSON (raw format, the default), passed through unchanged. The shape is X's and can change; see https://www.twittrapi.com/docs/response-format.

## Other responses

- `400`: usernames is missing, has more than 100 entries, or a handle contains characters X blocks.
- `401`: Missing or unknown API key. Not charged.
- `402`: No balance left, or the trial expired. Not charged. Top up in the dashboard.
- `403`: Key deactivated, or the endpoint is not in your plan (trial keys and account actions). Not charged.
- `422`: A handle is not 2 to 15 letters, digits or underscores.
- `429`: Rate limit for your key exceeded. Not charged. No Retry-After header: back off exponentially.
- `500`: Something failed on our side or between us and X. Refunded (400, 407, 408, 409 or a 5xx error are refunded). Retry with backoff.

---

[API](https://skmtc.dev/twittrapi/apis/twittrapi-api.md) · [All operations](https://skmtc.dev/twittrapi/apis/twittrapi-api/llms.txt) · [OpenAPI document](https://skmtc.dev/twittrapi/apis/twittrapi-api/revisions/0618e38b54c2?raw)
