twitterapi-io (Python)
Official Python SDK + CLI for twitterapi.io — Twitter/X data API. Search tweets, fetch user profiles, followers, replies, retweeters, trends. One API key, no OAuth, no Twitter Developer Account.
Install
pip install twitterapi-io
Get an API key
Sign up at twitterapi.io — free tier available.
Quick start (sync)
from twitterapi_io import TwitterApiClient
client = TwitterApiClient(api_key="your_api_key") # or env TWITTERAPI_TOKEN
user = client.get_user_info(user_name="elonmusk")
print(user["data"]["name"], user["data"]["followers"])
tweets = client.search_tweets(query="from:elonmusk has:images", query_type="Latest")
for t in tweets["tweets"]:
print(t["text"])
Async variant
import asyncio
from twitterapi_io import AsyncTwitterApiClient
async def main():
async with AsyncTwitterApiClient(api_key="your_api_key") as client:
user = await client.get_user_info(user_name="elonmusk")
print(user)
asyncio.run(main())
CLI
export TWITTERAPI_TOKEN=your_api_key
twitterapi user-info elonmusk
twitterapi search "from:elonmusk has:images" Latest
twitterapi trends 1 10 # 1 = Worldwide
twitterapi help
Output is JSON to stdout — pipe to jq:
twitterapi user-info elonmusk | jq '.data.followers'
API reference
12 read endpoints (v0.1.0):
| Method | Endpoint |
|---|---|
search_tweets(query, query_type, cursor) |
Advanced search |
get_user_info(user_name) |
Basic profile |
get_user_about(user_name) |
Extended profile |
get_user_followers(user_name, cursor, page_size) |
Followers |
get_user_followings(user_name, cursor, page_size) |
Followings |
get_user_last_tweets(user_name OR user_id, cursor, include_replies) |
Recent tweets |
get_user_mentions(user_name, since_time, until_time, cursor) |
Mentions |
get_tweets_by_ids(tweet_ids) |
Batch fetch (≤100) |
get_tweet_replies(tweet_id, cursor, query_type) |
Replies |
get_tweet_quotes(tweet_id, since_time, until_time, cursor) |
Quote-tweets |
get_tweet_retweeters(tweet_id, cursor) |
Retweeters |
get_trends(woeid, count) |
Trending topics |
Low-level escape hatch
For any endpoint not yet wrapped above:
result = client.get("/twitter/some/new/endpoint", {"foo": "bar"})
Full REST API: twitterapi.io/docs.
Error handling
from twitterapi_io import TwitterApiClient, TwitterApiError
try:
client.get_user_info(user_name="nonexistent_user_xyz")
except TwitterApiError as e:
print(f"API {e.status}: {e}")
Automatic retry on 429 / 5xx (3 attempts, exponential backoff).
MCP server (alternative for AI agents)
If building Claude.ai / Claude Code / Cursor integrations, use the hosted MCP:
URL: https://mcp.twitterapi.io/mcp
Or stdio: @kaitoinfra/twitterapi-io-mcp-server
License
MIT
Metadata
Release files for twitterapi-io 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 | |
|---|---|---|---|
| twitterapi_io-0.1.0.tar.gz | 8.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| twitterapi_io-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.0 kB
Release files / twitterapi_io-0.1.0.tar.gz
| Download URL | twitterapi_io-0.1.0.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b3a7149622eef15e113fdf2ebf1213f6d66e11bfdf79342957cf40bc0879a1b
|
|
BLAKE2b-256 checksum How to use checksums |
080f735a64be93aa462d567c0c9bcebc44202bae2e54cecf9cc459da93ea9051
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / twitterapi_io-0.1.0-py3-none-any.whl
| Download URL | twitterapi_io-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ea0b85aff257bb0b4373d3740aa488dbaa6a0af191291ac5604a34af647538b1
|
|
BLAKE2b-256 checksum How to use checksums |
af1fe09145ea2a815b1a694e5eaa791c5186bfd2de35478454865dde7f88a18a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|