Tweets & Posts
Access tweets, replies, retweets, and conversation threads with comprehensive data including media, metrics, and user information.
Overview
The Tweets & Posts endpoints provide access to Twitter's core content - tweets. You can retrieve individual tweets by ID, get all replies to a tweet, fetch retweets, and access full conversation threads. All endpoints return rich data including text, media, engagement metrics, and author information.
Key Features
- Tweet Lookup: Get complete tweet data including text, media, metrics, and author
- Replies: Access all replies to any tweet with full conversation context
- Retweets: Retrieve all users who retweeted a specific tweet
- Private Tweets: Access tweets even from private accounts (when authorized)
- Media Support: Full support for images, videos, GIFs, and other media types
- Real-time Data: Get the most up-to-date information available
Authentication
All endpoints require authentication via the X-API-KEY header. Include your API key in every request:
X-API-KEY: YOUR_API_KEYFor more information about authentication, see our Authentication Guide.
Endpoints
Get Tweet by ID
Retrieves a single tweet by its unique ID, including all associated data like media, metrics, author information, and conversation context.
Endpoint: GET /tweet/{tweetId}
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
tweetId | string | Yes | The unique ID of the tweet (e.g., "1668868113725550592") |
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
count | integer | No | Number of replies to include (Default: 20, Max: 100) |
cursor | string | No | Pagination cursor from previous response. Learn more about cursors |
includeTimestamp | boolean | No | Include detailed timestamp information (Default: false) |
Request Examples
cURL:
curl --request GET \
--url 'https://<direct.gateway>/tweet/1668868113725550592?count=20' \
--header 'X-API-KEY: YOUR_API_KEY'JavaScript (fetch):
const response = await fetch('https://<direct.gateway>/tweet/1668868113725550592?count=20', {
method: 'GET',
headers: {
'X-API-KEY': 'YOUR_API_KEY'
}
});
const data = await response.json();
console.log(data);Python (requests):
import requests
url = "https://<direct.gateway>/tweet/1668868113725550592"
params = {"count": 20}
headers = {"X-API-KEY": "YOUR_API_KEY"}
response = requests.get(url, params=params, headers=headers)
data = response.json()
print(data)Node.js (axios):
const axios = require('axios');
const response = await axios.get('https://<direct.gateway>/tweet/1668868113725550592', {
params: { count: 20 },
headers: { 'X-API-KEY': 'YOUR_API_KEY' }
});
console.log(response.data);Response Example
The response includes the tweet data along with replies (if any) and pagination cursors:
{
"data": {
"threaded_conversation_with_injections_v2": {
"instructions": [
{
"type": "TimelineAddEntries",
"entries": [
{
"entryId": "tweet-1668868113725550592",
"content": {
"itemContent": {
"tweet_results": {
"result": {
"__typename": "Tweet",
"rest_id": "1668868113725550592",
"core": {
"user_results": {
"result": {
"rest_id": "44196397",
"legacy": {
"screen_name": "elonmusk",
"name": "Elon Musk",
"followers_count": 226943745,
"verified": false
}
}
}
},
"legacy": {
"full_text": "This is the tweet text content",
"created_at": "Wed Jun 14 12:00:00 +0000 2023",
"favorite_count": 5234,
"retweet_count": 1234,
"reply_count": 567
},
"views": {
"count": "59242758"
},
"edit_control": {
"is_edit_eligible": true,
"edits_remaining": "5"
}
}
}
}
}
}
]
}
]
}
},
"cursor": {
"top": "DAABCgABGNqxkNkKAAIZ2rGBvwoAABnatQ7dCgACGdq1DQ8IAAIZ2rqXFQgAAhnauprOAAA",
"bottom": "DAABCgABGNqxkNkKAAIZ2rqXFQgAAhnauprOAAA"
}
}Response Fields
| Field | Type | Description |
|---|---|---|
rest_id | string | The tweet's unique ID |
full_text | string | The complete text content of the tweet |
created_at | string | Creation timestamp in Twitter format |
favorite_count | integer | Number of likes |
retweet_count | integer | Number of retweets |
reply_count | integer | Number of replies |
views.count | string | Number of views (if available) |
edit_control | object | Information about tweet edit eligibility |
core.user_results | object | Author information including username, name, followers |
Common Use Cases
- Display a single tweet: Use this endpoint to show tweet details in your application
- Get tweet metrics: Access engagement data (likes, retweets, views)
- Fetch conversation context: Retrieve replies along with the original tweet
- Media extraction: Access images, videos, and other media attached to the tweet
Notes
- The
countparameter controls how many replies are included in the response - Use the
cursorparameter for pagination through replies - Tweet IDs are unique and never change, even if the tweet is edited
- Deleted tweets will return a 404 error
Get Tweet Retweets
Retrieves all users who retweeted a specific tweet. This is useful for understanding tweet reach and identifying influential retweeters.
Endpoint: GET /tweet/{tweetId}/retweets
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
tweetId | string | Yes | The unique ID of the tweet |
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
count | integer | No | Number of retweeters to return (Default: 20, Max: 100) |
cursor | string | No | Pagination cursor from previous response |
Request Examples
cURL:
curl --request GET \
--url 'https://<direct.gateway>/tweet/1668868113725550592/retweets?count=20' \
--header 'X-API-KEY: YOUR_API_KEY'JavaScript:
const response = await fetch('https://<direct.gateway>/tweet/1668868113725550592/retweets?count=20', {
headers: { 'X-API-KEY': 'YOUR_API_KEY' }
});
const data = await response.json();Python:
import requests
response = requests.get(
'https://<direct.gateway>/tweet/1668868113725550592/retweets',
params={'count': 20},
headers={'X-API-KEY': 'YOUR_API_KEY'}
)
data = response.json()Response Example
{
"entries": [
{
"type": "TimelineAddEntries",
"entries": [
{
"entryId": "user-1968798245309583360",
"content": {
"itemContent": {
"user_results": {
"result": {
"rest_id": "1968798245309583360",
"legacy": {
"screen_name": "example_user",
"name": "Example User",
"followers_count": 1523,
"verified": false,
"profile_image_url_https": "https://pbs.twimg.com/profile_images/..."
}
}
}
}
}
}
]
}
],
"cursor": {
"top": "HCaAgICf6ZL3lTMAAA==",
"bottom": "HBbq7uzA7avBpjIAAA=="
}
}Response Fields
| Field | Type | Description |
|---|---|---|
rest_id | string | User ID of the retweeter |
screen_name | string | Username (without @) |
name | string | Display name |
followers_count | integer | Number of followers |
verified | boolean | Whether the account is verified |
profile_image_url_https | string | URL to profile image |
Common Use Cases
- Influencer identification: Find users with large followings who retweeted
- Audience analysis: Understand who is sharing your content
- Viral tracking: Monitor how tweets spread through retweets
- Engagement metrics: Calculate potential reach based on retweeter followers
Notes
- Results are ordered by retweet time (most recent first)
- Use pagination cursors to retrieve all retweeters for popular tweets
- Private accounts that retweeted may not appear in results if you don't follow them
For comprehensive error handling, rate limits, and troubleshooting information, see our guides:
- Error Handling Guide - Complete error handling reference
- Rate Limits Guide - Rate limit details and management
Best Practices
Tweet-Specific Tips
- Cache tweet data: Tweets don't change after posting, cache for 5-15 minutes
- Extract data efficiently: Response structure is nested - use helper functions to extract relevant fields
- Handle media: Media URLs are in
legacy.extended_entities.mediafield - Process replies: Use pagination to get all replies, not just the first page
For general API best practices including caching, error handling, and performance optimization, see our Best Practices Guide.
Troubleshooting
| Issue | Symptoms | Possible Causes | Solutions |
|---|---|---|---|
| Tweet not found (404) | Getting 404 errors for valid-looking tweet IDs | Tweet was deleted, ID is incorrect, or account was suspended | Verify tweet ID format (should be numeric), check if tweet exists on Twitter directly |
| Incomplete reply data | Not getting all replies to a tweet | Not using pagination, hitting count limit (max 100), private account replies | Use cursor-based pagination, check if you're hitting the limit, be aware private replies may not be accessible |
| Rate limit errors | Frequent 429 errors | Making too many requests too quickly, not implementing rate limit handling | Implement exponential backoff, monitor rate limit headers, cache responses, consider upgrading plan - see Rate Limits Guide |
| Large response sizes | Slow response times, memory issues | Requesting too many replies at once, not filtering unnecessary data | Use smaller count values with pagination, only request data you need, process responses in chunks |
FAQ
Can I get deleted tweets?
No, deleted tweets return a 404 error. Once a tweet is deleted, it cannot be retrieved through the API.
How do I get all replies to a tweet?
Use the main tweet endpoint with pagination. Set count=100 (maximum) and use the cursor parameter to paginate through all replies.
Can I access tweets from private accounts?
Yes, if your API credentials have access to the private account (i.e., you follow them). Otherwise, you'll receive a 403 Forbidden error.
What's the difference between tweet ID formats?
Tweet IDs are always numeric strings. The rest_id field in responses is the standard format. Some older systems may use different formats, but they all represent the same tweet.
How often is tweet data updated?
Tweet data (metrics, replies, etc.) is updated in real-time. However, for performance, consider caching data for a few minutes if you don't need real-time accuracy.
Can I get historical tweets?
Yes, as long as the tweet hasn't been deleted. Tweet IDs are permanent and can be used to retrieve tweets from any time period.
What media formats are supported?
The API supports all Twitter media formats including:
- Images (JPG, PNG, GIF, WebP)
- Videos (MP4)
- Animated GIFs
- Media are included in the
legacy.extended_entities.mediafield
Related Documentation
- Users Endpoints - Get user information and timelines
- Search Endpoints - Search for tweets
- Using Pagination Cursors - Detailed cursor usage guide
- Error Handling Guide - Comprehensive error handling
- Rate Limits Guide - Understanding rate limits
- Best Practices - API usage best practices
