Vai al contenuto principale

Paginazione

Gli endpoint list usano uno di tre stili di paginazione a seconda del dominio. Leggi l'API Reference per i parametri esatti di un dato endpoint; questa pagina spiega i pattern che incontrerai e quali endpoint usano ciascuno.

A colpo d'occhio

StyleParametersUsed by
ID cursors (after / before)after, beforeNotifications, row comments
Keyset cursor (cursor / nextCursor)limit, cursorBookings
Offset (limit / offset)limit, offsetChannels, workspace members, workspace teams
Limit-only (no continuation)limitSearch, docs search, drive search
Not paginatedBoard rows list, list-boards, booking types

Cursor ID — after / before

Alcuni endpoint paginano usando l'_id di un item come cursor. Passi l'ID dell'ultimo (o del primo) item che hai visto come after (o before) per recuperare la pagina adiacente.

Notifications

GET /public/v1/notifications

  • after — restituisce le notifiche dopo questo notification ID.
  • before — restituisce le notifiche prima di questo notification ID.

La response è { notifications, unreadCount, count }. Non c'è un campo cursor separato — il cursor è l'_id di una notifica. Per paginare in avanti, prendi l'_id dell'ultima notifica e passalo come after sulla richiesta successiva:

# First page
curl "https://api.copera.ai/public/v1/notifications" \
-H "Authorization: Bearer cp_pat_your_token_here"

# Next page — use the last notification's _id from the previous response
curl "https://api.copera.ai/public/v1/notifications?after=665f0a1b2c3d4e5f60718293" \
-H "Authorization: Bearer cp_pat_your_token_here"

Commenti di riga

GET /public/v1/board/{boardId}/table/{tableId}/row/{rowId}/comments

Stessi param cursor after / before (comment ID), più un filtro visibility (all | internal | external, default all). A differenza delle notifiche, questo endpoint restituisce un pageInfo in stile relay:

{
"items": [ /* ...comments... */ ],
"pageInfo": {
"endCursor": "665f0a1b2c3d4e5f60718293",
"startCursor": "665f0a1b2c3d4e5f60718210",
"hasNextPage": true,
"hasPreviousPage": false
}
}

Per paginare in avanti, passa endCursor come after finché hasNextPage è true.

Cursor keyset — cursor / nextCursor

Bookings

GET /public/v1/bookings

  • limit — page size, 1–100 (default 25).
  • cursor — cursor keyset opaco dalla response precedente.

La response include nextCursor e hasMore:

{
"bookings": [ /* ... */ ],
"nextCursor": "eyJpZCI6Ii4uLiJ9",
"hasMore": true
}

Cicla finché hasMore è true, ripassando nextCursor come cursor:

curl "https://api.copera.ai/public/v1/bookings?limit=50&cursor=eyJpZCI6Ii4uLiJ9" \
-H "Authorization: Bearer cp_pat_your_token_here"

Offset — limit / offset

Classico scorrimento di pagina con offset numerico.

Endpointlimit (default / max)offset
GET /chat/channels100 / 200from 0
GET /workspace/members100 / 500from 0
GET /workspace/teams100 / 200from 0
# Second page of 50 members
curl "https://api.copera.ai/public/v1/workspace/members?limit=50&offset=50" \
-H "Authorization: Bearer cp_pat_your_token_here"

Solo limit

Gli endpoint in stile search limitano il conteggio dei risultati con limit ma non offrono un cursor di continuazione — richiedi un limit più grande (fino al max dell'endpoint) o affina la query.

Endpointlimit (default / max)
GET /search50 / 100
GET /docs/search20 / 50
GET /drive/search20 / 50

Gli endpoint tree di docs e drive (/docs/tree, /drive/tree) sono limitati da un parametro depth (default 3, max 10) e da un parentId, non da limit/cursor.

Non paginati

Alcuni endpoint list restituiscono l'intero set in una sola response:

  • GET /board/list-boards
  • GET /board/{boardId}/table/{tableId}/rows — supporta q, filter e sort, ma restituisce tutte le righe corrispondenti.
  • GET /booking-types
suggerimento

Quando iteri set di risultati grandi, aggiungi un breve delay tra le richieste per restare sotto il rate limit per-minuto, e fermati non appena un flag hasMore / hasNextPage è false.