Twitter/X Spaces API
Endpoints related to retrieving, managing Spaces
Endpoints related to retrieving, managing Spaces
openapi: 3.0.0
info:
description: X API v2 available endpoints
version: '2.166'
title: X API v2 Account Activity Spaces 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: Spaces
description: Endpoints related to retrieving, managing Spaces
externalDocs:
description: Find out more
url: https://developer.twitter.com/en/docs/twitter-api/spaces
paths:
/2/spaces:
get:
security:
- BearerToken: []
- OAuth2UserToken:
- space.read
- tweet.read
- users.read
tags:
- Spaces
summary: Get Spaces by IDs
description: Retrieves details of multiple Spaces by their IDs.
externalDocs:
url: https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces
operationId: getSpacesByIds
parameters:
- name: ids
in: query
description: The list of Space IDs to return.
required: true
schema:
type: array
minItems: 1
maxItems: 100
items:
type: string
description: The unique identifier of this Space.
pattern: ^[a-zA-Z0-9]{1,13}$
example: 1SLjjRYNejbKM
style: form
- $ref: '#/components/parameters/SpaceFieldsParameter'
- $ref: '#/components/parameters/SpaceExpansionsParameter'
- $ref: '#/components/parameters/UserFieldsParameter'
- $ref: '#/components/parameters/TopicFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Get2SpacesResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
/2/spaces/by/creator_ids:
get:
security:
- BearerToken: []
- OAuth2UserToken:
- space.read
- tweet.read
- users.read
tags:
- Spaces
summary: Get Spaces by creator IDs
description: Retrieves details of Spaces created by specified User IDs.
externalDocs:
url: https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-by-creator-ids
operationId: getSpacesByCreatorIds
parameters:
- name: user_ids
in: query
description: The IDs of Users to search through.
required: true
schema:
type: array
minItems: 1
maxItems: 100
items:
$ref: '#/components/schemas/UserId'
style: form
- $ref: '#/components/parameters/SpaceFieldsParameter'
- $ref: '#/components/parameters/SpaceExpansionsParameter'
- $ref: '#/components/parameters/UserFieldsParameter'
- $ref: '#/components/parameters/TopicFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Get2SpacesByCreatorIdsResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
/2/spaces/search:
get:
security:
- BearerToken: []
- OAuth2UserToken:
- space.read
- tweet.read
- users.read
tags:
- Spaces
summary: Search Spaces
description: Retrieves a list of Spaces matching the specified search query.
externalDocs:
url: https://developer.twitter.com/en/docs/twitter-api/spaces/search/api-reference/get-spaces-search
operationId: searchSpaces
parameters:
- name: query
in: query
description: The search query.
required: true
example: crypto
schema:
type: string
minLength: 1
maxLength: 2048
example: crypto
style: form
- name: state
in: query
description: The state of Spaces to search for.
required: false
schema:
type: string
enum:
- live
- scheduled
- all
default: all
style: form
- name: max_results
in: query
description: The number of results to return.
required: false
schema:
type: integer
minimum: 1
maximum: 100
format: int32
default: 100
style: form
- $ref: '#/components/parameters/SpaceFieldsParameter'
- $ref: '#/components/parameters/SpaceExpansionsParameter'
- $ref: '#/components/parameters/UserFieldsParameter'
- $ref: '#/components/parameters/TopicFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Get2SpacesSearchResponse'
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}:
get:
security:
- BearerToken: []
- OAuth2UserToken:
- space.read
- tweet.read
- users.read
tags:
- Spaces
summary: Get space by ID
description: Retrieves details of a specific space by its ID.
externalDocs:
url: https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-id
operationId: getSpacesById
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
- $ref: '#/components/parameters/SpaceFieldsParameter'
- $ref: '#/components/parameters/SpaceExpansionsParameter'
- $ref: '#/components/parameters/UserFieldsParameter'
- $ref: '#/components/parameters/TopicFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Get2SpacesIdResponse'
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:
- Spaces
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:
- Spaces
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'
components:
parameters:
TweetExpansionsParameter:
name: expansions
in: query
description: A comma separated list of fields to expand.
schema:
type: array
description: The list of fields you can expand for a [Tweet](#Tweet) object. If the field has an ID, it can be expanded into a full object.
minItems: 1
uniqueItems: true
items:
type: string
enum:
- article.cover_media
- article.media_entities
- attachments.media_keys
- attachments.media_source_tweet
- attachments.poll_ids
- author_id
- edit_history_tweet_ids
- entities.mentions.username
- geo.place_id
- in_reply_to_user_id
- entities.note.mentions.username
- referenced_tweets.id
- referenced_tweets.id.attachments.media_keys
- referenced_tweets.id.author_id
example:
- article.cover_media
- article.media_entities
- attachments.media_keys
- attachments.media_source_tweet
- attachments.poll_ids
- author_id
- edit_history_tweet_ids
- entities.mentions.username
- geo.place_id
- in_reply_to_user_id
- entities.note.mentions.username
- referenced_tweets.id
- referenced_tweets.id.attachments.media_keys
- referenced_tweets.id.author_id
explode: false
style: form
TopicFieldsParameter:
name: topic.fields
in: query
description: A comma separated list of Topic fields to display.
required: false
schema:
type: array
description: The fields available for a Topic object.
minItems: 1
uniqueItems: true
items:
type: string
enum:
- description
- id
- name
example:
- description
- id
- name
explode: false
style: form
UserExpansionsParameter:
name: expansions
in: query
description: A comma separated list of fields to expand.
schema:
type: array
description: The list of fields you can expand for a [User](#User) object. If the field has an ID, it can be expanded into a full object.
minItems: 1
uniqueItems: true
items:
type: string
enum:
- affiliation.user_id
- most_recent_tweet_id
- pinned_tweet_id
example:
- affiliation.user_id
- most_recent_tweet_id
- pinned_tweet_id
explode: false
style: form
TweetFieldsParameter:
name: tweet.fields
in: query
description: A comma separated list of Tweet fields to display.
required: false
schema:
type: array
description: The fields available for a Tweet object.
minItems: 1
uniqueItems: true
items:
type: string
enum:
- article
- attachments
- author_id
- card_uri
- community_id
- context_annotations
- conversation_id
- created_at
- display_text_range
- edit_controls
- edit_history_tweet_ids
- entities
- geo
- id
- in_reply_to_user_id
- lang
- matched_media_notes
- media_metadata
- non_public_metrics
- note_request_suggestions
- note_tweet
- organic_metrics
- paid_partnership
- possibly_sensitive
- promoted_metrics
- public_metrics
- referenced_tweets
- reply_settings
- scopes
- source
- suggested_source_links
- suggested_source_links_with_counts
- text
- withheld
example:
- article
- attachments
- author_id
- card_uri
- community_id
- context_annotations
- conversation_id
- created_at
- display_text_range
- edit_controls
- edit_history_tweet_ids
- entities
- geo
- id
- in_reply_to_user_id
- lang
- matched_media_notes
- media_metadata
- non_public_metrics
- note_request_suggestions
- note_tweet
- organic_metrics
- paid_partnership
- possibly_sensitive
- promoted_metrics
- public_metrics
- referenced_tweets
- reply_settings
- scopes
- source
- suggested_source_links
- suggested_source_links_with_counts
- text
- withheld
explode: false
style: form
PollFieldsParameter:
name: poll.fields
in: query
description: A comma separated list of Poll fields to display.
required: false
schema:
type: array
description: The fields available for a Poll object.
minItems: 1
uniqueItems: true
items:
type: string
enum:
- duration_minutes
- end_datetime
- id
- options
- voting_status
example:
- duration_minutes
- end_datetime
- id
- options
- voting_status
explode: false
style: form
UserFieldsParameter:
name: user.fields
in: query
description: A comma separated list of User fields to display.
required: false
schema:
type: array
description: The fields available for a User object.
minItems: 1
uniqueItems: true
items:
type: string
enum:
- affiliation
- confirmed_email
- connection_status
- created_at
- description
- entities
- id
- is_identity_verified
- location
- most_recent_tweet_id
- name
- parody
- pinned_tweet_id
- profile_banner_url
- profile_image_url
- protected
- public_metrics
- receives_your_dm
- subscription
- subscription_type
- url
- username
- verified
- verified_followers_count
- verified_type
- withheld
example:
- affiliation
- confirmed_email
- connection_status
- created_at
- description
- entities
- id
- is_identity_verified
- location
- most_recent_tweet_id
- name
- parody
- pinned_tweet_id
- profile_banner_url
- profile_image_url
- protected
- public_metrics
- receives_your_dm
- subscription
- subscription_type
- url
- username
- verified
- verified_followers_count
- verified_type
- withheld
explode: false
style: form
SpaceFieldsParameter:
name: space.fields
in: query
description: A comma separated list of Space fields to display.
required: false
schema:
type: array
description: The fields available for a Space object.
minItems: 1
uniqueItems: true
items:
type: string
enum:
- created_at
- creator_id
- ended_at
- host_ids
- id
- invited_user_ids
- is_ticketed
- lang
- participant_count
- scheduled_start
- speaker_ids
- started_at
- state
- subscriber_count
- title
- topic_ids
- updated_at
example:
- created_at
- creator_id
- ended_at
- host_ids
- id
- invited_user_ids
- is_ticketed
- lang
- participant_count
- scheduled_start
- speaker_ids
- started_at
- state
- subscriber_count
- title
- topic_ids
- updated_at
explode: false
style: form
PlaceFieldsParameter:
name: place.fields
in: query
description: A comma separated list of Place fields to display.
required: false
schema:
type: array
description: The fields available for a Place object.
minItems: 1
uniqueItems: true
items:
type: string
enum:
- contained_within
- country
- country_code
- full_name
- geo
- id
- name
- place_type
example:
- contained_within
- country
- country_code
- full_name
- geo
- id
- name
- place_type
explode: false
style: form
MediaFieldsParameter:
name: media.fields
in: query
description: A comma separated list of Media fields to display.
required: false
schema:
type: array
description: The fields available for a Media object.
minItems: 1
uniqueItems: true
items:
type: string
enum:
- alt_text
- duration_ms
- height
- media_key
- non_public_metrics
- organic_metrics
- preview_image_url
- promoted_metrics
- public_metrics
- type
- url
- variants
- width
example:
- alt_text
- duration_ms
- height
- media_key
- non_public_metrics
- organic_metrics
- preview_image_url
- promoted_metrics
- public_metrics
- type
- url
- variants
- width
explode: false
style: form
SpaceExpansionsParameter:
name: expansions
in: query
description: A comma separated list of fields to expand.
schema:
type: array
description: The list of fields you can expand for a [Space](#Space) object. If the field has an ID, it can be expanded into a full object.
minItems: 1
uniqueItems: true
items:
type: string
enum:
- creator_id
- host_ids
- invited_user_ids
- speaker_ids
- topic_ids
example:
- creator_id
- host_ids
- invited_user_ids
- speaker_ids
- topic_ids
explode: false
style: form
schemas:
HashtagEntity:
allOf:
- $ref: '#/components/schemas/EntityIndicesInclusiveExclusive'
- $ref: '#/components/schemas/HashtagFields'
Space:
type: object
description: ''
required:
- id
- state
properties:
created_at:
type: string
description: Creation time of the Space.
format: date-time
example: '2021-07-06T18:40:40.000Z'
creator_id:
$ref: '#/components/schemas/UserId'
ended_at:
type: string
description: End time of the Space.
format: date-time
example: '2021-07-06T18:40:40.000Z'
host_ids:
type: array
description: The user ids for the hosts of the Space.
items:
$ref: '#/components/schemas/UserId'
id:
$ref: '#/components/schemas/SpaceId'
invited_user_ids:
type: array
description: An array of user ids for people who were invited to a Space.
items:
$ref: '#/components/schemas/UserId'
is_ticketed:
type: boolean
description: Denotes if the Space is a ticketed Space.
example: 'false'
lang:
type: string
description: The language of the Space.
example: en
participant_count:
type: integer
description: The number of participants in a Space.
format: int32
example: 10
scheduled_start:
type: string
description: A date time stamp for when a Space is scheduled to begin.
format: date-time
example: '2021-07-06T18:40:40.000Z'
speaker_ids:
type: array
description: An array of user ids for people who were speakers in a Space.
items:
$ref: '#/components/schemas/UserId'
started_at:
type: string
description: When the Space was started as a date string.
format: date-time
example: '2021-7-14T04:35:55Z'
state:
type: string
description: The current state of the Space.
enum:
- live
- scheduled
- ended
example: live
subscriber_count:
type: integer
description: The number of people who have either purchased a ticket or set a reminder for this Space.
format: int32
example: 10
title:
type: string
description: The title of the Space.
example: Spaces are Awesome
topics:
type: array
description: The topics of a Space, as selected by its creator.
items:
type: object
description: The X Topic object.
required:
- id
- name
properties:
description:
type: string
description: The description of the given topic.
id:
type: string
description: An ID suitable for use in the REST API.
name:
type: string
description: The name of the given topic.
example:
description: All about technology
id: '848920371311001600'
name: Technology
updated_at:
type: string
description: When the Space was last updated.
format: date-time
example: '2021-7-14T04:35:55Z'
PlaceId:
type: string
description: The identifier for this place.
example: f7eb2fa2fea288b1
ContextAnnotationEntityFields:
type: object
description: Represents the data for the context annotation entity.
required:
- id
properties:
description:
type: string
description: Description of the context annotation entity.
id:
type: string
description: The unique id for a context annotation entity.
pattern: ^[0-9]{1,19}$
name:
type: string
description: Name of the context annotation entity.
Media:
type: object
required:
- type
properties:
height:
$ref: '#/components/schemas/MediaHeight'
media_key:
$ref: '#/components/schemas/MediaKey'
type:
type: string
width:
$ref: '#/components/schemas/MediaWidth'
discriminator:
propertyName: type
mapping:
animated_gif: '#/components/schemas/AnimatedGif'
photo: '#/components/schemas/Photo'
video: '#/components/schemas/Video'
User:
type: object
description: The X User object.
required:
- id
- name
- username
properties:
affiliation:
type: object
description: Metadata about a user's affiliation.
properties:
badge_url:
type: string
description: The badge URL corresponding to the affiliation.
format: uri
description:
type: string
description: The description of the affiliation.
url:
type: string
description: The URL, if available, to details about an affiliation.
format: uri
user_id:
type: array
minItems: 1
items:
$ref: '#/components/schemas/UserId'
connection_status:
type: array
description: Returns detailed information about the relationship between two users.
minItems: 0
items:
type: string
description: Type of connection between users.
enum:
- follow_request_received
- follow_request_sent
- blocking
- followed_by
- following
- muting
created_at:
type: string
description: Creation time of this User.
format: date-time
description:
type: string
description: The text of this User's profile description (also known as bio), if the User provided one.
entities:
type: object
description: A list of metadata found in the User's profile description.
properties:
description:
$ref: '#/components/schemas/FullTextEntities'
url:
type: object
description: Expanded details for the URL specified in the User's profile, with start and end indices.
properties:
urls:
type: array
minItems: 1
items:
$ref: '#/components/schemas/UrlEntity'
id:
$ref: '#/components/schemas/UserId'
location:
type: string
description: The location specified in the User's profile, if the User provided one. As this is a freeform value, it may not indicate a valid location, but it may be fuzzily evaluated when performing searches with location queries.
most_recent_tweet_id:
$ref: '#/components/schemas/TweetId'
name:
type: string
description: The friendly name of this User, as shown on their profile.
pinned_tweet_id:
$ref: '#/components/schemas/TweetId'
profile_banner_url:
type: string
description: The URL to the profile banner for this User.
format: uri
profile_image_url:
type: string
description: The URL to the profile image for this User.
format: uri
protected:
type: boolean
description: Indicates if this User has chosen to protect their Posts (in other words, if this User's Posts are private).
public_metrics:
type: object
description: A list of metrics for this User.
required:
- followers_count
- following_count
- tweet_count
- listed_count
properties:
followers_count:
type: integer
description: Number of Users who are following this User.
following_count:
type: integer
description: Number of Users this User is following.
like_count:
type: integer
description: The number of likes created by this User.
listed_count:
type: integer
description: The number of lists that include this User.
tweet_count:
type: integer
description: The number of Posts (including Retweets) posted by this User.
receives_your_dm:
type: boolean
description: Indicates if you can send a DM to this User
subscription_type:
type: string
description: 'The X Blue subscription type of the user, eg: Basic, Premium, PremiumPlus or None.'
enum:
- Basic
- Premium
- PremiumPlus
- None
url:
type: string
description: The URL specified in the User's profile.
username:
$ref: '#/components/schemas/UserName'
verified:
type: boolean
description: Indicate if this User is a verified X User.
verified_type:
type: string
description: 'The X Blue verified type of the user, eg: blue, government, business or none.'
enum:
- blue
- government
- business
- none
withheld:
$ref: '#/components/schemas/UserWithheld'
example:
created_at: '2013-12-14T04:35:55Z'
id: '2244994945'
name: X Dev
protected: false
username: TwitterDev
UserName:
type: string
description: The X handle (screen name) of this user.
pattern: ^[A-Za-z0-9_]{1,15}$
MentionEntity:
allOf:
- $ref: '#/components/schemas/EntityIndicesInclusiveExclusive'
- $ref: '#/components/schemas/MentionFields'
Expansions:
type: object
properties:
media:
type: array
minItems: 1
items:
$ref: '#/components/schemas/Media'
places:
type: array
minItems: 1
items:
$ref: '#/components/schemas/Place'
polls:
# --- truncated at 32 KB (65 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/twitter-x/refs/heads/main/openapi/twitter-x-spaces-api-openapi.yml