Models Reference
****************
-API v1.1
-========
+.. tabs::
-.. class:: tweepy.models.BoundingBox
+ .. group-tab:: API v1.1
- :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/geo#bounding-box
+ .. class:: tweepy.models.BoundingBox
-.. class:: tweepy.models.DirectMessage
+ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/geo#bounding-box
- :reference: https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/guides/message-create-object
+ .. class:: tweepy.models.DirectMessage
-.. class:: tweepy.models.Friendship
+ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/guides/message-create-object
- :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-friendships-show#example-response
+ .. class:: tweepy.models.Friendship
-.. class:: tweepy.models.List
+ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-friendships-show#example-response
- :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/get-lists-show#example-response
+ .. class:: tweepy.models.List
-.. class:: tweepy.models.Media
+ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/get-lists-show#example-response
- :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/entities#media
+ .. class:: tweepy.models.Media
-.. class:: tweepy.models.Place
+ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/entities#media
- :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/geo#place
+ .. class:: tweepy.models.Place
-.. class:: tweepy.models.Relationship
+ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/geo#place
- :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-friendships-lookup#example-response
+ .. class:: tweepy.models.Relationship
-.. class:: tweepy.models.SavedSearch
+ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-friendships-lookup#example-response
- :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/get-saved_searches-show-id#example-response
+ .. class:: tweepy.models.SavedSearch
-.. class:: tweepy.models.SearchResults
+ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/get-saved_searches-show-id#example-response
- :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets#example-response
+ .. class:: tweepy.models.SearchResults
-.. class:: tweepy.models.Status
+ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets#example-response
- :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/tweet
+ .. class:: tweepy.models.Status
-.. class:: tweepy.models.User
+ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/tweet
- :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/user
+ .. class:: tweepy.models.User
-API v2
-======
+ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/user
-.. class:: tweepy.Media
+ .. group-tab:: API v2
- :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/media
+ .. class:: tweepy.Media
-.. class:: tweepy.Place
+ :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/media
- :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/place
+ .. class:: tweepy.Place
-.. class:: tweepy.Poll
+ :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/place
- :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/poll
+ .. class:: tweepy.Poll
-.. class:: tweepy.ReferencedTweet
+ :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/poll
- :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/tweet
+ .. class:: tweepy.ReferencedTweet
-.. class:: tweepy.Tweet
+ :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/tweet
- :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/tweet
+ .. class:: tweepy.Tweet
-.. class:: tweepy.User
+ :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/tweet
- :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/user
+ .. class:: tweepy.User
+
+ :reference: https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/user
Pagination
**********
-API v1.1
-========
+.. tabs::
-.. autoclass:: Cursor
- :members:
+ .. group-tab:: API v1.1
+
+ .. autoclass:: Cursor
+ :members:
+
+ .. group-tab:: API v2
+
+ .. autoclass:: Paginator
+ :members:
Example
-------
-::
+.. tabs::
- import tweepy
+ .. group-tab:: API v1.1
- auth = tweepy.AppAuthHandler("Consumer Key here", "Consumer Secret here")
- api = tweepy.API(auth)
+ ::
- for status in tweepy.Cursor(api.search_tweets, "Tweepy",
- count=100).items(250):
- print(status.id)
+ import tweepy
- for page in tweepy.Cursor(api.get_followers, screen_name="TwitterDev",
- count=200).pages(5):
- print(len(page))
+ auth = tweepy.AppAuthHandler("Consumer Key here", "Consumer Secret here")
+ api = tweepy.API(auth)
-API v2
-======
+ for status in tweepy.Cursor(api.search_tweets, "Tweepy",
+ count=100).items(250):
+ print(status.id)
-.. autoclass:: Paginator
- :members:
+ for page in tweepy.Cursor(api.get_followers, screen_name="TwitterDev",
+ count=200).pages(5):
+ print(len(page))
-Example
--------
+ .. group-tab:: API v2
-::
+ ::
- import tweepy
+ import tweepy
- client = tweepy.Client("Bearer Token here")
+ client = tweepy.Client("Bearer Token here")
- for response in tweepy.Paginator(client.get_users_followers, 2244994945,
- max_results=1000, limit=5):
- print(response.meta)
+ for response in tweepy.Paginator(client.get_users_followers, 2244994945,
+ max_results=1000, limit=5):
+ print(response.meta)
- for tweet in tweepy.Paginator(client.search_recent_tweets, "Tweepy",
- max_results=100).flatten(limit=250):
- print(tweet.id)
+ for tweet in tweepy.Paginator(client.search_recent_tweets, "Tweepy",
+ max_results=100).flatten(limit=250):
+ print(tweet.id)