Pagination

The list endpoints page with limit and offset and tell you the total, so you always know how far you have left to go.

How it works

  • limit — how many to return. Defaults to 20 and is capped at 100. Asking for more gives you 100, not an error.
  • offset — how many to skip. Defaults to 0.

Both apply to GET /recipes and GET /popular.

curl 'https://api.tinyplates.dev/recipes?limit=20&offset=40' \
  -H 'Authorization: Bearer rd_your_api_key'

The pagination object

Every paged response carries one, alongside the rows. It reflects the page you asked for and the size of the whole filtered set.

limitinteger

How many recipes this response holds. Capped at 100.

offsetinteger

How many were skipped.

totalinteger

How many match the filter in total.

Walking the whole list

Stop when the offset reaches the total. Filters change the total, so read it from each response rather than assuming it.

const limit = 100
let offset = 0
let total = Infinity

while (offset < total) {
  const response = await fetch(
    `https://api.tinyplates.dev/recipes?limit=${limit}&offset=${offset}`,
    { headers: { Authorization: 'Bearer rd_your_api_key' } }
  )

  const page = await response.json()

  total = page.pagination.total
  offset += limit

  for (const recipe of page.recipes) {
    console.log(recipe.title)
  }
}

At 100 a page and 500 requests a day, an account can read 50,000 recipes in a day — comfortably more than the database holds. See rate limits.