# Pagination

> Page through lists with cursor and limit.

Source: https://legion.ambient.xyz/docs/api/pagination

List operations return one page at a time.

## Request a page

| Parameter | What it does |
| --- | --- |
| `limit` | How many items to return, from 1 to 100. The default is 50. |
| `cursor` | Where to continue. Pass the `next_cursor` of the previous page. |

The response has `items`, and `next_cursor` when there's another page:

```sh
curl -s "https://api.legion.ambient.xyz/v1/rentals?limit=20" \
  -H "Authorization: Bearer $LEGION_API_KEY"
```

```json
{
  "items": [ … ],
  "next_cursor": "…"
}
```

## Get the next page

Pass `next_cursor` back as `cursor`, with the same filters:

```sh
curl -s "https://api.legion.ambient.xyz/v1/rentals?limit=20&cursor=$NEXT_CURSOR" \
  -H "Authorization: Bearer $LEGION_API_KEY"
```

The last page has no `next_cursor`.

## Rules

- A cursor is opaque. Don't build or change one.
- A cursor that isn't one the API returned answers `400 invalid_cursor`.
- A `limit` out of range answers `400 invalid_request`.
