Skip to main content

FastAPI pagination

Project description

FastAPI Pagination

Installation

Basic version

pip install fastapi-pagination

Gino integration

pip install fastapi-pagination[gino]

SQLAlchemy integration

pip install fastapi-pagination[sqlalchemy]

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi-pagination-0.3.1.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

fastapi_pagination-0.3.1-py3-none-any.whl (7.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page