Back to Collection Items
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Http")
set http = CreateObject("Chilkat.Http")
http.SetRequestHeader "API-Key","{{API_KEY}}"
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.StringBuilder")
set sbResponseBody = CreateObject("Chilkat.StringBuilder")
success = http.QuickGetSb("https://api.shipengine.com/v1/labels/se-123456/track",sbResponseBody)
If (success = 0) Then
outFile.WriteLine(http.LastErrorText)
WScript.Quit
End If
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set jResp = CreateObject("Chilkat.JsonObject")
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = 0
outFile.WriteLine("Response Body:")
outFile.WriteLine(jResp.Emit())
respStatusCode = http.LastStatus
outFile.WriteLine("Response Status Code = " & respStatusCode)
If (respStatusCode >= 400) Then
outFile.WriteLine("Response Header:")
outFile.WriteLine(http.LastHeader)
outFile.WriteLine("Failed.")
WScript.Quit
End If
' Sample JSON response:
' (Sample code for parsing the JSON response is shown below)
' {
' "tracking_number": "9405511899564298877610",
' "status_code": "NY",
' "status_description": "Not Yet In System",
' "carrier_status_code": "-2147219283",
' "carrier_status_description": "A status update is not yet available for this tracking number. More information will become available when USPS receives the tracking information, or when the package is received by USPS.",
' "ship_date": null,
' "estimated_delivery_date": null,
' "actual_delivery_date": null,
' "exception_description": null,
' "events": null
' }
' Sample code for parsing the JSON response...
' Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
tracking_number = jResp.StringOf("tracking_number")
status_code = jResp.StringOf("status_code")
status_description = jResp.StringOf("status_description")
carrier_status_code = jResp.StringOf("carrier_status_code")
carrier_status_description = jResp.StringOf("carrier_status_description")
ship_date = jResp.StringOf("ship_date")
estimated_delivery_date = jResp.StringOf("estimated_delivery_date")
actual_delivery_date = jResp.StringOf("actual_delivery_date")
exception_description = jResp.StringOf("exception_description")
events = jResp.StringOf("events")
outFile.Close
Curl Command
curl -X GET
-H "API-Key: {{API_KEY}}"
https://api.shipengine.com/v1/labels/se-123456/track
Postman Collection Item JSON
{
"name": "Track using a label ID",
"event": [
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "https://api.shipengine.com/v1/labels/{{label_id}}/track",
"protocol": "https",
"host": [
"api",
"shipengine",
"com"
],
"path": [
"v1",
"labels",
"{{label_id}}",
"track"
]
},
"description": "If you created the shipping label using ShipEngine, then tracking a package is even easier. No need to specify the `carrier_code` and `tracking_number`. All you need is the `label_id`."
},
"response": [
{
"name": "Track using a label ID",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "https://api.shipengine.com/v1/labels/{{label_id}}/track",
"protocol": "https",
"host": [
"api",
"shipengine",
"com"
],
"path": [
"v1",
"labels",
"{{label_id}}",
"track"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Wed, 18 Sep 2019 18:53:59 GMT"
},
{
"key": "Content-Type",
"value": "application/json; charset=utf-8"
},
{
"key": "Content-Length",
"value": "531"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Access-Control-Allow-Origin",
"value": "https://www.shipengine.com"
},
{
"key": "Vary",
"value": "Origin"
},
{
"key": "x-shipengine-requestid",
"value": "853bc684-6123-43aa-91ab-5ce1a8da908b"
}
],
"cookie": [
],
"body": "{\n \"tracking_number\": \"9405511899564298877610\",\n \"status_code\": \"NY\",\n \"status_description\": \"Not Yet In System\",\n \"carrier_status_code\": \"-2147219283\",\n \"carrier_status_description\": \"A status update is not yet available for this tracking number. More information will become available when USPS receives the tracking information, or when the package is received by USPS.\",\n \"ship_date\": null,\n \"estimated_delivery_date\": null,\n \"actual_delivery_date\": null,\n \"exception_description\": null,\n \"events\": null\n}"
}
]
}