Twitter API v2
  1. Users
Twitter API v2
  • General
    • Returns the open api spec document.
      GET
  • Spaces
    • Space lookup up Space IDs
      GET
    • Space lookup by their creators
      GET
    • Search for Spaces
      GET
    • Space lookup by Space ID
      GET
  • Tweets
    • Tweet lookup by Tweet IDs
      GET
    • Full archive search counts
      GET
    • Recent search counts
      GET
    • Sample stream
      GET
    • Full-archive search
      GET
    • Recent search
      GET
    • Filtered stream
      GET
    • Rules lookup
      GET
    • Add/Delete rules
      POST
    • Tweet lookup by Tweet ID
      GET
    • Hide replies
      PUT
    • Returns Tweet objects liked by the provided User ID
      GET
    • Causes the user (in the path) to like the specified tweet
      POST
    • Causes the user (in the path) to unlike the specified tweet
      DELETE
    • User mention timeline by User ID
      GET
    • Causes the user (in the path) to retweet the specified tweet
      POST
    • Causes the user (in the path) to unretweet the specified tweet
      DELETE
    • User Tweets timeline by User ID
      GET
  • Users
    • Returns user objects that have liked the provided Tweet ID
      GET
    • Returns user objects that have retweeted the provided Tweet ID
      GET
    • User lookup by IDs
      GET
    • User lookup by usernames
      GET
    • User lookup by username
      GET
    • User lookup by ID
      GET
    • Returns user objects that are blocked by provided user ID
      GET
    • Block User by User ID
      POST
    • Returns user objects that follow the provided user ID
      GET
    • Following by User ID
      GET
    • Follow User
      POST
    • Mute User by User ID
      POST
    • Unblock User by User ID
      DELETE
    • Unfollow User
      DELETE
    • Unmute User by User ID
      DELETE
  1. Users

User lookup by usernames

GET
/2/users/by
Users
This endpoint returns information about users. Specify users by their username.
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request GET 'https://api.twitter.com/2/users/by?usernames=TwitterDev,TwitterAPI,jack'
Response Response Example
200 - Example 1
{
  "data": [
    {
      "created_at": "2013-12-14T04:35:55Z",
      "id": "2244994945",
      "name": "Twitter Dev",
      "protected": false,
      "username": "TwitterDev"
    }
  ],
  "errors": [
    {
      "detail": "string",
      "title": "string",
      "status": 0,
      "type": "about:blank"
    }
  ],
  "includes": {
    "media": [
      {
        "height": 0,
        "media_key": "string",
        "width": 0,
        "alt_text": "string",
        "type": "photo",
        "url": "http://example.com"
      }
    ],
    "places": [
      {
        "contained_within": [
          "f7eb2fa2fea288b1"
        ],
        "country": "United States",
        "country_code": "US",
        "full_name": "Lakewood, CO",
        "geo": {
          "bbox": [
            -105.193475,
            39.60973,
            -105.053164,
            39.761974
          ],
          "geometry": {
            "coordinates": [
              -105.18816086351444,
              40.247749999999996
            ],
            "type": "Point"
          },
          "properties": {},
          "type": "Feature"
        },
        "id": "f7eb2fa2fea288b1",
        "name": "Lakewood",
        "place_type": "city"
      }
    ],
    "polls": [
      {
        "duration_minutes": 0,
        "end_datetime": "2019-08-24T14:15:22Z",
        "id": "1365059861688410112",
        "options": [
          {
            "label": "string",
            "position": 0,
            "votes": 0
          },
          {
            "label": "string",
            "position": 0,
            "votes": 0
          }
        ],
        "voting_status": "open"
      }
    ],
    "tweets": [
      {
        "author_id": "2244994945",
        "created_at": "Wed Jan 06 18:40:40 +0000 2021",
        "id": "1346889436626259968",
        "text": "Learn how to use the user Tweet timeline and user mention timeline endpoints in the Twitter API v2 to explore Tweet\\u2026 https:\\/\\/t.co\\/56a0vZUx7i"
      }
    ],
    "users": [
      {
        "created_at": "2013-12-14T04:35:55Z",
        "id": "2244994945",
        "name": "Twitter Dev",
        "protected": false,
        "username": "TwitterDev"
      }
    ]
  }
}

