FastAPI pagination
Project description
FastAPI Pagination
Installation
# Basic version
pip install fastapi-pagination
# All available integrations
pip install fastapi-pagination[all]
Available integrations:
Example
from fastapi import FastAPI, Depends
from pydantic import BaseModel
from fastapi_pagination import PaginationParams, Page
from fastapi_pagination.paginator import paginate
app = FastAPI()
class User(BaseModel):
name: str
surname: str
users = [
User(name='Yurii', surname='Karabas'),
# ...
]
@app.get('/users', response_model=Page[User])
async def get_users(params: PaginationParams = Depends()):
return paginate(users, params)
Example using implicit params
from fastapi import FastAPI, Depends
from pydantic import BaseModel
from fastapi_pagination import Page, pagination_params
from fastapi_pagination.paginator import paginate
app = FastAPI()
class User(BaseModel):
name: str
surname: str
users = [
User(name='Yurii', surname='Karabas'),
# ...
]
@app.get('/users', response_model=Page[User], dependencies=[Depends(pagination_params)])
async def get_users():
return paginate(users)
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
Close
Hashes for fastapi_pagination-0.5.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28d6ce2018383127afe0bf52058dfaf9071616ae1e79a62297c0f98c4ccc87e7 |
|
MD5 | f74f299aa29397b8a903ec58ec912542 |
|
BLAKE2b-256 | f2b8cf357d8eafcfae083760726cdba2383cbe0101fd7bfa162c422cba7dec84 |