TweetHub API Documentation
Welcome to the TweetHub API. This documentation will help you get up and running with our fastest and most affordable Twitter/X data API.
Authentication
All requests to the TweetHub API require authentication using an API key. Include your API key in the request headers.
curl -H "x-api-key: your_api_key_here" \
https://api.TweetHub.io/twitter/user/info?userName=twitterdevGet User Info
Retrieve detailed information about a Twitter user by username or ID.
Request
GET /twitter/user/info?userName=elonmuskResponse
{
"id": "44196397",
"name": "Elon Musk",
"userName": "elonmusk",
"description": "CEO of Tesla, SpaceX, Neuralink, Boring Co",
"followers": 156234567,
"following": 123,
"tweets": 45678,
"verified": true,
"createdAt": "2009-06-17T23:57:11.000Z"
}Parameters
userName
string
The Twitter username
id
string
The Twitter user ID
Search Tweets
Search for tweets using keywords, hashtags, or advanced query syntax.
Request
GET /twitter/tweet/advanced_search?query=AI&queryType=Latest&limit=20Query Syntax
from:username keyword
Search tweets from specific user
keyword1 keyword2
Search tweets containing both keywords
#hashtag
Search by hashtag
lang:en
Filter by language
Post Tweet
Post a new tweet to a Twitter account. Requires user authentication.
Request
POST /twitter/tweet/create
Content-Type: application/json
x-api-key: your_api_key
{
"text": "Hello from TweetHub API!",
"login_cookie": "your_login_cookie"
}WebSocket Real-time Streaming
Connect to real-time tweet streams using WebSocket.
const socket = new WebSocket('wss://stream.TweetHub.io/v1/tweets/filter');
socket.onopen = () => {
socket.send(JSON.stringify({
track: ["AI", "machine learning"],
follow: ["44196397"],
api_key: "your_api_key"
}));
};
socket.onmessage = (event) => {
const tweet = JSON.parse(event.data);
console.log('New tweet:', tweet);
};Rate Limits
Rate limits vary based on your account balance and plan.
| Account Balance | QPS Limit | Monthly Requests |
|---|---|---|
| Free ($0.10) | 0.2 | 1,000 |
| >= $10 | 3 | 10M |
| >= $50 | 10 | 50M |
| >= $100 | 20 | 100M |