The latest version of the X API v2 is a big deal. As such, we’ve broken this migration section into a few partitions:

What’s new with X API v2Learn about the new endpoints and functionality that we’ve released to X API v2.
Ready to migrate?Get started with your migration with a set of guides and instructions.
Data format migration guideLearn how to rework your data parsers that previously worked with the standard v1.1, and enterprise data formats.
X API endpoint mapSee how standard v1.1, and enterprise endpoints map to the new X API v2 endpoints.

What is the X API v2?

The X API v2 is now the primary X API, and is where product investment and innovation are focused. We’ve partnered with developers to build the next generation of the X API to better serve our diverse community of developers. Based on developer feedback, we’ve re-built the API to better serve a broader collection of needs, introduced new features and endpoints, and improved upon the developer experience.

The X API v2 is now the primary X API, and is where product investment and innovation are focused. Over the past few years, we partnered with developers and re-built the API to better serve a broader collection of needs, introduce new features and endpoints, and improve upon the developer experience. We are committed to continuing to build an open developer platform, and are excited to see what you build with the X API v2.

Why migrate?

The X API v2 is built with a modern and more sustainable foundation and includes both improved replacement endpoints for the standard v1.1, and enterprise products, but also net-new functionality. We strongly encourage customers of legacy APIs (v1.1, and enterprise) to begin to migrate to v2 as we do intend to deprecate them eventually. Use the X API to listen to and analyze the public conversation, engage with people on X, and innovate.

In this section, we will discuss the endpoints and functionality.

V2 endpoints

You can see a full list of v2 endpoints and their pre-v2 equivalent via the following guide:

While most of the endpoints in X API v2 are replacements, we have introduced several new endpoints. Here are several examples of new endpoints that we’ve released to v2:

  • Spaces endpoints to help people get more out of X Spaces, and to allow developers to help shape the future of audio conversations.
  • Hide replies, which allows you to build tools that help limit the impact of abusive, distracting, or misleading replies at scale.
  • New Lists endpoints that allow you to pin and unpin Lists, or look up someone’s pinned Lists.
  • New batch compliance endpoints that allow you to ensure your stored user and Tweet data is in compliance.

New Functionality

X API v2 also includes new features that will help you find more value with the X API. A lot of what is new has been driven by your feedback and includes certain features that were reserved for enterprise customers previously.

Some of the improvements to the API include:

Discover New and Updated Response Objects

The following six data objects are available with the v2 endpoints:

ObjectDescription
TweetThe Tweet object has a long list of root-level fields, such as id, text, and created_at. Tweet objects are also the parent object to several child objects including user, media, poll, and place.
UserThe user object contains X user account metadata describing the referenced user.
SpacesThe Space object consists of fields such as state, host_id, is_ticketed, and even lang.
ListsThe List object contains basic information about the requested list including description, member_count, and owner_id.
MediaIf a Tweet contains media (such as images), then the media object can be requested using the media.fields parameter and includes fields such as the media_key, type, url, preview_image_url, and more.
PollA poll included in a Tweet is not a primary object on any endpoint, but can be found and expanded in the Tweet object.
PlaceThe place object consists of fields such as place_id, geo object, country_code, and more. This information can be used to identify Tweets and study Tweets by location.

Learn more about how to use fields and expansions.

Flexibility to Choose Which Objects and Fields You Receive

When making a request to a GET endpoint, you will receive the primary data object that relates to that endpoint, which will include a set of default fields. For example, the Tweet object delivers the id and text fields as its default.

If you would like to retrieve additional fields with your request, you will have to use the fields and expansions parameters. The expansions parameter enables you to retrieve related data objects such as a user’s pinned Tweet or a media object, while the field operators enable you to request specific fields within returned objects beyond the defaults.

Here is a full list of expansions that you can request with the different X API v2 endpoints:

Object / ResourceAvailable Expansions
Tweetsauthor_id, edit_history_tweet_ids, entities.mentions.username, in_reply_to_user_id, referenced_tweets.id, referenced_tweets.id.author_id, attachments.poll_ids, attachments.media_keys, geo.place_id
Userspinned_tweet_id
Spacesinvited_user_ids, speaker_ids, creator_id, host_ids, topic_ids

