Skip to main content
Fanfare uses cursor-based pagination for list endpoints, providing efficient traversal of large datasets.

Cursor-Based Pagination

Cursor-based pagination uses opaque cursors instead of page numbers, offering several advantages:
  • Consistent results: No skipped or duplicated items when data changes
  • Efficient: Doesn’t require counting total items
  • Bidirectional: Navigate forward and backward through results

Request Parameters

Query Parameters

Example Request

Response Format

Paginated Response Structure

Response Fields

Pagination Examples

Forward Pagination

Fetch the first page:
Fetch the next page using endCursor:

Backward Pagination

Fetch the previous page using startCursor:
Combine pagination with search:
Note: Search requires at least 2 characters.

With Sorting

Combine pagination with custom sorting:

Implementation Guide

JavaScript/TypeScript

React Hook Example

Infinite Scroll Example

Sortable Fields

Different endpoints support different sortable fields:

Consumers

Experiences

Audiences

Best Practices

1. Use Appropriate Page Sizes

  • Interactive UIs: 20-50 items for quick loading
  • Background sync: 100 items for efficiency
  • Never exceed: Maximum of 100 items per request

2. Handle Empty Results

3. Preserve Cursor on Refresh

When implementing “pull to refresh”, preserve the current position:

4. Combine with Filters Carefully

When combining pagination with filters, cursors may become invalid if filter criteria change:

Cursor Format

Cursors are Base64-encoded JSON objects. While the format is not guaranteed to remain stable, they typically contain:
Important: Treat cursors as opaque strings. Do not decode or construct them manually.

Limitations

  • Maximum page size: 100 items
  • Cursors expire after 24 hours of inactivity
  • Cursor format may change between API versions
  • Some filtered views may not support all sort options