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.
Decide on what details you want to retrieve
You can query lists of orders based on similar accountOrderId
s 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
query orders($ordersFilter: OrdersFilter, $first: Int) {
orders(filter: $ordersFilter, first: $first) {
edges {
node {
id
# ... field names here
}
}
}
}
Variables
{
"ordersFilter": {
"between": {
"before": "2022-10-01",
"after": "2022-09-01"
}
}
}
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
query orders($filter: OrderFilter!, $first: Int) {
orders(orderFilter: $filter, first: $first) {
# ... field names here
}
}
Variables
{
"first": 20
}
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
query orders($ordersFilter: OrdersFilter, $first: Int) {
orders(filter: $ordersFilter, first: $first) {
edges {
node {
id
items {
description
hsCode
quantity
}
}
}
}
}
Variables
{
"ordersFilter": {
"between": {
"before": "2022-10-01",
"after": "2022-09-01"
}
},
"first": 20
}
Response
{
"data": [
{
"order": {
"id": "1000753",
"items": [
{
"description": "Blue Snorkle Set",
"hsCode": "9506290000",
"quantity": 2
}
]
}
}
]
}
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.