Pagination

How cursor-based pagination works in list endpoints.

Unmarkdown™ uses cursor-based pagination for list endpoints. This approach is more reliable than offset-based pagination, especially when documents are being created or deleted between page requests.

How It Works

List endpoints return a page of results along with pagination metadata:

{
  "data": [ ... ],
  "has_more": true,
  "next_cursor": "2026-02-14T12:30:00.000Z"
}
FieldTypeDescription
dataarrayArray of results for the current page
has_morebooleanWhether more results exist after this page
next_cursorstring | nullCursor value to pass for the next page. null when there are no more results.

Parameters

ParameterTypeDefaultDescription
limitinteger20Number of results per page. Maximum: 100.
cursorstringISO 8601 timestamp from next_cursor of the previous response

Example: Paginating Through Documents

First page:

curl "https://api.unmarkdown.com/v1/documents?limit=10" \
  -H "Authorization: Bearer um_your_key"
{
  "data": [
    { "id": "doc-1", "title": "First Document", "updated_at": "2026-02-14T15:00:00.000Z" },
    { "id": "doc-2", "title": "Second Document", "updated_at": "2026-02-14T14:00:00.000Z" }
  ],
  "has_more": true,
  "next_cursor": "2026-02-14T14:00:00.000Z"
}

Next page (using the cursor):

curl "https://api.unmarkdown.com/v1/documents?limit=10&cursor=2026-02-14T14:00:00.000Z" \
  -H "Authorization: Bearer um_your_key"
{
  "data": [
    { "id": "doc-3", "title": "Third Document", "updated_at": "2026-02-13T10:00:00.000Z" }
  ],
  "has_more": false,
  "next_cursor": null
}

Iterating All Pages

async function getAllDocuments(apiKey) {
  const documents = [];
  let cursor = null;

  do {
    const url = new URL('https://api.unmarkdown.com/v1/documents');
    url.searchParams.set('limit', '100');
    if (cursor) url.searchParams.set('cursor', cursor);

    const res = await fetch(url, {
      headers: { 'Authorization': `Bearer ${apiKey}` }
    });
    const page = await res.json();

    documents.push(...page.data);
    cursor = page.next_cursor;
  } while (cursor);

  return documents;
}
import requests

def get_all_documents(api_key):
    documents = []
    cursor = None

    while True:
        params = {'limit': 100}
        if cursor:
            params['cursor'] = cursor

        res = requests.get(
            'https://api.unmarkdown.com/v1/documents',
            headers={'Authorization': f'Bearer {api_key}'},
            params=params
        )
        page = res.json()

        documents.extend(page['data'])

        if not page['has_more']:
            break
        cursor = page['next_cursor']

    return documents

Endpoints That Use Pagination

Currently, only the List Documents endpoint uses cursor-based pagination. Other list endpoints (such as List Templates) return all results in a single response.

Sort Order

Documents are sorted by updated_at in descending order (most recently updated first). The cursor is based on this timestamp.

NOTE

Cursor values are opaque strings. While they are currently ISO 8601 timestamps, do not parse or construct them manually. Always use the next_cursor value returned by the API.