unpaginate


Nameunpaginate JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryChain calls of paginated APIs
upload_time2024-04-28 14:36:10
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseThe 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.
keywords api chain iterable page paginated pagination
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <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 -->

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "unpaginate",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "api, chain, iterable, page, paginated, pagination",
    "author": null,
    "author_email": "Rogdham <contact@rogdham.net>",
    "download_url": "https://files.pythonhosted.org/packages/30/b1/e907f33a94c1f2d8ae62f2bc1d515b09432379748665dfea735fae2714eb/unpaginate-0.1.0.tar.gz",
    "platform": null,
    "description": "<div align=\"center\" size=\"15px\">\n\n# Unpaginate\n\nChain calls of paginated APIs\n\n[![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)\n[![Release on PyPI](https://img.shields.io/pypi/v/unpaginate)](https://pypi.org/project/unpaginate/)\n[![Code coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/rogdham/unpaginate/search?q=fail+under&type=Code)\n[![Mypy type checker](https://img.shields.io/badge/type_checker-mypy-informational)](https://mypy.readthedocs.io/)\n[![MIT License](https://img.shields.io/pypi/l/unpaginate)](https://github.com/Rogdham/unpaginate/blob/master/LICENSE.txt)\n\n---\n\n[\ud83d\udcd6 Documentation](https://unpaginate.rogdham.net/)&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;[\ud83d\udcc3 Changelog](./CHANGELOG.md)\n\n</div>\n\n---\n\n<!-- BEGIN README INSERT -->\n\nAPI endpoints are often paginated, meaning that you must chain requests to get the\ncontent in full. _Unpaginate_ provides a decorator to make that task easy:\n\n```python\n>>> from unpaginate import unpaginate\n\n>>> @unpaginate\n... def get_cities(pagination, country):\n...     return requests.post(\n...         \"https://api.example.org/cities\",\n...         json={\"country\": country, \"page\": pagination.page},\n...     ).json()[\"items\"]\n```\n\nCalling the decorated function allows to iterate over all items of all pages:\n\n```python\n>>> iterator = get_cities(\"France\")  # the 'pagination' parameter is added by the decorator\n>>> iterator\n<generator object get_cities ...>\n\n>>> next(iterator)\n'Paris'\n>>> next(iterator)\n'Lyon'\n>>> next(iterator)\n'Marseille'\n```\n\nAll pagination schemes are supported:\n\n- [By page index](https://unpaginate.rogdham.net/usecases/#by-page)\n- [By offset](https://unpaginate.rogdham.net/usecases/#by-offset)\n- [Using a cursor](https://unpaginate.rogdham.net/usecases/#by-cursor)\n- Other schemes through [avdanced mode](https://unpaginate.rogdham.net/usecases/#advanced)\n\n<!-- END README INSERT -->\n",
    "bugtrack_url": null,
    "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.",
    "summary": "Chain calls of paginated APIs",
    "version": "0.1.0",
    "project_urls": {
        "Documentation": "https://unpaginate.rogdham.net/",
        "Homepage": "https://github.com/rogdham/unpaginate",
        "Source": "https://github.com/rogdham/unpaginate"
    },
    "split_keywords": [
        "api",
        " chain",
        " iterable",
        " page",
        " paginated",
        " pagination"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "547d181e00f6abfe1361db15074fe39bbd69fe336760cf69e5defa513ccccd8c",
                "md5": "868605663a006ee26be8da8eca256a6a",
                "sha256": "cbcaf68df41ea78a5bb569989c74464e499af234e4ba8462b7f9bec8afcec6d9"
            },
            "downloads": -1,
            "filename": "unpaginate-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "868605663a006ee26be8da8eca256a6a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8237,
            "upload_time": "2024-04-28T14:36:09",
            "upload_time_iso_8601": "2024-04-28T14:36:09.123591Z",
            "url": "https://files.pythonhosted.org/packages/54/7d/181e00f6abfe1361db15074fe39bbd69fe336760cf69e5defa513ccccd8c/unpaginate-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "30b1e907f33a94c1f2d8ae62f2bc1d515b09432379748665dfea735fae2714eb",
                "md5": "31fc688ab1215350488870c18cfcfdde",
                "sha256": "a40db65bfed0be43a3f5bddd259d58b484359db84a34322a1b946953bd5f158c"
            },
            "downloads": -1,
            "filename": "unpaginate-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "31fc688ab1215350488870c18cfcfdde",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 20128,
            "upload_time": "2024-04-28T14:36:10",
            "upload_time_iso_8601": "2024-04-28T14:36:10.374768Z",
            "url": "https://files.pythonhosted.org/packages/30/b1/e907f33a94c1f2d8ae62f2bc1d515b09432379748665dfea735fae2714eb/unpaginate-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-28 14:36:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rogdham",
    "github_project": "unpaginate",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "unpaginate"
}
        
Elapsed time: 0.43567s