tweepy
stable
  • Installation
  • Getting started
  • Authentication
  • Logging
  • Streaming

Twitter API v1.1 Reference

  • API
  • Stream
  • AsyncStream
  • Exceptions
  • Models
  • Pagination
  • Extended Tweets

Twitter API v2 Reference

  • Client
  • Response
  • StreamingClient
  • StreamResponse
  • StreamRule
  • AsyncClient
  • AsyncStreamingClient
  • Exceptions
  • Expansions and Fields
  • Models
  • Pagination

Meta

  • Changelog
  • Development
  • Examples
  • Frequently Asked Questions
tweepy
  • »
  • Pagination
  • Edit on GitHub

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

Note

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.

New in version 4.0.

Parameters
  • 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

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)
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

Note

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.

New in version 4.11.

Parameters
  • 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

flatten(limit=inf)

Flatten paginated data

Parameters

limit – Maximum number of results to yield

Previous Next

© Copyright 2009-2022, Joshua Roesslein. Revision cc8dd493.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: stable
Versions
latest
stable
v4.12.1
v4.12.0
v4.11.0
v4.10.1
v4.10.0
v4.9.0
v4.8.0
v4.7.0
v4.6.0
v4.5.0
v4.4.0
v4.3.0
v4.2.0
v4.1.0
v4.0.1
v4.0.0
v3.10.0
v3.9.0
v3.8.0
v3.7.0
v3.6.0
v3.5.0
v3.4.0
v3.3.0
v3.2.0
v3.1.0
v3.0.0
v2.3.0
Downloads
On Read the Docs
Project Home
Builds