Skip to main content

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.

Usage

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
'1Z999AA10123456784'
>>> package.shipper
'UPS'
>>> package.tracking_number
'1Z999AA10123456784'

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
True

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
False
>>> package.shipper
None

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

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

Changelog

Version 0.0.2

  • Improved pattern match for USPS IMpb barcodes

  • Added support for 20 character USPS barcodes

Version 0.0.1

  • Initial release

Metadata

Release files for drogher 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for drogher 0.0.2
File Size Uploaded
drogher-0.0.2.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for drogher 0.0.2
File Interpreter ABI Platform
drogher-0.0.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 26.9 kB

Release files / drogher-0.0.2.tar.gz

Download URL drogher-0.0.2.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d7c7137091be5772f9c3fef31405636ea868b6a43964031fd21ad57e1560b854
BLAKE2b-256 checksum
How to use checksums
b9c07c72bb24cf5ab0f92750d4ee13754721a1659f365db6c63bba24f6457b12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / drogher-0.0.2-py2.py3-none-any.whl

Download URL drogher-0.0.2-py2.py3-none-any.whl
Size 21.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
d1bdfa34ded1c1034e9a20f1d824e33c9a9256adf63f6480183c74e0d1f0acff
BLAKE2b-256 checksum
How to use checksums
e75e11becbb068238f118e49696159c01d418ed98f69ffaf40f70afdbba814bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page