Standard v1.1 compared to X API v2
If you have been working with the v1.1 search/posts, the goal of this guide is to help you understand the similarities and differences between the standard and X API v2 search Posts endpoint.- Similarities
- OAuth 1.0a User Context and OAuth 2.0 App-Only
- Support for Post edit history and metadata.
- Differences
- Endpoint URLs
- App and Project requirements
- Response data format
- Request parameters
- New query operators
- AND / OR operator precedence
Similarities
OAuth 1.0a User Context and OAuth 2.0 App-Only authentication The v1.1 search/posts and the X API v2 recent search endpoint support both OAuth 1.0a User Context and OAuth 2.0 App-Only. Therefore, if you were previously using the standard v1.1 search endpoint you can continue using the same authentication method if you migrate to the X API v2 version. Depending on your authentication library/package of choice, App-Only authentication is probably the easiest way to get started and can be set with a simple request header. To learn how to generate an App Access Token see this OAuth 2.0 App-Only guide. If you would like to take advantage of the ability to pull private or advertising metrics with the X API v2 endpoint, you will need to use OAuth 1.0a User Context, and pass the user access tokens related to the user who posted the Post for which you would like to pull metrics. Support for Post edit history and metadata Both versions provide metadata that describes any edit history. Check out the search API References and the Post edits fundamentals page for more details.Differences
Endpoint URLs- Standard v1.1 endpoints:
- X API v2 endpoint:
- 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 Tweets. Many legacy 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 non-null values.
- A 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
The following standard v1.1 request parameters have equivalents in X API v2:Standard search v1.1 | Search Posts v2 |
---|---|
q | query |
start_time (YYYY-MM-DDTHH:mm:ssZ) | |
until (YYYY-MM-DD) | end_time (YYYY-MM-DDTHH:mm:ssZ) |
since_id | since_id |
max_id | until_id |
count | max_results |
Response provides search_metadata.next_results | next_token |
Standard v1.1 parameter | Details |
---|---|
geocode | Search Posts at the Basic Access level does not support geo operators. |
locale | With standard search, this was used to specify the language of the query but never fully implemented. |
lang | Search Posts endpoints provide a lang query operator for matching on languages of interest. |
include_entities | Post entities are always included. |
result_type | Search Posts endpoints deliver all matching Posts, regardless of engagement level. |
extended | X API v2 is built from the ground up to support Posts with up to 280 characters. With v2, there is no concept of ‘extended’ Posts. |
Standard v1.1 | X API v2 |
https://api.x.com/1.1/search/tweets.json?q=snow&count=50 | https://api.x.com/2/tweets/search/recent?query=snow&max_results=50 |
X API v2 |
https://api.x.com/2/tweets/search/recent?query=snow&max\_results=50&tweet.fields=id,created\_at,author_id,text,source,entities,attachments&user.fields=id,name,username,description |
- Conversation IDs - As conversations unfold on X, a conservation ID will be available to mark Posts that are part of the conversation. All Posts in the conversation will have their conversation_id set to the Post ID that started it.
conversation_id:
- X Annotations provide contextual information about Posts, and include entity and context annotations. Entities are comprised of people, places, products and organizations. Contexts are domains, or topics, that surfaced entities are a part of. For example, people mentioned in a Post may have a context that indicates whether they are an athlete, actor, or politician.
- context: matches on Posts that have been annotated with a context of interest.
- entity: matches on Posts that have been annotated with an entity of interest.