List every run of a Sume Format in Python: the keyset cursor pager

GET /v1/formats/{handle}/{slug}/runs returns data, has_more and next_cursor. Pass next_cursor back until has_more is false; limit is 1 to 100.

4 min readSume
All posts

To list all runs of one Format, call GET /v1/formats/{handle}/{slug}/runs with limit up to 100, and keep passing next_cursor as cursor until has_more is false. A Format that was never run returns an empty list, not an error.

The cursor is a keyset over created_at and id, so new runs arriving during a walk do not shift the pages the way an offset would.

The response shape

From the Runs and results page (read 2026-10-03).

List runs request and response (read 2026-10-03)
ItemBehavior
limit1 to 100
cursorThe next_cursor from the previous page
Responsedata (receipts), has_more, next_cursor
Invalid cursor400
Format never runEmpty data list
Scopeformats:read

A pager

Store the cursor only as an opaque string and never parse it. Each item in data is a run receipt, so you can read status and usage without a second call.

import json, os, urllib.parse, urllib.request

BASE = "https://api.sume.com/v1/formats/acme/teaser/runs"
KEY = os.environ["SUME_API_KEY"]

def pages():
    cursor = None
    while True:
        q = {"limit": 100}
        if cursor:
            q["cursor"] = cursor
        req = urllib.request.Request(
            BASE + "?" + urllib.parse.urlencode(q),
            headers={"Authorization": "Bearer " + KEY})
        page = json.load(urllib.request.urlopen(req))
        yield from page["data"]
        if not page["has_more"]:
            return
        cursor = page["next_cursor"]

print(sum(1 for _ in pages()))

Reads count against your budget

Listing is a GET, so it spends the read budget, which is forty times the write budget on every plan. A walk of a thousand runs is ten calls. For the arithmetic see how the other list endpoints page in the jobs list cursor, and for totalling cost from the receipts you just listed, cost per row from receipts.

Sources

Related posts

More in Formats

All Formats posts

Written by Sume