Skip to main content
The X API gives you programmatic access to X’s public conversation. Read posts, publish content, manage users, and analyze trends—all through modern REST endpoints with flexible pay-per-usage pricing.

Get started

Create an app and make your first request in minutes.

API reference

Explore all available endpoints.

SDKs

Official Python and TypeScript libraries.

What you can build

Posts

Search, retrieve, and publish posts. Access timelines, threads, and quote posts.

Users

Look up users, manage follows, blocks, and mutes.

Spaces

Find live audio conversations and their participants.

Direct Messages

Send and receive private messages.

Lists

Create and manage curated lists of accounts.

Trends

Access trending topics by location.

Pricing

The X API uses pay-per-usage pricing. No subscriptions—pay only for what you use.

Flexible scaling

Start small and grow. Costs scale with your actual usage.

No commitments

No contracts or minimum spend. Stop anytime.

Real-time tracking

Monitor usage and costs live in the Developer Console.

Credit-based

Purchase credits upfront. Deducted as you use the API.
Earn free xAI API credits when you purchase X API credits—up to 20% back based on your spend. Learn more
Pay-per-usage plans are subject to a monthly cap of 2 million Post reads. If you need higher volume, consider an Enterprise plan.

Key features

Rich data objects

Access detailed, structured data for posts, users, media, and more:
  • Posts: Full text, metrics, entities, annotations, conversation threads
  • Users: Profiles, follower counts, verification status
  • Media: Images, videos, GIFs with metadata
  • Polls: Options and vote counts
Customize responses with fields and expansions to get exactly the data you need.

API versions

VersionStatusDescription
v2CurrentModern endpoints, flexible pricing, all new features
EnterpriseAvailableHigh-volume access with dedicated support
Use X API v2 for all new projects. It’s where all new features and improvements are released.

Quick start

1

Create a developer account

Sign up at console.x.com and create an app.
2

Get your credentials

Generate your Bearer Token for app-only requests.
3

Make a request

Try looking up a user:
curl "https://api.x.com/2/users/by/username/xdevelopers" \
  -H "Authorization: Bearer $BEARER_TOKEN"

Tools & libraries

Python SDK

Official Python library with async support.

TypeScript SDK

Official TypeScript/JavaScript library.

Postman

Interactive API explorer.
Browse all libraries →

Support

Developer Forum

Get help from the community and X team.

Support Hub

FAQs and troubleshooting guides.