Discussing APIs and development related to customers, discounts, and order management.
I'm trying to get all orders that are made during a period of time. However, the results from Shopify API and from Shopify Admin's Sales Over Time Report are not matching on most periods I've tried (most of the time the API has fewer results).
Shopify Admin's Sales Over Time Report: https://DOMAIN.myshopify.com/admin/reports/sales_over_time?startDate=2019-05-01&endDate=2019-05-02&o...
Python Code:
import pytz from datetime import datetime min_date = datetime(year=2019, month=5, day=1, hour=0, minute=0, second=0, tzinfo=pytz.timezone("America/Los_Angeles")).isoformat() max_date = datetime(year=2019, month=5, day=2, hour=23, minute=59, second=59, tzinfo=pytz.timezone("America/Los_Angeles")).isoformat() def get_all_resources(resource, **kwargs): resource_count = resource.count(**kwargs) resources = [] if resource_count > 0: for page in range(1, ((resource_count-1) // 250) + 2): kwargs.update({"limit" : 250, "page" : page}) resources.extend(resource.find(**kwargs)) return resources resources = get_all_resources(shopify.Order, created_at_min = min_date, created_at_max = max_date)
Hey there,
In all honesty I'm not sure off the top of my head what order status our reports will use by default, but I know that by default our API will only return orders with a status of open unless specified otherwise in the request being made. Have you tried including the status=any parameter when making your API request? You may see that numbers start to line up more accurately if you do. Let me know if not though!
Josh | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Hi @Josh, thanks for the status=any tip, now I'm able to retrieve a count of orders that is similar to the Admin report. I tested on a year period and the result from the API is 21,796 orders while, surprisingly, the Admin report says only 21,769 orders. While it's just a minor difference in a year scale, however, I just want to understand the discrepancy between the two sources and which one should I trust.
Cheers!
Hey again @sasawatc ,
Happy to help (somewhat help for now at least)! That sounds interesting, I'm not sure off the top of my head where the difference could come from though.
Would you mind sending me the shop that this is happening on? I could take a closer look for you, I'd just need to know where to be looking. If you're not comfortable sharing your .myshopify.com domain on our forums that's ok, even a random order ID from the shop would work and I could look it up with that.
Josh | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Thanks @Josh for offering to help! I think we can try with an order id first then... 913658609786
Cheers!