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"

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

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
https://api.skyhub.com.br/orders?filters[statuses][]=order_invoiced
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
https://api.skyhub.com.br/orders?filters[statuses][]=complete
order posted do carrier
https://api.skyhub.com.br/orders?filters[statuses][]=order_shipped
See the example below:


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.
https://api.skyhub.com.br/orders?filters[statuses][]=payment_received&page=1&per_page=1
In the example above, we are looking for approved status orders that appear on the first page.
Caution: Status filtering feature should NOT be used under any circumstances for order consumption/download always use the order queue endpoint.
How to filter requests by date:
To filter requests by date, you'll need to use filters [start_date] = DD / MM / YYYY
https://api.skyhub.com.br/orders?filters[start_date]=15/08/2018

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
.
https://api.skyhub.com.br/orders?filters[start_date]=15/08/2018&filters[end_date]=15/08/2018

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.
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:

Result

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

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]
Last updated
Was this helpful?