Pagination

class tweepy.Paginator(method, *args, **kwargs)

Paginator can be used to paginate for any Client methods that support pagination

New in version 4.0.

Parameters
  • methodClient method to paginate for

  • args – Positional arguments to pass to method

  • kwargs – Keyword arguments to pass to method

flatten(limit=inf)

Flatten paginated data

Parameters

limit – Maximum number of results to yield

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)