Skip to main content

Overview

List endpoints in the Mighty Networks API return paginated results to efficiently handle large datasets. Understanding pagination is essential for building robust integrations that work with all your data.

How Pagination Works

When you request a list of resources (members, posts, spaces, etc.), the API returns:
  1. Items - An array of resources for the current page
  2. Links - URLs for navigating between pages
  3. Metadata - Information about the pagination state (in some endpoints)

Standard Response Format

Pagination Parameters

Control pagination using query parameters:

Example Request

Checking for More Pages

The links object in the response indicates if there are more pages:
  • links.next exists - There are more pages available
  • links.next is null/absent - You’ve reached the last page

Iterating Through All Pages

Basic Pagination Loop

Instead of manually incrementing the page number, you can use the next link:

Advanced Patterns

Paginated Generator Function

For memory efficiency with large datasets:

Parallel Pagination

Fetch multiple pages concurrently (use with caution regarding rate limits):
Parallel pagination can quickly exhaust your rate limit. Use sparingly and monitor your rate limit headers.

Pagination with Progress Tracking

Show progress when fetching large datasets:

Python Examples

Basic Pagination

Generator Pattern

Best Practices

  1. Use Maximum Page Size - Set per_page=100 to minimize API calls
  2. Check for Next Page - Use links.next instead of guessing total pages
  3. Implement Rate Limiting - Add delays between requests to respect rate limits
  4. Handle Errors - Implement retry logic for failed pagination requests
  5. Use Generators - For large datasets, use generator patterns to avoid memory issues
  6. Cache Results - Store paginated results when appropriate to reduce API calls
  7. Monitor Progress - Implement progress tracking for long-running pagination
  8. Avoid Parallel Requests - Unless necessary, paginate sequentially to stay within rate limits

Common Pitfalls

❌ Hardcoding Total Pages

❌ Ignoring Rate Limits

✅ Add Delays

Next Steps

Rate Limits

Understand API rate limiting.

Error Handling

Handle pagination errors gracefully.

Members

Work with paginated member lists.

Posts

Paginate through posts and content.