Twitter API Developer Guides
Step-by-step tutorials, technical documentation, and best practices for integrating with Twitter's API.
Start LearningGetting Started
Setup Your Account
Learn how to create a developer account and generate API keys and tokens.
Read GuideAuthentication
Understand Bearer tokens, OAuth 1.0a, and how to secure your API communications.
Read GuideAuthentication Guide
OAuth 1.0a Setup
OAuth 1.0a Authentication
Learn to implement OAuth 1.0a for secure API access to protected resources.
consumer_key
#
String
consumer_secret
#
String
{`// Pseudocode for OAuth 1.0a signature generation
const hmacSHA1signature = createHMACSHA1(
"POST&https%3A%2F%2Fapi.twitter.com%2F2%2Ftweets" +
"&oauth_consumer_key%3D%26oauth_nonce=" +
%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp=" +
%26oauth_token%3D%26oauth_version%3D1.0",
&);
const baseString = `OAuth ` +
`oauth_consumer_key="YOUR_KEY", ` +
`oauth_nonce="GENERATED_NONCE, ` +
`oauth_signature="${encodeURIComponent(signature)}", ` +
`oauth_signature_method="HMAC-SHA1", ` +
`oauth_timestamp="EPOCH_TIME", ` +
`oauth_token="USER_ACCESS_TOKEN", ` +
`oauth_version="1.0"`;}
Bearer Authentication
Bearer Token Usage
Implement Bearer token authentication for read-only endpoints and application-only access.
Authorization: Bearer AAAAAAAAAAAAAAAAAAAAANN4JgAAAAA%3D
{`const bearerHeaders = {
"Authorization": `Bearer ${process.env.TWITTER_BEARER_TOKEN}`,
"Content-Type": "application/json"
};}
Popular Guides
Beginner's Tutorial
Your First Twitter API Call
Step-by-step guide to making your first authenticated API request
Try in SandboxAdvanced Tutorial