client.posts (PostsClient).
Methods
create
POST /2/tweets
Create or Edit Post
Creates a new Post for the authenticated user, or edits an existing Post when edit_options are provided. Media in media.media_ids is attached in the order given; get the ids by uploading each image with Upload Media, or a video with Initialize Media Upload. Supports paid partnership disclosure via the paid_partnership field. To share a clip of another Post’s video, set clip to that Post’s id and a range of 5 to 60 seconds.
Parameters
Returns:CreateResponse
create_post_draft
POST /2/posts/drafts
Create Post Draft
Saves a Post draft to the authenticated user’s X account without publishing it. Takes the body of Create or Edit Post, of which a draft stores text, media with tagged users, a reply and the AI and paid partnership disclosures. Any other field that is set is a 400 that names it.
Parameters
Returns:CreatePostDraftResponse
delete
DELETE /2/tweets/{id}
Delete Post
Deletes a specific Post by its ID, if owned by the authenticated user.
Parameters
Returns:DeleteResponse
delete_post_draft
DELETE /2/posts/drafts/{id}
Delete Post Draft
Deletes one of the authenticated user’s Post drafts by its ID. The whole draft is deleted, including any part Get Post Drafts does not list, and cannot be restored. An ID that is not one of the user’s drafts also returns deleted: true.
Parameters
Returns:DeletePostDraftResponse
get_analytics
GET /2/tweets/analytics
Get Post Analytics
Retrieves analytics data for specified Posts within a defined time range.
Parameters
Returns:GetAnalyticsResponse
get_by_id
GET /2/tweets/{id}
Get Post by ID
Retrieves details of a specific Post by its ID.
Parameters
Returns:GetByIdResponse
get_by_ids
GET /2/tweets
Get Posts by IDs
Retrieves details of multiple Posts by their IDs.
Parameters
Returns:GetByIdsResponse
get_counts_all
GET /2/tweets/counts/all Paginated
Get Count of All Posts
Retrieves the count of Posts matching a search query from the full archive.
At most one of pagination_token, next_token may be provided.
Parameters
Returns:Iterator[GetCountsAllResponse]
get_counts_recent
GET /2/tweets/counts/recent Paginated
Get Count of Recent Posts
Retrieves the count of Posts from the last 7 days matching a search query.
At most one of pagination_token, next_token may be provided.
Parameters
Returns:Iterator[GetCountsRecentResponse]
get_liking_users
GET /2/tweets/{id}/liking_users Paginated
Get Liking Users
Retrieves a list of Users who liked a specific Post by its ID.
Parameters
Returns:Iterator[GetLikingUsersResponse]
get_post_drafts
GET /2/posts/drafts Paginated
Get Post Drafts
Returns the authenticated user’s Post drafts, newest first, in the fields of the Create or Edit Post body. thread holds the Posts after the first. A draft with unsupported_content is not listed in full: do not publish it from this list or delete it unless the user asks. Needs the tweet.write scope.
Parameters
Returns:Iterator[GetPostDraftsResponse]
get_quoted
GET /2/tweets/{id}/quote_tweets Paginated
Get Quoted Posts
Retrieves a list of Posts that quote a specific Post by its ID.
Parameters
Returns:Iterator[GetQuotedResponse]
get_reposted_by
GET /2/tweets/{id}/retweeted_by Paginated
Get Reposted By
Retrieves a list of Users who reposted a specific Post by its ID.
Parameters
Returns:Iterator[GetRepostedByResponse]
get_reposts
GET /2/tweets/{id}/retweets Paginated
Get Reposts
Retrieves a list of Posts that repost a specific Post by its ID.
Parameters
Returns:Iterator[GetRepostsResponse]
hide_reply
PUT /2/tweets/{tweet_id}/hidden
Hide Reply
Hides or unhides a reply to a conversation owned by the authenticated user.
Parameters
Returns:HideReplyResponse
search_all
GET /2/tweets/search/all Paginated
Search All Posts
Retrieves Posts from the full archive matching a search query.
At most one of start_time, since_id may be provided. At most one of end_time, until_id may be provided. At most one of pagination_token, next_token may be provided.
Parameters
Returns:Iterator[SearchAllResponse]
search_recent
GET /2/tweets/search/recent Paginated
Search Recent Posts
Retrieves Posts from the last 7 days matching a search query.
At most one of start_time, since_id may be provided. At most one of end_time, until_id may be provided. At most one of pagination_token, next_token may be provided.
Parameters
Returns:Iterator[SearchRecentResponse]