Calculate Gross Sales using Shopify API

Highlighted
New Member
3 0 0

I want to calculate Gross Sales using Shopify API. I have already readed the shopify API documentation and tried the formula they used to calculate gross sales and failed to get the same result they have at the shopify reports website.

I used this shopify endpoint to retrieve all orders

/admin/api/2020-07/orders.json?status=any&created_at_min=2020-07-03T00:00:00-04:00&created_at_max=2020-07-04T00:00:00-04:00&limit=250

PS: The number of orders from shopify API and shopify Dashboard is equal. ( I am getting all the orders correctly, 141 orders)

I tried to use the sum of total_line_items_price, but I got a different result from Shopify Reports.
Shopify API results after summing the total_line_items_price: 13124.62
Also, I tried to use the formula they provided at Shopify API documentation where they mentioned that Gross Sales = product selling price x ordered quantity and I got the same result as sum of the total_line_items_price: 13124.62
Shopify Gross Sales at the financial report dashboard: 13082.76
Shopify API sum of total_tax: 48.2 Which is equal to the financial report taxes.
Please I need your help to calculate Gross Sales Correctly

Thank you

0 Likes
Highlighted
Shopify Staff
Shopify Staff
54 6 8

Hi @Taherooo,

Can you provide the X-Request-Id from the response headers so we can troubleshoot further?

Callum | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
New Member
3 0 0

Hey @CalD 

Request for 2 july orders data

/admin/api/2020-07/orders.json?status=any&created_at_min=2020-07-02T00:00:00-04:00&created_at_max=2020-07-03T00:00:00-04:00&limit=250

X-Request-ID

8bf4bb72-af2d-438b-8ae2-b3dcf89d9916

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
54 6 8

Hey @Taherooo,

I notice the store in question's Timezone is set as GMT-05:00. If you update the request params to use created_at_mincreated_at_max with -05:00 instead of -04:00 for both, does that change the Gross Sales number you get? It could be the case that there was one order that was placed during the hour in question that could account for the difference you're seeing.

In the Analytics dashboard, it now looks like the Gross Sales figure for July 2nd is $13,328.56.

Callum | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
New Member
3 0 0

Hey @CalD 

Date 2 July Orders

using -05:00 instead of -04 returns 

X-Request-ID

a2c2f349-3972-45c5-b74d-6b12336b9cc0

Gross Sales = product selling price x ordered quantity) = $12,718.059 but in the Analytics Dashboards it's $13,328.56

using -04:00 returns

Gross Sales = product selling price x ordered quantity) = $13,382.73 but in the Analytics Dashboards it's $13,328.56

0 Likes
Highlighted
Shopify Staff
Shopify Staff
54 6 8

Hey @Taherooo,

After looking into this, the discrepancy is related to how the store calculates tax. An example order where this is relevant is 2355927580774 where the Gross Sale in the report is 108.92 and the total_line_items_price in the API is 111.84. This is because the store is displaying the price with taxes included ("taxes_included" boolean in the /orders API response).

If you notice a discrepancy like this in the future, a good rule of thumb is to use the Report as the source of truth (you can 'Edit columns' to identify individual orders and the Gross Sales), and double check that you're taking into consideration how tax is calculated for the orders/line items in question.

Callum | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes