How correctly make REST API request to get complete orders between a date range in Magento 2 - rest

I want to get complete orders between a date range using Magento 2 REST Api. So request looks like:
/rest/V1/orders?searchCriteria[filterGroups][0][filters][0][field]=status&searchCriteria[filterGroups][0][filters][0][value]=Complete&searchCriteria[filterGroups][0][filters][0][conditionType]=eq
Now I want get it in specific period. I found that Magento api has "from" and "to" fields but I always confused in searchCriteria filter index. Can anybody complete my request? Thanks

You will get complete orders between a date range by using the conditions from and to.
This API will get you the orders between the two dates:
http://<magento_host>/rest/V1/orders?
searchCriteria[filter_groups][0][filters][0][field]=created_at&
searchCriteria[filter_groups][0][filters][0][condition_type]=from&
searchCriteria[filter_groups][0][filters][0][value]=from_date&
searchCriteria[filter_groups][1][filters][0][field]=created_at&
searchCriteria[filter_groups][1][filters][0][condition_type]=to&
searchCriteria[filter_groups][1][filters][0][value]=to_date
Example:
http://<magento_host>/rest/V1/orders?
searchCriteria[filter_groups][0][filters][0][field]=created_at&
searchCriteria[filter_groups][0][filters][0][condition_type]=from&
searchCriteria[filter_groups][0][filters][0][value]=2016-07-01 00:00:00&
searchCriteria[filter_groups][1][filters][0][field]=created_at&
searchCriteria[filter_groups][1][filters][0][condition_type]=to&
searchCriteria[filter_groups][1][filters][0][value]=2018-07-01 00:00:00
The above API will get you the orders between a by using created_at timestamp.
For an example also see the Magento Docs.

Related

Magento 2 rest order API show duplicate sku in order item if product is configurable

I am getting Magento 2 order details by rest order API but the result is showing the same SKU in configured product order item that is creating an issue in SAP integration.
Anyone let me know how can we overwrite Magento 2 rest API code?
You should not need to “overwrite magento 2 rest API code” because what you described is perfectly normal and expected.
In Magento orders, each configurable product creates two sales order line items due to the way that configurable product data is structured in the catalog. One line corresponds to the “parent” catalog product, and one corresponds to the specific variant “child” (simple) product. Both records contain the same SKU value but their product IDs are different.
In order to get all information about the ordered item both of those records could be important, however if you can get by with just the data from the simple product then you could filter your REST request like below:
GET <host>/rest/V1/orders/items?
searchCriteria[filter_groups][0][filters][0][field]=order_id&
searchCriteria[filter_groups][0][filters][0][value]=1&
searchCriteria[filter_groups][1][filters][0][field]=product_type&
searchCriteria[filter_groups][1][filters][0][value]=simple

Shopify API: How to get id where is greater than

How can I get orders thru Shopify API where the id is greater than xxxxx?
Something like:
admin/api/2020-01/orders.json?id>=1900000000
or
admin/api/2020-01/orders.json?min_id=1900000000
I hope you understand what I mean.
If you read the documentation you see that orders have a created_at_min and created_at_max. Those values are what you use as your filter criteria for dates. If you need to work off of ID then you can try the since_id filter. In other words, give me all order since 123456. You get what I mean?

How to delete only a subset of posted data in firebase

Posting data to firebase generate new items similar to the following example:
log
-K4JVL1PZUpMc0r0xYcw
-K4jVRhOeL7fH6CoNNI8
-K4Jw0Uo0gUcxZ74MWBO
I struggle to find how to e.g. delete entries that is older than x days - preferably with the REST API. Suggestions appreciated.
You can do a range query.
This technique requires you to have a timestamp property for each record.
Using orderBy and endAt you can retrieve all of the items before a specified date.
curl https://<my-firebase-app>.firebaseio.com/category/.json?orderBy="timestamp"&endAt=1449754918067
Then with the result, you can delete each individual item.

woocommerce customer Fetch with time filter

I am requesting customer data using Rest Api of woocommerce. Woocommerce api documentation says
"All endpoints (except for customer orders) support date filtering via created_at_min and created_at_max as ?filter[] parameters. e.g. ?filter[created_at_min]=2013-12-01".
However, when I am giving date filter in request URL it results in blank response!!
My question is,can the customer data be fetched via date filter in woocommerce.
Thanks.
You can pass Filter with time in REST API of WooCommerce.
Just pass the filter in H:i:s format.
Note : while trying to generate the signature, I found, the URL encoding needs to be done twice because of extra space between DateTime filter criteria. Just encode the clean text once to get RFC3986 encoding, and do it again to generate the signature. Pass the first encoded string and append the generated signature. I saw the filter to be working.

Instagram Search for a tag within particular date range

I am looking to retrieve results from instagram for a particular tag mytag , I tried using this API call,
https://api.instagram.com/v1/tags/{tag-name}/media/recent
but it only returned 33 results even though there are more results. This question can be considered an extension to this question: How To Search Instagram via API Query?
What is the way to return instagram results for a particular tag within a date range?
This may be done through the min_tag_id and max_tag_id which. Not sure how to convert my date time to min_tag_id or max_tag_id?
call the API with max_tag_id and min_tag_id like this:
https://api.instagram.com/v1/tags/{tag-name}/media/recent?client_id={CLIENT_ID}&max_tag_id=1378677250000000&min_tag_id=1375998850000000
max_tag_id and min_tag_id is epoch_time + "000000"
you still only get 20 per API call, use pagination to get all
Update: Instagram changed the tag_id, so date filter cannot be done
this way. Login on http://gramfeed.com and search for a hashtag and
you can do date/time filter, its a different hack implementation.