Quick navigation
- Post (Tweet) fields
- User fields
- Space, List, Media, Poll, Place, Community, DM events
- How to request fields & expansions
- Example payloads
Quick navigation
Post (Tweet)
Posts are the core content unit on X. Each Post object includes text, metadata, and references to related objects like authors, media, and polls. Default fields:id, text, edit_history_tweet_ids
Use tweet.fields to request additional fields and expansions to include related objects.
All Post fields
Retrieving a Tweet Object
Sample Request
In the following request, we are requesting fields for the Tweet on the Tweets lookup endpoint. Be sure to replace
$BEARER_TOKEN with your own generated Bearer Token.
User
The user object contains Twitter user account metadata describing the referenced user. The user object is the primary object returned in the users lookup endpoint. When requesting additional user fields on this endpoint, simply use the fields parameteruser.fields.
The user object can also be found as a child object and expanded in the Tweet object. The object is available for expansion with ?expansions=author_id or ?expansions=in_reply_to_user_id to get the condensed object with only default fields. Use the expansion with the field parameter: user.fields when requesting additional fields to complete the object.
Retrieving a user object
Sample Request
In the following request, we are requesting fields for the user on the users lookup endpoint. Be sure to replace
$BEARER_TOKEN with your own generated Bearer Token.
Space
Spaces allow expression and interaction via live audio conversations. The Space data dictionary contains relevant metadata about a Space; all the details are updated in real time. User objects can be found and expanded in the user resource. These objects are available for expansion by adding at least one ofhost_ids, creator_id, speaker_ids, mentioned_user_ids to the expansions query parameter.
Unlike Tweets, Spaces are ephemeral and become unavailable after they end or when they are canceled by their creator. When your app handles Spaces data, you are responsible for returning the most up-to-date information and must remove data that is no longer available from the platform. The Spaces lookup endpoints can help you ensure you respect the users’ expectations and intent.
**Retrieving a Space Object **
Sample Request
In the following request, we are requesting fields for the Space on the Spaces lookup endpoint. Be sure to replace
$BEARER_TOKEN with your own generated Bearer Token.
List
The list object contains Twitter Lists metadata describing the referenced List. The List object is the primary object returned in the List lookup endpoint. When requesting additional List fields on this endpoint, simply use the fields parameterlist.fields.
The List object is not found as a child of other data objects. However, user objects can be found and expanded in the user resource. These objects are available for expansion by adding owner_id to the expansions query parameter. Use this expansion with the list.fields field parameter when requesting additional fields to complete the primary List object and user.fields to complete the expansion object.
Retrieving a User Object
Sample Request
In the following request, we are requesting fields for the user on the List lookup by ID endpoint. Replace
$BEARER_TOKEN with your generated Bearer Token.
Media
Media refers to any image, GIF, or video attached to a Tweet. The media object is not a primary object on any endpoint, but can be found and expanded in the Tweet object. The object is available for expansion with?expansions=attachments.media_keys to get the condensed object with only default fields. Use the expansion with the field parameter: media.fields when requesting additional fields to complete the object.
Retrieving a media object
Sample Request
In the following request, we are requesting fields for the media object attached to the Tweet on the Tweet lookup endpoint. Since media is a child object of a Tweet, the
attachment.media_keys expansion is required. Be sure to replace $BEARER_TOKEN with your own generated Bearer Token.
Poll
A poll included in a Tweet is not a primary object on any endpoint, but can be found and expanded in the Tweet object. The object is available for expansion with?expansions=attachments.poll_ids to get the condensed object with only default fields. Use the expansion with the field parameter: poll.fields when requesting additional fields to complete the object.
Retrieving a poll object
Sample Request
In the following request, we are requesting fields for the poll object attached to the Tweet on the Tweets lookup endpoint. Since poll is a child object of a Tweet, the
attachments.poll_id expansion is required. Be sure to replace $BEARER_TOKEN with your own generated Bearer Token.
Place
The place tagged in a Tweet is not a primary object on any endpoint, but can be found and expanded in the Tweet resource. The object is available for expansion with?expansions=geo.place_id to get the condensed object with only default fields. Use the expansion with the field parameter: place.fields when requesting additional fields to complete the object.
Retrieving a place object
Sample Request
In the following request, we are requesting fields for the place object attached to the Tweet on the Tweets lookup endpoint. Since place is a child object of a Tweet, the
geo.place_id expansion is required. Be sure to replace $BEARER_TOKEN with your own generated Bearer Token.
Direct Message events
Direct Message (DM) conversations are made up of events. The X API v2 currently supports three event types: MessageCreate, ParticipantsJoin, and ParticipantsLeave. DM event objects are returned by the Direct Message lookup endpoints, and a MessageCreate event is created when Direct Messages are successfully created with the Manage Direct Messages endpoints. When requesting DM events, there are three default event object attributes, or fields, included: id, event_type, and text. To receive additional event fields, use the fields parameter dm_event.fields to select others. Other available event fields include the following: dm_conversation_id, created_at, sender_id, attachments, participant_ids, and referenced_tweets. Several of these fields provide the IDs of other X objects related to the Direct Message event:- sender_id - The ID of the account that sent the message, or who invited a participant to a group conversation
- partricipants_ids - An array of account IDs. For ParticipantsJoin and ParticipantsLeave events this array will contain a single ID of the account that created the event
- attachments - Provides media IDs for content that has been uploaded to Twitter by the sender
- referenced_tweets - If a Tweet URL is found in the text field, the ID of that Tweet is included in the response
Retrieving a Direct Message event object
Sample Request
For this example, we will build a request that retrieves events associated with a one-to-one conversation. This request will return fundamental Direct Message event fields, along with additional fields for referenced Tweets and their authors. Let’s build a query that asks for:
- Fundamental event attributes such as when it was created and what conversation it is part of (dm_conversation).
- The account ID and description of who sent the Direct Message.
- The text of any referenced Tweet, and when it was posted.
- The account ID and description of any referenced Tweet author.
?dm_event.fields=id,sender_id,text,created_at,dm_conversation_id&expansions=sender_id,referenced_tweets.id&tweet.fields=created_at,text,author_id&user.fields=description
Community
Communities are dedicated places for X users to connect, share, and get closer to the discussions they care about most. Posts in Communities can be seen by anyone on X, but only others within the Community itself can engage and participate in the discussion. The Community object contains relevant metadata about a Community.
Retrieving Community objects
Sample Request
In the following request, we are requesting specific fields while searching for a list of Communities based on a provided keyword. Be sure to replace
$BEARER_TOKEN with your own generated Bearer Token.
Complete field tables and additional examples are in the Data Dictionary Reference.