fastapi-paginate
Effortless pagination for FastAPI + SQLAlchemy
Install
pip install fastapi-paginate
Usage
from fastapi import FastAPI, Depends
from fastapi_paginate import paginate, PaginationParams, Page
from sqlalchemy import select
@app.get("/users", response_model=Page[UserResponse])
async def list_users(
params: PaginationParams = Depends(),
db: AsyncSession = Depends(get_db),
):
query = select(User).order_by(User.created_at.desc())
return await paginate(db, query, params, schema=UserResponse)
Response:
{
"items": [...],
"total": 150,
"page": 1,
"size": 20,
"pages": 8,
"has_next": true,
"has_prev": false
}
Features
- One function call —
paginate(db, query, params) - Auto-counts total rows
has_next/has_prevfor frontend navigation- Generic
Page[T]works with any Pydantic schema - Query params auto-extracted via
PaginationParamsdependency - Works with any SQLAlchemy select query
License
MIT
Release files for fastapi-paginate-pro 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastapi_paginate_pro-0.1.0.tar.gz | 3.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_paginate_pro-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.6 kB
Release files / fastapi_paginate_pro-0.1.0.tar.gz
| Download URL | fastapi_paginate_pro-0.1.0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac87c3aa2d3cc5f156dc8735dc73aacfa05a1a11c182d1367dae10c38245d507
|
|
BLAKE2b-256 checksum How to use checksums |
0d779837b834540803f76fb778fb08d60f34c0c0eef44e5a22a15d7753b6bb31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / fastapi_paginate_pro-0.1.0-py3-none-any.whl
| Download URL | fastapi_paginate_pro-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
afee0105aecfb823e74f04e11fc82fa550abcc175f248d2b2035e961d78dd8d1
|
|
BLAKE2b-256 checksum How to use checksums |
62925a9c3b0c6600b52d71ba3bb0714a76f0a1ba9c09be13189c5953ef992172
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|