> For the complete documentation index, see [llms.txt](https://skyhub-english.gitbook.io/skyhub-api-english/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://skyhub-english.gitbook.io/skyhub-api-english/skyhub-api-guides/order-and-product-filtering.md).

# Order and Product Filtering

The Skyhub API has a feature to filter orders and products accordingly to the status that they are in.

### Filter Orders by Status

For example, when you perform the `GET` through the endpoint `https://api.skyhub.com.br/orders/`, the result bring all the orders, regardless of whether they are approved, sent, canceled, delivered, and so on ...

By using the filter, we can search for an specific status. In order to do that you need to know what status your store has on Skyhub by cheking the order statuses through the following path within Skyhub plataform portal following the path: **"Skyhub" > "status de pedidos"**

![](/files/-LWpDngA7eMdO8AuxmkY)

{% hint style="info" %}
The status used to make the filter are avaiable at the field # (code)
{% endhint %}

You can also check the different types of statuses through the endpoint: `api.skyhub.com.br/statuses`

![response sample](/files/-LWpEqPw3Ir3g4bC4JAY)

### How to Filter Requests by Status?

To filter, we must use the `GET` method at the `https://api.skyhub.com.br/orders?filters[statuses][]={code}` endpoint with the following Headers:

```
X-User-Email: YOUR_EMAIL
X-Api-Key: YOUR_API_KEY
X-Accountmanger: YOUR_X_ACCOUNTMANAGER-KEY
Accept: application/json
Content-Type: application/json
```

Using Skyhub's standard statuses, the endpoints would be:

| Action                      | Request                                                                            |
| --------------------------- | ---------------------------------------------------------------------------------- |
| **Approved Orders**         | <https://api.skyhub.com.br/orders?filters\\[statuses]\\[]=payment\\_received>      |
| **Invoice Issued**          | <p><https://api.skyhub.com.br/orders?filters[statuses>]\[]=order\_invoiced<br></p> |
| **Pending payment**         | <https://api.skyhub.com.br/orders?filters\\[statuses]\\[]=book\\_product>          |
| **Canceled**                | <https://api.skyhub.com.br/orders?filters\\[statuses]\\[]=order\\_canceled>        |
| **Delivered to Customer**   | <p><https://api.skyhub.com.br/orders?filters[statuses>]\[]=complete<br></p>        |
| **order posted do carrier** | <https://api.skyhub.com.br/orders?filters\\[statuses]\\[]=order\\_shipped>         |

See the example below:

![](/files/-LWpHHXm3-U_s1U7hsHl)

![](/files/-LWpHJfxoLsRvqL8rpQN)

In case your store has many orders by status, you can also filter by page using the "page" and "per\_page".

* Page: indicates the page number of the records that will be returned. If not specified, the first page is returned (default value 1).
* Per\_page: Indicates the number of records to be returned. In both endpoints (products and orders), per\_page has 100 as default and maximum value.

{% code title="Example:" %}

```
https://api.skyhub.com.br/orders?filters[statuses][]=payment_received&page=1&per_page=1
```

{% endcode %}

In the example above, we are looking for approved status orders that appear on the first page.

{% hint style="danger" %}
Caution: Status filtering feature should **NOT** be used under any circumstances for order consumption/download always use the order queue endpoint.
{% endhint %}

### How to filter requests by date:

To filter requests by date, you'll need to use `filters [start_date] = DD / MM / YYYY`

{% code title="Example:" %}

```
https://api.skyhub.com.br/orders?filters[start_date]=15/08/2018
```

{% endcode %}

![](/files/-LWpJ7UpN14NethhEWjY)

In the example above we can see that the filter used is `[start_date] = 15/08/2018`, in this case the request response is those orders created from 08/15/2018 onwards.

To filter just the orders at 08/15/2018, you will also need to use `[end_date] = DD / MM / YYYY`.

{% code title="Example:" %}

```
https://api.skyhub.com.br/orders?filters[start_date]=15/08/2018&filters[end_date]=15/08/2018
```

{% endcode %}

![](/files/-LWpN0Ccmhnb1qeKS6Et)

If we look at the responses from the last two images above, we see that the number of requests returned are divergent, because the 1° example returns orders to day 15 onwards and 2° one only the requests from day 15.

{% hint style="info" %}
To check the date, you must verify the information presented in the "placed\_at" field.
{% endhint %}

The filter by date will always be performed by **the order creation date**, never by its update date.

### Filter products by status

In Skyhub's Api, in addition to filtering orders by status, we also have the possibility to filter products by status.

What are the product statuses?

* Enabled
* Disabled

#### How do I filter products by status?

To filter a product by status, you must use the headers bellow at `https://api.skyhub.com.br/products?filters[status]={enabled ou disabled}` endpoint.

```
X-User-Email: YOU_EMAIL
X-Api-Key: YOUR_API_KEY
X-Accountmanger: YOUR_X_ACCOUNTMANAGER-KEY
Accept: application/json
Content-Type: application/json
```

Here is an example of a request:

![](/files/-LWpRA1IMbt3hUAnUNf7)

Result

![](/files/-LWpRCK80q8-wEBjgmkP)

As in orders, you can filter by status, page, and quantity:

```
https://api.skyhub.com.br/products?page=1&per_page=1&filters[status]=enabled
```

![](/files/-LWpROZEKolbn5BJdcdI)

As we can see in the example above, the product was filtered with the status "enabled", bringing page 1 and only 1 product.

#### Other filters

In addition to the filters already mentioned, Skyhub has other types of filters.

* filters\[sku]
* filters\[name]
* filters\[status]
* filters\[qty\_from]
* filters\[qty\_to]
