Skip to main content

Identify shippers and valid tracking numbers from package barcodes

Project description

Identify shippers and valid tracking numbers from package barcodes.

A package barcode string is tested against known shipper barcode types, matching the format and calculating checksum validity to identify the type provided. The module supports these barcode formats:

  • DHL
  • FedEx Express
  • FedEx Ground “96”
  • OnTrac
  • UPS
  • USPS IMpb
  • USPS UPU S10
  • USPS 20

Note: For some shippers the package barcode is the same as the tracking number, while for others the tracking number is a subset of the barcode. Inputting a tracking number instead of a barcode will work in some cases but not others.


Begin by importing the Drogher module:

>>> import drogher

Now, call the barcode function with a package barcode string:

>>> package = drogher.barcode('1Z999AA10123456784')

That returns a Package subclass containing some useful information:

>>> package.barcode
>>> package.shipper
>>> package.tracking_number

We can also ensure the package is valid, which tells us the barcode matched an expected format and the calculated checksum matches the check digit:

>>> package.is_valid

If a barcode cannot be matched with a shipper, the class does not validate and the shipper is None:

>>> package = drogher.barcode('123456')
>>> package.is_valid
>>> package.shipper

For some shippers, the barcode is not the same as the tracking number:

>>> package = drogher.barcode('420221539101026837331000039521')
>>> package.barcode
>>> package.tracking_number
>>> package.shipper


Version 0.0.2

  • Improved pattern match for USPS IMpb barcodes
  • Added support for 20 character USPS barcodes

Version 0.0.1

  • Initial release

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for drogher, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size drogher-0.0.2-py2.py3-none-any.whl (21.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size drogher-0.0.2.tar.gz (5.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page