Metadata-Version: 2.3
Name: unpaginate
Version: 0.1.0
Summary: Chain calls of paginated APIs
Project-URL: Homepage, https://github.com/rogdham/unpaginate
Project-URL: Documentation, https://unpaginate.rogdham.net/
Project-URL: Source, https://github.com/rogdham/unpaginate
Author-email: Rogdham <contact@rogdham.net>
License: The MIT License (MIT)
        
        Copyright (c) 2020 Rogdham
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE.txt
Keywords: api,chain,iterable,page,paginated,pagination
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Requires-Dist: typing-extensions>=4.11.0; python_version < '3.13'
Description-Content-Type: text/markdown

<div align="center" size="15px">

# Unpaginate

Chain calls of paginated APIs

[![GitHub build status](https://img.shields.io/github/actions/workflow/status/rogdham/unpaginate/build.yml?branch=master)](https://github.com/rogdham/unpaginate/actions?query=branch:master)
[![Release on PyPI](https://img.shields.io/pypi/v/unpaginate)](https://pypi.org/project/unpaginate/)
[![Code coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/rogdham/unpaginate/search?q=fail+under&type=Code)
[![Mypy type checker](https://img.shields.io/badge/type_checker-mypy-informational)](https://mypy.readthedocs.io/)
[![MIT License](https://img.shields.io/pypi/l/unpaginate)](https://github.com/Rogdham/unpaginate/blob/master/LICENSE.txt)

---

[📖 Documentation](https://unpaginate.rogdham.net/)&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;[📃 Changelog](./CHANGELOG.md)

</div>

---

<!-- BEGIN README INSERT -->

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:

```python
>>> 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:

```python
>>> 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:

- [By page index](https://unpaginate.rogdham.net/usecases/#by-page)
- [By offset](https://unpaginate.rogdham.net/usecases/#by-offset)
- [Using a cursor](https://unpaginate.rogdham.net/usecases/#by-cursor)
- Other schemes through [avdanced mode](https://unpaginate.rogdham.net/usecases/#advanced)

<!-- END README INSERT -->
