--- /dev/null
+.. _pagination_guide:
+
+.. currentmodule:: tweepy
+
+**********
+Pagination
+**********
+
+API v2
+======
+
+.. autoclass:: Paginator
+ :members:
+
+Example
+-------
+
+::
+
+ import tweepy
+
+ 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 tweet in tweepy.Paginator(client.search_recent_tweets, "Tweepy",
+ max_results=100).flatten(limit=250):
+ print(tweet.id)
class Paginator:
+ """:class:`Paginator` can be used to paginate for any :class:`Client`
+ methods that support pagination
+
+ Parameters
+ ----------
+ method
+ :class:`Client` method to paginate for
+ args
+ Positional arguments to pass to ``method``
+ kwargs
+ Keyword arguments to pass to ``method``
+ """
def __init__(self, method, *args, **kwargs):
self.method = method
**self.kwargs)
def flatten(self, limit=inf):
+ """Flatten paginated data
+
+ Parameters
+ ----------
+ limit
+ Maximum number of results to yield
+ """
if limit <= 0:
return