Skip to main content
The X API provides programmatic access to X’s public conversation. Retrieve posts, analyze trends, build integrations, and create new experiences on the platform.

What you can do

CapabilityDescription
Read postsSearch, look up, and stream posts in real-time
Publish contentCreate posts, replies, and threads
Manage usersLook up users, manage follows, blocks, and mutes
Analyze dataAccess metrics, trends, and engagement analytics
Build integrationsSend DMs, manage lists, and interact with Spaces

API versions


Available resources

The X API provides access to these resource types:

Posts

Search, retrieve, create, and delete posts. Access timelines, threads, and quote posts.

Users

Look up profiles, manage relationships, and access follower data.

Spaces

Discover live audio conversations and participants.

Direct Messages

Send and receive private messages between users.

Lists

Create and manage curated lists of accounts.

Trends

Access trending topics by location.

v2 highlights

Request only the data you need. Use fields parameters to select specific attributes and expansions to include related objects.
curl "https://api.x.com/2/tweets/123?tweet.fields=created_at,public_metrics&expansions=author_id&user.fields=username" \
  -H "Authorization: Bearer $TOKEN"
Learn more about fields →
Posts include semantic annotations identifying people, places, products, and topics. Filter streams and searches by topic.Learn more about annotations →
Access public metrics (likes, reposts, replies) and private metrics (impressions, clicks) for your own posts.Learn more about metrics →
Reconstruct entire conversation threads using conversation_id. Track replies across the full thread.Learn more about conversation tracking →
Access the edit history of posts, including all previous versions and edit metadata.Learn more about edit posts →

Pricing

X API v2 uses pay-per-usage pricing:
BenefitDescription
No subscriptionsPay only for what you use
No capsUse as much as you need
Credit-basedPurchase credits, deducted per request
Real-time trackingMonitor usage in the Developer Console
DeduplicationSame resource requested twice in 24 hours is only charged once
View pricing details →

Next steps