DOCS

Searching and filtering orders

/

Searching and filtering orders

Retrieve lists of orders with GraphQL.

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

Get your API key

Get a Zonos account: In order to use the Zonos API you will need an API key. To get your key you will need to complete our sign-up form. Onboarding will begin once you have an account agreement in place. During onboarding, a representative will help you set up your account correctly so that you get the most accurate API responses.

Access your API key here if you have a Zonos account. This will allow you to authenticate with the Zonos API. If you don't have an account see the note above.

2

Decide what details 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 the pages 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 your request

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
13
14
15
16
{
  "data": [
    {
      "order": {
        "id": "1000753",
        "items": [
          {
            "description": "Blue Snorkle Set",
            "hsCode": "9506290000",
            "quantity": 2
          }
        ]
      }
    }
  ]
}

Was this page helpful?