Skip to main content

Overview

Endpoints that return lists of resources support pagination to manage large result sets efficiently. Pagination is implemented using page numbers and page sizes.

Pagination Parameters

All list endpoints accept these query parameters: From fkapi/api.py:50-51:
From fkapi/api.py:828-829:

Paginated Endpoints

The following endpoints support pagination:
  • GET /api/kits - List kits with filtering
  • GET /api/clubs/{club_id}/kits - Get club kits
  • Any endpoint that returns a list of resources

Request Examples

Basic Pagination

Get the first page with default page size (20 items):

Custom Page Size

Get 50 items per page:

Maximum Page Size

Get maximum allowed items (100) per page:

Response Format

Paginated responses return an array of items. The actual pagination metadata (total count, page info) is not included in the response body but can be inferred from the result count. From fkapi/api.py:614-619:

Example Response

Determining End of Results

If a page returns fewer items than the requested page_size, you’ve reached the end of the result set:

Pagination with Filtering

Combine pagination with filter parameters:

Example: Club Kits with Pagination

Implementation Examples

Python

JavaScript

TypeScript

Pagination Best Practices

For API Consumers

  1. Use Appropriate Page Size: Balance between request count and response size
    • Small datasets: 20-50 items
    • Large datasets: 50-100 items
    • Avoid requesting 1-2 items per page (inefficient)
  2. Implement Pagination Logic: Always handle multiple pages when fetching all data
  3. Cache Results: Cache paginated results to avoid repeated requests
  4. Handle Empty Results: Check for empty arrays to detect end of data
  5. Combine with Filters: Use filters to reduce total result count

Performance Tips

Caching Considerations

Paginated responses are cached for performance. From fkapi/api.py:603-604,618:
Each page is cached separately, so changing page parameters will result in a new cache lookup.

Error Handling

Invalid Page Number

Requesting a page beyond available results returns an empty array:
Response:

Invalid Page Size

Page size above 100 is automatically capped at 100:

Invalid Parameters

Non-numeric or negative values return validation errors:
Status Code: 400 Bad Request

API Overview

Learn about available API endpoints

Error Handling

Understand error responses