Lấy khóa API của bạn
Đầu tiên, hãy đăng ký một tài khoản Zonos và cấu hình tài khoản của bạn trong Zonos Dashboard. Sau đó, bạn sẽ có thể lấy khóa API của mình, điều này sẽ cho phép bạn xác thực với API Zonos.
Quyết định thông tin nào cần lấy
Vì cách hoạt động của GraphQL, bạn có thể yêu cầu chỉ các trường mà bạn quan tâm từ API, hoặc bạn có thể chọn yêu cầu tất cả thông tin mà hệ thống có liên quan đến một đơn hàng - sự lựa chọn là của bạn. Tham khảo tài liệu tham khảo API GraphQL để biết các trường có sẵn.
Thông tin liên quan đến đơn hàng như chi tiết báo giá landed cost, chi tiết đánh giá vận chuyển, chi tiết giỏ hàng, v.v. có thể được truy vấn thông qua đồ thị bằng cách thêm các trường từ những đối tượng đó vào truy vấn order của bạn.
Tối thiểu, bạn cần một số đơn hàng để có thể truy vấn API. Điều này được truyền vào trường orderId với các biến trong yêu cầu GraphQL của bạn.
Truy vấn
query order($orderId: String!) {
  order(orderId: $orderId) {
    # ... other field names here
  }
}
Biến số
{
  "orderId": "order_88891908-5fd2-42fb-833f-b0afb11ea646"
}
Gửi yêu cầu của bạn
Bây giờ bạn đã xây dựng yêu cầu của mình và cấu hình nó, bạn có thể gửi một yêu cầu POST đến API Zonos. Hãy chắc chắn xác thực bằng khóa API của bạn và cung cấp tiêu đề phiên bản chính xác trong yêu cầu của bạn.
POST https://api.zonos.com/graphql/
Truy vấn
query order($orderId: String!) {
  order(orderId: $orderId) {
    accountOrderNumber
    amountSubtotals {
      duties
      taxes
      fees
      shipping
      items
    }
    landedCosts {
      id
      rootId
      tariffRate
      duties {
        amount
        currency
        formula
        item {
          id
          description
        }
        exchangeRate {
          rate
          sourceCurrencyCode
          targetCurrencyCode
        }
      }
      fees {
        amount
        currency
        description
        note
        formula
        type
        item {
          id
          description
        }
        exchangeRate {
          rate
        }
      }
      taxes {
        amount
        currency
        formula
        item {
          id
          description
        }
        exchangeRate {
          rate
        }
      }
      deMinimis {
        formula
        method
        note
        threshold
        type
      }
      shipmentRating {
        id
        amount
        currencyCode
        displayName
        minTransitAt
        maxTransitAt
        details {
          amount
          carrierCode
          type
        }
        amountSubtotals {
          shipping
          fuelSurcharge
          insuranceCost
          otherSurcharge
        }
        shipmentRatingCartons {
          chargeableWeight
          carton {
            length
            width
            height
            weight
          }
        }
        shippingProfile {
          id
          customServiceLevelCode
          landedCostMethod
          serviceLevel {
            code
          }
        }
      }
    }
  }
}
Biến số
{
  "orderId": "order_88891908-5fd2-42fb-833f-b0afb11ea646"
}
Phản hồi
{
  "data": {
    "order": {
      "accountOrderNumber": "10014067",
      "amountSubtotals": {
        "duties": 0,
        "taxes": 11.86,
        "fees": 7.49,
        "shipping": 37.79,
        "items": 229.99
      },
      "landedCosts": [
        {
          "id": "landed_cost_5d9ff0c2-059d-42c9-a1bc-3c9bbfaaca5b",
          "rootId": "root_df4d61f9-21cc-4b73-a466-a9794cc14963",
          "tariffRate": "ZONOS_PREFERRED",
          "duties": [
            {
              "amount": 0,
              "currency": "USD",
              "formula": "0 %",
              "item": {
                "id": "item_abfa8dc2-1ae2-4b23-82e3-0b100d0a73a9",
                "description": "Volvo & Mack Feeler Gauge & Jake Brake Tools 88880053 88880052 85111377"
              },
              "exchangeRate": null
            }
          ],
          "fees": [
            {
              "amount": 7.29,
              "currency": "USD",
              "description": "FedEx Canada Advancement Fee",
              "note": null,
              "formula": "2.500% of duties & taxes amount with a minimum of 10 cad, whichever is greater",
              "type": "advancement",
              "item": null,
              "exchangeRate": null
            },
            {
              "amount": 0.2,
              "currency": "USD",
              "description": "FedEx Currency Conversion Fee",
              "note": null,
              "formula": "1.75% of the amount converted",
              "type": "currency_conversion_fee",
              "item": null,
              "exchangeRate": null
            }
          ],
          "taxes": [
            {
              "amount": 11.4995,
              "currency": "USD",
              "formula": "5%",
              "item": {
                "id": "item_abfa8dc2-1ae2-4b23-82e3-0b100d0a73a9",
                "description": "Volvo & Mack Feeler Gauge & Jake Brake Tools 88880053 88880052 85111377"
              },
              "exchangeRate": null
            },
            {
              "amount": 0,
              "currency": "USD",
              "formula": "5%",
              "item": {
                "id": "item_abfa8dc2-1ae2-4b23-82e3-0b100d0a73a9",
                "description": "Volvo & Mack Feeler Gauge & Jake Brake Tools 88880053 88880052 85111377"
              },
              "exchangeRate": null
            },
            {
              "amount": 0.36,
              "currency": "USD",
              "formula": "5%",
              "item": null,
              "exchangeRate": null
            }
          ],
          "deMinimis": [
            {
              "formula": "(cost {'<='} 150 cad and hs_code not_starts_with \"2203,2204,2205,2206,2208,24\")",
              "method": "FOB",
              "note": "Items value less than 150 CAD and not containing alcohol, tobacco, or other excluded items",
              "threshold": "ABOVE",
              "type": "DUTY"
            },
            {
              "formula": "(cost {'<='} 40 cad and hs_code not_starts_with \"2203,2204,2205,2206,2208,24\")",
              "method": "FOB",
              "note": "Items value less than 40 CAD and not containing alcohol, tobacco, or other excluded items",
              "threshold": "ABOVE",
              "type": "TAX"
            }
          ],
          "shipmentRating": {
            "id": "shipment_rating_5551cd40-9477-47b4-9354-6be457f17b6d",
            "amount": 37.79,
            "currencyCode": "USD",
            "displayName": "FedEx International Priority",
            "minTransitAt": "2022-10-19T17:00:00Z",
            "maxTransitAt": null,
            "details": [
              {
                "amount": 120.56,
                "carrierCode": "retail_shipping",
                "type": "PUBLISHED_RATE"
              },
              {
                "amount": -96.2,
                "carrierCode": "discount",
                "type": "DISCOUNT"
              },
              {
                "amount": 1,
                "carrierCode": "carrier_fee",
                "type": "SURCHARGE"
              },
              {
                "amount": 5.3,
                "carrierCode": "carrier_fee",
                "type": "SURCHARGE"
              },
              {
                "amount": 7.13,
                "carrierCode": "fuel_surcharge",
                "type": "FUEL_SURCHARGE"
              }
            ],
            "amountSubtotals": {
              "shipping": 37.79,
              "fuelSurcharge": 7.13,
              "insuranceCost": null,
              "otherSurcharge": 6.3
            },
            "shipmentRatingCartons": [],
            "shippingProfile": {
              "id": "shipping_profile_28632acb-81d2-46ff-8c8e-699c9eafe288",
              "customServiceLevelCode": "INTERNATIONAL_PRIORITY",
              "landedCostMethod": "DDP_FORCED",
              "serviceLevel": {
                "code": "fedex.international_priority"
              }
            }
          }
        }
      ]
    }
  }
}
Lấy chi tiết đơn hàng
Lấy chi tiết đơn hàng của bạn với GraphQL.Để lấy chi tiết cho các đơn hàng quốc tế của bạn trong hệ thống Zonos, bạn có thể truy vấn API GraphQL. Điều này cho phép bạn lấy chi tiết đơn hàng và bất kỳ thông tin nào liên quan đến một đơn hàng, chẳng hạn như đánh giá vận chuyển, báo giá landed cost, v.v.