Effortless pagination for FastAPI + SQLAlchemy
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_paginate_pro-0.1.0.tar.gz.
File metadata
- Download URL: fastapi_paginate_pro-0.1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac87c3aa2d3cc5f156dc8735dc73aacfa05a1a11c182d1367dae10c38245d507
|
|
| MD5 |
7465d33f045dca0f70612aaf448de374
|
|
| BLAKE2b-256 |
0d779837b834540803f76fb778fb08d60f34c0c0eef44e5a22a15d7753b6bb31
|
File details
Details for the file fastapi_paginate_pro-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fastapi_paginate_pro-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afee0105aecfb823e74f04e11fc82fa550abcc175f248d2b2035e961d78dd8d1
|
|
| MD5 |
42f31df98fc816fd4a646a4abe503098
|
|
| BLAKE2b-256 |
62925a9c3b0c6600b52d71ba3bb0714a76f0a1ba9c09be13189c5953ef992172
|