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

# Filtering, Ordering, & Pagination

> Learn how Maesn Unified API handles Filtering, Ordering and Pagination to access exactly the data that you need.

Some of the resources in the maesn API support filtering, ordering and/or pagination.

## Pagination

Pagination is done through the query parameters `limit` and `page`. The `limit` parameter specifies the number of resources to return per page, while the `page` parameter specifies the page number to return.
The `page` parameter starts at 1.
The `limit` parameter can be the following values: 5, 10, 20, 50, 100

```javascript Example code snippet theme={null}
    const response = await axios.get(url, {
        params: {
            "limit": limit,
            "page": page
        },
        headers: {
            'X-API-KEY': apiKey,
            'X-ACCOUNT-KEY': accountKey
        }
    });
```

## Filtering

Filtering of API responses is done through query parameters. The parameters supported by the respective endpoint is documented in the API reference.

As an example, when fetching invoices you can filter on invoices modified since a given date and time by supplying the parameter `lastModified`. Thus, as an example, passing`lastModified=2021-03-30T20:44:18` to GET [/invoices](/api-reference/accounting-endpoints/invoices/get-invoices) would return all invoices modified 30th March 2021 at 20:44:18 or later.

```javascript Example code snippet theme={null}
    const response = await axios.get(url, {
        params: {
            "lastModified": lastModified
        },
        headers: {
            'X-API-KEY': apiKey,
            'X-ACCOUNT-KEY': accountKey
        }
    });
```

The query parameter 'status' is currently available for GET [/invoices](/api-reference/accounting-endpoints/invoices/get-invoices) for Business Central, Lexware Office, Qonto, Sage Active, Sevdesk, weclapp, Xentral and Xero.
It is also available for  GET [/bills](/api-reference/accounting-endpoints/bills/get-bills) and GET [/booking proposals](/api-reference/accounting-endpoints/bookingproposals/get-booking-proposals) for Lexware Office and Qonto.

```javascript Example code snippet theme={null}
    const response = await axios.get(url, {
        params: {
            "status": status
        },
        headers: {
            'X-API-KEY': apiKey,
            'X-ACCOUNT-KEY': accountKey
        }
    });
```

### Sage Active specific filters

In case of Sage Active there is a filter called 'paymentStatus' for invoices to filter based on the payment status.
This is useful since Sage Active, unlike many other systems, does not feature 'paid' or 'partially paid' statuses as part of the regular invoice status.

```javascript Example code snippet theme={null}
    const response = await axios.get(url, {
        params: {
            "paymentStatus": paymentStatus
        },
        headers: {
            'X-API-KEY': apiKey,
            'X-ACCOUNT-KEY': accountKey
        }
    });
```

### Lexware Office specific filters

In case of Lexware Office there is a filter called 'name' and one called 'email' for contacts to filter based on the name and email of the contact respectively.

```javascript Example code snippet theme={null}
    const response = await axios.get(url, {
        params: {
            "name": name,
            "email": email
        },
        headers: {
            'X-API-KEY': apiKey,
            'X-ACCOUNT-KEY': accountKey
        }
    });
```

### Sevdesk specific filters

In case of sevdesk there is a filter called `number` for contacts (both customers and suppliers). This filter allows you to search or filter contacts based on their contact number.

```javascript Example code snippet theme={null}
    const response = await axios.get(url, {
        params: {
            "number": number
        },
        headers: {
            'X-API-KEY': apiKey,
            'X-ACCOUNT-KEY': accountKey
        }
    });
```

## Ordering

Response ordering of API responses is done through query parameters.
Currently the GET [/invoices](/api-reference/accounting-endpoints/invoices/get-invoices), GET [/bills](/api-reference/accounting-endpoints/bills/get-bills) and GET [/booking proposals](/api-reference/accounting-endpoints/bookingproposals/get-booking-proposals) endpoints supports ordering by the `orderField` and `orderDir` parameters.
The `orderField` parameter specifies the field to order by, while the `orderDir` parameter specifies the direction of the ordering.

In case of invoices the supported values for `orderField` are: `invoiceDate`, `invoiceNumber`, `createdDate`, `updatedDate`.

For bills the supported values for `orderField` are: `billDate`, `billNumber`, `createdDate`, `updatedDate`.

Finally, for booking proposals the supported values for `orderField` are: `bookingProposalDate`, `number`, `createdDate`, `updatedDate`.

```javascript Example code snippet theme={null}
    const response = await axios.get(url, {
        params: {
            "orderField": orderField,
            "orderDir": orderDir
        },
        headers: {
            'X-API-KEY': apiKey,
            'X-ACCOUNT-KEY': accountKey
        }
    });
```
