Skip to main content

A CLI for tracking packages from USPS.

Project description

iiPythonx / USPS

A CLI for tracking packages from USPS (with crude support for UPS packages).

Installation

uv pip install usps-cli

# or, install from dev:
uv pip install git+https://github.com/iiPythonx/usps

Usage

[!IMPORTANT]
For UPS packages, USPS-cli only support the 1Z version of UPS tracking numbers right now.

Get the tracking information for a package:

usps track 9400100000000000000000

Add a tracking number to your package list:

usps add 9400100000000000000000

Remove a tracking number from your package list:

usps remove 9400100000000000000000

Show all your current packages:

usps track

Add a name to a package:

$ usps name 9400100000000000000000 "Amazon Package"

# If you don't specify name, it will prompt for one.
$ usps name 9400100000000000000000
Choose a package name: Amazon Package

Remove the name from a package:

usps name --erase 9400100000000000000000

For more details, run usps --help.

Requirements

[!NOTE]
If you only plan to track UPS packages, you can skip installing a selenium driver.

Since this package uses selenium for challenge solving, you'll need to install a Gecko-based browser and geckodriver.
Feel free to modify the code to use Chromium instead if you prefer it.

If you're on Arch: sudo pacman -S firefox geckodriver,

How it works

  • Selenium goes to the USPS tracking website, completing the JS challenge and saving the cookies.
  • This client saves that request data to a JSON file for reuse (speeds up the client dramatically).
  • Next, requests pulls the page from USPS using our saved cookies and parses it with BeautifulSoup.
  • Apply some basic scraping and there you go, a USPS tracking client.

It's worth noting I scrape USPS because their APIs get basically no support, require the creation of business accounts and filling out every piece of information about yourself, and even then you have to request explicit access to the tracking API.

Triggered?

If you're a USPS web tools representative or something and have a problem with this repository, shoot me an email: ben@iipython.dev.

Project details


Download files

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

Source Distribution

usps_cli-0.9.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

usps_cli-0.9.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file usps_cli-0.9.0.tar.gz.

File metadata

  • Download URL: usps_cli-0.9.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for usps_cli-0.9.0.tar.gz
Algorithm Hash digest
SHA256 b658e5bfdceab443a367b9c3a1354758334872735a22a10d95f23ac9bd6d5bde
MD5 3c07238de879c371895350ba0e8fb942
BLAKE2b-256 09f19d5dc70f83b493c66f34c72f99ba9e55fb78cc527f726fd59f1329282a2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for usps_cli-0.9.0.tar.gz:

Publisher: publish.yml on iiPythonx/usps

Attestations:

File details

Details for the file usps_cli-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: usps_cli-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for usps_cli-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 695fe1a1b09adcfbb7f83a89d60e5348176d27db930f183f880ab58a4ba6819c
MD5 7548e98551d95997344ed01186f6f9e7
BLAKE2b-256 8d60bc823ed56d03d4177717e01e6cbe7671d1cc8ba7eb9132ed1320f6f46b82

See more details on using hashes here.

Provenance

The following attestation bundles were made for usps_cli-0.9.0-py3-none-any.whl:

Publisher: publish.yml on iiPythonx/usps

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page