# logistics.getPath

Call this API at the server side. For more information, see Server API.

This API supports Cloud Calls. The WeChat DevTools version must be 1.02.1904090 or later (download the latest stable version here), and the wx-server-sdk version must be 0.4.0 or later.

Queries the trace of the waybill.

Calling methods:

# HTTPS Call

# Request Address

POST https://api.weixin.qq.com/cgi-bin/express/business/path/get?access_token=ACCESS_TOKEN

# Request Parameters

Attribute Type Default Required Description
access_token string Yes Credentials to call API
order_id string Yes The ID of the order. It must be globally unique.
openid string Yes The OpenID of the user.
delivery_id string Yes The ID of the express company. See getAllDelivery.
waybill_id string Yes The ID of the waybill.

# Return Value

# Object

Property Type Description
openid string The openid of the user
delivery_id string The ID of the express company
waybill_id string The ID of the waybill
path_item_num number The quantity of trace nodes
path_item_list Array.<Object> The list of trace nodes

path_item_list is composed as follows

Property Type Description
action_time number Unix timestamp of the trace node
action_type number The type of the trace node
action_msg string Details about the trace node

Valid values of action_type

Value Description Minimum Version
100001 Pick-up — Picked up successfully
100002 Pick-up — Pick-up failed
100003 Pick-up — Assigning the courier
200001 Transportation — Updating the transportation trace
300002 Delivery — Starting the delivery
300003 Delivery — Signed successfully
300004 Delivery — Signing failed
400001 Exception — Order canceled
400002 Exception — Order delayed

# Request Data Example

{
  "order_id": "01234567890123456789",
  "openid": "oABC123456",
  "delivery_id": "SF",
  "waybill_id": "123456789"
}

# Return Data Example

{
  "openid": "OPENID",
  "delivery_id": "SF",
  "waybill_id": "12345678901234567890",
  "path_item_num": 3,
  "path_item_list": [
    {
      "action_time": 1533052800,
      "action_type": 100001,
      "action_msg": "The parcel has been picked up."
    },
    {
      "action_time": 1533062800,
      "action_type": 200001,
      "action_msg": "The parcel has arrived at the xxx distribution center, and is to be delivered to xxx"
    },
    {
      "action_time": 1533072800,
      "action_type": 300001,
      "action_msg": "The parcel is arriving soon. Contact number: xxxxxx"
    }
  ]
}

# Cloud Call

Cloud call is a capability provided by Mini Program·Cloud Base that allows you to call WeChat APIs in a cloud function. It must be used via wx-server-sdk in the cloud function.

# API Calling Method

openapi.logistics.getPath

You need to configure the permissions for the logistics.getPath API via config.json. Details

# Request Parameters

Attribute Type Default Required Description
orderId string Yes The ID of the order. It must be globally unique.
openid string Yes The OpenID of the user.
deliveryId string Yes The ID of the express company. See getAllDelivery.
waybillId string Yes The ID of the waybill.

# Return Value

# Object

Property Type Description
openid string The openid of the user
deliveryId string The ID of the express company
waybillId string The ID of the waybill
pathItemNum number The quantity of trace nodes
pathItemList Array.<Object> The list of trace nodes

pathItemList is composed as follows

Property Type Description
actionTime number Unix timestamp of the trace node
actionType number The type of the trace node
actionMsg string Details about the trace node

Valid values of actionType

Value Description Minimum Version
100001 Pick-up — Picked up successfully
100002 Pick-up — Pick-up failed
100003 Pick-up — Assigning the courier
200001 Transportation — Updating the transportation trace
300002 Delivery — Starting the delivery
300003 Delivery — Signed successfully
300004 Delivery — Signing failed
400001 Exception — Order canceled
400002 Exception — Order delayed

# Request Data Example

const cloud = require('wx-server-sdk')
  cloud.init()
  exports.main = async (event, context) => {
    try {
      const result = await cloud.openapi.logistics.getPath({
        openid: 'oABC123456',
        orderId: '01234567890123456789',
        deliveryId: 'SF',
        waybillId: '123456789'
      })
      console.log(result)
      return result
    } catch (err) {
      console.log(err)
      return err
    }
  }

# Return Data Example

{
  "openid": "OPENID",
  "deliveryId": "SF",
  "waybillId": "12345678901234567890",
  "pathItemNum": 3,
  "pathItemList": [
    {
      "actionTime": 1533052800,
      "actionType": 100001,
      "actionMsg": "The parcel has been picked up."
    },
    {
      "actionTime": 1533062800,
      "actionType": 200001,
      "actionMsg": "The parcel has arrived at the xxx distribution center, and is to be delivered to xxx"
    },
    {
      "actionTime": 1533072800,
      "actionType": 300001,
      "actionMsg": "The parcel is arriving soon. Contact number: xxxxxx"
    }
  ],
  "errMsg": "openapi.logistics.getPath:ok"
}