How to access all refund orders using API

jw_pei
New Member
9 0 0

GET /admin/api/2021-01/orders/{order_id}/refunds.json

Only one order can be accessed. How can I access the used refund order。

0 Likes
KikeMelero
Tourist
4 1 0

Are you locked to REST Admin API calls? GraphQL Bulk Operations would do the trick

https://shopify.dev/tutorials/perform-bulk-operations-with-admin-api

Just a quick query draft:

{
  orders {
    edges {
      node {
        name
        id
        createdAt
        updatedAt
        processedAt
        cancelledAt
        refunds {
          id
          createdAt
          note
          refundLineItems {
            ...
          }
          transactions {
            ...
          }
        }
      }
    }
  }
}

You need to introduce required fields for refundLineItems and transactions. Bulk Operations returns a jsonl file, so you need to store it (disk or memory, better on disk for lower memory consumption) and treat the returned data line by line. The best part is that Bulk Operations defers all the processing stuff to Shopify, so you only need to do one API call and then do some short polling until the processing is completed.

Cheers!

0 Likes
jw_pei
New Member
9 0 0
  • Is there any other API that can access all refund orders?

0 Likes
jw_pei
New Member
9 0 0
  • How does this query construct the URL?

0 Likes
KikeMelero
Tourist
4 1 0

You have all the GraphQL documentation here https://shopify.dev/docs/admin-api/graphql/reference

but if you really need to use the REST Admin API, you can make a call to GET /admin/api/2021-01/orders.json and then add a search syntax parameter for retrieving only refunded o partially refunded orders like financial_status=refunded or financial_status=partially_refunded.

This will return you all the refunded or partially_refunded orders, but you will need to paginate through it and access the refunds field inside the order object.

 

 

0 Likes