# Pagination

Source: https://parasend.com/docs/pagination

Endpoints that list objects, such as [List deliveries](/docs/api/deliveries/list), answer one page at a time:

```json
{
  "object": "list",
  "data": [ { "id": "dlv_01M6P3R2…", "object": "delivery" } ],
  "has_more": true,
  "next_cursor": "eyJjIjoiMjAyNi0xMS0wNlQw…"
}
```

| Parameter | What it does |
|---|---|
| `limit` | How many objects on a page. Default 25, at most 100. |
| `cursor` | Where to continue: the `next_cursor` from the page before. Leave it out for the first page. |

Pages run newest first. While `has_more` is `true`, ask again with `cursor` set to `next_cursor`:

```bash
curl "https://api.parasend.com/v1/deliveries?limit=100&cursor=eyJjIjoiMjAyNi0xMS0wNlQw…" \
  -H "Authorization: Bearer $PARASEND_KEY"
```

```js
let cursor;
do {
  const url = new URL('https://api.parasend.com/v1/deliveries');
  url.searchParams.set('limit', '100');
  if (cursor) url.searchParams.set('cursor', cursor);
  const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.PARASEND_KEY}` } });
  const page = await res.json();
  for (const delivery of page.data) handle(delivery);
  cursor = page.has_more ? page.next_cursor : undefined;
} while (cursor);
```

A cursor is opaque: pass it back as it is, and never build one yourself. One that has been changed answers `400 cursor_invalid`; a `limit` outside the range answers `400 limit_invalid`.

Filters, such as `status` on deliveries, stay the same from page to page: send them with every request.
