Discrepancy Between API Calls and Shopify Dashboard Total Sales Calculation

Topic summary

Discrepancy between Shopify API results and the Shopify dashboard for both total sales and order counts. API shows €356,953.18 and 5,415 orders, while the dashboard shows €355,571.59 and 5,536 orders.

Work done to reconcile: refunds (partial and full) incorporated into API calculations; orders fetched with status=any; time zone aligned to GMT+1 (Paris). These steps reduced but did not eliminate gaps.

Suspected contributors to the mismatch include how returns, net vs. gross sales, shipping costs, taxes, and discounts are treated. Partially refunded and voided orders seem correlated with discrepancy dates, but refunds alone don’t explain the exact differences.

Key questions posed: What exact formula does the Shopify dashboard use for “total sales”? Does it include gross sales, and how are full/partial refunds, shipping, taxes, and discounts factored? How should these be handled via API to match dashboard numbers.

A simplified Python example sums order total_price and subtracts refund_line_items subtotals for refunds, then counts orders. No definitive answer yet; guidance requested to replicate the dashboard calculation precisely.

Summarized with AI on December 17. AI used: gpt-5.

Hi Shopify Community,

I’ve been working on pulling data via the Shopify API and comparing the results with the Shopify dashboard for total sales and order numbers. While most of the data aligns, I’ve noticed a discrepancy between the API and dashboard totals, especially when accounting for partially refunded and voided orders.

Here are the key details:

  • Total Sales (API): €356,953.18
  • Total Sales (Dashboard): €355,571.59
  • Total Orders (API): 5,415
  • Total Orders (Dashboard): 5,536

What I’ve Investigated So Far:

  1. Refunds: I’ve adjusted my API call to account for refunds (both partial and full refunds). This helped explain part of the discrepancy, but the exact difference between the API and dashboard totals still isn’t fully explained.
  2. Order Status: I’m using status=any in my API call, which should capture all order statuses.
  3. Time Zone: I’ve ensured that the API request aligns with the store’s time zone (GMT +1:00, Paris).

Despite these adjustments, there are still minor differences that are difficult to trace back to a single metric or calculation. It’s possible that factors such as returns, net sales, shipping costs, tax, and discounts are being handled differently between the API response and the dashboard’s total sales calculation.

My Question:

What is the exact formula that the Shopify dashboard uses to calculate total sales? What I’ve found so far is that there is a refund or partial refund on every discrepancy date, but the refunded amounts alone do not explain the exact difference. Some of the difference can be attributed to taxes and returns, but other parts remain unexplained.

  • Does it include gross sales?
  • Does it account for refunds (both full and partial)?
  • How does it handle shipping and tax?
  • Are discounts factored into the total?

Additionally, is there a specific way to handle these variables in the API response to match the dashboard’s numbers more closely?

Code Example:

Here’s a simplified version of my Python code for fetching order data, including handling refunds:

python

Copy code

def fetch_shopify_data(fetch_date):

Date handling and API request code…

total_sales = 0

order_count = 0

for order in response_data[‘orders’]:

order_total_price = float(order[‘total_price’])

Calculate total refund for this order

total_refunds = 0

if ‘refunds’ in order and len(order[‘refunds’]) > 0:

for refund in order[‘refunds’]:

refund_total = sum(float(item[‘subtotal’]) for item in refund[‘refund_line_items’])

total_refunds += refund_total

Subtract refunds from total sales

net_order_total = order_total_price - total_refunds

total_sales += net_order_total

order_count += 1

return total_sales, order_count

Any insights on how to match the API’s total sales and order counts more closely with the dashboard would be greatly appreciated!

2 Likes