Skip to content

Latest commit

 

History

History
646 lines (518 loc) · 38.4 KB

client.rst

File metadata and controls

646 lines (518 loc) · 38.4 KB

tweepy

Client

Client

Twitter API v2 Endpoint Client Method

Tweets

Hide replies_

PUT /2/tweets/:id/hidden Client.hide_reply
PUT /2/tweets/:id/hidden Client.unhide_reply

Likes_

DELETE /2/users/:id/likes/:tweet_id Client.unlike
GET /2/tweets/:id/liking_users Client.get_liking_users
GET /2/users/:id/liked_tweets Client.get_liked_tweets
POST /2/users/:id/likes Client.like

Manage Tweets_

DELETE /2/tweets/:id Client.delete_tweet
POST /2/tweets Client.create_tweet

Quote Tweets_

GET /2/tweets/:id/quote_tweets Client.get_quote_tweets

Retweets_

DELETE /2/users/:id/retweets/:source_tweet_id Client.unretweet
GET /2/tweets/:id/retweeted_by Client.get_retweeters
POST /2/users/:id/retweets Client.retweet

Search Tweets_

GET /2/tweets/search/all Client.search_all_tweets
GET /2/tweets/search/recent Client.search_recent_tweets

Timelines_

GET /2/users/:id/mentions Client.get_users_mentions
GET /2/users/:id/tweets Client.get_users_tweets

Tweet counts_

GET /2/tweets/counts/all Client.get_all_tweets_count
GET /2/tweets/counts/recent Client.get_recent_tweets_count

Tweet lookup_

GET /2/tweets/:id Client.get_tweet
GET /2/tweets Client.get_tweets

Users

Blocks_

DELETE /2/users/:source_user_id/blocking/:target_user_id Client.unblock
GET /2/users/:id/blocking Client.get_blocked
POST /2/users/:id/blocking Client.block

Follows_

DELETE /2/users/:source_user_id/following/:target_user_id Client.unfollow_user
GET /2/users/:id/followers Client.get_users_followers
GET /2/users/:id/following Client.get_users_following
POST /2/users/:id/following Client.follow_user

Mutes_

DELETE /2/users/:source_user_id/muting/:target_user_id Client.unmute
GET /2/users/:id/muting Client.get_muted
POST /2/users/:id/muting Client.mute

User lookup_

GET /2/users/:id Client.get_user
GET /2/users/by/username/:username Client.get_user
GET /2/users Client.get_users
GET /2/users/by Client.get_users
GET /2/users/me Client.get_me

Spaces

Search Spaces_

GET /2/spaces/search Client.search_spaces

Spaces lookup_

GET /2/spaces Client.get_spaces
GET /2/spaces/:id Client.get_space
GET /2/spaces/:id/buyers Client.get_space_buyers
GET /2/spaces/:id/tweets Client.get_space_tweets
GET /2/spaces/by/creator_ids Client.get_spaces

Lists

List Tweets lookup_

GET /2/lists/:id/tweets Client.get_list_tweets

List follows_

DELETE /2/users/:id/followed_lists/:list_id Client.unfollow_list
GET /2/lists/:id/followers Client.get_list_followers
GET /2/users/:id/followed_lists Client.get_followed_lists
POST /2/users/:id/followed_lists Client.follow_list

List lookup_

GET /2/lists/:id Client.get_list
GET /2/users/:id/owned_lists Client.get_owned_lists

List members_

DELETE /2/lists/:id/members/:user_id Client.remove_list_member
GET /2/lists/:id/members Client.get_list_members
GET /2/users/:id/list_memberships Client.get_list_memberships
POST /2/lists/:id/members Client.add_list_member

Manage Lists_

DELETE /2/lists/:id Client.delete_list
PUT /2/lists/:id Client.update_list
POST /2/lists Client.create_list

Pinned Lists_

DELETE /2/users/:id/pinned_lists/:list_id Client.unpin_list
GET /2/users/:id/pinned_lists Client.get_pinned_lists
POST /2/users/:id/pinned_lists Client.pin_list

Compliance

Batch Compliance_

GET /2/compliance/jobs Client.get_compliance_jobs
GET /2/compliance/jobs/:id Client.get_compliance_job
POST /2/compliance/jobs Client.create_compliance_job

Tweets

Hide replies

Client.hide_reply

Client.unhide_reply

Likes

Client.unlike

Client.get_liking_users

Client.get_liked_tweets

Client.like

Manage Tweets

Client.delete_tweet

Client.create_tweet

Quote Tweets

Client.get_quote_tweets

Retweets

Client.unretweet

Client.get_retweeters

Client.retweet

Search Tweets

Client.search_all_tweets

Client.search_recent_tweets

Timelines

Client.get_users_mentions

Client.get_users_tweets

Tweet counts

Client.get_all_tweets_count

Client.get_recent_tweets_count

Tweet lookup

Client.get_tweet

Client.get_tweets

Users

Blocks

Client.unblock

Client.get_blocked

Client.block

Follows

Client.unfollow_user

Client.unfollow

