What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Getting product sales via api vs product sales report

Getting product sales via api vs product sales report

global_dbanks
New Member
8 0 0

Hello, has anyone figured out a way to get the exact numbers that are displayed on the Sales by Product using the Orders API? 

Im using the orders endpoint with the parameters status=any, limit=250,

since_id={last} - which gets the last order id on the page to paginate through all the results, and the created_at_min/max for the date.

From the Sales by Product report it shows 139 for the product OP but the api call only brings back 138. I contacted support on how the net quantity is 
calculated which is "

Net quantity equates to number of sold items - number of returned items." 

Any tips here to get the same results as the report from Shopify admin? 

 

Replies 8 (8)

CloudlabSam
Shopify Partner
591 47 103

Honestly, it is possible but very time consuming and fraught with peril based exceptions and nuance. We have created a reporting app and we spent the better part of 6 months insuring data accuracy.

global_dbanks
New Member
8 0 0
Thanks, I figured it would be multiple calls using the different parameters
to try to get close to the actual numbers from the report but it seems that
I would have to spend a lot of time on it. Whew 6 months kudos to you and
your team. 1 of 1 here.

francis_ilustre
Tourist
6 0 0

Hi Global! 

 

I thought I was the only one with this issue. I'm also pulling the orders through API and comparing it with the Total Sales in the Analytics page. There are always discrepancies with the total as well as per day.

CloudlabSam
Shopify Partner
591 47 103

That’s because you aren’t comparing apples to apples. If you want to compare something to the Admin Order API, you would use the orders screen or the export csv. If you want to compare to the analytics page, you need to use the Sales model in the Shopify QL API

francis_ilustre
Tourist
6 0 0

Thank you for that! I will try using Shopify QL API instead. 

francis_ilustre
Tourist
6 0 0

Hi CloudlabSam!

Already tried pulling orders from Shopify QL API but I still get discrepancies between the sales over time report in the Analytics page if I compare it per day. However, if I compare the total, I usually get a 1% variance.

 

The closest I got to the total sales in the Analytics page was by using SubTotalPrice . 
Appreciate your help!

 

{
  orders (first:100,
  query:"created_at:>2020-07-25",
  ) {
    edges {
      node {
        id
        createdAt
        taxesIncluded
        currentSubtotalPriceSet {
          shopMoney {
            amount
          }
        }
      }
    }
  }
}

 

CloudlabSam
Shopify Partner
591 47 103

Hi there - the query you included is not actually a Shopify QL query, it is just querying the orders model via GraphQL. So this would be comparable to records found on the Orders admin screen.

 

To compare to sales you will need to use the Shopify QL API. You can read more about that here - https://shopify.engineering/shopify-commerce-data-querying-language-shopifyql.

francis_ilustre
Tourist
6 0 0

Thanks CloudlabSam!

I was able to get the sales data I need using the Shopify QL API!