Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Dear Shopify Support,
I hope this message finds you well.
I am currently using the Shopify Admin REST API to display sales totals on a custom dashboard built with Laravel. While I am able to successfully fetch order data using the GET /admin/api/{version}/orders.json endpoint, I’ve noticed a discrepancy between the sales totals on my dashboard and the amounts shown in the Shopify Admin panel.
Upon further investigation, I believe this discrepancy may be due to the return orders not being included or accounted for in the API response. I would like to know:
Is it possible to retrieve the returned order amount or refund amount using the Admin REST API?
If so, which endpoint and fields should I be using to accurately include return/refund values in my sales calculations?
If not available via the REST API, is it accessible through the GraphQL Admin API or any other recommended method?
Any guidance or documentation references you could provide would be greatly appreciated, as I would like to ensure the accuracy and consistency of our dashboard data with the Shopify Admin.
Thank you in advance for your support.
Hello @developerAnna
Returns and refunds aren’t lumped into the /orders.json totals by default—that endpoint only gives you the original order amounts. To factor in refunds, you’ll need to pull in the refund data and subtract it yourself. Here’s what to do next:
1. Retrieve refunds for each order
Use the REST endpoint
GET /admin/api/{version}/orders/{order_id}/refunds.json
2. Sum refunded amounts in your dashboard
In your Laravel code, after fetching the orders:
// Pseudocode
$orders = Http::get("/admin/api/2025-01/orders.json?status=any")->json()['orders'];
foreach ($orders as $order) {
$refunds = Http::get("/admin/api/2025-01/orders/{$order['id']}/refunds.json")->json()['refunds'];
$totalRefunded = array_sum(array_map(fn($r) => array_sum(array_column($r['transactions'], 'amount')), $refunds));
$netSales += $order['total_price'] - $totalRefunded;
}
That way you subtract exactly what was returned.
3. (Optional) Use GraphQL for fewer calls
If you’d rather avoid an extra REST request per order, switch to GraphQL and request refunds in one go:
query {
orders(first: 50) {
edges {
node {
id
totalPriceSet { shopMoney { amount } }
refunds {
refundLineItems {
lineItems { quantity }
}
transactions {
amount { amount }
}
}
}
}
}
}
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025