---
title: "X (Twitter) Search API · SocialToAI"
canonical: https://socialtoai.app/x-search-api/
updated: 2026-10-17
---

# X (Twitter) Search API

Search X posts by keyword and get back text, author, likes, comment count, views and publish time, as JSON over HTTP or from your AI client over MCP. A call to the X (Twitter) Search API costs 2 credits ($0.004 to $0.0067 depending on the pack), failed calls are free, and the response has the same format as every other call. Last tested 2026-11-19.

- Page: https://socialtoai.app/x-search-api/
- Last updated: 2026-10-17
- Last tested: 2026-11-19

| Request | Price key | Credits |
| --- | --- | --- |
| `POST /v1/search` | `x.search` | 2 |

Need 100 items? Send `limit: 100` and one call pages for you: at most 5 pages, 10 credits. It stops once it has them or the list ends; pages it does not use are not charged, and neither are pages that fail. Reading 1,000 items comes to about 100 credits, about $0.33.

Daily watch: tell your AI “watch this daily” and this call runs by itself every day, sending only what is new: at most 62 credits a month, about $0.21. [How to set it up](https://socialtoai.app/docs/schedules.md#watch)

## What you get from the X (Twitter) Search API

A recorded call returned 20 items; here is the first, field by field. Names and text are removed from the sample; the numbers are as recorded.

Lighter for your AI: the same recorded data (20 items) is about 36,372 tokens as the platform's raw JSON and about 10,818 as this interface returns it, 70% fewer (measured 2026-11-06).

| Field | In the recorded answer |
| --- | --- |
| url | removed from the sample |
| format | video |
| title | null: X cannot give it |
| text | removed from the sample |
| published_at | 2026-10-12T00:44:12.000Z |
| author.id | removed from the sample |
| author.username | removed from the sample |
| author.name | removed from the sample |
| author.verified | true |
| author.followers | 7,425 |
| metrics.likes | 238 |
| metrics.comments | 37 |
| metrics.shares | null: X cannot give it |
| metrics.collects | 145 |
| metrics.views | 8,357 |
| metrics.reposts | 121 |
| images | empty list |
| hashtags | empty list |
| is_pinned | null: X cannot give it |

2 credits a call (≈ $0.004–$0.0067): about 1,500 calls for $10.

[Easier with a ready-made tool: Viral finder. Posts that did clearly better than their authors usually do.](https://socialtoai.app/tools/viral-finder.md)

## X (Twitter) Search API: request and response

```bash
curl https://socialtoai.app/v1/search \
  -H "Authorization: Bearer $SOCIALTOAI_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "x",
    "query": "weather forecast"
  }'
```

```python
import os
import uuid
import requests

response = requests.post(
    "https://socialtoai.app/v1/search",
    headers={
        "Authorization": f"Bearer {os.environ['SOCIALTOAI_API_KEY']}",
        # A new key for each request; the same one again retries it without paying twice.
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "platform": "x",
        "query": "weather forecast",
    },
)
print(response.json())
```

## X (Twitter) Search API parameters

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `platform` | string | Required | — | Always "x" on this page. |
| `query` | string | Required | — | Search terms |
| `sort` | string | Optional | popular | Most popular first, or newest first. "latest": newest first (2 credits). `"popular"` `"latest"` |
| `type` | string | Optional | — | "user": accounts instead of posts (5 credits). `"user"` |
| `cursor` | string | Optional | — | Pass page.cursor from the last response to get the next page. |

## Other values of this call

| Selected by | Returns | Price key | Credits | Parameters |
| --- | --- | --- | --- | --- |
| `sort=latest` | newest first | `x.search:latest` | 2 | `query` |
| `type=user` | accounts instead of posts | `x.search:user` | 5 | `query` |

## X (Twitter) Search API response fields

| Field | Type | Meaning | Given |
| --- | --- | --- | --- |
| `items[].extra` | object | What the platform gives of this item beyond the fields below, under the platform's own names (an IP location, a uid, a showcase flag); the interface's extra_fields says what each is. Empty when there is nothing more. Of a comment or a review, never who wrote it. | yes |
| `items[].url` | string | A link that opens the item. | yes |
| `items[].format` | string | video, image, text or article. | yes |
| `items[].title` | string | The title. | always null: X does not give it |
| `items[].text` | string | The body text or caption. | yes |
| `items[].published_at` | string | When it was published, ISO 8601 in UTC. | yes |
| `items[].author.id` | string | The author's account ID. | yes |
| `items[].author.username` | string | The author's handle. | yes |
| `items[].author.name` | string | The author's display name. | yes |
| `items[].author.verified` | boolean | Whether the author is verified. | yes |
| `items[].author.followers` | integer | The author's follower count. | yes |
| `items[].metrics.likes` | integer | Likes. | yes |
| `items[].metrics.comments` | integer | Comments. | yes |
| `items[].metrics.shares` | integer | Shares. | always null: X does not give it |
| `items[].metrics.collects` | integer | Saves. | yes |
| `items[].metrics.views` | integer | Views or plays. | yes |
| `items[].metrics.reposts` | integer | Reposts. | yes |
| `items[].images` | string[] | Image addresses. | yes |
| `items[].hashtags` | string[] | Hashtags, without the #. | yes |
| `items[].is_pinned` | boolean | Whether the author pinned it. | always null: X does not give it |

Compared with the Reddit Search API, this call also gives author followers, saves, reposts, views and hashtags but does not give title.

Every item also has platform, id, ref, approx and type; the response around the items is the same on every call. [Response format](https://socialtoai.app/docs/api/response.md)

## Sample response

Sample data: names, links and text are replaced by placeholders; the numbers are as recorded.

```json
{
  "request_id": "req_00000000-0000-4000-8000-000000000001",
  "schema_version": "v1",
  "fetched_at": "2026-10-12T19:10:39.000Z",
  "action": "search",
  "platform": "x",
  "status": "ok",
  "items": [
    {
      "platform": "x",
      "id": "…",
      "ref": "…",
      "approx": [],
      "extra": {},
      "type": "content",
      "url": "https://example.com/…",
      "format": "video",
      "title": null,
      "text": "…",
      "published_at": "2026-10-12T00:44:12.000Z",
      "author": {
        "id": "…",
        "username": "…",
        "name": "…",
        "verified": true,
        "followers": 7425
      },
      "metrics": {
        "likes": 238,
        "comments": 37,
        "shares": null,
        "collects": 145,
        "views": 8357,
        "reposts": 121
      },
      "images": [],
      "hashtags": [],
      "is_pinned": null
    }
  ],
  "unavailable": ["title", "metrics.shares", "is_pinned"],
  "page": {
    "has_more": true,
    "cursor": "cur_…",
    "cursor_expires_at": "2026-10-12T19:40:39.000Z"
  },
  "warnings": [],
  "applied_params": {
    "query": "weather forecast"
  },
  "cost_credits": 2,
  "billing": {
    "cost_credits": 2,
    "balance_credits": 98,
    "today_spend_credits": 2,
    "daily_limit_credits": null,
    "daily_remaining_credits": null,
    "display": "This call: 2 credits (≈ $0.0067). Balance: 98 credits (≈ $0.33)."
  },
  "replayed": false
}
```

## X (Twitter) Search API: paging and billing

- One call returns a page of up to 20 items. When page.has_more is true, send page.cursor back as cursor for the next page; each page costs 2 credits and a cursor works for 30 minutes.
- A call that runs and finds nothing is a successful call: status is "empty", items is empty, and it costs 2 credits.
- 5 calls per second per key, 20 after a purchase; going over is not charged. [Rate limits](https://socialtoai.app/docs/credits-and-billing.md#rate-limits)
- A failed call costs 0 credits and is never retried on its own. [Error codes](https://socialtoai.app/docs/api/errors.md)
- “Last tested” above is the last day a real call of this interface succeeded. Each call reads from the platform, and `fetched_at` in the answer is when it was read. The same request sent again with the same key within 5 minutes is a replay (`replayed: true`): 0 credits, and the answer as first read.

## Once connected over MCP, these questions use the X (Twitter) Search API

- Search X for posts about "weather forecast". → `search {"platform":"x","query":"weather forecast"}`, 2 credits
- Search X for posts about "weather forecast": newest first. → `search {"platform":"x","query":"weather forecast","sort":"latest"}`, 2 credits

## Give this to your AI

```
Use the SocialToAI MCP server (https://socialtoai.app/mcp) for this: Search X for posts about "weather forecast".
Call the search tool with {"platform":"x","query":"weather forecast"}. Needed: query; optional: sort (popular, latest).
For many items pass limit (limit=100 is at most 5 pages) and one call pages for you; each page costs 2 credits and unused pages are not charged.
Before you start, work out how many credits it will take in all and ask me; call it only after I agree.
What usually comes next, with the ref or username it returns: detail (Detail), comments (Comments).
If SocialToAI is not connected yet, tell me how to connect it; never ask me to paste a key into the chat.
Answer with a link to every item you used, and tell me how many credits it cost.
```

## Work scenarios that use it

- [Brand monitoring](https://socialtoai.app/use-cases/brand-monitoring.md): Your AI tells you what people say about a brand: the share of each attitude, what they praise and what they complain about, with the posts behind each point.
- [Product research](https://socialtoai.app/use-cases/product-research.md): Your AI reads what people say about a product category in threads and posts, and comes back with the complaints and wishes that keep coming up, each with the post it came from.
- [Content ideas](https://socialtoai.app/use-cases/content-ideas.md): Your AI reads what was posted on a subject this week and tells you which angles took off, with the posts, their numbers and what they have in common.

## These ready-made tools call it when they run

- [Brand buzz](https://socialtoai.app/tools/brand-buzz.md): How people feel about it on each platform, what comes up most, and the posts behind it
- [Find creators](https://socialtoai.app/tools/find-creators.md): Creators who make that content, with their size, recent posts and how well each fits
- [Creator profile](https://socialtoai.app/tools/creator-card.md): Their accounts on other platforms, the numbers on each, and how sure the match is
- [Viral finder](https://socialtoai.app/tools/viral-finder.md): Posts that did clearly better than their authors usually do

## The same call on other platforms

| Interface | Price key | Credits |
| --- | --- | --- |
| [TikTok Search API](https://socialtoai.app/tiktok-search-api.md) | `tiktok.search` | 2 |
| [Instagram Search API](https://socialtoai.app/instagram-search-api.md) | `instagram.search:user` | 3 |
| [Reddit Search API](https://socialtoai.app/reddit-search-api.md) | `reddit.search` | 2 |
| [YouTube Search API](https://socialtoai.app/youtube-search-api.md) | `youtube.search` | 2 |
| [LinkedIn Search API](https://socialtoai.app/linkedin-search-api.md) | `linkedin.search` | 2 |
| [Threads Search API](https://socialtoai.app/threads-search-api.md) | `threads.search` | 2 |
| [Pinterest Search API](https://socialtoai.app/pinterest-search-api.md) | `pinterest.search` | 2 |
| [Xiaohongshu (RedNote) Search API](https://socialtoai.app/xiaohongshu-search-api.md) | `xiaohongshu.search` | 12 |
| [Douyin Search API](https://socialtoai.app/douyin-search-api.md) | `douyin.search` | 12 |
| [Weibo Search API](https://socialtoai.app/weibo-search-api.md) | `weibo.search` | 2 |
| [WeChat Articles Search API](https://socialtoai.app/wechat-search-api.md) | `wechat.search` | 12 |
| [Bilibili Search API](https://socialtoai.app/bilibili-search-api.md) | `bilibili.search` | 2 |
| [Zhihu Search API](https://socialtoai.app/zhihu-search-api.md) | `zhihu.search` | 2 |
| [Kuaishou Search API](https://socialtoai.app/kuaishou-search-api.md) | `kuaishou.search` | 12 |
| [WeChat Channels Search API](https://socialtoai.app/wechat-channels-search-api.md) | `wechat_channels.search` | 12 |

## More on X

| Interface | What it does | Price key | Credits |
| --- | --- | --- | --- |
| [X (Twitter) Trending API](https://socialtoai.app/x-trending-api.md) | What is trending now: title, rank and heat. | `x.trending` | 6 |
| [X (Twitter) list members API](https://socialtoai.app/x-list-members-api.md) | Get a page of the accounts an X list is made of, by the list's ID, 20 a page. | `x.list_members` | 5 |
| [X (Twitter) Detail API](https://socialtoai.app/x-detail-api.md) | One post by ID or link: text, author, likes, comment count, views and publish time. | `x.detail` | 1 |
| [X (Twitter) Comments API](https://socialtoai.app/x-comments-api.md) | The comments under one post: text, likes, reply count and time. | `x.comments` | 2 |
| [X (Twitter) User Profile API](https://socialtoai.app/x-user-profile-api.md) | One account: name, bio, followers, following and post count. | `x.user_profile` | 1 |
| [X (Twitter) User Posts API](https://socialtoai.app/x-user-posts-api.md) | The recent posts of one account. | `x.user_posts` | 2 |
| [X (Twitter) community profile API](https://socialtoai.app/x-community-api.md) | Get an X community by its ID. | `x.community` | 1 |
| [X (Twitter) community posts API](https://socialtoai.app/x-community-posts-api.md) | Get a page of the posts in an X community by the community's ID. | `x.community_posts` | 4 |
| [X (Twitter) list posts API](https://socialtoai.app/x-list-posts-api.md) | Get a page of the posts on an X list's timeline by the list's ID, newest first, about 100 a page. | `x.list_posts` | 2 |
| [X (Twitter) article detail API](https://socialtoai.app/x-article-api.md) | Get the long-form article attached to an X post by the post's ID. | `x.article` | 2 |

## Read next

- [X official API: access, prices and limits](https://socialtoai.app/does-x-have-an-api.md): What its own API allows, who can use it and what it costs, with sources.
- [How to let AI read X when the official API is too expensive](https://socialtoai.app/how-to/read-x-when-the-official-api-is-too-expensive.md): X's official prices, with sources, and reading X per call instead
- [How to search X by date with since and until](https://socialtoai.app/how-to/search-x-by-date.md): since and until, as parameters or in the query, tested, with what a month of posts costs
- [Monitor X (Twitter) every day: what it really costs](https://socialtoai.app/monitors/x.md): an X keyword or account, daily, 2 credits a run, with the month worked out against X's own price
- [Monitor brand mentions every day, with the posts behind them](https://socialtoai.app/monitors/brand.md): a brand, daily, across platforms: attitudes and the posts behind them, from 16 credits a run
- [X (Twitter) MCP server](https://socialtoai.app/mcp/x.md): Let your AI read X.

## X (Twitter) Search API: questions

**Do I need a X account or X's own API access?**

No. You only need a SocialToAI key. The call returns content and account information publicly visible on X; you never sign in to X or apply for anything there.

**Can I get newest first?**

Yes: send sort=latest in the request. That call costs 2 credits.

**Can I get accounts instead of posts?**

Yes: send type=user in the request. That call costs 5 credits.

**What does one call cost in dollars?**

2 credits: $0.0067 at 300 credits per dollar (purchases from $10), $0.004 at 500 per dollar (from $200). Credits never expire and there is no subscription. 100 free credits on sign-up, no card.

**Am I charged when a call fails or finds nothing?**

A failed call costs 0 credits and is never retried on its own. A call that runs and finds nothing is a successful call: status is "empty" and it costs 2 credits.

**How much does one call return?**

One call returns a page of up to 20 items. When page.has_more is true, send page.cursor back as cursor for the next page; each page costs 2 credits and a cursor works for 30 minutes.

**Is there a rate limit?**

5 calls a second per key, 20 a second after your first purchase. A request over the limit is told how long to wait and is not charged.

**How do I use it from Claude, ChatGPT or Cursor?**

Yes. In Claude or ChatGPT, add the MCP address https://socialtoai.app/mcp as a custom connector, sign in with the code we email you and press Allow; there is no key to paste. In Claude Code, run one command, type /mcp, pick socialtoai and sign in; Codex and Cursor sign in too, with their steps on the connect page. Then ask in plain words and your AI calls search for you.
