Zonos logo
DOCS

Searching and filtering orders

/

Searching and filtering orders 

Using the orders query in GraphQL, you can retrieve paginated lists of orders with various criteria. This is useful when you need a list of orders by country, between specific dates, to build a search, etc.

1

Set up Zonos

First, register for a Zonos account and configure your account on Zonos Dashboard. You will then be able to get your API key, which will allow you to authenticate with the Zonos API.

2

Decide on what details you want to retrieve

You can query lists of orders based on similar accountOrderIds or by providing a date range between which orders were published. For a complete list of available fields, consult the GraphQL API reference.

On each individual order you query, all normal Order fields are available, e.g., the country, shipping information, landed cost totals, etc. All possible fields are listed in the GraphQL API reference.

Query

1
2
3
4
5
6
7
8
9
10
query orders($ordersFilter: OrdersFilter, $first: Int) {
 orders(filter: $ordersFilter, first: $first) {
  edges {
   node {
    id
    # ... field names here
   }
  }
 }
}

Variables

1
2
3
4
5
6
7
8
{
 "ordersFilter": {
  "between": {
   "before": "2022-10-01",
   "after": "2022-09-01"
  }
 }
}
3

Send what pages you want to fetch

All queries that retrieve lists support Relay-style pagination. The first variable allows you to specify how many objects are returned.

Query

1
2
3
4
5
query orders($filter: OrderFilter!, $first: Int) {
 orders(orderFilter: $filter, first: $first) {
  # ... field names here
 }
}

Variables

1
2
3
{
 "first": 20
}
4

Send a request to the Zonos API

Now that you have built your request and configured it, you can send a POST request to the Zonos API. Make sure to authenticate with your API key and provide the correct version header in your request.

POST https://api.zonos.com/graphql/

Query

1
2
3
4
5
6
7
8
9
10
11
12
13
14
query orders($ordersFilter: OrdersFilter, $first: Int) {
 orders(filter: $ordersFilter, first: $first) {
  edges {
   node {
    id
    items {
     description
     hsCode
     quantity
    }
   }
  }
 }
}

Variables

1
2
3
4
5
6
7
8
9
{
 "ordersFilter": {
  "between": {
   "before": "2022-10-01",
   "after": "2022-09-01"
  }
 },
 "first": 20
}

Response

1
2
3
4
5
6
7
8
9
10
11
12
{
 "data": [{
  "order": {
         "id": "1000753",
            "items": [
          "description": "Blue Snorkle Set",
             "hsCode": "9506290000",
          "quantity": 2
      ]
  }
 }]
}