Retrieving Return Order Amounts via Shopify Admin REST API

Retrieving Return Order Amounts via Shopify Admin REST API

developerAnna
Visitor
2 0 2

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:

  1. Is it possible to retrieve the returned order amount or refund amount using the Admin REST API?

  2. If so, which endpoint and fields should I be using to accurately include return/refund values in my sales calculations?

  3. 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.

 

Reply 1 (1)

Kudosi-Carlos
Trailblazer
246 25 114

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

  • This returns an array of refund objects. Each refund has a transactions array with amount fields you can sum to get the total refunded per order.

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 }
}
}
}
}
}
}

  • Sum transactions.amount.amount for each refund and subtract from totalPriceSet.shopMoney.amount.

 

- Was this helpful? Click Like or Mark as Solution to support the community.
- Kudosi Product Reviews – Instantly import high-quality reviews from AliExpress, Amazon, eBay, Etsy, Temu and anywhere you want. Build trust fast, boost conversions, and kickstart your sales.
Start free trial