Twitter Logo

API Reference

Help Home API Docs
ARC

Twitter API v2

Access the full power of Twitter with our REST and Streaming APIs. Build amazing experiences and discover how millions of users interact with the world.

Twitter API v2 Illustration

Getting Started

Authentication

curl -X POST "https://api.twitter.com/2/oauth2/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -u "API_KEY:API_SECRET_KEY"
              

Use OAuth 2.0 for server-to-server applications and OAuth 1.0a for user context authentication flows.

Endpoints

GET

/2/tweets

Retrieve tweets by ID or query

POST

/2/users/me/tweets

Post new tweet

GET

/2/users/{id}/tweets

Get user's tweets

Rate Limits

All authenticated requests are rate limited:

GET endpoints /v2 10000 reqs/hour
POST endpoints /v2 300 reqs/hour

Need Help?

Can't find what you're looking for? Our developer relations team is here to help with your API integration.

Contact Support

Endpoints

REST API

  • GET

    /2/tweets

    Search and retrieve tweets

  • POST

    /2/users/me/tweets

    Post tweets on behalf of the authenticating user

  • GET

    /2/users/{id}/tweets

    Get user's most recent tweets

Streaming API

  • WSS

    /2/tweets/sample/stream

    Sampled stream of recent public tweets

  • WSS

    /2/tweets/filter

    Filter tweets by keywords, users, locations, etc.

  • WSS

    /2/users/{id}/liked_tweets

    Stream of tweets liked by a user

Code Examples

Search Tweets

curl -X GET "https://api.twitter.com/2/tweets/search/recent?query=mars&tweet.fields=created_at,author_id" \
  -H "Authorization: Bearer $BEARER_TOKEN"
          

This request will search for recent tweets containing "mars" and return creation time and author ID