Twitter/X Tweets API
Endpoints related to retrieving, searching, and modifying Tweets
Endpoints related to retrieving, searching, and modifying Tweets
openapi: 3.0.0
info:
description: X API v2 available endpoints
version: '2.166'
title: X API v2 Account Activity Tweets API
termsOfService: https://developer.x.com/en/developer-terms/agreement-and-policy.html
contact:
name: X Developers
url: https://developer.x.com/
license:
name: X Developer Agreement and Policy
url: https://developer.x.com/en/developer-terms/agreement-and-policy.html
servers:
- description: X API
url: https://api.x.com
tags:
- name: Tweets
description: Endpoints related to retrieving, searching, and modifying Tweets
externalDocs:
description: Find out more
url: https://developer.twitter.com/en/docs/twitter-api/tweets/lookup
paths:
/2/insights/28hr:
get:
security:
- OAuth2UserToken:
- tweet.read
- UserToken: []
tags:
- Tweets
summary: Get 28-hour Post insights
description: Retrieves engagement metrics for specified Posts over the last 28 hours.
operationId: getInsights28Hr
parameters:
- name: tweet_ids
in: query
description: List of PostIds for 28hr metrics.
required: true
schema:
type: array
minItems: 1
maxItems: 25
uniqueItems: true
items:
$ref: '#/components/schemas/TweetId'
example:
- '20'
style: form
- name: granularity
in: query
description: granularity of metrics response.
required: true
schema:
type: string
enum:
- Daily
- Hourly
- Weekly
- Total
example: Total
style: form
- name: requested_metrics
in: query
description: request metrics for historical request.
required: true
schema:
type: array
minItems: 1
uniqueItems: true
items:
type: string
enum:
- AppInstallAttempts
- AppOpens
- DetailExpands
- EmailTweet
- Engagements
- Follows
- HashtagClicks
- Impressions
- Likes
- LinkClicks
- MediaEngagements
- MediaViews
- PermalinkClicks
- ProfileVisits
- QuoteTweets
- Replies
- Retweets
- UniqueVideoViews
- UrlClicks
- UserProfileClicks
- VideoCompletions
- VideoPlayed25Percent
- VideoPlayed50Percent
- VideoPlayed75Percent
- VideoStarts
- VideoViews
style: form
- $ref: '#/components/parameters/EngagementFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Get2Insights28hrResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
/2/insights/historical:
get:
security:
- OAuth2UserToken:
- tweet.read
- UserToken: []
tags:
- Tweets
summary: Get historical Post insights
description: Retrieves historical engagement metrics for specified Posts within a defined time range.
operationId: getInsightsHistorical
parameters:
- name: tweet_ids
in: query
description: List of PostIds for historical metrics.
required: true
schema:
type: array
minItems: 1
maxItems: 25
uniqueItems: true
items:
$ref: '#/components/schemas/TweetId'
example:
- '20'
style: form
- name: end_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The UTC timestamp representing the end of the time range.
required: true
example: '2021-02-01T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
- name: start_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The UTC timestamp representing the start of the time range.
required: true
example: '2021-02-01T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
- name: granularity
in: query
description: granularity of metrics response.
required: true
schema:
type: string
enum:
- Daily
- Hourly
- Weekly
- Total
example: Total
style: form
- name: requested_metrics
in: query
description: request metrics for historical request.
required: true
schema:
type: array
minItems: 1
uniqueItems: true
items:
type: string
enum:
- AppInstallAttempts
- AppOpens
- DetailExpands
- EmailTweet
- Engagements
- Follows
- HashtagClicks
- Impressions
- Likes
- LinkClicks
- MediaEngagements
- MediaViews
- PermalinkClicks
- ProfileVisits
- QuoteTweets
- Replies
- Retweets
- UniqueVideoViews
- UrlClicks
- UserProfileClicks
- VideoCompletions
- VideoPlayed25Percent
- VideoPlayed50Percent
- VideoPlayed75Percent
- VideoStarts
- VideoViews
style: form
- $ref: '#/components/parameters/EngagementFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Get2InsightsHistoricalResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
/2/lists/{id}/tweets:
get:
security:
- BearerToken: []
- OAuth2UserToken:
- list.read
- tweet.read
- users.read
- UserToken: []
tags:
- Tweets
summary: Get List Posts
description: Retrieves a list of Posts associated with a specific List by its ID.
externalDocs:
url: https://developer.twitter.com/en/docs/twitter-api/lists/list-tweets/api-reference/get-lists-id-tweets
operationId: getListsPosts
parameters:
- name: id
in: path
description: The ID of the List.
required: true
schema:
$ref: '#/components/schemas/ListId'
style: simple
- name: max_results
in: query
description: The maximum number of results.
required: false
schema:
type: integer
minimum: 1
maximum: 100
format: int32
default: 100
style: form
- name: pagination_token
in: query
description: This parameter is used to get the next 'page' of results.
required: false
schema:
$ref: '#/components/schemas/PaginationToken36'
style: form
- $ref: '#/components/parameters/TweetFieldsParameter'
- $ref: '#/components/parameters/TweetExpansionsParameter'
- $ref: '#/components/parameters/MediaFieldsParameter'
- $ref: '#/components/parameters/PollFieldsParameter'
- $ref: '#/components/parameters/UserFieldsParameter'
- $ref: '#/components/parameters/PlaceFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Get2ListsIdTweetsResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
/2/spaces/{id}/buyers:
get:
security:
- OAuth2UserToken:
- space.read
- tweet.read
- users.read
tags:
- Tweets
summary: Get Space ticket buyers
description: Retrieves a list of Users who purchased tickets to a specific Space by its ID.
externalDocs:
url: https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-id-buyers
operationId: getSpacesBuyers
parameters:
- name: id
in: path
description: The ID of the Space to be retrieved.
required: true
example: 1YqKDqWqdPLsV
schema:
type: string
description: The unique identifier of this Space.
pattern: ^[a-zA-Z0-9]{1,13}$
example: 1SLjjRYNejbKM
style: simple
- name: pagination_token
in: query
description: This parameter is used to get a specified 'page' of results.
required: false
schema:
$ref: '#/components/schemas/PaginationToken32'
style: form
- name: max_results
in: query
description: The maximum number of results.
required: false
schema:
type: integer
minimum: 1
maximum: 100
format: int32
default: 100
style: form
- $ref: '#/components/parameters/UserFieldsParameter'
- $ref: '#/components/parameters/UserExpansionsParameter'
- $ref: '#/components/parameters/TweetFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Get2SpacesIdBuyersResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
/2/spaces/{id}/tweets:
get:
security:
- BearerToken: []
- OAuth2UserToken:
- space.read
- tweet.read
- users.read
tags:
- Tweets
summary: Get Space Posts
description: Retrieves a list of Posts shared in a specific Space by its ID.
externalDocs:
url: https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-id-tweets
operationId: getSpacesPosts
parameters:
- name: id
in: path
description: The ID of the Space to be retrieved.
required: true
example: 1YqKDqWqdPLsV
schema:
type: string
description: The unique identifier of this Space.
pattern: ^[a-zA-Z0-9]{1,13}$
example: 1SLjjRYNejbKM
style: simple
- name: max_results
in: query
description: The number of Posts to fetch from the provided space. If not provided, the value will default to the maximum of 100.
required: false
schema:
type: integer
minimum: 1
maximum: 100
format: int32
default: 100
example: 25
style: form
- $ref: '#/components/parameters/TweetFieldsParameter'
- $ref: '#/components/parameters/TweetExpansionsParameter'
- $ref: '#/components/parameters/MediaFieldsParameter'
- $ref: '#/components/parameters/PollFieldsParameter'
- $ref: '#/components/parameters/UserFieldsParameter'
- $ref: '#/components/parameters/PlaceFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Get2SpacesIdTweetsResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
/2/tweets:
get:
security:
- BearerToken: []
- OAuth2UserToken:
- tweet.read
- users.read
- UserToken: []
tags:
- Tweets
summary: Get Posts by IDs
description: Retrieves details of multiple Posts by their IDs.
externalDocs:
url: https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/api-reference/get-tweets
operationId: getPostsByIds
parameters:
- name: ids
in: query
description: A comma separated list of Post IDs. Up to 100 are allowed in a single request.
required: true
schema:
type: array
minItems: 1
maxItems: 100
items:
$ref: '#/components/schemas/TweetId'
explode: false
style: form
- $ref: '#/components/parameters/TweetFieldsParameter'
- $ref: '#/components/parameters/TweetExpansionsParameter'
- $ref: '#/components/parameters/MediaFieldsParameter'
- $ref: '#/components/parameters/PollFieldsParameter'
- $ref: '#/components/parameters/UserFieldsParameter'
- $ref: '#/components/parameters/PlaceFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Get2TweetsResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
post:
security:
- OAuth2UserToken:
- tweet.read
- tweet.write
- users.read
- UserToken: []
tags:
- Tweets
summary: Create or Edit Post
description: Creates a new Post for the authenticated user, or edits an existing Post when edit_options are provided. Supports paid partnership disclosure via the paid_partnership field.
externalDocs:
url: https://developer.x.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/post-tweets
operationId: createPosts
parameters: []
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/TweetCreateRequest'
required: true
responses:
'201':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/TweetCreateResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
/2/tweets/analytics:
get:
security:
- OAuth2UserToken:
- tweet.read
- users.read
- UserToken: []
tags:
- Tweets
summary: Get Post analytics
description: Retrieves analytics data for specified Posts within a defined time range.
operationId: getPostsAnalytics
parameters:
- name: ids
in: query
description: A comma separated list of Post IDs. Up to 100 are allowed in a single request.
required: true
schema:
type: array
minItems: 1
maxItems: 100
items:
$ref: '#/components/schemas/TweetId'
explode: false
style: form
- name: end_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The UTC timestamp representing the end of the time range.
required: true
example: '2021-02-01T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
- name: start_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The UTC timestamp representing the start of the time range.
required: true
example: '2021-02-01T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
- name: granularity
in: query
description: The granularity for the search counts results.
required: true
schema:
type: string
enum:
- hourly
- daily
- weekly
- total
default: total
style: form
- $ref: '#/components/parameters/AnalyticsFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Analytics'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
/2/tweets/counts/all:
get:
security:
- BearerToken: []
tags:
- Tweets
summary: Get count of all Posts
description: Retrieves the count of Posts matching a search query from the full archive.
externalDocs:
url: https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-all
operationId: getPostsCountsAll
parameters:
- name: query
in: query
description: One query/rule/filter for matching Posts. Refer to https://t.co/rulelength to identify the max query length.
required: true
schema:
type: string
minLength: 1
maxLength: 4096
example: (from:TwitterDev OR from:TwitterAPI) has:media -is:retweet
style: form
- name: start_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The oldest UTC timestamp from which the Posts will be provided. Timestamp is in second granularity and is inclusive (i.e. 12:00:01 includes the first second of the minute).
required: false
schema:
type: string
format: date-time
style: form
- name: end_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The newest, most recent UTC timestamp to which the Posts will be provided. Timestamp is in second granularity and is exclusive (i.e. 12:00:01 excludes the first second of the minute).
required: false
schema:
type: string
format: date-time
style: form
- name: since_id
in: query
description: Returns results with a Post ID greater than (that is, more recent than) the specified ID.
required: false
schema:
$ref: '#/components/schemas/TweetId'
style: form
- name: until_id
in: query
description: Returns results with a Post ID less than (that is, older than) the specified ID.
required: false
schema:
$ref: '#/components/schemas/TweetId'
style: form
- name: next_token
in: query
description: This parameter is used to get the next 'page' of results. The value used with the parameter is pulled directly from the response provided by the API, and should not be modified.
required: false
schema:
$ref: '#/components/schemas/PaginationToken36'
style: form
- name: pagination_token
in: query
description: This parameter is used to get the next 'page' of results. The value used with the parameter is pulled directly from the response provided by the API, and should not be modified.
required: false
schema:
$ref: '#/components/schemas/PaginationToken36'
style: form
- name: granularity
in: query
description: The granularity for the search counts results.
required: false
schema:
type: string
enum:
- minute
- hour
- day
default: hour
style: form
- $ref: '#/components/parameters/SearchCountFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Get2TweetsCountsAllResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
/2/tweets/counts/recent:
get:
security:
- BearerToken: []
tags:
- Tweets
summary: Get count of recent Posts
description: Retrieves the count of Posts from the last 7 days matching a search query.
externalDocs:
url: https://developer.twitter.com/en/docs/twitter-api/tweets/counts/api-reference/get-tweets-counts-recent
operationId: getPostsCountsRecent
parameters:
- name: query
in: query
description: One query/rule/filter for matching Posts. Refer to https://t.co/rulelength to identify the max query length.
required: true
schema:
type: string
minLength: 1
maxLength: 4096
example: (from:TwitterDev OR from:TwitterAPI) has:media -is:retweet
style: form
- name: start_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The oldest UTC timestamp (from most recent 7 days) from which the Posts will be provided. Timestamp is in second granularity and is inclusive (i.e. 12:00:01 includes the first second of the minute).
required: false
schema:
type: string
format: date-time
style: form
- name: end_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The newest, most recent UTC timestamp to which the Posts will be provided. Timestamp is in second granularity and is exclusive (i.e. 12:00:01 excludes the first second of the minute).
required: false
schema:
type: string
format: date-time
style: form
- name: since_id
in: query
description: Returns results with a Post ID greater than (that is, more recent than) the specified ID.
required: false
schema:
$ref: '#/components/schemas/TweetId'
style: form
- name: until_id
in: query
description: Returns results with a Post ID less than (that is, older than) the specified ID.
required: false
schema:
$ref: '#/components/schemas/TweetId'
style: form
- name: next_token
in: query
description: This parameter is used to get the next 'page' of results. The value used with the parameter is pulled directly from the response provided by the API, and should not be modified.
required: false
schema:
$ref: '#/components/schemas/PaginationToken36'
style: form
- name: pagination_token
in: query
description: This parameter is used to get the next 'page' of results. The value used with the parameter is pulled directly from the response provided by the API, and should not be modified.
required: false
schema:
$ref: '#/components/schemas/PaginationToken36'
style: form
- name: granularity
in: query
description: The granularity for the search counts results.
required: false
schema:
type: string
enum:
- minute
- hour
- day
default: hour
style: form
- $ref: '#/components/parameters/SearchCountFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Get2TweetsCountsRecentResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
/2/tweets/firehose/stream:
get:
security:
- BearerToken: []
tags:
- Tweets
summary: Stream all Posts
description: Streams all public Posts in real-time.
operationId: streamPostsFirehose
parameters:
- name: backfill_minutes
in: query
description: The number of minutes of backfill requested.
required: false
schema:
type: integer
minimum: 0
maximum: 5
format: int32
style: form
- name: partition
in: query
description: The partition number.
required: true
schema:
type: integer
minimum: 1
maximum: 20
format: int32
style: form
- name: start_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp to which the Posts will be provided.
required: false
example: '2021-02-14T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
- name: end_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp to which the Posts will be provided.
required: false
example: '2021-02-14T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
- $ref: '#/components/parameters/TweetFieldsParameter'
- $ref: '#/components/parameters/TweetExpansionsParameter'
- $ref: '#/components/parameters/MediaFieldsParameter'
- $ref: '#/components/parameters/PollFieldsParameter'
- $ref: '#/components/parameters/UserFieldsParameter'
- $ref: '#/components/parameters/PlaceFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/StreamingTweetResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
x-twitter-streaming: true
/2/tweets/firehose/stream/lang/en:
get:
security:
- BearerToken: []
tags:
- Tweets
summary: Stream English Posts
description: Streams all public English-language Posts in real-time.
operationId: streamPostsFirehoseEn
parameters:
- name: backfill_minutes
in: query
description: The number of minutes of backfill requested.
required: false
schema:
type: integer
minimum: 0
maximum: 5
format: int32
style: form
- name: partition
in: query
description: The partition number.
required: true
schema:
type: integer
minimum: 1
maximum: 8
format: int32
style: form
- name: start_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp to which the Posts will be provided.
required: false
example: '2021-02-14T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
- name: end_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp to which the Posts will be provided.
required: false
example: '2021-02-14T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
- $ref: '#/components/parameters/TweetFieldsParameter'
- $ref: '#/components/parameters/TweetExpansionsParameter'
- $ref: '#/components/parameters/MediaFieldsParameter'
- $ref: '#/components/parameters/PollFieldsParameter'
- $ref: '#/components/parameters/UserFieldsParameter'
- $ref: '#/components/parameters/PlaceFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/StreamingTweetResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
x-twitter-streaming: true
/2/tweets/firehose/stream/lang/ja:
get:
security:
- BearerToken: []
tags:
- Tweets
summary: Stream Japanese Posts
description: Streams all public Japanese-language Posts in real-time.
operationId: streamPostsFirehoseJa
parameters:
- name: backfill_minutes
in: query
description: The number of minutes of backfill requested.
required: false
schema:
type: integer
minimum: 0
maximum: 5
format: int32
style: form
- name: partition
in: query
description: The partition number.
required: true
schema:
type: integer
minimum: 1
maximum: 2
format: int32
style: form
- name: start_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp to which the Posts will be provided.
required: false
example: '2021-02-14T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
- name: end_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp to which the Posts will be provided.
required: false
example: '2021-02-14T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
- $ref: '#/components/parameters/TweetFieldsParameter'
- $ref: '#/components/parameters/TweetExpansionsParameter'
- $ref: '#/components/parameters/MediaFieldsParameter'
- $ref: '#/components/parameters/PollFieldsParameter'
- $ref: '#/components/parameters/UserFieldsParameter'
- $ref: '#/components/parameters/PlaceFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/StreamingTweetResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
x-twitter-streaming: true
/2/tweets/firehose/stream/lang/ko:
get:
security:
- BearerToken: []
tags:
- Tweets
summary: Stream Korean Posts
description: Streams all public Korean-language Posts in real-time.
operationId: streamPostsFirehoseKo
parameters:
- name: backfill_minutes
in: query
description: The number of minutes of backfill requested.
required: false
schema:
type: integer
minimum: 0
maximum: 5
format: int32
style: form
- name: partition
in: query
description: The partition number.
required
# --- truncated at 32 KB (170 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/twitter-x/refs/heads/main/openapi/twitter-x-tweets-api-openapi.yml