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.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f4b7b4f1766d29ad5fad926dc133635e2fee2abe3f2df749e5f03f97832442b |
|
MD5 | 5261e100912b25a67e3ea6b1798106e9 |
|
BLAKE2b-256 | 7e0389e141fe9afedfa72986c3f7e7d4a490ce96d1973124fd17127b96abd5a9 |