# Parameters

## Pagination

Endpoints that returns data in paginated format, by default paginate every 15 records. You may pass a parameter to paginate custom number of records using `paginate=250` in the request

## Basics

Certain routes allow you to query responses more efficiently, include relationships or sort and filter data. Queries can be stacked on top of each other. You can specify multiple unique operators.

| Type          | Operator               | Description                  |
| ------------- | ---------------------- | ---------------------------- |
| Relationships | `include=relationship` | Include relation with record |
| Filters       | `filter[key]=value`    | Filter based on key value    |
| Sorting       | `sort[key]=asc`        | Sort based on key value      |
| Dates         | `date=Date1,Date2`     | Filter between two dates     |

## Relationships

Relationships are objects that have some sort of associations / coherence with each other. Certain endpoints support custom relations that are loaded if specified. (See example below)

For instance, if you want to retrieve users with all their payments, you may specify it in the request with `?include=payments`, this will return all users with their respected payments. You can specify more than one relation separating them with a comma "," `` ?include=address,payments,emails` ``

Example: (Retrieve users with their payments)

```sh
curl "https://wemx.app/api/v1/users?include=payments" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer apikey' \
  -X GET
```

## Filters

Filters allow you to refine the data that you want returned. Supported filters are specified on the API endpoint under "Available Filters".  Filters can be passed inside the endpoint `?filter[key]=value`

Example 1: (Retrieve all subscribed users)

```sh
curl "https://wemx.app/api/v1/users?filter[is_subscribed]=0" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer apikey' \
  -X GET
```

This request returns all users subscribed to emails

Example 2: (Retrieve subscribed & online users)

```sh
curl "https://wemx.app/api/v1/users?filter[is_subscribed]=0&filter[is_online]=1" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer apikey' \
  -X GET
```

## Sorting

Sorting helps you sort records alphabetically or depending on the date. Sorting parameters can be specified like so: `?sort[key]=operator` The supported operators are `asc`, `desc`, `random`

Example 1: (Retrieve latest users based on when they were created)

```sh
curl "https://wemx.app/api/v1/users?sort[created_at]=desc" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer apikey' \
  -X GET
```

Example 2: (Retrieve latest users with the highest balance)

```sh
curl "https://wemx.app/api/v1/users?sort[created_at]=desc&sort[balance]=desc" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer apikey' \
  -X GET
```

## Dates

Dates allow you to filter records between two dates, or commonly used dates. The commonly used dates include `today, yesterday, 3days, 7days, 14days, 30days, 90days`

To filter records based on dates, you can pass the following parameter `?date=30days` this will return all records created within the last 30 days. You can also pass a custom date range using `?date=01-01-2024,01-01-2025`

```sh
curl "https://wemx.app/api/v1/users?date=30days" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer apikey' \
  -X GET
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wemx.gitbook.io/wemx-api/parameters.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
