Docs
REST APIPagination

Pagination

How cursor-based pagination works in the Moviie REST API.

Pagination

Paginated endpoints use cursor-based pagination. Cursors are opaque tokens: you should never parse or construct them manually.

Query parameters

ParameterTypeDefaultDescription
cursorstringCursor from a previous response. Omit to get the first page.
limitnumber24Number of items per page (max varies per endpoint).

Response format

{
  "data": [ ... ],
  "pageInfo": {
    "nextCursor": "eyJpZCI6IjEyMyIsInNvcnRWYWx1ZSI6Ii4uLiJ9",
    "hasMore": true
  }
}
FieldDescription
dataArray of items for the current page.
pageInfo.nextCursorPass as cursor to fetch the next page. null when there are no more pages.
pageInfo.hasMoretrue when there are more items to fetch.

Iterating through all pages

async function fetchAllVideos() {
  const videos = []
  let cursor = undefined

  do {
    const url = new URL('https://api.moviie.ai/v1/videos')
    url.searchParams.set('limit', '96')
    if (cursor) url.searchParams.set('cursor', cursor)

    const res = await fetch(url, {
      headers: { Authorization: `Bearer ${process.env.MOVIIE_API_KEY}` },
    })
    const { data, pageInfo } = await res.json()

    videos.push(...data)
    cursor = pageInfo.nextCursor
  } while (cursor)

  return videos
}

Common pitfalls

  • Do not store cursors long-term. They are tied to a specific sort order and may become invalid if underlying data changes significantly.
  • Always check pageInfo.hasMore before fetching the next page: nextCursor is null on the last page.

On this page