User by username
Profile of one account by handle, including its numeric user ID.
/user/by/username/{username}Free tool: Twitter user ID finder, Follower count checker, Shadowban checker, no API key needed.
Parameters
usernamepath · string · requiredHandle, with or without a leading @. 2 to 15 characters: letters, digits and underscore.
Example request
curl 'https://api.twittrapi.com/user/by/username/jack' \
--header 'X-API-KEY: YOUR_API_KEY'from twittrapi import TwittrAPI
client = TwittrAPI(api_key="YOUR_API_KEY")
data = client.users.get_by_username("jack")import { TwittrAPI } from "twittrapi";
const client = new TwittrAPI({ apiKey: process.env.TWITTRAPI_API_KEY });
const data = await client.users.getByUsername("jack");curl 'https://twitter-aio.p.rapidapi.com/user/by/username/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 UserByScreenName query (data.user.result, with rest_id and legacy profile fields). When X returns no user, the API answers 200 with {"data": {}, "userExists": false}.
Simple format (?format=simple or X-Response-Format: simple): {data: User}, or {data: null} when the handle does not exist. Schema.
{
"data": {
"user": {
"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"
}
},
"avatar": {
"image_url": "https://pbs.twimg.com/profile_images/1683501992314798080/xl1POYLw_normal.jpg"
},
"business_account": {},
"core": {
"created_at": "Sat Dec 14 04:35:55 +0000 2013",
"name": "Developers",
"screen_name": "XDevelopers"
},
"creator_subscriptions_count": 0,
"dm_permissions": {
"can_dm": true
},
"follow_request_sent": false,
"has_graduated_access": true,
"has_hidden_subscriptions_on_profile": false,
"highlights_info": {
"can_highlight_tweets": true,
"highlighted_tweets": "4"
},
"id": "VXNlcjoyMjQ0OTk0OTQ1",
"is_blue_verified": true,
"is_profile_translatable": false,
"legacy": {
"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,
"followers_count": 698074,
"friends_count": 770,
"has_custom_timelines": true,
"is_translator": false,
"listed_count": 2977,
"media_count": 832,
"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_interstitial_type": "",
"statuses_count": 4376,
"time_zone": "",
"translator_type": "regular",
"url": "https://t.co/NIwHVIVyrN",
"utc_offset": 0,
"want_retweets": false,
"withheld_description": "",
"withheld_scope": ""
},
"legacy_extended_profile": {},
"location": {
"location": "127.0.0.1"
},
"media_permissions": {
"can_media_tag": true
},
"parody_commentary_fan_label": "None",
"premium_gifting_eligible": false,
"privacy": {
"protected": false
},
"professional": {
"category": [
{
"icon_name": "IconBriefcaseStroke",
"id": 1009,
"name": "Community"
}
],
"professional_type": "Business",
"rest_id": "1516891231749517312"
},
"profile_bio": {
"description": "The voice of the X Dev team and your official source for updates, news, and events, related to the X API."
},
"profile_description_language": "en",
"profile_image_shape": "Square",
"profile_sort_enabled": true,
"relationship_perspectives": {
"blocked_by": false,
"blocking": false,
"followed_by": false,
"following": false,
"muting": false
},
"rest_id": "2244994945",
"super_follow_eligible": false,
"super_followed_by": false,
"super_following": false,
"user_seed_tweet_count": 3,
"verification": {
"verified": false,
"verified_type": "Business"
},
"verification_info": {
"is_identity_verified": false,
"reason": {
"description": {
"entities": [
{
"from_index": 54,
"ref": {
"url": "https://twitter.com/X",
"url_type": "ExternalUrl"
},
"to_index": 56
},
{
"from_index": 63,
"ref": {
"url": "https://help.twitter.com/en/rules-and-policies/profile-labels",
"url_type": "ExternalUrl"
},
"to_index": 73
}
],
"text": "This account is verified because it's an affiliate of @X on X. Learn more"
},
"verified_since_msec": "1395425700472"
}
}
}
}
}
}{
"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
}
}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
- 422The username is not 2 to 15 letters, digits or underscores.
- 400The username contains characters X blocks, or X returned an error.
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, 408, 409 or a 5xx error are refunded.