This lib identifies valid tracking numbers and can tell you a little bit about the shipment just from the number.
It detects tracking numbers from UPS, FedEx, DHL, USPS, OnTrac, Amazon Logistics, and 160+ countries national postal services (S10 standard).
Wraps JSON data from a shared repository. It is based off by jkeen's Ruby library.
const t = new TrackingNumber("MYSTERY_TRACKING_NUMBER");
console.log(t.valid); // false
const t = new TrackingNumber("1Z879E930346834440");
console.log(t.valid); // true
As of 1.0, the possible courier codes are usps, fedex, ups, ontrac, dhl, amazon, s10
. S10 is the international standard used by local government post offices. When packages are shipped internationally via normal post, it's usually an S10 number.
const t = new TrackingNumber("1Z879E930346834440");
console.log(t.valid); // true
console.log(t.courierCode); // "ups"
console.log(t.courierName); // "UPS"
const t = new TrackingNumber("RB123456785GB");
console.log(t.courierName); // "Royal Mail Group plc"
console.log(t.courierCode); // "s10"
const t = new TrackingNumber("1001901781990001000300617767839437");
console.log(t.courierName); // "United States Postal Service"
Some tracking numbers indicate their service type
const t = new TrackingNumber("1Z879E930346834440");
console.log(t.serviceType); // "UPS United States Ground""
const t = new TrackingNumber("1ZXX3150YW44070023");
console.log(t.serviceType); // "UPS SurePost - Delivered by the USPS"
const t = new TrackingNumber("RB123456785US");
console.log(t.serviceType); // "Letter Post Registered"
Some tracking numbers indicate information about their package
const t = new TrackingNumber("1Z6072AF0320751583");
console.log(t.shipperId); // "6072AF" <-- this is Target
Some tracking numbers indicate their destination
const t = new TrackingNumber("1001901781990001000300617767839437");
console.log(t.destinationZip); // "10003"
Some tracking numbers indicate information about their package
const t = new TrackingNumber("012345000000002");
console.log(t.packageType); // "case/carton"
Most tracking numbers have a format where each part of the number has meaning. decode
splits up the number into its known named parts.
const t = new TrackingNumber("1Z879E930346834440");
console.log(t.decode);
Copyright (c) 2018 Try.com. See LICENSE for further details.