Twitter API

Social / OAuth Advanced HTTPS
500 tweets/month, 1 request per 24 hours (free tier)

Overview

The X API (formerly Twitter API) allows you to read and post content on X, search tweets, manage followers, and access user timelines using OAuth 2.0. Note that as of 2023, free tier access is very limited — most useful features require a paid Basic or Pro subscription. It is widely used for social media analytics, bots, and content monitoring tools.

💡

Beginner Tip

The free tier only allows posting up to 1,500 tweets per month with very limited reading; for reading recent tweets or building a search tool, you will likely need the Basic plan ($100/month) or higher.

Available Data

Found
Response fields: meta result count, data for each
Twitter data via REST API
JSON-formatted response data
Requires OAuth authentication

Example Response

JSON Response
{
  "status": "success",
  "data": {
    "result": "Data from Twitter",
    "description": "Read and write Twitter data",
    "timestamp": "2025-01-15T10:00:00Z"
  }
}

Field Reference

data Array of tweet objects matching the request.
data[].id Unique identifier for the tweet.
data[].text The full text content of the tweet.
data[].author_id The user ID of the tweet's author; expand with expansions=author_id to get user details.
data[].created_at ISO 8601 timestamp of when the tweet was posted.
meta.result_count Number of results returned in this response.

Implementation Example

// Search recent tweets (requires Bearer Token)
const url = "https://api.x.com/2/tweets/search/recent?query=from:twitterdev&max_results=10";

const response = await fetch(url, {
  headers: {
    "Authorization": "Bearer YOUR_BEARER_TOKEN"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();

console.log(`Found ${data.meta.result_count} tweets`);
data.data.forEach(tweet => {
  console.log(`${tweet.id}: ${tweet.text}`);
});

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

401 Unauthorized Bearer token or OAuth credentials are missing, expired, or incorrectly formatted.
Ensure the Authorization header is exactly "Bearer YOUR_BEARER_TOKEN" with a valid token from the developer portal.
403 Forbidden: Client not enrolled Your app's access level does not permit the endpoint you are calling.
Upgrade your developer plan or apply for elevated access in the X Developer Portal for the endpoints you need.
429 Too Many Requests You have hit the rate limit for the endpoint; limits vary by plan and endpoint.
Check the x-rate-limit-remaining and x-rate-limit-reset headers to know when you can retry.

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 10/20
🔒 Security 15/15
🛠 Developer XP 3/20
✓ Reliability 10/15

Partially tested on Apr 5, 2026

Technical Specifications

Auth OAuth
HTTPS REQUIRED
CORS UNKNOWN
Category Social
Difficulty Advanced
Verified: 2026-04-04

Similar APIs

View All →