X (Twitter) user search API
Find X accounts by name, handle or keyword, ranked as X’s People search ranks them, about 20 a page with after for more.
GET /v1/x/search/users1 credit per callRefunded on failureimport os, requests
res = requests.get(
"https://api.groundsocial.dev/v1/x/search/users?q=nasa",
headers={"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"},
)
res.raise_for_status()
data = res.json()Response
200 · 1 credit{ "data": [ { "id": "11348282", "name": "NASA", "username": "NASA", "description": "Making the seemingly impossible, possible. ✨", "profile_image_url": "https://pbs.twimg.com/profile_images/1321163587679784960/0ZxKlEKB_normal.jpg", "protected": false, "verified": true, "verified_type": "government" }, { "id": "14091091", "name": "Hubble", "username": "NASAHubble", "description": "The official X account for the NASA Hubble Space Telescope, managed and operated by NASA's Goddard Space Flight Center.", "profile_image_url": "https://pbs.twimg.com/profile_images/3468011581/efb985f24af0a814a722457a768f3cc5_normal.jpeg", "protected": false, "verified": true, "verified_type": "government" }, "… 6 more" ], "meta": { "result_count": 8, "next_token": "DAAFCgABHX7W7J9__z8LAAIAAADwRW1QQzZ3QUFBZlEvZ0dKTjB2R3AvQUFBQUJRQUFBQUFKYkRRQVFBQUFBQUE1MmcxRVJ1NTByT1ZBQUFBQUFBQUFjRzRJ…" }}Parameters
| Name | Type | Description |
|---|---|---|
qquery · required | string | Name, handle or keyword. Example: nasa. |
afterquery | string | Cursor: the previous page's meta.next_token. |
Response fields
200 with a XUsersResponse, in the shape of X’s API v2 Tweet and User objects.
| Field | Type | Description |
|---|---|---|
data | XUser[] | |
meta | object |
Status codes
| Status | Meaning |
|---|---|
200 | Matching accounts, with a next_token. |
400 | Invalid input. Nothing was charged. |
401 | Missing or invalid API key. |
402 | Not enough credits, a spend cap was reached, or payment is required. |
403 | The target is private, or the account is suspended. |
404 | The post or account does not exist, was deleted, or is suspended. |
429 | Too many requests. Wait for Retry-After seconds. |
503 | X is temporarily unavailable. Retryable; nothing was charged. |
Every error has code, message, hint and retryable. All error codes
Questions
Are follower counts included?
No, X’s search results carry the profile basics only. Call x_user_get on the accounts you keep.
X is a trademark of X Corp. We are not affiliated with or endorsed by X Corp.