Pagination Standards
Skip-offset pagination convention across all services with standardized response format
All list-based endpoints across MQUAD microservices follow a unified pagination contract.
Request Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
skip | integer | 0 | Number of records to skip (0-based) |
limit | integer | 20 | Maximum records per page (max: 100) |
Response Format
{
"items": [],
"total": 100,
"skip": 0,
"limit": 20,
"has_next": true,
"has_previous": false
}| Field | Type | Description |
|---|---|---|
items | array | The page of results |
total | integer | Total matching records across all pages |
skip | integer | Current offset |
limit | integer | Current page size |
has_next | boolean | More pages available after this one |
has_previous | boolean | Previous pages exist before this one |
Implementation
from pydantic import BaseModel
from typing import Generic, TypeVar, List
T = TypeVar("T")
class PaginatedResponse(BaseModel, Generic[T]):
items: List[T]
total: int
skip: int
limit: int
has_next: bool
has_previous: bool
def paginate(query, skip: int, limit: int, total: int) -> PaginatedResponse:
return PaginatedResponse(
items=query,
total=total,
skip=skip,
limit=limit,
has_next=(skip + limit) < total,
has_previous=skip > 0,
)Usage
# First page
GET /responses?skip=0&limit=20
# Second page
GET /responses?skip=20&limit=20Frontend Integration
The pagination format is designed to work with the AdvanceTable component:
interface PaginatedResponse<T> {
items: T[];
total: number;
skip: number;
limit: number;
has_next: boolean;
has_previous: boolean;
}All services use this standard. The generic items field simplifies frontend integration regardless of resource type.
