langchain-xdataapi
LangChain tools for xdataapi.io: read-only public X (Twitter) data. Profiles, posts, threads, replies, quotes, reposters, followers, and search with the x.com operators.
Read-only by design. No posting, no likes, no direct messages, no private data. Not affiliated with X Corp.
pip install langchain-xdataapi
Use
from langchain_xdataapi import XdataapiToolkit
# Reads XDATAAPI_KEY from the environment.
tools = XdataapiToolkit.from_api_key().get_tools()
With an agent:
from langchain.agents import create_agent
from langchain_xdataapi import XdataapiToolkit
agent = create_agent(
"anthropic:claude-opus-5",
tools=XdataapiToolkit.from_api_key(max_results=25).get_tools(),
)
result = agent.invoke({"messages": [{"role": "user", "content": "What is @vercel posting about this week?"}]})
One tool on its own:
from langchain_xdataapi import SearchTweets, XdataapiClient
search = SearchTweets(client=XdataapiClient())
print(search.invoke({"q": "from:vercel since:2026-09-01", "count": 10}))
Tools
| Tool | Reads | Credits |
|---|---|---|
x_search_tweets |
Search with the x.com operators | 1 per result |
x_get_user |
One profile | 1 |
x_get_users |
Up to 100 profiles in one call | 1 per profile |
x_get_user_tweets |
Latest posts of a user | 1 per post |
x_get_tweet |
One post | 1 |
x_get_tweets |
Up to 100 posts in one call | 1 per post |
x_get_thread |
A post with its thread and replies | 1 per post |
x_get_replies |
Direct replies to a post | 1 per reply |
x_get_quotes |
Posts that quote a post | 1 per post |
x_get_retweeters |
Accounts that reposted a post | 0.5 per profile |
x_get_followers |
Followers, as profiles | 0.1 per profile |
x_get_follower_ids |
Follower ids only | 0.02 per id |
x_get_following |
Accounts a user follows | 0.1 per profile |
x_get_balance |
Credits left and rate limit | free |
Empty results and failed requests cost nothing. A repeated read inside the cache window costs half.
Every response carries credits_charged and balance_remaining, so the model can see the budget shrink
and stop on its own.
Spending guards
max_results caps the page size of every paging tool, so one agent step cannot ask for more than you allow:
toolkit = XdataapiToolkit.from_api_key(max_results=25)
Narrow the surface with include or exclude:
toolkit = XdataapiToolkit.from_api_key(include=["x_search_tweets", "x_get_user", "x_get_balance"])
Errors
A failure the model can act on — no credits, not found, a search product X refused — comes back as JSON
with error.code, so the model can change plan. None of those are charged.
A missing or revoked key raises XdataapiAuthError, because no model can repair it.
Rate limits and upstream faults raise XdataapiError, so your framework's retry policy sees them.
MCP instead
An agent that speaks MCP needs no package. Connect the hosted server:
claude mcp add --transport http xdataapi https://api.xdataapi.io/mcp
It signs in with OAuth on first use. It is on the official MCP Registry as io.xdataapi/xdataapi.
Keys and pricing
Get a key at xdataapi.io/dashboard. 5,000 credits to start, no card. Prepaid packs from $10; credits never expire. Live status: xdataapi.io/status.
MIT licensed.
Metadata
Release files for langchain-xdataapi 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langchain_xdataapi-0.1.0.tar.gz | 9.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_xdataapi-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.2 kB
Release files / langchain_xdataapi-0.1.0.tar.gz
| Download URL | langchain_xdataapi-0.1.0.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
849f0f04f5b6e2ffabac17bcd2b57118f5aa923dbfc325fc1078df4e0888c2d6
|
|
BLAKE2b-256 checksum How to use checksums |
588f997ba6b3272b824e948c8a936acb258385b5d5243028b7d37ea0b006ceea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / langchain_xdataapi-0.1.0-py3-none-any.whl
| Download URL | langchain_xdataapi-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
35c6d035855521cfdefc01a6d65e83810b55956c1d8ed82d0a2d809e65edf559
|
|
BLAKE2b-256 checksum How to use checksums |
b4fc99eae2614d436a1c3519b4a24a9aeda9b6bcc6b675d583864fa3fa0b8aef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|