{"id":13424734,"url":"https://github.com/uriyyo/fastapi-pagination","last_synced_at":"2026-01-27T23:54:17.254Z","repository":{"id":37456490,"uuid":"310670921","full_name":"uriyyo/fastapi-pagination","owner":"uriyyo","description":"FastAPI pagination 📖 ","archived":false,"fork":false,"pushed_at":"2025-04-21T14:32:10.000Z","size":5899,"stargazers_count":1328,"open_issues_count":13,"forks_count":147,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-04-24T00:53:56.744Z","etag":null,"topics":["fastapi","fastapi-pagination","fastapi-sqlalchemy","gino","pagination"],"latest_commit_sha":null,"homepage":"https://uriyyo-fastapi-pagination.netlify.app/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uriyyo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-11-06T18:05:12.000Z","updated_at":"2025-04-23T23:47:52.000Z","dependencies_parsed_at":"2022-07-11T10:31:22.265Z","dependency_job_id":"aa04fc4b-bcb6-4be6-8c7a-5b25accd6325","html_url":"https://github.com/uriyyo/fastapi-pagination","commit_stats":{"total_commits":1258,"total_committers":47,"mean_commits":26.76595744680851,"dds":0.3767885532591415,"last_synced_commit":"206af6306d2cfa7c123b9c99f85e9771b409c2eb"},"previous_names":[],"tags_count":69,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uriyyo%2Ffastapi-pagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uriyyo%2Ffastapi-pagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uriyyo%2Ffastapi-pagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uriyyo%2Ffastapi-pagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uriyyo","download_url":"https://codeload.github.com/uriyyo/fastapi-pagination/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250541005,"owners_count":21447427,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastapi","fastapi-pagination","fastapi-sqlalchemy","gino","pagination"],"created_at":"2024-07-31T00:00:58.551Z","updated_at":"2026-01-25T18:15:18.382Z","avatar_url":"https://github.com/uriyyo.png","language":"Python","readme":"\u003ch1 align=\"center\"\u003e\n\u003cimg alt=\"logo\" src=\"https://raw.githubusercontent.com/uriyyo/fastapi-pagination/main/docs/img/logo.png\"\u003e\n\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg alt=\"license\" src=\"https://img.shields.io/badge/License-MIT-lightgrey\"\u003e\n\u003cimg alt=\"test\" src=\"https://github.com/uriyyo/fastapi-pagination/workflows/Test/badge.svg\"\u003e\n\u003cimg alt=\"codecov\" src=\"https://codecov.io/gh/uriyyo/fastapi-pagination/branch/main/graph/badge.svg?token=QqIqDQ7FZi\"\u003e\n\u003ca href=\"https://pepy.tech/project/fastapi-pagination\"\u003e\u003cimg alt=\"downloads\" src=\"https://pepy.tech/badge/fastapi-pagination\"\u003e\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/fastapi-pagination\"\u003e\u003cimg alt=\"pypi\" src=\"https://img.shields.io/pypi/v/fastapi-pagination\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n## Introduction\n\n`fastapi-pagination` is a Python library designed to simplify pagination in FastAPI applications. \nIt provides a set of utility functions and data models to help you paginate your database queries \nand return paginated responses to your clients.\n\nWith `fastapi-pagination`, you can easily define pagination parameters in your FastAPI endpoint functions,\nand use them to generate paginated responses that include the requested subset of your data.\nThe library supports a variety of pagination strategies, including cursor-based pagination and page-based pagination.\n\n`fastapi-pagination` is built on top of the popular `fastapi` library, and it works with a wide range \nof SQL and NoSQL databases frameworks. It also supports async/await syntax and is compatible with Python 3.10 and higher.\n\nFeatures:\n\n* Simplifies pagination in FastAPI applications.\n* Supports a variety of pagination strategies, including cursor-based pagination and page-based pagination\n* Works with a wide range of SQL and NoSQL databases frameworks, including `SQLAlchemy`, `Tortoise ORM`, and `PyMongo`.\n* Supports async/await syntax.\n* Compatible with Python 3.10 and higher.\n\n----\n\nFor more information on how to use fastapi-pagination, please refer to the \n[official documentation](https://uriyyo-fastapi-pagination.netlify.app/).\n\n---\n\n## Installation\n\n```bash\npip install fastapi-pagination\n```\n\n## Quickstart\n\nAll you need to do is to use `Page` class as a return type for your endpoint and call `paginate` function\non data you want to paginate.\n\n```py\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel, Field\n\n# import all you need from fastapi-pagination\nfrom fastapi_pagination import Page, add_pagination, paginate\n\napp = FastAPI()  # create FastAPI app\nadd_pagination(app)  # important! add pagination to your app\n\n\nclass UserOut(BaseModel):  # define your model\n    name: str = Field(..., example=\"Steve\")\n    surname: str = Field(..., example=\"Rogers\")\n\n\nusers = [  # create some data\n    UserOut(name=\"Steve\", surname=\"Rogers\"),\n    # ...\n]\n\n\n# req: GET /users\n@app.get(\"/users\")\nasync def get_users() -\u003e Page[UserOut]:\n    # use Page[UserOut] as return type annotation\n    return paginate(users)  # use paginate function to paginate your data\n```\n\nPlease, be careful when you work with databases, because default `paginate` will require to load all data in memory.\n\nFor instance, if you use `SQLAlchemy` you can use `paginate` from `fastapi_pagination.ext.sqlalchemy` module.\n\n```python\nfrom sqlalchemy import select\nfrom fastapi_pagination.ext.sqlalchemy import paginate\n\n\n@app.get(\"/users\")\ndef get_users(db: Session = Depends(get_db)) -\u003e Page[UserOut]:\n    return paginate(db, select(User).order_by(User.created_at))\n```\n\n---\n\nCode from `Quickstart` will generate OpenAPI schema as bellow:\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg alt=\"app-example\" src=\"https://raw.githubusercontent.com/uriyyo/fastapi-pagination/main/docs/img/example.png\"\u003e\n\u003c/div\u003e\n","funding_links":[],"categories":["Third-Party Extensions","Python"],"sub_categories":["Utils"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furiyyo%2Ffastapi-pagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furiyyo%2Ffastapi-pagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furiyyo%2Ffastapi-pagination/lists"}