Users by usernames
Profiles of up to 100 accounts by handle in one call.
/user/users/by/usernamesParameters
usernamesquery · string (comma-separated) · requiredHandles separated by commas, with or without @. At most 100; duplicates count once.
Notes
- Billed per handle (duplicates count once), at most 10 calls per request.
Example request
curl 'https://api.twittrapi.com/user/users/by/usernames?usernames=XDevelopers,jack' \
--header 'X-API-KEY: YOUR_API_KEY'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()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",
},
});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'Base URL https://api.twittrapi.com, key in the X-API-KEY header. Python and Node.js use the official SDKs.
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.
Simple format (?format=simple or X-Response-Format: simple): Collection of User objects without cursors (hasNextPage false), plus errors for handles without a user. Schema.
{
"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",
"id": 1009,
"name": "Community"
}
],
"professional_type": "Business",
"rest_id": "1516891231749517312"
},
"profile_image_shape": "Square",
"rest_id": "2244994945",
"super_follow_eligible": false,
"super_followed_by": false,
"super_following": false,
"tipjar_settings": {}
}
},
{
"result": {
"__typename": "User",
"affiliates_highlighted_label": {
"label": {
"badge": {
"url": "https://pbs.twimg.com/profile_images/1285655593592791040/HtwPZgej_bigger.jpg"
},
"description": "Square",
"url": {
"url": "https://twitter.com/Square",
"urlType": "DeepLink"
},
"userLabelDisplayType": "Badge",
"userLabelType": "BusinessLabel"
}
},
"has_graduated_access": true,
"id": "VXNlcjoxMg==",
"is_blue_verified": true,
"legacy": {
"blocked_by": false,
"blocking": false,
"can_dm": true,
"can_media_tag": true,
"created_at": "Tue Mar 21 20:50:14 +0000 2006",
"default_profile": false,
"default_profile_image": false,
"description": "no state is the best state",
"entities": {
"description": {},
"url": {
"urls": [
{
"display_url": "primal.net/jack",
"expanded_url": "http://primal.net/jack",
"indices": [
0,
23
],
"url": "https://t.co/ZEpOg6rn5L"
}
]
}
},
"fast_followers_count": 0,
"favourites_count": 40745,
"follow_request_sent": false,
"followed_by": false,
"followers_count": 12498634,
"following": false,
"friends_count": 3,
"has_custom_timelines": true,
"is_translator": false,
"listed_count": 33145,
"location": "",
"media_count": 2976,
"muting": false,
"name": "jack",
"needs_phone_verification": false,
"normal_followers_count": 12498634,
"notifications": false,
"pinned_tweet_ids_str": [
"1833951636005552366"
],
"possibly_sensitive": false,
"profile_banner_url": "https://pbs.twimg.com/profile_banners/12/1742427520",
"profile_image_url_https": "https://pbs.twimg.com/profile_images/1661201415899951105/azNjKOSH_normal.jpg",
"profile_interstitial_type": "",
"protected": false,
"screen_name": "jack",
"statuses_count": 31011,
"time_zone": "",
"translator_type": "regular",
"url": "https://t.co/ZEpOg6rn5L",
"utc_offset": 0,
"verified": false,
"want_retweets": false,
"withheld_description": "",
"withheld_scope": ""
},
"parody_commentary_fan_label": "None",
"profile_image_shape": "Circle",
"rest_id": "12",
"super_follow_eligible": false,
"super_followed_by": false,
"super_following": false,
"tipjar_settings": {
"is_enabled": true
}
}
}
]
},
"errors": [
{
"username": "gone_user",
"error": "not_found",
"message": "No user id for this username"
}
]
}{
"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
},
{
"id": "12",
"username": "jack",
"name": "jack",
"description": "no state is the best state",
"location": "",
"url": "http://primal.net/jack",
"createdAt": "2006-03-21T20:50:14Z",
"avatarUrl": "https://pbs.twimg.com/profile_images/1661201415899951105/azNjKOSH.jpg",
"bannerUrl": "https://pbs.twimg.com/profile_banners/12/1742427520",
"verified": true,
"verifiedType": null,
"protected": false,
"counts": {
"followers": 12498634,
"following": 3,
"tweets": 31011,
"likes": 40745,
"media": 2976,
"listed": 33145
},
"pinnedTweetIds": [
"1833951636005552366"
],
"isAutomated": false
}
],
"nextCursor": null,
"previousCursor": null,
"hasNextPage": false,
"errors": [
{
"username": "gone_user",
"error": "not_found",
"message": "No user id for this username"
}
]
}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
- 400usernames is missing or has more than 100 handles.
- 422A handle is not 1 to 15 letters, digits or underscores.
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, 407, 408, 409 or a 5xx error are refunded.