[PR]

Pagination

class tweepy.Paginator(self, method, *args, limit=inf, pagination_token=None, **kwargs)

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

注釈

When the returned response from the method being passed is of type requests.Response, it will be deserialized in order to parse the pagination tokens, likely negating any potential performance benefits from using a requests.Response return type.

バージョン 4.0 で追加.

パラメータ:
  • method -- Client method to paginate for

  • args -- Positional arguments to pass to method

  • limit -- Maximum number of requests to make to the API

  • pagination_token -- Pagination token to start pagination with

  • kwargs -- Keyword arguments to pass to method

flatten(limit=inf)

Flatten paginated data

パラメータ:

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)
class tweepy.asynchronous.AsyncPaginator(self, method, *args, limit=inf, pagination_token=None, **kwargs)

AsyncPaginator can be used to paginate for any AsyncClient methods that support pagination

注釈

When the returned response from the method being passed is of type aiohttp.ClientResponse, it will be deserialized in order to parse the pagination tokens, likely negating any potential performance benefits from using a aiohttp.ClientResponse return type.

バージョン 4.11 で追加.

パラメータ:
  • method -- AsyncClient method to paginate for

  • args -- Positional arguments to pass to method

  • limit -- Maximum number of requests to make to the API

  • pagination_token -- Pagination token to start pagination with

  • kwargs -- Keyword arguments to pass to method

async flatten(limit=inf)

Flatten paginated data

パラメータ:

limit -- Maximum number of results to yield