> Agent-readable docs index: /llms.txt. Download /docs.zip to grep all markdown files locally.

---
title: "ordersByQuery"
description: "Returns a paginated list of `Order` objects matching the provided filter criteria."
---

Returned orders are sorted by createdAt in descending order; the latest appears at index 0.
The maximum page size is `100`.
Only supports API key authentication.

***

### Arguments

<ParamField path="filter" type={<a href="/api-reference/ordersFilterInput">OrdersFilterInput</a>}>
  Filter parameters to narrow down the search results based on order creation datetime.
</ParamField>

<ParamField path="pagination" type={<a href="/api-reference/cursorPaginationInput">CursorPaginationInput</a>}>
  Pagination parameters to control the fetching of data, such as specifying the number of items before or after a cursor.
</ParamField>

### Returns

<ParamField path="OrdersConnection" type={<a href="/api-reference/ordersConnection">OrdersConnection</a>}>
  Returns an `OrdersConnection` object, which includes a list of orders matching the specified criteria along with pagination information.
</ParamField>

***

### Example - request

```json
{
  "filter": {
    "createdBefore" : "2025-06-20T21:24:00.000Z",
    "createdAfter" : "2025-05-10T21:24:00.000Z"
  },
  "pagination": {
    "first": 2
  }
}
```

### Example - query

```GraphQL GraphQL
query OrdersByQuery($pagination: CursorPaginationInput!, $filter: OrdersFilterInput!) {
  ordersByQuery(pagination: $pagination, filter: $filter) {
    edges {
        cursor
        node {
            id
            createdAt
            status
        }
    },
    pageInfo {
        hasNextPage
        hasPreviousPage
        startCursor
        endCursor
    }
  }
}
```

### Example - response

```json
{
    "data": {
        "ordersByQuery": {
            "edges": [
                {
                    "cursor": "75417c9f-b679-4579-b4d2-f83ad7ea3c27",
                    "node": {
                        "id": "75417c9f-b679-4579-b4d2-f83ad7ea3c27",
                        "createdAt": "2025-06-06T17:08:49.906Z",
                        "status": "CANCELLED"
                    }
                },
                {
                    "cursor": "c5afed4b-d9c8-48e6-8e98-0de065ae6f9e",
                    "node": {
                        "id": "c5afed4b-d9c8-48e6-8e98-0de065ae6f9e",
                        "createdAt": "2025-06-05T19:36:04.033Z",
                        "status": "SUCCEEDED"
                    }
                }
            ],
            "pageInfo": {
                "hasNextPage": true,
                "hasPreviousPage": false,
                "startCursor": "75417c9f-b679-4579-b4d2-f83ad7ea3c27",
                "endCursor": "c5afed4b-d9c8-48e6-8e98-0de065ae6f9e"
            }
        }
    },
    "extensions": {
        "cost": {
            "queryCost": 12,
            "queryCostLimit": 750
        }
    }
}
```

***

### Related queries

* [`orderByID`](/api-reference/orderbyid)


---

*Powered by [holocron.so](https://holocron.so)*