Request

Query Params
usernames
array[string]
required
Required . A list of usernames, comma-separated. You can specify up to 100 usernames.
Example:
TwitterDev,TwitterAPI,jack
expansions
array[string]
optional
A comma separated list of fields to expand.
tweet.fields
array[string]
optional
A comma separated list of Tweet fields to display.
user.fields
array[string]
optional
A comma separated list of User fields to display.

Responses

🟢200The request was successful
application/json
Body
data
array[object (User) {14}] 
optional
>= 1 items
created_at
string <date-time>
optional
Creation time of this user.
description
string 
optional
The text of this user's profile description (also known as bio), if the user provided one.
entities
object 
optional
A list of metadata found in the user's profile description.
id
string 
required
Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.
Example:
2244994945
Match pattern:
^[0-9]{1,19}$
location
string 
optional
The location specified in the user's profile, if the user provided one. As this is a freeform value, it may not indicate a valid location, but it may be fuzzily evaluated when performing searches with location queries.
name
string 
required
The friendly name of this user, as shown on their profile.
pinned_tweet_id
string 
optional
Unique identifier of this Tweet. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.
Example:
1346889436626259968
Match pattern:
^[0-9]{1,19}$
profile_image_url
string <uri>
optional
The URL to the profile image for this user.
protected
boolean 
optional
Indicates if this user has chosen to protect their Tweets (in other words, if this user's Tweets are private).
public_metrics
object 
optional
A list of metrics for this user
url
string 
optional
The URL specified in the user's profile.
username
string 
required
The Twitter handle (screen name) of this user.
Match pattern:
^[A-Za-z0-9_]{1,15}$
verified
boolean 
optional
Indicate if this user is a verified Twitter User.
withheld
object (UserWithheld) 
optional
Indicates withholding details for withheld content.
errors
array[null (Problem) {17}] 
optional
>= 1 items
object 
GenericProblem
optional
A generic problem with no additional information beyond that provided by the HTTP status code.
object 
InvalidRequestProblem
optional
A problem that indicates this request is invalid.
object 
ClientForbiddenProblem
optional
A problem that indicates your client is forbidden from making this request.
object 
ResourceNotFoundProblem
optional
A problem that indicates that a given Tweet, User, etc. does not exist.
object 
ResourceUnavailableProblem
optional
A problem that indicates a particular Tweet, User, etc. is not available to you.
object 
ResourceUnauthorizedProblem
optional
A problem that indicates you are not allowed to see a particular Tweet, User, etc.
object 
FieldUnauthorizedProblem
optional
A problem that indicates that you are not allowed to see a particular field on a Tweet, User, etc.
object 
DisallowedResourceProblem
optional
A problem that indicates that the resource requested violates the precepts of this API.
object 
UnsupportedAuthenticationProblem
optional
A problem that indicates that the authentication used is not supported.
object 
UsageCapExceededProblem
optional
A problem that indicates that a usage cap has been exceeded.
object 
ConnectionExceptionProblem
optional
A problem that indicates something is wrong with the connection
object 
ClientDisconnectedProblem
optional
Your client has gone away.
object 
OperationalDisconnectProblem
optional
You have been disconnected for operational reasons.
object 
RulesCapProblem
optional
You have exceeded the maximum number of rules.
object 
InvalidRuleProblem
optional
The rule you have submitted is invalid.
object 
DuplicateRuleProblem
optional
The rule you have submitted is a duplicate.
object 
ConflictProblem
optional
You cannot create a new job if one is already in progress.
includes
object (Expansions) 
optional
media
array[null (Media) {3}] 
optional
>= 1 items
places
array[object (Place) {8}] 
optional
>= 1 items
polls
array[object (Poll) {5}] 
optional
>= 1 items
tweets
array[object (Tweet) {20}] 
optional
>= 1 items
users
array[object (User) {14}] 
optional
>= 1 items
🔴500500
Modified at 2022-09-10 21:25:17
Previous
User lookup by IDs
Next
User lookup by username
Built with