Learn more about how to use fields and expansions.

New Metrics Available within Tweets, Users, Spaces, and Media Objects

More metrics are now accessible within Tweet, user, Spaces, Lists, and media objects. These metrics are both public and private, and some metrics can be broken down into an organic or promoted context for Tweet ads.

Learn more about the available metrics.

ObjectAvailable MetricsPublic MetricsPrivate MetricsOrganic MetricsPromoted Metrics
tweetsretweet_count✔️✔️✔️
quote_count✔️
like_count✔️✔️✔️
reply_count✔️✔️✔️
impression_count✔️✔️✔️
url_profile_clicks✔️✔️✔️
url_link_clicks✔️✔️✔️
userfollower_count✔️
userfollowing_count✔️
mediaview_count✔️
mediaplayback_0_count✔️
spaceparticipant_count✔️

Edit Tweets

The X API v2 endpoints provide edited Tweet metadata. The Edit Tweet feature was first introduced for testing among X employees on September 1, 2022. Starting on that date, eligible Tweets are editable for 30 minutes and up to 5 times. Learn more about Edit Tweets. Using the X API v2, a developer can find out:

  • If a Tweet was edit eligible at the time of creation. Some Tweets, such as those with polls or scheduled Tweets, can not be edited.
  • Tweets are editable for 30 minutes, and can be edited up to 5 times. For editable Tweets you can see if time for editing remains and how many more edits are possible.
  • If you are viewing an edited version of a Tweet (in most cases the API will return the most recent version of a Tweet, unless a specific past version is requested by Tweet ID).
  • The entire edit history of the Tweet.
  • The engagement attributed to each version of the Tweet.

Track Threaded Conversations

A new Tweet field helps identify which conversation thread a Tweet belongs to. A conversation ID is the Tweet ID of the Tweet that started the conversation. Learn more about conversation tracking.

Ready to migrate

In order to use v2 endpoints, you will need the following things:

Please note the importance of using keys and tokens from an App within a Project. If you are using keys and tokens from an App outside of a Project, you will not be able to make a request to v2 endpoints.

Once you have a developer account, you can set up all of the above in the developer portal.

Authentication

With the new Twitter API, you’ll use two different authentication patterns, OAuth 1.0a User Context and OAuth 2.0 Bearer Token, to access different endpoints. Each serves a different purpose when making requests to the endpoints:

OAuth 1.0a User Context is required when making a request on behalf of a Twitter user OAuth 2.0 Bearer token is required to make requests on behalf of your developer App

Tools and Code

To help you get started and familiarize yourself with the new endpoints and capabilities we have a few options to jump start your work:

  • We have a Twitter Postman collection that allows you to use the Postman client to make requests of and connect to the individual endpoints. This is a low-friction way to test authentication and experiment with the endpoints.
  • We’ve also provided a list of both Twitter-supported and third-party libraries in Ruby, Python, Node, Java, and many more. For additional context, take a look at our tools and libraries page.

Migrating to Updated Endpoints

As you start to explore the new Twitter v2 endpoints, we’ve built a series of detailed migration guides to help you compare and contrast each updated endpoint’s capabilities compared to older versions:

Migrating to the New Data Format

As you move from v1.1 or enterprise to v2, it is important to understand that the format the data is delivered in has changed significantly. We have added new fields, modified the sequence of fields, and in some cases removed elements altogether.

To learn more about these changes, we are developing a series of guides that will help you map out the pre-v2 data format fields to the newer fields, and describe how to request these new fields.

You can learn more by visiting our data formats migration section of this migration hub, or by visiting our specific data format guides:

What’s Next?

Those of you who have used the platform for some time will notice that many of the new endpoints are aligned with existing standard v1.1 and enterprise endpoints. Indeed, we intend for these to replace all three versions in the future.

We’ve put together a table to help you understand how the Twitter API endpoints map to previous versions.

If you’d like to see what’s coming next, please visit our product roadmap.

We also have a changelog that you can check out to understand what we have already released.

What Should We Build Next?

As we build out additional capabilities of the Twitter API v2 we want to continue to hear from you. We welcome and encourage feedback from you.

Take a look at the ideas that have already been submitted, show your support for those that correlate with your needs, and provide feedback as well!