Need to find order data in your Shopify store? The GraphQL Admin API makes it possible to request the orders and details you need, from a specific customer’s purchases to information like line items and fulfillment status.
In this guide, you’ll learn how to use Shopify GraphQL to retrieve orders, build a query, and handle the results. Whether you’re creating an integration or exploring the API for the first time, you’ll have a clear path to getting started.
Prepare a Shopify GraphQL query to retrieve orders
Before requesting order data, decide what your integration is allowed to see and which details it actually needs. A little planning up front helps keep the query focused, the response manageable, and access aligned with your app’s purpose.
Start by confirming your app can access the store’s order data. The required scope and the age of the orders you need both affect whether a request will succeed.
Check API access and required permissions
For order queries, the app generally needs the readorders access scope. Add the scope to your app’s configuration, then have the store authorize or reinstall the app if Shopify prompts for updated permissions. Send requests to the GraphQL Admin API endpoint for the API version your app uses, with its Admin API access token in the request headers.
By default, access is limited to orders created within the last 60 days. If your use case requires older records, request the readallorders access scope in addition to readorders; Shopify must approve access. You can review the current requirements in Shopify’s orders access scopes documentation.
Once access is in place, shape the response around the job your app performs. Selecting only useful fields can reduce unnecessary data transfer and make results easier to process.
Choose the order fields your app needs
For a basic order list, consider selecting the order ID, name, creation date, and financial or fulfillment status. Add nested fields only when needed—for example, line-item titles and quantities for an order summary, or customer details for a customer-facing workflow. Some customer data is protected and may require additional app approval.
Think through the response before writing the query:
- Order identification:
idandname - Timing and progress:
createdAt,displayFinancialStatus, anddisplayFulfillmentStatus - Purchased items:
lineItems, including fields such astitleandquantity
With permissions and fields settled, you can assemble a query that supports filtering and pagination. This example requests recent orders and leaves room to pass a search filter and a cursor as variables.
Build and run the orders query
Send a POST request to /admin/api/{version}/graphql.json with your access token. A query can look like this:
query GetOrders($first: Int!, $after: String, $search: String!) {
orders(first: $first, after: $after, query: $search) {
edges {
cursor
node {
id
name
createdAt
displayFinancialStatus
displayFulfillmentStatus
lineItems(first: 10) {
nodes {
title
quantity
}
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}Pass values such as first: 20 and a search string like status:open in the request’s variables. If hasNextPage is true, send another request using endCursor as after. This cursor-based approach lets you retrieve larger result sets in manageable batches.
Use Shopify GraphQL to retrieve orders with filters and pagination
A broad order search can quickly return more data than an integration needs. After building the basic request, narrow the results and retrieve them in predictable batches so the workflow stays efficient as the store grows.
Search filters help you target a useful slice of a store’s order history. The examples below can be passed as the $search variable in the query you already built.
Filter orders by date, status, or customer
Shopify’s order search syntax supports filters such as createdat, status, financialstatus, fulfillmentstatus, and customer identifiers. Combine terms to narrow results; for example, status:open financialstatus:paid finds open orders that are paid.
For a date range, use a lower and upper bound. An example search string is createdat:>=2026-01-01T00:00:00Z createdat:<2026-02-01T00:00:00Z. To focus on a customer, use a supported customer filter such as customerid:123456789, substituting the customer’s actual ID. Check Shopify’s orders query documentation for supported filters and syntax.
Once the search is focused, pagination lets you process matching orders without asking for the entire result set at once. The response’s page information tells you whether another batch is available.
Retrieve additional pages with cursor-based pagination
Set first to the batch size, then pass the previous response’s endCursor into after for the next request. Continue while hasNextPage is true; stop when it becomes false. Keep each page’s results before requesting the next one.
For a predictable sequence, specify a sort key such as CREATEDAT and choose the sort direction with reverse. Your loop can follow this pattern:
- Start with
after: null. - Store the returned orders and
endCursor. - Request the next page using that cursor.
Batching is useful, but larger requests are not always better. Keeping each response lean helps control query cost and makes failures easier to recover from.
Manage query limits and large result sets
Shopify GraphQL connections allow up to 250 objects per page. Start with a smaller batch, such as 50, and increase it only if the response size and processing time remain manageable. Also remember that nested connections, such as lineItems, have their own pagination and limits.
Request only fields your workflow uses, and monitor the GraphQL response’s cost and throttle information. For long-running exports, save progress after each page so a temporary error does not require starting over. Splitting a large date range into smaller intervals can also make retries and reconciliation simpler.
Handle and troubleshoot retrieved order data
A request can complete without giving your integration everything it needs. Knowing how to interpret the response—and spot partial results—helps you turn retrieved data into a reliable workflow.
Start by tracing the response structure from the connection down to each order. This makes it easier to map results into your app and preserve the cursor needed for the next page.
Read edges, nodes, and order fields in the response
In the query above, each item in data.orders.edges is an edge: a wrapper containing a cursor and a node. The node holds the order fields you requested, such as its ID, name, timestamps, and statuses. For example, your code might read an order name from edge.node.name and save edge.cursor for pagination.
Nested connections follow the same pattern. In this query, line items are returned under node.lineItems.nodes, while pagination details for orders are under data.orders.pageInfo. Check whether a value is absent, null, or an empty list before using it; these cases can mean different things. The Shopify orders query reference documents the available fields and connection structure.
Once your code can read the expected shape, account for responses that are incomplete or blocked. GraphQL can return both data and errors, so a successful HTTP response alone does not confirm that every requested field was available.
Handle errors, missing fields, and access restrictions
Inspect both data and errors in each response. If errors are present, log their messages and any available path information; a path can help identify which field caused the issue. Avoid discarding usable data automatically, since some GraphQL responses contain partial results alongside errors.
A missing value may reflect the order itself, a field that was not selected, or an access restriction. Confirm the app’s scopes and Shopify’s protected customer data requirements before treating unavailable customer details as a query bug. For troubleshooting, compare the response with the fields in your query and consult Shopify’s access scopes documentation.
With response handling in place, test the complete flow rather than only a single request. A few deliberate test cases can reveal pagination and recovery issues before they affect a live integration.
Test and refine your Shopify GraphQL retrieve orders workflow
Use a development store or a controlled date range to test representative cases: no matching orders, several pages of results, and orders with different fulfillment or financial statuses. Verify that cursors advance, records are not duplicated, and your app handles empty or nullable fields safely.
Then refine the workflow by checking that it:
- Requests only needed fields and records errors without exposing tokens or sensitive data in logs.
- Saves progress after each page so a retry can resume without restarting the full retrieval.
- Uses a supported API version and is retested when that version changes.
Build a reliable Shopify order retrieval workflow
Shopify GraphQL gives you a flexible way to retrieve the order data your app needs—provided you plan for permissions, focused queries, and results that may span multiple pages. Filtering orders and requesting only relevant fields helps keep retrieval efficient, while careful response and error handling makes the data more dependable.
Test the full workflow with realistic scenarios, and refine it as your store’s needs evolve. With those foundations in place, you can retrieve Shopify orders confidently and build integrations that are easier to maintain and scale.