# Users by usernames

`GET https://api.twittrapi.com/user/users/by/usernames`

Profiles of up to 100 accounts by handle in one call.

HTML page: https://www.twittrapi.com/docs/reference/user-users-by-usernames

## Parameters

| Name | In | Type | Required | Default | Description |
| --- | --- | --- | --- | --- | --- |
| `usernames` | query | string (comma-separated) | yes |  | Handles separated by commas, with or without @. At most 100; duplicates count once. |

This endpoint also accepts `format=simple` (or the header `X-Response-Format: simple`) for compact, flat JSON with a fixed schema. Same price.

## Notes

- Billed per handle (duplicates count once), at most 10 calls per request.

## Response

Raw JSON of X's UsersByRestIds query (data.users), in the order of usernames. A handle without a user is left out of data.users and listed in errors: [{"username": "...", "error": "not_found" | "suspended" | "upstream_error", "message": "..."}]; errors is left out when there are none.

With `format=simple`: Collection of User objects without cursors (hasNextPage false), plus errors for handles without a user.

## Errors

| Status | When |
| --- | --- |
| 400 | usernames is missing or has more than 100 handles. |
| 422 | A handle is not 1 to 15 letters, digits or underscores. |

Shared errors (401 missing key, 402 no balance, 429 rate limit, 5xx) are listed on https://www.twittrapi.com/docs/helpful-infos/error-handling. Calls that fail with 400, 407, 408, 409 or a 5xx error are refunded.

## Example request

curl:

```bash
curl 'https://api.twittrapi.com/user/users/by/usernames?usernames=XDevelopers,jack' \
  --header 'X-API-KEY: YOUR_API_KEY'
```

Python:

```python
import httpx

# No SDK method for this endpoint yet, so this is a plain HTTP call.
resp = httpx.get(
    "https://api.twittrapi.com/user/users/by/usernames",
    headers={"X-API-KEY": "YOUR_API_KEY"},
    params={
        "usernames": "XDevelopers,jack",
    },
    timeout=60,
)
data = resp.json()
```

Node.js:

```js
import { TwittrAPI } from "twittrapi";

const client = new TwittrAPI({ apiKey: process.env.TWITTRAPI_API_KEY });
// No wrapper method for this endpoint yet; client.get() sends the same authenticated GET.
const data = await client.get({
  path: "/user/users/by/usernames",
  query: {
    usernames: "XDevelopers,jack",
  },
});
```

RapidAPI:

```bash
curl 'https://twitter-aio.p.rapidapi.com/user/users/by/usernames?usernames=XDevelopers,jack' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
  --header 'x-rapidapi-host: twitter-aio.p.rapidapi.com'
```

## Example response

Shortened: arrays keep their first items and long strings are cut.

Raw (default):

```json
{
  "data": {
    "users": [
      {
        "result": {
          "__typename": "User",
          "affiliates_highlighted_label": {
            "label": {
              "badge": {
                "url": "https://pbs.twimg.com/profile_images/1955359038532653056/OSHY3ewP_bigger.jpg"
              },
              "description": "X",
              "url": {
                "url": "https://twitter.com/X",
                "urlType": "DeepLink"
              },
              "userLabelDisplayType": "Badge",
              "userLabelType": "BusinessLabel"
            }
          },
          "has_graduated_access": true,
          "id": "VXNlcjoyMjQ0OTk0OTQ1",
          "is_blue_verified": true,
          "legacy": {
            "blocked_by": false,
            "blocking": false,
            "can_dm": true,
            "can_media_tag": true,
            "created_at": "Sat Dec 14 04:35:55 +0000 2013",
            "default_profile": false,
            "default_profile_image": false,
            "description": "The voice of the X Dev team and your official source for updates, news, and events, related to the X API.",
            "entities": {
              "description": {},
              "url": {
                "urls": [
                  {
                    "display_url": "docs.x.com",
                    "expanded_url": "https://docs.x.com/",
                    "indices": [
                      0,
                      23
                    ],
                    "url": "https://t.co/NIwHVIVyrN"
                  }
                ]
              }
            },
            "fast_followers_count": 0,
            "favourites_count": 2758,
            "follow_request_sent": false,
            "followed_by": false,
            "followers_count": 698074,
            "following": false,
            "friends_count": 770,
            "has_custom_timelines": true,
            "is_translator": false,
            "listed_count": 2977,
            "location": "127.0.0.1",
            "media_count": 832,
            "muting": false,
            "name": "Developers",
            "needs_phone_verification": false,
            "normal_followers_count": 698074,
            "notifications": false,
            "pinned_tweet_ids_str": [
              "2019881223666233717"
            ],
            "possibly_sensitive": false,
            "profile_banner_url": "https://pbs.twimg.com/profile_banners/2244994945/1690213128",
            "profile_image_url_https": "https://pbs.twimg.com/profile_images/1683501992314798080/xl1POYLw_normal.jpg",
            "profile_interstitial_type": "",
            "protected": false,
            "screen_name": "XDevelopers",
            "statuses_count": 4376,
            "time_zone": "",
            "translator_type": "regular",
            "url": "https://t.co/NIwHVIVyrN",
            "utc_offset": 0,
            "verified": false,
            "verified_type": "Business",
            "want_retweets": false,
            "withheld_description": "",
            "withheld_scope": ""
          },
          "parody_commentary_fan_label": "None",
          "professional": {
            "category": [
              {
                "icon_name": "IconBriefcaseStroke",
… (26 more lines)
```

Simple (`format=simple`):

```json
{
  "data": [
    {
      "id": "2244994945",
      "username": "XDevelopers",
      "name": "Developers",
      "description": "The voice of the X Dev team and your official source for updates, news, and events, related to the X API.",
      "location": "127.0.0.1",
      "url": "https://docs.x.com/",
      "createdAt": "2013-12-14T04:35:55Z",
      "avatarUrl": "https://pbs.twimg.com/profile_images/1683501992314798080/xl1POYLw.jpg",
      "bannerUrl": "https://pbs.twimg.com/profile_banners/2244994945/1690213128",
      "verified": true,
      "verifiedType": "Business",
      "protected": false,
      "counts": {
        "followers": 698074,
        "following": 770,
        "tweets": 4376,
        "likes": 2758,
        "media": 832,
        "listed": 2977
      },
      "pinnedTweetIds": [
        "2019881223666233717"
      ],
      "isAutomated": false
    },
    "… 1 more"
  ],
  "nextCursor": null,
  "previousCursor": null,
  "hasNextPage": false,
  "errors": [
    {
      "username": "gone_user",
      "error": "not_found",
      "message": "No user id for this username"
    }
  ]
}
```
