Expansions let you include related objects in a single API response. Instead of making multiple requests, get a post and its author, media, or referenced posts in one call.Documentation Index
Fetch the complete documentation index at: https://docs.x.com/llms.txt
Use this file to discover all available pages before exploring further.
How expansions work
When you request an expansion, the API includes the full object in theincludes section of the response:
author_id in data links to the user object in includes.
Post expansions
| Expansion | Returns | Use case |
|---|---|---|
author_id | User object | Get post author details |
referenced_tweets.id | Post object(s) | Get quoted/replied-to posts |
referenced_tweets.id.author_id | User object(s) | Get authors of referenced posts |
in_reply_to_user_id | User object | Get user being replied to |
attachments.media_keys | Media object(s) | Get images, videos, GIFs |
attachments.poll_ids | Poll object | Get poll options and votes |
geo.place_id | Place object | Get location details |
entities.mentions.username | User object(s) | Get mentioned users |
edit_history_tweet_ids | Post object(s) | Get previous versions of edited posts |
User expansions
| Expansion | Returns | Use case |
|---|---|---|
pinned_tweet_id | Post object | Get user’s pinned post |
Space expansions
| Expansion | Returns | Use case |
|---|---|---|
creator_id | User object | Get Space creator |
host_ids | User object(s) | Get Space hosts |
speaker_ids | User object(s) | Get Space speakers |
invited_user_ids | User object(s) | Get invited users |
DM expansions
| Expansion | Returns | Use case |
|---|---|---|
sender_id | User object | Get message sender |
participant_ids | User object(s) | Get conversation participants |
attachments.media_keys | Media object | Get attached media |
referenced_tweets.id | Post object | Get referenced post |
List expansions
| Expansion | Returns | Use case |
|---|---|---|
owner_id | User object | Get list owner |
Combining with fields
Expansions return default fields for each object. To get additional fields, combine expansions with field parameters:Multiple expansions
Request multiple expansions as a comma-separated list:Common patterns
- Full post context
- Conversation thread
- User with pinned post
Get a post with author, media, and referenced posts:
Linking data and includes
The objects inincludes don’t contain position information. Link them using IDs:
Next steps
Fields
Request specific fields for each object.
Data Dictionary
Complete object schemas.