X (Twitter) API
by docs.x.com
Social media
Added on February 6th, 2011
Checked and working on November 16th, 2026
Visit docs.x.com →
What it does
The X API (formerly Twitter API) lets you post, read and search posts, and work with users, followers, lists, likes, direct messages and trends on X. It uses REST with JSON and OAuth. The X API is now paid per use: you buy credits up front, which are used up as you make calls; there are no subscriptions or minimum spend. An official MCP server at https://api.x.com/mcp lets AI agents use the X API; calls are billed like normal API calls.
At a glance
- Formats
- JSON
- Interface
- REST, MCP
- Provider
- docs.x.com
- Last checked
- Working on November 16th, 2026
More information: https://docs.x.com/x-api/introduction
Is this your service? Show that it is listed
Put this badge on your website or in your README; it links to this page. About the badge
Example request
curl
curl 'https://api.x.com/2/users/by/username/XDevelopers' \
-H 'Authorization: Bearer YOUR_API_KEY'
JavaScript
const response = await fetch("https://api.x.com/2/users/by/username/XDevelopers", {
headers: {
"Authorization": "Bearer YOUR_API_KEY",
},
});
const data = await response.json();
console.log(data);
Python
import requests
response = requests.get(
"https://api.x.com/2/users/by/username/XDevelopers",
headers={
"Authorization": "Bearer YOUR_API_KEY",
},
timeout=30,
)
print(response.json())
Replace YOUR_API_KEY with your own key.