# X (Twitter) API **Provider:** X Corp **Category:** social **Base URL:** `https://api.twitter.com/2` **Auth:** oauth2 — `Authorization: Bearer AAAA...` **Rate Limit:** 300 requests/15min (Basic) **Free Tier:** Yes — [object Object] **Pricing:** Free tier available (freemium) **Docs:** https://developer.twitter.com/en/docs/twitter-api ## Description The X API (formerly Twitter API v2) provides programmatic access to tweets, users, trends, and DMs. Look up tweets and users by ID, search recent or full-archive posts, stream real-time tweets matching filters, post and reply, and manage likes and bookmarks. ## Endpoints | Method | Endpoint | Description | |--------|----------|-------------| | GET | `https://api.twitter.com/2/tweets/{id}` | Look up a specific tweet | | POST | `https://api.twitter.com/2/tweets` | Create a tweet | | GET | `https://api.twitter.com/2/tweets/search/recent` | Search tweets from the past 7 days | | GET | `https://api.twitter.com/2/tweets/search/all` | Full-archive search (Academic/Pro) | | GET | `https://api.twitter.com/2/users/{id}/tweets` | Get a user's timeline | | GET | `https://api.twitter.com/2/tweets/sample/stream` | Stream 1% sample of all tweets | ## Authentication Supports OAuth 2.0 Bearer Token (app-only) for read-only, and OAuth 2.0 PKCE for user-context actions. ``` Authorization: Bearer AAAA... ``` ## Sample Request ```bash curl "https://api.twitter.com/2/tweets/search/recent?query=from:nasa&tweet.fields=created_at,public_metrics&max_results=5" \ -H "Authorization: Bearer $TWITTER_BEARER_TOKEN" ``` ## Sample Response ```json { "data": [{ "id": "1234567890", "text": "🚀 Artemis update: our lunar gateway...", "created_at": "2024-01-18T14:00:00.000Z", "public_metrics": {"retweet_count": 823, "like_count": 4521} }], "meta": {"newest_id": "1234567890", "result_count": 5} } ``` ## Pricing Details Free: 1,500 writes/mo, 500k reads/mo. Basic: $100/mo (3M reads). Pro: $5,000/mo (1M posts). Enterprise: $42,000/mo. --- *Source: [API Map](https://apimap.dev/apis/twitter-x/) — CC BY 4.0*