Order and Product Filtering
Last updated
Last updated
The Skyhub API has a feature to filter orders and products accordingly to the status that they are in.
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"
The status used to make the filter are avaiable at the field # (code)
You can also check the different types of statuses through the endpoint: api.skyhub.com.br/statuses
To filter, we must use the GET
method at the https://api.skyhub.com.br/orders?filters[statuses][]={code}
endpoint with the following Headers:
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.
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.
To filter requests by date, you'll need to use filters [start_date] = DD / MM / YYYY
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
.
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.
To check the date, you must verify the information presented in the "placed_at" field.
The filter by date will always be performed by the order creation date, never by its update date.
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
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.
Here is an example of a request:
Result
As in orders, you can filter by status, page, and quantity:
As we can see in the example above, the product was filtered with the status "enabled", bringing page 1 and only 1 product.
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]