TweetAPI Documentation
Access comprehensive public Twitter/X data through our developer-friendly REST API.
Base URL
All API requests should be made to:
https://api.tweetapi.com/tw-v2/
Authentication
Include your API key in the X-API-Key header:
headers: {
'X-API-Key': 'YOUR_API_KEY'
}
Before You Call the API
- Responses are JSON.
- Rate-limit details are returned in response headers.
- Collection endpoints use cursor-based pagination where available.
- Posting, engagement, profile, DM, and X Chat endpoints can require account authorization fields in addition to your TweetAPI key. Check each endpoint page for the exact required parameters.
- Handle
429responses with backoff and retry after the reset window shown by the API.
TweetAPI SDKs
TweetAPI provides maintained SDKs for Python and Node.js with full type support, auto-retry, and built-in pagination.
Python
pip install tweetapi
from tweetapi import TweetAPI
client = TweetAPI(api_key="YOUR_API_KEY")
user = client.user.get_by_username(username="sample_user_96991")
print(user["data"]["followerCount"])
Node.js / TypeScript
npm install tweetapi-node
import TweetAPI from "tweetapi-node";
const client = new TweetAPI({ apiKey: "YOUR_API_KEY" });
const user = await client.user.getByUsername({ username: "sample_user_96991" });
console.log(user.data.followerCount);
Key Features
- Public Data Access: User profiles, tweets/posts, followers, and engagement metrics
- Interaction Capabilities: Post tweets, manage likes, retweets, bookmarks, and direct messages
- Search: Search tweets, users, and media with documented query parameters
- Real-time Data: Get up-to-date metrics and engagement counts
- Pagination: Cursor-based pagination for collection endpoints
- Media Support: Full support for images, videos, and GIFs
Available Endpoints
User Endpoints
- Get user by username
- Get user by ID
- Get multiple users by IDs
- Followers and following lists
- User tweets and replies
- Subscription information
Tweet Endpoints
- Tweet details and conversation threads
- Quote tweets and retweets
- Tweet translation
- Engagement metrics
Interaction Endpoints
- Create, reply, and delete posts
- Like and bookmark tweets
- Retweet and quote tweet
- List management
List & Community Endpoints
- List details and members
- Community information
- Timeline tweets
Search Endpoints
- Search tweets, users, and media
- Advanced search operators
- Filtering and sorting options
Rate Limits
The v2 API has the following rate limits:
- Pro: 60 requests per minute
- Ultra: 120 requests per minute
- Mega: 180 requests per minute
Error Handling
TweetAPI uses standard HTTP status codes to indicate success or failure.
Common Error Codes
400s Errors
400
BAD_REQUESTBad Request - Invalid parameters401
UNAUTHORIZEDUnauthorized - Invalid API key404
NOT_FOUNDNot Found - Resource doesn't exist429
RATE_LIMITToo Many Requests - Rate limit exceeded500s Errors
500
INTERNAL_ERRORInternal Server ErrorError Response Format
All errors follow a consistent format:
{
"statusCode": 400,
"message": "Invalid username parameter"
}
Best Practices
- Always check the response status code
- Log error responses for debugging
- Implement exponential backoff for retries
- Handle rate limits gracefully
Security Best Practices
- Never share your API key publicly or commit it to version control
- Rotate your keys regularly for enhanced security
- Use environment variables to store API keys in your applications
- Monitor usage through your dashboard to detect any unusual activity
Support
If you need help or have questions:
- Email us at support@tweetapi.com
- Contact support at @tweetapi on Telegram
- Visit our public status page for API availability