Pagination
List endpoints use cursor pagination, serialized through API resources. Each response wraps the page of items in a data array alongside links and meta objects. To page through results, follow links.next until it's null.
Response
{
"data": [
{
"id": "110527",
"type": "video"
}
],
"links": {
"first": null,
"last": null,
"prev": null,
"next": "https://loops.video/api/v1/example?cursor=eyJpZCI6MTEwNTI3fQ"
},
"meta": {
"path": "https://loops.video/api/v1/example",
"per_page": 20,
"next_cursor": "eyJpZCI6MTEwNTI3fQ",
"prev_cursor": null
}
}Response fields
| Field | Description |
|---|---|
| data | The array of resources for the current page. |
| links.next | URL for the next page, or null when you reach the end. |
| links.prev | URL for the previous page, or null at the start. |
| meta.next_cursor | Opaque cursor for the next page (also encoded in links.next). |
| meta.prev_cursor | Opaque cursor for the previous page, or null. |
| meta.per_page | Number of items returned per page. |
Paging through results
Each links.next URL already has the cursor query parameter baked in, so you can request it directly without building it yourself.
JavaScript
async function fetchAll(url, token) {
const all = []
while (url) {
const res = await fetch(url, {
headers: { Authorization: 'Bearer ' + token },
})
const body = await res.json()
all.push(...body.data)
// Follow links.next until it's null
url = body.links?.next ?? null
}
return all
} Cursor pagination can't jump to an arbitrary page, so
links.first and links.last are always null. Treat the cursor as opaque — pass it back exactly as received rather than decoding or constructing it.