Skip to content

Latest commit

 

History

History
244 lines (174 loc) · 7.93 KB

client.rst

File metadata and controls

244 lines (174 loc) · 7.93 KB

tweepy

tweepy.Client --- Twitter API v2 Reference

Client

Tweets

Hide replies

Client.hide_reply

Client.unhide_reply

Likes

Client.unlike

Client.get_liking_users

Client.get_liked_tweets

Client.like

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

Client.get_users_followers

Client.get_users_following

Client.follow

Mutes

Client.unmute

Client.mute

User lookup

Client.get_user

Client.get_users

Expansions and Fields Parameters

expansions

For methods that return Tweets, Expansions enable you to request additional data objects that relate to the originally returned Tweets. 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 Tweet 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 Tweet object.

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

For methods that return users, Expansions enable you to request additional data objects that relate to the originally returned users. The ID that represents the expanded data object will be included directly in the 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 Tweet 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.

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.

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 Tweets, this fields parameter enables you to select which specific user fields will deliver in each returned 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.