为开发者设计的运输商 API

1. 运输商完整列表

GET 请求可以检索由中国包裹追踪 API 支持的所有运输商的完整列表

请求示例


curl -X GET "https://developers.chinaparcels.com/api/v1/user/{USER_API_SECRET_ACCESS_KEY}/carriers"

注意:{USER_API_SECRET_ACCESS_KEY} 替换为您在控制面板中获取的唯一 API 密钥。

响应参数描述

以下是响应参数的详细说明:

  • error:指示请求结果的错误代码(参阅错误代码列表)。
  • result:包含运输商信息的对象数组。
    • carrier_id:运输商的唯一标识符。
    • carrier_name:运输商的名称(例如:"中国邮政","USPS")。
    • carrier_type:运输商类型(例如:"邮政","快递")。
    • carrier_support:是否支持追踪:
      • 1:支持。
      • 0:不支持。
    • carrier_country_code:运输商的国家代码,采用 ISO 3166-1 alpha-2 格式(例如:"cn" 表示中国,"us" 表示美国)。

响应示例(部分)


{
  "error": -1,
  "result": [
    {
      "carrier_id": "1",
      "carrier_name": "中国邮政",
      "carrier_type": "邮政",
      "carrier_support": "1",
      "carrier_country_code": "cn"
    },
    {
      "carrier_id": "2",
      "carrier_name": "USPS",
      "carrier_type": "邮政",
      "carrier_support": "1",
      "carrier_country_code": "us"
    },
    {
      "carrier_id": "3",
      "carrier_name": "Canada Post",
      "carrier_type": "邮政",
      "carrier_support": "1",
      "carrier_country_code": "ca"
    },
    {
      "carrier_id": "4",
      "carrier_name": "Royal Mail",
      "carrier_type": "邮政",
      "carrier_support": "1",
      "carrier_country_code": "gb"
    }
  ]
}

错误代码

  • -1 - 请求成功;
  • 0 - 找不到用户;
  • 1 - 余额不足;

2. 获取运输商详细信息

通过 China Parcels 追踪 API,可以发送 GET 请求来获取 运输商的详细信息

请求示例


curl -X GET "https://developers.chinaparcels.com/api/v1/user/{USER_API_SECRET_ACCESS_KEY}/carriers/{CARRIER_ID}"

注意:

  • {USER_API_SECRET_ACCESS_KEY} 替换为您在控制面板中获取的唯一 API 密钥。
  • {CARRIER_ID} 替换为上一步获取的运输商唯一标识符。

响应参数描述

  • error:指示请求结果的错误代码(参阅错误代码列表)。
  • result:包含运输商详细信息的对象:
    • carrier_id:运输商的唯一标识符。
    • carrier_name:运输商的名称(例如:"USPS")。
    • carrier_type:运输商类型(例如:"邮政","快递")。
    • carrier_support:是否支持追踪:
      • 1:支持。
      • 0:不支持。
    • carrier_website:运输商的官方网站。
    • carrier_email:运输商的联系邮箱(如果可用)。
    • carrier_phone:运输商的联系电话(如果可用)。
    • carrier_country_code:运输商的国家代码,采用 ISO 3166-1 alpha-2 格式。
    • carrier_country_name:运输商所在国家的完整名称。
    • carrier_icon_background_hex:运输商图标的背景颜色(HEX 格式)。
    • carrier_language_code:运输商在追踪数据中使用的语言代码(例如:"en" 表示英文)。
    • carrier_icon:运输商图标的 URL。
    • carrier_icon_width:运输商图标的宽度(以像素为单位)。
    • carrier_icon_height:运输商图标的高度(以像素为单位)。
    • carrier_thumbnail:运输商缩略图的 URL。
    • carrier_thumbnail_width:缩略图的宽度(以像素为单位)。
    • carrier_thumbnail_height:缩略图的高度(以像素为单位)。

响应示例


{
  "error": -1,
  "result": {
    "carrier_id": "2",
    "carrier_name": "USPS",
    "carrier_type": "邮政",
    "carrier_support": "1",
    "carrier_website": "https://www.usps.com",
    "carrier_email": "support@usps.com",
    "carrier_phone": "1-800-222-1811",
    "carrier_country_code": "us",
    "carrier_country_name": "United States of America",
    "carrier_icon_background_hex": "#333366",
    "carrier_language_code": "en",
    "carrier_icon": "https://developers.chinaparcels.com/cdn/images/carriers/icons/0002-usps.png",
    "carrier_icon_width": 256,
    "carrier_icon_height": 256,
    "carrier_thumbnail": "http://developers.chinaparcels.com/cdn/images/carriers/thumbnails/0002-usps.png",
    "carrier_thumbnail_width": 640,
    "carrier_thumbnail_height": 256
  }
}

错误代码

  • -1 - 请求成功;
  • 0 - 找不到用户;
  • 1 - 余额不足;
  • 2 - 找不到运输商;