> ## Documentation Index
> Fetch the complete documentation index at: https://apidocs.ipxo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Pagination, filtering and sorting

> How list endpoints page, filter and sort their results.

List endpoints return a page of results rather than everything at once. IPXO's APIs
use two different paging conventions depending on which service you are calling, so
it is worth knowing which one applies.

## Page-based paging

Used by the **Billing** and **E-commerce** APIs — subnets, services, invoices,
payouts, orders, subscriptions.

<ParamField query="page" type="integer">
  Which page to return, starting at `1`.
</ParamField>

<ParamField query="per_page" type="integer">
  How many records per page.
</ParamField>

```bash theme={null}
curl 'https://apigw.ipxo.com/ecommerce/public/{tenant_uuid}/invoices?page=1&per_page=50' \
  -H 'Authorization: Bearer {access_token}'
```

To walk the whole collection, increment `page` until a request returns fewer than
`per_page` records.

## Offset-based paging

Used by the **NetHub Data** API — prefix search and prefix metadata.

<ParamField query="limit" type="integer">
  How many records to return.
</ParamField>

<ParamField query="offset" type="integer">
  How many records to skip before starting.
</ParamField>

These endpoints echo the values back in a `metadata` object, so you can confirm
what you asked for:

```json theme={null}
{
  "data": [],
  "metadata": {
    "limit": 50,
    "offset": 0
  }
}
```

<Tip>
  Prefix search can return a great many records. Start with `"limit": 2` to see
  the shape of the response before requesting a full page.
</Tip>

## Sorting

Pass a field name to `sort`. Prefix it with `-` to reverse the order.

```bash theme={null}
# newest first
curl 'https://apigw.ipxo.com/ecommerce/public/{tenant_uuid}/invoices?sort=-placed_at' \
  -H 'Authorization: Bearer {access_token}'
```

Which fields a given endpoint accepts is listed on its own reference page.

## Filtering

Filters are passed as `filter[field]`, and several can be combined. Values are
comma-separated for a set.

```bash theme={null}
curl 'https://apigw.ipxo.com/ecommerce/public/{tenant_uuid}/invoices?filter[status]=paid,unpaid' \
  -H 'Authorization: Bearer {access_token}'
```

Remember to URL-encode the brackets (`%5B` and `%5D`) if your HTTP client does not
do it for you.

<Note>
  Not every list endpoint supports every parameter on this page. The reference page
  for each endpoint lists the parameters it accepts.
</Note>
