Skip to main content

Pagination patterns

Gorillaa Mail list endpoints support two pagination patterns depending on the endpoint:

Page-based pagination

Used by: GET /v1/emails, GET /v1/domains

Parameters

ParameterTypeDefaultDescription
pageinteger1Page number (1-indexed)
limitinteger20Results per page (max 100)

Request

curl "https://api.mail.gorillaa.one/v1/emails?page=2&limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response metadata

{
  "data": [ ... ],
  "pagination": {
    "total": 156,
    "page": 2,
    "limit": 10,
    "totalPages": 16
  }
}
FieldDescription
pagination.totalTotal number of matching records
pagination.pageCurrent page number
pagination.limitResults per page
pagination.totalPagesTotal number of pages

Iterating through all pages

async function fetchAllEmails(apiKey) {
  const allEmails = [];
  let page = 1;
  let totalPages = 1;

  do {
    const response = await fetch(
      `https://api.mail.gorillaa.one/v1/emails?page=${page}&limit=100`,
      { headers: { Authorization: `Bearer ${apiKey}` } }
    );
    const result = await response.json();

    allEmails.push(...result.data);
    totalPages = result.pagination.totalPages;
    page++;
  } while (page <= totalPages);

  return allEmails;
}

Offset-based pagination

Used by: GET /v1/suppressions

Parameters

ParameterTypeDefaultDescription
offsetinteger0Number of records to skip
limitinteger50Results per page (max 100)

Request

curl "https://api.mail.gorillaa.one/v1/suppressions?offset=20&limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response metadata

{
  "data": [ ... ],
  "pagination": {
    "total": 42,
    "offset": 20,
    "limit": 10,
    "hasMore": true
  }
}
FieldDescription
pagination.totalTotal number of matching records
pagination.offsetCurrent offset
pagination.limitResults per page
pagination.hasMoretrue if more results exist beyond the current page

Iterating with offset

async function fetchAllSuppressions(apiKey) {
  const allSuppressions = [];
  let offset = 0;
  let hasMore = true;

  while (hasMore) {
    const response = await fetch(
      `https://api.mail.gorillaa.one/v1/suppressions?offset=${offset}&limit=100`,
      { headers: { Authorization: `Bearer ${apiKey}` } }
    );
    const result = await response.json();

    allSuppressions.push(...result.data);
    hasMore = result.pagination.hasMore;
    offset += result.data.length;
  }

  return allSuppressions;
}

Best practices

Request limit=100 to minimize the number of API calls. Each call counts against your rate limit.
If you only need the first 50 results, don’t paginate beyond that. Use filters to narrow results.
Most list endpoints support filters like status, from, startDate, endDate, or reason. Filtering is faster and cheaper than paginating through everything.
If data is an empty array, you’ve reached the end — stop paginating.