Skip to content

Pagination: reading lists page by page

Every list has data, has_more and next_cursor. Page on with ?cursor=… until has_more is false.

As Markdown (for AI)OpenAPI

Contents and all reference pages

Lists always have the same shape: object “list”, data, has_more and next_cursor. Paging works for videos, renders and speech jobs. All other lists come complete in one response.

Ask for the first page with limit, then send next_cursor as cursor – with the same filters – until has_more is false.

Shape of every list

FieldMeaning
objectalways "list"
datathe entries of this page, newest first
has_moretrue if there is another page
next_cursorvalue for cursor of the next page, otherwise null
Response 200
{
  "object": "list",
  "data": [
    { "id": "vid_7Hq2LmN0pQrS3tUv4WxY", "object": "video", "status": "ready" },
    { "id": "vid_2bC9dE8fG7hJ6kL5mN4p", "object": "video", "status": "draft" }
  ],
  "has_more": true,
  "next_cursor": "vid_2bC9dE8fG7hJ6kL5mN4p"
}

Parameters and endpoints

  • limit: 1 to 100, default 20. Larger values are set to 100, invalid ones to 20.
  • cursor: the next_cursor of the previous response. Today it is the id of the last entry; treat it as opaque text anyway.
  • Filters such as status apply per page. Send them again with every page.
EndpointPagedFilters
GET /videosyes (limit, cursor)status
GET /rendersyes (limit, cursor)status, video_id
GET /speechyes (limit, cursor)–
GET /webhooks/{id}/deliveriesonly limit (default 50), no cursor–
all other lists (/templates, /voices, /webhooks, /uploads, /usage, /models …)no – complete, has_more: falseper endpoint

Note: Further filters (for example by project, template, date or metadata) do not exist today. The API ignores unknown parameters – filter on those yourself.

Cursor rules

  • New entries appear on the first page, not on later pages. For “everything since yesterday”, read from the start until you hit known ids.
  • If a cursor is unknown or invalid – for example because the video was deleted meanwhile – the API ignores it and returns the first page again. Remember the ids you read and stop as soon as one comes twice.
  • An invalid status value is ignored too; you then get the unfiltered list.
  • Every page is a read request (class “read”). limit=100 saves requests.

Reading all pages

curl
# first page
curl -s "https://flow-marketing.org/api/turbo/v1/videos?limit=100&status=ready" \
  -H "Authorization: Bearer $FLOW_API_KEY"

# next page: next_cursor of the previous answer, same filters
curl -s "https://flow-marketing.org/api/turbo/v1/videos?limit=100&status=ready&cursor=vid_2bC9dE8fG7hJ6kL5mN4p" \
  -H "Authorization: Bearer $FLOW_API_KEY"
JavaScript
async function* listAll(path, params = {}) {
  const seen = new Set()
  let cursor = null
  do {
    const q = new URLSearchParams({ ...params, limit: '100', ...(cursor ? { cursor } : {}) })
    const res = await fetch(`https://flow-marketing.org/api/turbo/v1${path}?${q}`, {
      headers: { Authorization: `Bearer ${process.env.FLOW_API_KEY}` },
    })
    if (!res.ok) throw new Error(`${res.status} ${(await res.json()).code}`)
    const page = await res.json()
    for (const item of page.data) {
      if (seen.has(item.id)) return // cursor was reset (e.g. item deleted) – stop instead of looping
      seen.add(item.id)
      yield item
    }
    cursor = page.has_more ? page.next_cursor : null
  } while (cursor)
}

for await (const video of listAll('/videos', { status: 'ready' })) {
  console.log(video.id, video.status)
}
Python
import os, requests

BASE = "https://flow-marketing.org/api/turbo/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['FLOW_API_KEY']}"}

def list_all(path, **params):
    seen, cursor = set(), None
    while True:
        q = {**params, "limit": 100, **({"cursor": cursor} if cursor else {})}
        r = requests.get(BASE + path, headers=HEADERS, params=q, timeout=30)
        r.raise_for_status()
        page = r.json()
        for item in page["data"]:
            if item["id"] in seen:  # cursor was reset – stop instead of looping
                return
            seen.add(item["id"])
            yield item
        if not page["has_more"]:
            return
        cursor = page["next_cursor"]

for video in list_all("/videos", status="ready"):
    print(video["id"], video["status"])

Did this help?

Still have a question?

Mo is an AI and answers right away from these articles. A person on our team replies within 24 hours on business days.

Some services degraded
Create a videoNo subscription needed · cancel any time