Skip to content

Twitter API v2 API

by twitter.com

HTTP BasicHTTPSSocial
Open documentation ↗

Overview

Twitter API v2 available endpoints

Twitter API v2 is a social API from twitter.com. Requests are authenticated with HTTP Basic auth. It is served over HTTPS. Its OpenAPI description documents 80 endpoints.

At a glance

Authentication
HTTP Basic
HTTPS
Yes
CORS
Unknown
Category
Social
Base URL
https://api.twitter.com
Version
2.61
Endpoints
80
Spec updated
2023-02-17

Make a first request

Replace the placeholders; the documentation says exactly where credentials go.

cURL
curl -X GET "https://api.twitter.com/2/compliance/jobs" \
  -H "Accept: application/json" \
  -H "Authorization: Basic BASE64_USER_PASSWORD"
JavaScript
const response = await fetch("https://api.twitter.com/2/compliance/jobs", {
  method: "GET",
  headers: {
    "Accept": "application/json",
    "Authorization": "Basic BASE64_USER_PASSWORD",
  },
});
const data = await response.json();
console.log(data);
Python
import requests

response = requests.request(
    "GET",
    "https://api.twitter.com/2/compliance/jobs",
    headers={
    "Accept": "application/json",
    "Authorization": "Basic BASE64_USER_PASSWORD",
    },
    timeout=30,
)
print(response.json())

Endpoints

MethodPathWhat it does
GET/2/compliance/jobsList Compliance Jobs
POST/2/compliance/jobsCreate compliance job
GET/2/compliance/jobs/{id}Get Compliance Job
POST/2/dm_conversationsCreate a new DM Conversation
GET/2/dm_conversations/with/{participant_id}/dm_eventsGet DM Events for a DM Conversation
POST/2/dm_conversations/with/{participant_id}/messagesSend a new message to a user
POST/2/dm_conversations/{dm_conversation_id}/messagesSend a new message to a DM Conversation
GET/2/dm_conversations/{id}/dm_eventsGet DM Events for a DM Conversation
GET/2/dm_eventsGet recent DM Events
POST/2/listsCreate List
GET/2/lists/{id}List lookup by List ID.
PUT/2/lists/{id}Update List.
DELETE/2/lists/{id}Delete List
GET/2/lists/{id}/followersReturns User objects that follow a List by the provided List ID
GET/2/lists/{id}/membersReturns User objects that are members of a List by the provided List ID.
POST/2/lists/{id}/membersAdd a List member
DELETE/2/lists/{id}/members/{user_id}Remove a List member
GET/2/lists/{id}/tweetsList Tweets timeline by List ID.
GET/2/openapi.jsonReturns the OpenAPI Specification document.
GET/2/spacesSpace lookup up Space IDs
GET/2/spaces/by/creator_idsSpace lookup by their creators
GET/2/spaces/searchSearch for Spaces
GET/2/spaces/{id}Space lookup by Space ID
GET/2/spaces/{id}/buyersRetrieve the list of Users who purchased a ticket to the given space
GET/2/spaces/{id}/tweetsRetrieve Tweets from a Space.
GET/2/tweetsTweet lookup by Tweet IDs
POST/2/tweetsCreation of a Tweet
GET/2/tweets/compliance/streamTweets Compliance stream
GET/2/tweets/counts/allFull archive search counts
GET/2/tweets/counts/recentRecent search counts
GET/2/tweets/firehose/streamFirehose stream
GET/2/tweets/label/streamTweets Label stream
GET/2/tweets/sample/streamSample stream
GET/2/tweets/sample10/streamSample 10% stream
GET/2/tweets/search/allFull-archive search
GET/2/tweets/search/recentRecent search
GET/2/tweets/search/streamFiltered stream
GET/2/tweets/search/stream/rulesRules lookup
POST/2/tweets/search/stream/rulesAdd/Delete rules
GET/2/tweets/{id}Tweet lookup by Tweet ID
DELETE/2/tweets/{id}Tweet delete by Tweet ID
GET/2/tweets/{id}/liking_usersReturns User objects that have liked the provided Tweet ID
GET/2/tweets/{id}/quote_tweetsRetrieve Tweets that quote a Tweet.
GET/2/tweets/{id}/retweeted_byReturns User objects that have retweeted the provided Tweet ID
PUT/2/tweets/{tweet_id}/hiddenHide replies
GET/2/usersUser lookup by IDs
GET/2/users/byUser lookup by usernames
GET/2/users/by/username/{username}User lookup by username
GET/2/users/compliance/streamUsers Compliance stream
GET/2/users/meUser lookup me
GET/2/users/{id}User lookup by ID
GET/2/users/{id}/blockingReturns User objects that are blocked by provided User ID
POST/2/users/{id}/blockingBlock User by User ID
GET/2/users/{id}/bookmarksBookmarks by User
POST/2/users/{id}/bookmarksAdd Tweet to Bookmarks
DELETE/2/users/{id}/bookmarks/{tweet_id}Remove a bookmarked Tweet
GET/2/users/{id}/followed_listsGet User's Followed Lists
POST/2/users/{id}/followed_listsFollow a List
DELETE/2/users/{id}/followed_lists/{list_id}Unfollow a List
GET/2/users/{id}/followersFollowers by User ID
GET/2/users/{id}/followingFollowing by User ID
POST/2/users/{id}/followingFollow User
GET/2/users/{id}/liked_tweetsReturns Tweet objects liked by the provided User ID
POST/2/users/{id}/likesCauses the User (in the path) to like the specified Tweet
DELETE/2/users/{id}/likes/{tweet_id}Causes the User (in the path) to unlike the specified Tweet
GET/2/users/{id}/list_membershipsGet a User's List Memberships
GET/2/users/{id}/mentionsUser mention timeline by User ID
GET/2/users/{id}/mutingReturns User objects that are muted by the provided User ID
POST/2/users/{id}/mutingMute User by User ID.
GET/2/users/{id}/owned_listsGet a User's Owned Lists.
GET/2/users/{id}/pinned_listsGet a User's Pinned Lists
POST/2/users/{id}/pinned_listsPin a List
DELETE/2/users/{id}/pinned_lists/{list_id}Unpin a List
POST/2/users/{id}/retweetsCauses the User (in the path) to retweet the specified Tweet.
DELETE/2/users/{id}/retweets/{source_tweet_id}Causes the User (in the path) to unretweet the specified Tweet
GET/2/users/{id}/timelines/reverse_chronologicalUser home timeline by User ID
GET/2/users/{id}/tweetsUser Tweets timeline by User ID
DELETE/2/users/{source_user_id}/blocking/{target_user_id}Unblock User by User ID
DELETE/2/users/{source_user_id}/following/{target_user_id}Unfollow User
DELETE/2/users/{source_user_id}/muting/{target_user_id}Unmute User by User ID

Questions

Does the Twitter API v2 API need an API key?

Yes. The Twitter API v2 API uses HTTP Basic authentication; the documentation explains how to get credentials.

Does the Twitter API v2 API support HTTPS?

Yes, the Twitter API v2 API is served over HTTPS.

How many endpoints does the Twitter API v2 API have?

Its OpenAPI description lists 80 endpoints in version 2.61. All of them are shown on this page.

What are alternatives to the Twitter API v2 API?

Other Social APIs include Blogger, Facebook, Twitter, Pinterest, TikTok.

Compare alternatives →

Listed from APIs.guru (CC0).