# Pagination

`GET /get-all-tracking-items` lists the tracking items of the organization identified by the client key
(`x-api-client-key` is required). It has two modes, chosen with `type`.

## Active list (`type=active`)

```bash
curl "https://api.load-market.com/v1/get-all-tracking-items?type=active" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-api-client-key: YOUR_CLIENT_KEY"
```

- Every tracking item that is not `done`: `request`, `active`, `stop`, `cancel` and the derived
  statuses, plus pending installation and scheduled tracking items.
- When the tracking time (`expDate`) runs out, the server finishes the tracking item automatically and
  it moves from this list to history. A pending installation tracking item the driver never accepts is
  removed by the server after its tracking time runs out and never appears in history.
- Newest first (by `createdAt`).
- **No pagination.** The list is bounded by your plan and capped at 500 regular plus 500 pending
  items. `fromDate`, `toDate`, `limit` and `cursor` are rejected with `400 LIST_PARAMS_INVALID`.

## History (`type=history`)

Finished tracking items (`done`), filtered and ordered by their **expiration date**
(`expDate`), oldest first.

| Parameter | Default | Rules |
| --- | --- | --- |
| `fromDate` | now minus 7 days | Epoch milliseconds, **exclusive**: `expDate > fromDate` |
| `toDate` | no upper bound | Epoch milliseconds, **inclusive**: `expDate <= toDate`. Must not be before `fromDate` |
| `limit` | 100 | 1 to 500 |
| `cursor` | - | `pagination.nextCursor` of the previous page |

```bash
curl "https://api.load-market.com/v1/get-all-tracking-items?type=history&fromDate=1792972800000&toDate=1793577600000&limit=100" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-api-client-key: YOUR_CLIENT_KEY"
```

```json
{
  "message": "Ok",
  "data": [ { "trackingId": "api-7fK2mQ9xLpR4tN8vB1cD", "status": { "value": "done", "description": "Tracking finished" } } ],
  "pagination": { "nextCursor": "eyJ2IjoxNzkzNDkxMjAwMDAwLCJwIjoi..." }
}
```

To get the next page, repeat the request with the **same** window and `cursor` set to
`pagination.nextCursor`. The last page has `nextCursor: null`.

```bash
curl "https://api.load-market.com/v1/get-all-tracking-items?type=history&fromDate=1792972800000&toDate=1793577600000&limit=100&cursor=eyJ2IjoxNzkzNDkxMjAwMDAwLCJwIjoi..." \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-api-client-key: YOUR_CLIENT_KEY"
```

### Things to know

- The cursor is opaque. Do not build or modify it: a cursor that cannot be decoded answers
  `400 LIST_PARAMS_INVALID`, and an edited cursor can silently skip or repeat items.
- The window applies to `expDate`, not to the moment the tracking finished. A tracking stopped early
  with `stop-tracking` keeps its original `expDate`, so it appears in the window that contains that
  date. Leave `toDate` empty (no upper bound) to include such tracking items.
- History keeps finished tracking items for a limited time only, so sync what you need regularly.
- With a test key, history is one page (`nextCursor` is always `null`).
- Items are slim: no email settings, driver files, ETA or reverse-geocoded address. Call
  `get-tracking` for the full view of a tracking.
- History items have `driverCoords: null` - a position is published only while a tracking is live
  (see [Tracking lifecycle](/tracking-lifecycle#driver-position)).

See [Daily history sync](/guides/daily-history-sync) for a complete job.
