This is a NodeJS module to simplify the process of tracking consignments. Tracking numbers are magically resolved, and results will always be in a uniform format. Currently supports UPS, Yodel & Truline in the United Kingdom.
Install
npm i consignment-tracker
Example
const config = ups: // UPS config (required for UPS tracking only) user: "xxxx" // UPS username pass: "xxxx" // UPS password access: "xxxx" // UPS Access License Number truline: // Truline config (require for Truline tracking only) account: "00000" ;const track = config; let result = await ; let results = await ;
Usage
Track a single consignment
let result = await ;
Track a batch of consignments
let results = await ;
Track a single consignment and request full tracking history.
let result = await ;
Notes
- In the case of tracking a single reference,
track()
will throw an error if there is a failure performing the tracking. - If you provide an array to
track()
, it will not throw. Instead, each individual error in the batch will be returned in the results along with the corresponding tracking reference. - If performing many lookups, it is always preferable to track an array of references, rather than individually. The tracking has appropriate built-in rate limiting (independent for each courier), and can sometimes eliminate some requests altogether.
- The result from a batch-track will not be returned in the same order as requested.
Result schema
Status codes
D
: DeliveredI
: In TransitX
: Exception (failure in the delivery process, e.g. address not found)M
: Manifested (parcel not yet handed to the courier)
Result object
courier: type:"string" service: type:"string" tracking_ref: type:"string" consignment_ref: type:"string" parcel_ref: type:"string" po_number: type:"string" dest_postal_code: type:"string" dest_country_code: type:"string" status_code: type:"string" enum:"D" "I" "X" "M" description: type:"string" location: type:"string" pod_signatory: type:"string" pod_image_url: type:"string" date: type:"date" comments: type:"string" history: status_code: type:"string" enum:"D" "I" "X" "M" description: type:"string" location: type:"string" pod_signatory: type:"string" pod_image_url: type:"string" date: type:"date" comments: type:"string"