Skip to content

Pagination

Read long lists page by page with an opaque cursor that never skips or repeats a row.

Every list call returns one page. To get the next page, pass back the cursor from the page you just read. There are no page numbers, so a post created while you read never shifts the pages, and you never see a row twice or miss one.

The shape

Send limit from 1 to 100. It defaults to 50.

{
  "data": [{ "postId": "…" }, { "postId": "…" }],
  "hasMore": true,
  "nextCursor": "eyJ2IjoxLCJrIjoi…"
}

When hasMore is true, pass nextCursor as cursor to read the next page. When it is false, you have read everything. Keep the same filters on every page; the cursor does not carry them.

Treat the cursor as an opaque string. Pass it back exactly as you got it and do not build or edit one. A changed, expired, or malformed cursor returns 400 with invalid_cursor; start again from the first page.

Read every page

The SDKs read the pages for you. Pass a page limit to bound the work.

for await (const post of workspace.posts.iterate(
  { isDraft: true, limit: 100 },
  { maxPages: 20 },
)) {
  console.log(post.postId, post.textPreview);
}

iterate takes { signal, maxPages } as its second argument. Lists that have iterate include posts, attempts, media, profiles, API keys, webhook endpoints and deliveries, inbox, and ads.

for post in workspace.posts.iterate_items(is_draft=True, limit=100, max_pages=20):
    print(post["postId"], post["textPreview"])

Use iterate_pages when you need each page’s has_more and next_cursor.

cursor=""
while :; do
  page=$(curl -s "https://pubnio.com/api/v1/posts?workspaceId=$WORKSPACE_ID&limit=100${cursor:+&cursor=$cursor}" \
    -H "Authorization: Bearer $PUBNIO_API_KEY")
  echo "$page" | jq -r '.data[].postId'
  [ "$(echo "$page" | jq -r '.hasMore')" = "true" ] || break
  cursor=$(echo "$page" | jq -r '.nextCursor')
done
pnio posts list --workspace "$WORKSPACE_ID" --limit 100
pnio posts list --workspace "$WORKSPACE_ID" --limit 100 --cursor "$NEXT_CURSOR"

Order

Lists return newest first unless the operation says otherwise. A few lists read in time order because that is how you use them: the schedule reads in ascending scheduled time, and conversation messages page oldest or newest first by choice. The API reference lists the order for each operation.

Some reads are ranges instead of lists. The schedule takes from and to instants up to 90 days apart, and analytics takes a date range. Both still use the same cursor for long results.

Type to search…

↑↓ navigate↵ selectEsc close