--- id: fastapi-pagination version: "0.15.16" license: MIT license_treatment: permissive maintenance: active --- # fastapi-pagination — FastAPI pagination License: permissive · Maintenance: active · Downloads: 3.9M/mo ## What it is and what it does fastapi-pagination is a utility library that integrates pagination into FastAPI applications by providing a Page return type and paginate function to handle subset selection and response formatting. It abstracts away the common logic needed to implement pagination across endpoints, supporting both page-based and cursor-based strategies. The library works with FastAPI's dependency injection and async/await patterns, and includes integrations for popular database libraries like SQLAlchemy to avoid loading entire result sets into memory. You define your endpoint's return type as Page[YourModel], call paginate on your data or query, and the library handles generating the paginated response with metadata. It requires Python 3.10 or higher and depends on fastapi, pydantic, and typing-extensions. Use it for: - Build REST APIs that return large datasets in manageable chunks without loading all records into memory. - Add cursor-based pagination to endpoints querying SQLAlchemy ORM models or other SQL databases. - Implement page-based pagination for in-memory lists or NoSQL database queries with automatic response formatting. - Generate OpenAPI documentation automatically for paginated endpoints without manual schema definition. - Support async database queries with pagination across Tortoise ORM or PyMongo without blocking. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Adds pagination support to FastAPI applications with utilities for defining pagination parameters and returning paginated responses across multiple database frameworks. Yes. Active maintenance, low install friction, permissive MIT license, and no known vulnerabilities make this a safe choice. The library solves a common FastAPI problem with minimal dependencies and integrates cleanly with popular databases. Install if you need pagination in FastAPI endpoints. ## Install pip install fastapi-pagination uv add fastapi-pagination poetry add fastapi-pagination ## Installing fastapi-pagination Before you install: Low friction install with three lightweight runtime dependencies (fastapi, pydantic, typing-extensions). Active maintenance with recent releases; last commit 2026-08-14 and 1677 repository stars indicate ongoing support. License in practice: MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute this package freely provided you include the license notice. Quickstart: pip install fastapi-pagination from fastapi import FastAPI from fastapi_pagination import Page, add_pagination, paginate from pydantic import BaseModel app = FastAPI() add_pagination(app) class Item(BaseModel): name: str items = [Item(name="a"), Item(name="b")] @app.get("/items") async def get_items() -> Page[Item]: return paginate(items) Requires Python 3.10 or higher. When working with databases, use database-specific paginate functions (e.g., from fastapi_pagination.ext.sqlalchemy) to avoid loading all data into memory. Verify before relying: - Which specific SQL and NoSQL frameworks are supported beyond SQLAlchemy, Tortoise ORM, and PyMongo mentioned in the description. - Performance characteristics and memory overhead when paginating large result sets with the default paginate function. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 3.9M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags fastapi pagination library, page-based cursor pagination, sqlalchemy pagination helper, fastapi query pagination, database result pagination, async pagination fastapi, paginate api responses, fastapi-extension, orm-agnostic, async-ready [View on SkillFed](https://skillfed.io/packages/fastapi-pagination) · [View on PyPI](https://pypi.org/project/fastapi-pagination/)