Skip to main content
This guide walks you through looking up users by their ID or username.
PrerequisitesBefore you begin, you’ll need:

Look up by ID

Single user

cURL
curl "https://api.x.com/2/users/2244994945?\
user.fields=created_at,description,verified,public_metrics" \
  -H "Authorization: Bearer $BEARER_TOKEN"

Response

{
  "data": {
    "id": "2244994945",
    "name": "X Developers",
    "username": "XDevelopers",
    "created_at": "2013-12-14T04:35:55.000Z",
    "description": "The voice of the X developer community",
    "verified": true,
    "public_metrics": {
      "followers_count": 583423,
      "following_count": 2048,
      "tweet_count": 14052,
      "listed_count": 1672
    }
  }
}

Multiple users

Look up up to 100 users at once:
cURL
curl "https://api.x.com/2/users?\
ids=2244994945,783214,6253282&\
user.fields=username,verified" \
  -H "Authorization: Bearer $BEARER_TOKEN"

Look up by username

Single user

cURL
curl "https://api.x.com/2/users/by/username/XDevelopers?\
user.fields=created_at,description,verified" \
  -H "Authorization: Bearer $BEARER_TOKEN"

Multiple users

cURL
curl "https://api.x.com/2/users/by?\
usernames=XDevelopers,X,elonmusk&\
user.fields=created_at,verified" \
  -H "Authorization: Bearer $BEARER_TOKEN"

Available fields

FieldDescription
created_atAccount creation date
descriptionUser bio
profile_image_urlAvatar URL
verifiedVerification status
public_metricsFollower/following counts
locationUser-defined location
urlUser’s website
protectedProtected account status
pinned_tweet_idPinned Post ID

Handle errors

User not found

{
  "errors": [
    {
      "resource_type": "user",
      "title": "Not Found Error",
      "detail": "Could not find user with username: [nonexistent_user]."
    }
  ]
}

Protected user

Protected users’ data is still returned, but you won’t be able to access their Posts unless you follow them.

Next steps

Authenticated user

Get the current user

Integration guide

Key concepts and best practices

API Reference

Full endpoint documentation