Skip to main content
This guide covers the key concepts you need to integrate the Post lookup endpoints into your application.

Authentication

All X API v2 endpoints require authentication. Choose the method that fits your use case:

App-Only authentication

For public Post data, use a Bearer Token:
cURL

User Context authentication

To access private metrics, authenticate on behalf of the Post author:
The following fields require User Context authentication:
  • tweet.fields.non_public_metrics
  • tweet.fields.promoted_metrics
  • tweet.fields.organic_metrics
  • media.fields.non_public_metrics
  • media.fields.promoted_metrics
  • media.fields.organic_metrics

Fields and expansions

The X API v2 returns minimal data by default. Use fields and expansions to request exactly what you need.

Default response

Available fields

Example with fields

cURL

Post edits

Posts can be edited up to 5 times within 30 minutes of creation.

How it works

  • Each edit creates a new Post ID
  • edit_history_tweet_ids contains all versions (oldest first)
  • The endpoint always returns the most recent version

Example response

Posts retrieved after their 30-minute edit window represent the final version. For real-time use cases, be aware that recently-published Posts may still be edited.

Error handling

Common errors

Deleted or protected Posts

If a Post is deleted or from a protected account you don’t follow:
  • Single Post lookup returns 404
  • Multi-Post lookup omits the Post from results with an errors array

Best practices

Batch requests

Use the multi-Post endpoint to fetch up to 100 Posts at once, reducing API calls.

Request only needed fields

Specify only the fields you need to minimize response size and processing time.

Cache responses

Cache Post data locally to reduce repeated requests for the same content.

Handle edits

For real-time apps, consider re-fetching Posts after the 30-minute edit window.

Next steps

API Reference

Complete endpoint documentation

Data dictionary

All available objects and fields

Sample code

Working code examples

Error handling

Handle errors gracefully