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.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48c0a63da08df7ed3c2f78e67cdd3062ed71e0fedcaac79199466cc56df4f53e |
|
MD5 | 29781e7db2ec61f116b7aab77e393d9e |
|
BLAKE2b-256 | d1b0f4b13af83d679cb492e6827c7de40f0b910277f3a3c21d8fab14ce76494e |