Standard v1.1 compared to Twitter API v2

Standard v1.1 compared to X API v2

If you have been working with the v1.1 statuses/sample endpoint, the goal of this guide is to help you understand the similarities and differences between the standard and X API v2 sample stream endpoints.

  • Similarities
    • Support for Post edit history and metadata
  • Differences
    • Endpoint URLs
    • App and Project requirements
    • Authentication method
    • Response data format
    • Request parameters
    • Availability of recovery and redundancy features

 

Similarities

Support for POst edit history and metadata

Both versions provide metadata that describes any edit history. Check out the volume streams API References and the Post edits fundamentals page for more details. 

 

Differences

Endpoint URLs

  • Standard v1.1 endpoints:
    • https://stream.twitter.com/1.1/statuses/sample

  • X API v2 endpoints:
    • 1% sampled stream: https://api.x.com/2/tweets/sample/stream

    • 10% sampled stream: https://api.x.com/2/tweets/sample10/stream

App and Project requirements

The X API v2 endpoints require that you use credentials from a developer App that is associated to a Project when authenticating your requests. All X API v1.1 endpoints can use credentials from standalone Apps or Apps associated with a project. 
 

Authentication method

The standard endpoint supports OAuth 1.0a User Context, whereas the new X API v2 sample stream endpoint supports OAuth 2.0 App-Only (also referred to as Application-only authentication). To make requests to the X API v2 version you must use a App Access Token to authenticate your requests.

You can easily obtain a App Access Token on navigating to your app's “Keys and tokens” page on the developer portal. If you’d like to generate an App Access Token, see this OAuth 2.0 App-Only guide
 

Response data format

One of the biggest differences between standard v1.1 and X API v2 endpoint versions is how you select which fields return in your payload.

For the standard endpoints, you receive many of the response fields by default, and then have the option to use parameters to identify which fields or sets of fields should return in the payload.

The X API v2 version only delivers the Post id and text fields by default. To request any additional fields or objects, you wil need to use the fields and expansions parameters. Any Post fields that you request from these endpoints will return in the primary Post object. Any expanded user, media, poll, or place objects and fields will return in an includes object within your response. You can then match any expanded objects back to the Post object by matching the IDs located in both the Post and the expanded object. 

We encourage you to read more about these new parameters in their respective guides, or by reading our guide on how to use fields and expansions

We have also put together a data format migration guide which can help you map standard v1.1 fields to the newer v2 fields. This guide will also provide you the specific expansion and field parameter that you will need to pass with your v2 request to return specific fields. 
 

In addition to the changes in how you request certain fields, X API v2 is also introducing new JSON designs for the objects returned by the APIs, including Post and user objects.

  • At the JSON root level, the standard endpoints return Post objects in a statuses array, while X API v2 returns a data array. 
  • Instead of referring to Retweeted and Quoted "statuses", X API v2 JSON refers to Retweeted and Quoted Posts. Many legacies and deprecated fields, such as contributors and user.translator_type are being removed. 
  • Instead of using both favorites (in Post object) and favourites (in user object), X API v2 uses the term like
  • X is adopting the convention that JSON values with no value (for example, null) are not written to the payload. Post and user attributes are only included if they have a non-null values. 
     

We also introduced a new set of fields to the Post object including the following:

  • conversation_id field
  • Two new annotations fields, including context and entities
  • Several new metrics fields 
  • A new reply_setting field, which shows you who can reply to a given Post

 

Request parameters

There is also a set of standard v1.1 request parameters not supported in X API v2:

Standard v1.1 parameter

Details

Delimited

With the v1.1 endpoint, setting this to the string length indicates that statuses should be delimited in the stream, so that clients know how many bytes to read before the end of the status message.

This functionality is not available with X API v2

Stall_warnings

With the v1.1 endpoint, setting this parameter to the string true will cause periodic messages to be delivered if the client is in danger of being disconnected. 

With X API v2, stall warnings are sent by default with the new line sent every so often. 


Availability of recovery and redundancy features

The X API v2 version of sampled streams introduces backfill, recovery, and redundancy features that can help you maximize streaming up-time as well as recover any Posts that might have been missed due to a disconnection. For missing five minutes or less of data, the backfill_minutes request parameter can be used to recover up to five minutes of missed data. With Academic Research and Enterprise access, redundant connections allow you to have more than one stream connection, which can help ensure that you maintain a connection to the stream at all times, even if one of your connections fails. With Enterprise access, you can also recover data from the previous 24 hours using start_time and end_time request parameters to recover the missing data. You can learn more about this functionality via our recovery and redundancy features integration guide.