Kanorio

API reference

Pagination

Every list endpoint on every Kanorio API takes limit and cursor and returns data, hasMore and nextCursor.

All list endpoints on the Management API, the Content Delivery API and the Customer API page the same way.

Request

ParameterTypeDefaultNotes
limitinteger20From 1 to 100. Some endpoints document a lower maximum.
cursorstringnoneThe nextCursor from the previous page. Omit it for the first page.

Response

{
  "data": [{ "id": "post_example01" }, { "id": "post_example02" }],
  "hasMore": true,
  "nextCursor": "eyJvIjoyMCwicyI6ImFiYzEyMyJ9"
}
FieldTypeNotes
dataarrayThe items of this page, in the endpoint's order.
hasMorebooleantrue when another page exists.
nextCursorstring or nullPass it as cursor to get the next page. null on the last page.

Some endpoints add fields next to these. For example, collection items add assets, a map of every image and file the page references.

Rules

  • Cursors are opaque. Do not parse, build or store them for long. Their format can change without notice.
  • Keep the other parameters. A cursor belongs to the filters, sort and limit it was issued for. Sending it with different filters returns 400 INVALID_CURSOR. Start again without a cursor when filters change.
  • No page numbers or offsets. The APIs do not accept page, pageSize or offset.
  • No totals by default. Counting every match is expensive, so lists do not return a total. Two Content Delivery API endpoints return total when you pass total=true: collection items, and search (where the total is counted in the same query as the results).
  • Short lists still use the envelope. Lists with a small fixed cap, such as webhook endpoints or redirects, return everything in one page with hasMore: false. Their reference pages say so.

Read every page

curl "https://app.kanorio.com/api/v1/sites/ws_example123/posts?limit=50" \
  -H "Authorization: Bearer $KANORIO_TOKEN"

# then, while hasMore is true
curl "https://app.kanorio.com/api/v1/sites/ws_example123/posts?limit=50&cursor=eyJvIjo1MH0" \
  -H "Authorization: Bearer $KANORIO_TOKEN"

The SDK's paginate follows nextCursor for you and works with any list endpoint:

import { createManagementClient, paginate } from "@kanorio/sdk";

const client = createManagementClient({ token: process.env.KANORIO_TOKEN! });

for await (const post of paginate((cursor) =>
  client.get("/sites/{id}/posts", { params: { id: "ws_example123" }, query: { limit: 50, cursor } })
)) {
  console.log(post.slug);
}

Use listAll instead of paginate when you want the whole list as an array.