Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Occurred_at
string ls_Description
string ls_City_locality
string ls_State_province
string ls_Postal_code
string ls_Country_code
string ls_Company_name
string ls_Signer
string ls_Event_code
string ls_Tracking_number
string ls_Status_code
string ls_Status_description
string ls_Carrier_status_code
string ls_Carrier_status_description
string ls_Ship_date
string ls_Estimated_delivery_date
string ls_Actual_delivery_date
string ls_Exception_description
integer i
integer li_Count_i
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_QueryParams = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat.JsonObject")
loo_QueryParams.UpdateString("carrier_code","fedex")
loo_QueryParams.UpdateString("tracking_number","555671072708")
loo_Http.SetRequestHeader("API-Key","{{API_KEY}}")
loo_Resp = loo_Http.QuickRequestParams("GET","https://api.shipengine.com/v1/tracking",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_QueryParams
return
end if
loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")
loo_Resp.GetBodySb(loo_SbResponseBody)
loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")
loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0
Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()
li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
Write-Debug "Response Header:"
Write-Debug loo_Resp.Header
Write-Debug "Failed."
destroy loo_Resp
destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp
return
end if
destroy loo_Resp
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "tracking_number": "789830651142",
// "status_code": "DE",
// "status_description": "Delivered",
// "carrier_status_code": "DL",
// "carrier_status_description": "Delivered",
// "ship_date": "2019-09-16T21:55:00Z",
// "estimated_delivery_date": null,
// "actual_delivery_date": "2019-09-17T20:02:00Z",
// "exception_description": null,
// "events": [
// {
// "occurred_at": "2019-09-17T20:02:00Z",
// "description": "Delivered",
// "city_locality": "Austin",
// "state_province": "TX",
// "postal_code": "78702",
// "country_code": "US",
// "company_name": null,
// "signer": "Signature not required",
// "event_code": "DL"
// },
// {
// "occurred_at": "2019-09-17T13:13:00Z",
// "description": "On FedEx vehicle for delivery",
// "city_locality": "AUSTIN",
// "state_province": "TX",
// "postal_code": "78721",
// "country_code": "US",
// "company_name": null,
// "signer": null,
// "event_code": "OD"
// },
// {
// "occurred_at": "2019-09-17T12:09:00Z",
// "description": "At local FedEx facility",
// "city_locality": "AUSTIN",
// "state_province": "TX",
// "postal_code": "78721",
// "country_code": "US",
// "company_name": null,
// "signer": null,
// "event_code": "AR"
// },
// {
// "occurred_at": "2019-09-17T08:05:00Z",
// "description": "Departed FedEx location",
// "city_locality": "FORT WORTH",
// "state_province": "TX",
// "postal_code": "76177",
// "country_code": "US",
// "company_name": null,
// "signer": null,
// "event_code": "DP"
// },
// {
// "occurred_at": "2019-09-17T06:22:00Z",
// "description": "Arrived at FedEx location",
// "city_locality": "FORT WORTH",
// "state_province": "TX",
// "postal_code": "76177",
// "country_code": "US",
// "company_name": null,
// "signer": null,
// "event_code": "AR"
// },
// {
// "occurred_at": "2019-09-17T03:27:00Z",
// "description": "Departed FedEx location",
// "city_locality": "OAKLAND",
// "state_province": "CA",
// "postal_code": "94621",
// "country_code": "US",
// "company_name": null,
// "signer": null,
// "event_code": "DP"
// },
// {
// "occurred_at": "2019-09-17T01:04:00Z",
// "description": "Arrived at FedEx location",
// "city_locality": "OAKLAND",
// "state_province": "CA",
// "postal_code": "94621",
// "country_code": "US",
// "company_name": null,
// "signer": null,
// "event_code": "AR"
// },
// {
// "occurred_at": "2019-09-17T00:10:00Z",
// "description": "Left FedEx origin facility",
// "city_locality": "PETALUMA",
// "state_province": "CA",
// "postal_code": "94954",
// "country_code": "US",
// "company_name": null,
// "signer": null,
// "event_code": "DP"
// },
// {
// "occurred_at": "2019-09-16T21:55:00Z",
// "description": "Picked up",
// "city_locality": "PETALUMA",
// "state_province": "CA",
// "postal_code": "94954",
// "country_code": "US",
// "company_name": null,
// "signer": null,
// "event_code": "PU"
// },
// {
// "occurred_at": "2019-09-16T15:31:38Z",
// "description": "Shipment information sent to FedEx",
// "city_locality": null,
// "state_province": null,
// "postal_code": null,
// "country_code": null,
// "company_name": null,
// "signer": null,
// "event_code": "OC"
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
ls_Tracking_number = loo_JResp.StringOf("tracking_number")
ls_Status_code = loo_JResp.StringOf("status_code")
ls_Status_description = loo_JResp.StringOf("status_description")
ls_Carrier_status_code = loo_JResp.StringOf("carrier_status_code")
ls_Carrier_status_description = loo_JResp.StringOf("carrier_status_description")
ls_Ship_date = loo_JResp.StringOf("ship_date")
ls_Estimated_delivery_date = loo_JResp.StringOf("estimated_delivery_date")
ls_Actual_delivery_date = loo_JResp.StringOf("actual_delivery_date")
ls_Exception_description = loo_JResp.StringOf("exception_description")
i = 0
li_Count_i = loo_JResp.SizeOfArray("events")
do while i < li_Count_i
loo_JResp.I = i
ls_Occurred_at = loo_JResp.StringOf("events[i].occurred_at")
ls_Description = loo_JResp.StringOf("events[i].description")
ls_City_locality = loo_JResp.StringOf("events[i].city_locality")
ls_State_province = loo_JResp.StringOf("events[i].state_province")
ls_Postal_code = loo_JResp.StringOf("events[i].postal_code")
ls_Country_code = loo_JResp.StringOf("events[i].country_code")
ls_Company_name = loo_JResp.StringOf("events[i].company_name")
ls_Signer = loo_JResp.StringOf("events[i].signer")
ls_Event_code = loo_JResp.StringOf("events[i].event_code")
i = i + 1
loop
destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp
Curl Command
curl -G -d "carrier_code=fedex"
-d "tracking_number=555671072708"
-H "API-Key: {{API_KEY}}"
https://api.shipengine.com/v1/tracking
Postman Collection Item JSON
{
"name": "Track a package",
"event": [
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "https://api.shipengine.com/v1/tracking?carrier_code=fedex&tracking_number=555671072708",
"protocol": "https",
"host": [
"api",
"shipengine",
"com"
],
"path": [
"v1",
"tracking"
],
"query": [
{
"key": "carrier_code",
"value": "stamps_com",
"disabled": true
},
{
"key": "tracking_number",
"value": "{{tracking_number}}",
"disabled": true
},
{
"key": "carrier_code",
"value": "fedex"
},
{
"key": "tracking_number",
"value": "555671072708"
}
]
},
"description": "This request demonstrates how to get tracking information for a package. The `carrier_code` and `tracking_number` are provided via query parameters."
},
"response": [
{
"name": "Track a package",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "https://api.shipengine.com/v1/tracking?carrier_code=fedex&tracking_number=789830651142",
"protocol": "https",
"host": [
"api",
"shipengine",
"com"
],
"path": [
"v1",
"tracking"
],
"query": [
{
"key": "carrier_code",
"value": "fedex"
},
{
"key": "tracking_number",
"value": "789830651142"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Wed, 18 Sep 2019 18:50:08 GMT"
},
{
"key": "Content-Type",
"value": "application/json; charset=utf-8"
},
{
"key": "Content-Length",
"value": "3515"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Access-Control-Allow-Origin",
"value": "https://www.shipengine.com"
},
{
"key": "Vary",
"value": "Origin"
},
{
"key": "x-shipengine-requestid",
"value": "f4e88104-edb8-4a8f-bd1c-a5d85334bdb1"
}
],
"cookie": [
],
"body": "{\n \"tracking_number\": \"789830651142\",\n \"status_code\": \"DE\",\n \"status_description\": \"Delivered\",\n \"carrier_status_code\": \"DL\",\n \"carrier_status_description\": \"Delivered\",\n \"ship_date\": \"2019-09-16T21:55:00Z\",\n \"estimated_delivery_date\": null,\n \"actual_delivery_date\": \"2019-09-17T20:02:00Z\",\n \"exception_description\": null,\n \"events\": [\n {\n \"occurred_at\": \"2019-09-17T20:02:00Z\",\n \"description\": \"Delivered\",\n \"city_locality\": \"Austin\",\n \"state_province\": \"TX\",\n \"postal_code\": \"78702\",\n \"country_code\": \"US\",\n \"company_name\": null,\n \"signer\": \"Signature not required\",\n \"event_code\": \"DL\"\n },\n {\n \"occurred_at\": \"2019-09-17T13:13:00Z\",\n \"description\": \"On FedEx vehicle for delivery\",\n \"city_locality\": \"AUSTIN\",\n \"state_province\": \"TX\",\n \"postal_code\": \"78721\",\n \"country_code\": \"US\",\n \"company_name\": null,\n \"signer\": null,\n \"event_code\": \"OD\"\n },\n {\n \"occurred_at\": \"2019-09-17T12:09:00Z\",\n \"description\": \"At local FedEx facility\",\n \"city_locality\": \"AUSTIN\",\n \"state_province\": \"TX\",\n \"postal_code\": \"78721\",\n \"country_code\": \"US\",\n \"company_name\": null,\n \"signer\": null,\n \"event_code\": \"AR\"\n },\n {\n \"occurred_at\": \"2019-09-17T08:05:00Z\",\n \"description\": \"Departed FedEx location\",\n \"city_locality\": \"FORT WORTH\",\n \"state_province\": \"TX\",\n \"postal_code\": \"76177\",\n \"country_code\": \"US\",\n \"company_name\": null,\n \"signer\": null,\n \"event_code\": \"DP\"\n },\n {\n \"occurred_at\": \"2019-09-17T06:22:00Z\",\n \"description\": \"Arrived at FedEx location\",\n \"city_locality\": \"FORT WORTH\",\n \"state_province\": \"TX\",\n \"postal_code\": \"76177\",\n \"country_code\": \"US\",\n \"company_name\": null,\n \"signer\": null,\n \"event_code\": \"AR\"\n },\n {\n \"occurred_at\": \"2019-09-17T03:27:00Z\",\n \"description\": \"Departed FedEx location\",\n \"city_locality\": \"OAKLAND\",\n \"state_province\": \"CA\",\n \"postal_code\": \"94621\",\n \"country_code\": \"US\",\n \"company_name\": null,\n \"signer\": null,\n \"event_code\": \"DP\"\n },\n {\n \"occurred_at\": \"2019-09-17T01:04:00Z\",\n \"description\": \"Arrived at FedEx location\",\n \"city_locality\": \"OAKLAND\",\n \"state_province\": \"CA\",\n \"postal_code\": \"94621\",\n \"country_code\": \"US\",\n \"company_name\": null,\n \"signer\": null,\n \"event_code\": \"AR\"\n },\n {\n \"occurred_at\": \"2019-09-17T00:10:00Z\",\n \"description\": \"Left FedEx origin facility\",\n \"city_locality\": \"PETALUMA\",\n \"state_province\": \"CA\",\n \"postal_code\": \"94954\",\n \"country_code\": \"US\",\n \"company_name\": null,\n \"signer\": null,\n \"event_code\": \"DP\"\n },\n {\n \"occurred_at\": \"2019-09-16T21:55:00Z\",\n \"description\": \"Picked up\",\n \"city_locality\": \"PETALUMA\",\n \"state_province\": \"CA\",\n \"postal_code\": \"94954\",\n \"country_code\": \"US\",\n \"company_name\": null,\n \"signer\": null,\n \"event_code\": \"PU\"\n },\n {\n \"occurred_at\": \"2019-09-16T15:31:38Z\",\n \"description\": \"Shipment information sent to FedEx\",\n \"city_locality\": null,\n \"state_province\": null,\n \"postal_code\": null,\n \"country_code\": null,\n \"company_name\": null,\n \"signer\": null,\n \"event_code\": \"OC\"\n }\n ]\n}"
}
]
}