Skip to main content

Unpaginate

Chain calls of paginated APIs

GitHub build status Release on PyPI Code coverage Mypy type checker MIT License


📖 Documentation   |   📃 Changelog


API endpoints are often paginated, meaning that you must chain requests to get the content in full. Unpaginate provides a decorator to make that task easy:

>>> from unpaginate import unpaginate

>>> @unpaginate
... def get_cities(pagination, country):
...     return requests.post(
...         "https://api.example.org/cities",
...         json={"country": country, "page": pagination.page},
...     ).json()["items"]

Calling the decorated function allows to iterate over all items of all pages:

>>> iterator = get_cities("France")  # the 'pagination' parameter is added by the decorator
>>> iterator
<generator object get_cities ...>

>>> next(iterator)
'Paris'
>>> next(iterator)
'Lyon'
>>> next(iterator)
'Marseille'

All pagination schemes are supported:

Metadata

Release files for unpaginate 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unpaginate 0.1.0
File Size Uploaded
unpaginate-0.1.0.tar.gz 20.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for unpaginate 0.1.0
File Interpreter ABI Platform
unpaginate-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.4 kB

Release files / unpaginate-0.1.0.tar.gz

Download URL unpaginate-0.1.0.tar.gz
Size 20.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a40db65bfed0be43a3f5bddd259d58b484359db84a34322a1b946953bd5f158c
BLAKE2b-256 checksum
How to use checksums
30b1e907f33a94c1f2d8ae62f2bc1d515b09432379748665dfea735fae2714eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / unpaginate-0.1.0-py3-none-any.whl

Download URL unpaginate-0.1.0-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cbcaf68df41ea78a5bb569989c74464e499af234e4ba8462b7f9bec8afcec6d9
BLAKE2b-256 checksum
How to use checksums
547d181e00f6abfe1361db15074fe39bbd69fe336760cf69e5defa513ccccd8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page