Client.get_users_followers

Client.get_users_following

Client.follow_user

Client.follow

Mutes

Client.unmute

Client.get_muted

Client.mute

User lookup

Client.get_user

Client.get_users

Client.get_me

Spaces

Search Spaces

Client.search_spaces

Spaces lookup

Client.get_spaces

Client.get_space

Client.get_space_buyers

Client.get_space_tweets

Lists

List Tweets lookup

Client.get_list_tweets

List follows

Client.unfollow_list

Client.get_list_followers

Client.get_followed_lists

Client.follow_list

List lookup

Client.get_list

Client.get_owned_lists

List members

Client.remove_list_member

Client.get_list_members

Client.get_list_memberships

Client.add_list_member

Manage Lists

Client.delete_list

Client.update_list

Client.create_list

Pinned Lists

Client.unpin_list

Client.get_pinned_lists

Client.pin_list

Compliance

Batch compliance

Client.get_compliance_jobs

Client.get_compliance_job

Client.create_compliance_job

Expansions and Fields Parameters

expansions

Expansions enable you to request additional data objects that relate to the originally returned List, Space, Tweets, or users. Submit a list of desired expansions in a comma-separated list without spaces. The ID that represents the expanded data object will be included directly in the List, Space, Tweet, or user data object, but the expanded object metadata will be returned within the includes response object, and will also include the ID so that you can match this data object to the original Space, Tweet, or user object.

At this time, the only expansion available to endpoints that primarily return List objects is expansions=owner_id. You will find the expanded user data object living in the includes response object.

For methods that return Spaces, the following data objects can be expanded using this parameter:

  • The Spaces creator's user object
  • The user objects of any Space co-host
  • Any mentioned users’ object
  • Any speaker's user object

For methods that return Tweets, the following data objects can be expanded using this parameter:

  • The Tweet author's user object
  • The user object of the Tweet’s author that the original Tweet is responding to
  • Any mentioned users’ object
  • Any referenced Tweets’ author’s user object
  • Attached media’s object
  • Attached poll’s object
  • Attached place’s object
  • Any referenced Tweets’ object

At this time, the only expansion available to endpoints that primarily return user objects is expansions=pinned_tweet_id. You will find the expanded Tweet data object living in the includes response object.

list_fields

This fields parameter enables you to select which specific List fields will deliver with each returned List objects. Specify the desired fields in a comma-separated list without spaces between commas and fields. These specified List fields will display directly in the List data objects.

media_fields

This fields parameter enables you to select which specific media fields will deliver in each returned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. The Tweet will only return media fields if the Tweet contains media and if you've also included the expansions=attachments.media_keys query parameter in your request. While the media ID will be located in the Tweet object, you will find this ID and all additional media fields in the includes data object.

place_fields

This fields parameter enables you to select which specific place fields will deliver in each returned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. The Tweet will only return place fields if the Tweet contains a place and if you've also included the expansions=geo.place_id query parameter in your request. While the place ID will be located in the Tweet object, you will find this ID and all additional place fields in the includes data object.

poll_fields

This fields parameter enables you to select which specific poll fields will deliver in each returned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. The Tweet will only return poll fields if the Tweet contains a poll and if you've also included the expansions=attachments.poll_ids query parameter in your request. While the poll ID will be located in the Tweet object, you will find this ID and all additional poll fields in the includes data object.

space_fields

This fields parameter enables you to select which specific Space fields will deliver in each returned Space. Specify the desired fields in a comma-separated list.

tweet_fields

For methods that return Tweets, this fields parameter enables you to select which specific Tweet fields will deliver in each returned Tweet object. Specify the desired fields in a comma-separated list without spaces between commas and fields. You can also pass the expansions=referenced_tweets.id expansion to return the specified fields for both the original Tweet and any included referenced Tweets. The requested Tweet fields will display in both the original Tweet data object, as well as in the referenced Tweet expanded data object that will be located in the includes data object.

For methods that return users, this fields parameter enables you to select which specific Tweet fields will deliver in each returned pinned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. The Tweet fields will only return if the user has a pinned Tweet and if you've also included the expansions=pinned_tweet_id query parameter in your request. While the referenced Tweet ID will be located in the original Tweet object, you will find this ID and all additional Tweet fields in the includes data object.

user_fields

For methods that return Spaces or Tweets, this fields parameter enables you to select which specific user fields will deliver in each returned Space or Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. While the user ID will be located in the original Tweet object, you will find this ID and all additional user fields in the includes data object.

You must also pass one of the user expansions to return the desired user fields:

  • expansions=author_id
  • expansions=entities.mentions.username
  • expansions=in_reply_to_user_id
  • expansions=referenced_tweets.id.author_id

For methods that return users, this fields parameter enables you to select which specific user fields will deliver with each returned users objects. Specify the desired fields in a comma-separated list without spaces between commas and fields. These specified user fields will display directly in the user data objects.

Response

Response

The Response returned by Client methods is a collections.namedtuple, with data, includes, errors, and meta fields, corresponding with the fields in responses from Twitter's API.

4.0