Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: API Call for Returns

Solved

API Call for Returns

greenroadsign
Shopify Partner
3 0 0

Essentially, I am trying to make an API call to retrieve bulk list of returns for the month with the original order date, the order number, transaction type, and transaction amount. I know that what I have inserted below can obtain the info I want about a single order. But not sure what I need to do to get it in bulk based off of specified dates.

query getOrderTransactions {
	order(id: "") {
		name
		subtotalPriceSet {
			shopMoney {
				amount
			}
		}
		totalTaxSet {
			shopMoney {
				amount
			}
		}
		totalShippingPriceSet {
			shopMoney {
				amount
			}
		}
		transactions {
			accountNumber
			amountSet {
				shopMoney {
					amount
				}
			}
			authorizationCode
			authorizationExpiresAt
			createdAt
			errorCode
			formattedGateway
			gateway
			id
			kind
			processedAt
			status
			test
		}
	}
}
Accepted Solution (1)

EcomGraduates
Shopify Partner
795 68 114

This is an accepted solution.

It looks like you're trying to retrieve a bulk list of returns for a specific time period using an API call. To do this, you'll need to modify your query to include a filter for the date range you're interested in.

Here's an example query that retrieves a list of all orders created between March 1, 2022 and March 31, 2022, and includes information about the transactions and the original order date:

 

 

query {
  orders(query: "created_at:>2022-03-01 AND created_at:<2022-03-31") {
    edges {
      node {
        name
        createdAt
        transactions(first: 10) {
          edges {
            node {
              kind
              processedAt
              amountSet {
                shopMoney {
                  amount
                }
              }
            }
          }
        }
      }
    }
  }
}

 

 

You can modify the query to include additional information about the orders and transactions as needed, and adjust the date range to fit your needs.

 


 If this fixed your issue, likes and accepting as a solution are highly appreciated
|  Build an online presence with our custom-built Shopify Theme: EcomifyTheme
|  Check out our reviews: Trustpilot Reviews
|  We are Shopify Partners: EcomGraduates Shopify Partner



View solution in original post

Replies 2 (2)

EcomGraduates
Shopify Partner
795 68 114

This is an accepted solution.

It looks like you're trying to retrieve a bulk list of returns for a specific time period using an API call. To do this, you'll need to modify your query to include a filter for the date range you're interested in.

Here's an example query that retrieves a list of all orders created between March 1, 2022 and March 31, 2022, and includes information about the transactions and the original order date:

 

 

query {
  orders(query: "created_at:>2022-03-01 AND created_at:<2022-03-31") {
    edges {
      node {
        name
        createdAt
        transactions(first: 10) {
          edges {
            node {
              kind
              processedAt
              amountSet {
                shopMoney {
                  amount
                }
              }
            }
          }
        }
      }
    }
  }
}

 

 

You can modify the query to include additional information about the orders and transactions as needed, and adjust the date range to fit your needs.

 


 If this fixed your issue, likes and accepting as a solution are highly appreciated
|  Build an online presence with our custom-built Shopify Theme: EcomifyTheme
|  Check out our reviews: Trustpilot Reviews
|  We are Shopify Partners: EcomGraduates Shopify Partner



ShopifyDevSup
Shopify Staff
1453 238 531

@EcomGraduates is on point here! The only thing I'd add to this is if you end up with a large list of transactions, you can add pagination like this:

query ($cursor: String) {
 orders(first: 10, after: $cursor, query: "created_at:>2022-03-01 AND created_at:<2023-03-31") {
   pageInfo {
     hasNextPage
     endCursor
   }
   edges {
     node {
       name
       createdAt
       transactions(first: 10) {
             kind
             processedAt
             amountSet {
               shopMoney {
                 amount
               }
             }
           }
         }
       }
     }
   }

This would make it easier to iterate through the full list without going over your rate limit or having to process the query as a bulk operation. Hope this helps! 

 

Al | Shopify Developer Support 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog