X API

API

X's v2 API for searching, reading and publishing posts on X (Twitter)

Price
Pay per use (prepaid credits)
Access
Bearer token or OAuth 2.0

About

The X API v2 gives programmatic access to posts, users, DMs, lists, trends and real-time streams on X. It is pay-per-use with prepaid credits and no free tier: a post read costs $0.005 and a new post $0.015, and reads are capped at 3M a month below Enterprise.

What you can do with it

  • Search recent or full-archive posts and stream matching posts live
  • Publish posts, replies and DMs on behalf of a user
  • Look up users, followers and post engagement metrics

Get started

  1. Sign in at console.x.com and create an app
  2. Buy credits and set a spending limit
  3. Copy the app's Bearer token

Example

# Look up a user with public metrics
curl "https://api.x.com/2/users/by/username/xdevelopers?user.fields=public_metrics" \
  -H "Authorization: Bearer $X_BEARER_TOKEN"
# Search posts from the last 7 days
curl "https://api.x.com/2/tweets/search/recent?query=from:xdevelopers" \
  -H "Authorization: Bearer $X_BEARER_TOKEN"

Details

Hosting
Hosted service
Available in
Worldwide
Official SDKs
Python, JavaScript/TypeScript
MCP server
Remote
Works with
X

Tasks

Alternatives

Other tools for the same tasks.

Last checked on .