Solutions · AI agents
Twitter/X data for AI agents
Read-only access to public X data for Claude, Cursor, LangChain and LlamaIndex agents: profiles, tweets, replies, search, followers, lists, communities and trends. No X account, no cookies, no developer app. Every tool call is one API call, $0.065 to $0.09 per 1,000.
Hosted MCP server: connect Claude, ChatGPT, Cursor or VS Code by URL, nothing to install. Setup guide
Setup
Pick your setup
Every option below is read-only and returns the simple format unless you ask for raw JSON.
No person to sign up? An agent can buy its own key with USDC, USDT or LTC at its own deposit address. Buy access with crypto
- Setup guide
Hosted MCP server
Connect by URL, nothing to install: Claude.ai, Claude Desktop and ChatGPT as a custom connector, Claude Code, Cursor and VS Code in their MCP settings. Sign in with your TwittrAPI account; 23 read-only tools. - Setup guide
Local MCP server
The open-source server on your own machine, for clients that only start local servers. Same 23 tools. - Setup guide
Agent skill
Teaches coding agents such as Claude Code, Codex and Cursor the API: auth, the simple format, pagination, errors and keeping spend inside a budget. Works next to the MCP server. - Setup guide
LangChain and LlamaIndex
Python packages with 13 tools each for LangChain, LangGraph and LlamaIndex agents (TwittrAPIToolkit, TwittrAPIToolSpec, sync and async). - Setup guide
n8n node
The TwittrAPI community node works as a tool for n8n's AI Agent. - Setup guide
SDKs for your own agent
The Python, Node.js or Go SDK with the simple format, and your own tool schema.
https://mcp.twittrapi.com/mcpnpx skills add twittrapi/twittrapi-skillsMCP
Connect by URL, or run it yourself
The same read-only tools run as a hosted server and as the open-source twittrapi-mcp package. Both answer in the simple format; raw JSON is one setting away, for the whole server or per tool call.
- Every tool has a size cap (50,000 characters by default). Longer output is cut with a marker, and the cursor stays above the cut so it is never lost.
- Errors come back as tool errors (402 balance, 429 rate limit, 404 not found), so the model can react.
- Every tool call is one billed API call on the caller's own balance, at the normal price and rate limit.
- Setup guide
Hosted, by URL
Claude.ai, Claude Desktop and ChatGPT add it as a custom connector; Claude Code, Cursor and VS Code take the URL in their MCP settings. Sign in with OAuth or send your API key in a header. - Setup guide
Local, on your machine
The open-source server runs with Node.js 20 or newer and your key, for clients that only start local servers. - Setup guide
Your own server for a team
Run the open-source server in HTTP mode; every request carries the caller's own key, so one server serves a team without sharing a key.
Frameworks
LangChain and LlamaIndex
Both packages are built on the official Python SDK, return the simple format and cut each result at 20,000 characters by default. The SDK underneath retries 429 and 5xx with backoff.
Pick only the tools the agent needs (search, one tweet, a user's timeline) to keep its choice simple, and lower the size cap per result. Both work with any chat model that supports tool calling, and both can return raw JSON instead when you need cards, polls, edit history or community notes.
Context window
Why response size matters for agents
X's raw JSON repeats long keys, IDs and nested wrappers for every tweet. The simple format keeps the content (full text with links expanded, author, counts, media, quoted tweet) in flat fields that are always present.
Measured on real responses: 61 % fewer input tokens at the median, 52–68 % depending on the endpoint. Same price per call, same parameters, same errors.
/user/{userId}/tweetsAndReplies
raw 81.7 KB → simple 24.2 KB23,009 → 7,274 tokens
−68 %
/user/{userId}/tweets
raw 72.2 KB → simple 22.8 KB20,484 → 6,866 tokens
−66 %
/tweet/{tweetId}
raw 38.7 KB → simple 15.0 KB10,601 → 4,669 tokens
−56 %
/search
raw 34.3 KB → simple 14.4 KB9,582 → 4,556 tokens
−52 %
/user/{userId}/followers
raw 9.1 KB → simple 2.8 KB2,272 → 801 tokens
−65 %
The big number is how many fewer input tokens the simple format needs. One captured response per endpoint, minified, tokens counted with o200k_base. Method and all nine endpoints: Simple format.
Custom tools
Your own tool in a dozen lines
If you run your own agent loop, the Python, Node.js and Go SDKs return the simple format when you ask for it. Keep only the fields the agent needs and the result shrinks further.
- One function per tool: take the query and an optional cursor, call search, return the next cursor.
- Return only id, author, time, text and likes; the agent rarely needs more, and every field costs tokens.
- Skip tweets marked unavailable (deleted or protected) before they reach the model.
In practice
Example prompts and the calls they turn into
Tool names and arguments as the MCP server defines them. Each page is one call.
What has @XDevelopers announced recently?
get_user_tweets({ username: "XDevelopers", count: 20 })
1 call (2 if it pages back)
Find English complaints about our checkout from the last 3 days, skip retweets.
search_tweets({ searchItem: "\"acme checkout\" lang:en within_time:3d -filter:nativeretweets", category: "Latest" })
1 call per page
Summarize the replies under this tweet.
get_tweet({ tweetId: "2019881223666233717" })
1 call per page of replies
Which of these 80 accounts are verified and have over 10k followers?
users_by_ids({ ids: ["…80 IDs…"] })
1 call (up to 100 profiles)
What is trending in Japan right now?
get_trend_locations() → get_trends({ locationId: "23424856" })
2 calls
Tip for the system prompt: resolve handles to IDs once and reuse them, and stop paging when the answer is complete.
Cost
What tool calls cost
One tool call is one API call; a paginated tool returns one page per call. Calls that fail with 400, 408, 409 or a 5xx error are refunded, and 429 is not charged. In practice the model's tokens cost more than the data.
Standard
$0.09per 1,000 calls
- 100,000 calls
- $9.00
- 1,000,000 calls
- $90.00
Volume
$0.075per 1,000 calls
- 100,000 calls
- $7.50
- 1,000,000 calls
- $75.00
Scale
$0.065per 1,000 calls
- 100,000 calls
- $6.50
- 1,000,000 calls
- $65.00
Volume: for 30 days after a top-up of $100. Scale: while top-ups of the last 30 days reach $500. New accounts get $0.10 free credit, about 1,100 calls at Standard. Pricing
Rate limits
Parallel tool calls and rate limits
Agents that run tools in parallel reach a limit quickly. The trial key allows 3 requests per second; after the first top-up you get 30, and higher tiers up to 1,000 per second are booked in the dashboard. A 429 is not charged, and the SDK-based tools retry it. Rate limits
FAQ
AI agent questions
Can the agent post tweets or send DMs?
No. All agent tools are read-only. Posting from your own account exists as separate account actions that need your X session cookie and your own proxy; they are deliberately not wired into the agent tools.
Do I need an X developer account?
No. You need a TwittrAPI key, or a RapidAPI key subscribed to the Twitter AIO API; the MCP server, the LangChain toolkit and the LlamaIndex tool spec accept both.
Which format do the MCP and LangChain tools return?
The simple format by default: flat camelCase JSON with a fixed schema, about 61 % fewer input tokens than X's raw JSON (median over the endpoints we measured). For raw JSON, pass format "raw" per MCP tool call or set TWITTRAPI_RESPONSE_FORMAT=raw; in LangChain and LlamaIndex use api_response_format="raw".
How do I stop an agent from burning through my balance?
Give it a small tool set, set max_chars low, cap the number of pages in the system prompt, and keep the balance small. At zero balance calls return 402 and are not charged.
Can I host the MCP server for my team?
You usually do not need to: with the hosted MCP server each person connects with their own account, and usage is billed to each of them. To run your own instance (for example inside a company network), the open-source server has an HTTP mode that uses the caller's key on every request. The integrations docs describe both.
Does it work with models other than Claude?
Yes. The LangChain and LlamaIndex tools work with any chat model that supports tool calling, and the MCP server with any MCP client.
Related
Read next
- Integrations →SDKs, MCP, LangChain, LlamaIndex, n8n/docs/integrations
- Simple format →Schema, fields and the measurement/docs/simple-format
- Search reference →Operators and the filters object/docs/reference/search
- Research datasets →Collect tweets in Python, cost per million/use-cases/research
- No-code workflows →The n8n node as an AI Agent tool/use-cases/no-code
- TwittrAPI vs the official X API →When the official API fits better/compare/official-x-api
Give your agent X data today
Get a key, connect the MCP server, and ask your first question. New accounts start with $0.10 free credit.