Twitter/X AI Search API
Returns a written answer to a plain-English question about X (Twitter), the X posts cited as sources, and how many searches the model ran.
50 credits a call · single call · failed calls free · 10 free calls to start
curl "https://api.insightsocial.app/v1/twitter/ai-search?query=What+is+%40elonmusk+saying+about+xAI+this+week%3F" \-H "x-api-key: $INSIGHTSOCIAL_API_KEY"
When to use it
Use it for open questions such as what an account has said about a topic this week. A thin answer means thin retrieval, not an empty corpus, so confirm coverage with search/tweets.
Parameters
Query parameters for GET /v1/twitter/ai-search. Send your key in the x-api-key header.
| Name | Required | Description |
|---|---|---|
| query | Yes | Natural-language prompt describing what you want to learn from X. The model autonomously searches X using the x_search tool with any handle / date filters you provide. |
| from_handles | No | Comma-separated X handles (max 10). Restricts the search to posts from these accounts only. Mutually exclusive with exclude_handles. |
| exclude_handles | No | Comma-separated X handles (max 10) to exclude from search results. Mutually exclusive with from_handles. |
| from_date | No | ISO 8601 start date (YYYY-MM-DD). Limits the search window to posts on or after this date. |
| to_date | No | ISO 8601 end date (YYYY-MM-DD). Limits the search window to posts on or before this date. |
| max_age_s | No | The oldest cached copy you accept, in seconds. A copy that old or younger is served, with its age in age_s and the X-Cache-Age header. Without it a copy up to 1800 seconds old is served. A lower value fetches fresh (billed) when the copy is older, and 0 always fetches live, like Cache-Control: no-cache. |
Response
This endpoint is beta: data holds the platform's own fields under our naming rules (snake_case keys, string ids, ISO times where the platform gives a timestamp) rather than a unified post or profile, and those fields may change.
Every field, error and example is in the Twitter/X AI Search API reference.
How much does the Twitter/X AI Search API cost?
50 credits per successful call.
Failed calls are free
A call that errors or finds nothing costs 0 credits.
Know the price first
Add dry_run=1 and the response quotes the call without making it. Nothing is charged.
One balance
API calls and Chrome extension exports share the same credits, on the free plan too.
Twitter/X AI Search API: frequently asked questions
Send GET /v1/twitter/ai-search with the query parameter and your key in the x-api-key header. Returns a written answer to a plain-English question about X (Twitter), the X posts cited as sources, and how many searches the model ran.
50 credits per successful call. A call that errors or finds nothing costs 0 credits. A repeat call is charged again: the full price when it fetches new data, 2 credits when the answer comes from the shared cache. Add fresh=1 to force a new read. Only a retry with the same Idempotency-Key is free. Pro's 10,000 monthly credits cover about 200 calls at 50 credits each (about $0.05 a call). Add dry_run=1 to see the price of a call without making it.
No. There is no Twitter/X app, OAuth flow or app review. One InsightSocial API key works for this endpoint and every other platform, and your first 10 calls priced at 100 credits or less are free.
One call returns the data in the data object of the standard response envelope. Fields the platform did not provide are listed in unavailable, so a null there means unknown, not zero.
You get an error or an empty result, and it costs 0 credits. The API reads public Twitter/X data only, so private accounts and deleted content come back as not found rather than as partial data.
Yes. Add the hosted MCP server at https://api.insightsocial.app/mcp to your AI app and sign in. The assistant finds this endpoint by name, shows its price and calls it with your credits.
More Twitter/X endpoints
- Twitter/X Profile API10 credits
- Twitter/X Communities Members API20 credits
- Twitter/X User Tweets API10 credits
- Twitter/X Communities Search API20 credits
- Twitter/X Tweet API10 credits
- Twitter/X Friendships API20 credits
- Twitter/X Community API10 credits
- Twitter/X Lists API20 credits
- Twitter/X Community Tweets API10 credits
- Twitter/X Lists Followers API20 credits
- Twitter/X Lists Members API20 credits
- Twitter/X Tweet Transcript API100 credits