usps-track

Python versions PyPI - Version GitHub tag (with filter) License GitHub commits since latest release (by SemVer including pre-releases) CodeQL QA Tests Coverage Status Dependabot Documentation Status mypy uv pytest Ruff Downloads Stargazers pre-commit Prettier Follow @Tatsh Mastodon Follow

Quickly track via SMS several USPS (and some international) tracking numbers via the command line.

Commands

usps-track

Track USPS packages using tracking numbers and phone number.

Usage

usps-track [OPTIONS] TRACKING_NUMBER PHONE_NUMBER

Options

-d, --debug

Enable debug logging.

Arguments

TRACKING_NUMBER

Optional argument(s)

PHONE_NUMBER

Required argument

Library

Constants.

usps_track.constants.DEFAULT_STR_VALUE

Default value for optional string parameters.

usps_track.constants.HEADERS : dict[str, str]

HTTP headers to use for requests.

usps_track.constants.URL_PREFIX

Base URL for USPS tracking tools.

usps_track.constants.URL_TRACK_CONFIRM_ACTION

URL for USPS tracking confirmation action.

usps_track.constants.URL_TRACK_CONFIRM_UPDATE

URL for USPS tracking confirmation update AJAX action.

usps_track.constants.US_PHONE_NUMBER_WITH_LEADING_ONE_LENGTH

Length of a US phone number with a leading ‘1’.

Main library code for usps_track.

exception usps_track.lib.TextServiceError

An error occurred with the USPS text service.

async usps_track.lib.usps_track(phone_number: str, tracking_numbers: Iterable[str], *, confirm_sms: bool = True, email: str = 'not required', name: str = 'not required', text_alert: bool = True, text_all: bool = True, text_dnd: bool = True, text_future: bool = True, text_oa: bool = True, text_pickup: bool = True, text_today: bool = True, raise_for_status: bool = False) None

Track a package using the USPS tracking system via SMS.

Parameters:
phone_number : str

Must be a US phone number including area code without a leading ‘1-’, and with each group separated using ‘-’ as the delimiter.

tracking_numbers : Iterable[str]

Tracking numbers to track. USPS does generally accept international values, usually after the package gets into the US, but sometimes earlier than that (especially for Royal Mail).

confirm_sms : bool

Whether to confirm SMS enrolment.

email : str

Email address for notifications.

name : str

Name associated with the tracking request.

text_alert : bool

Enable text alerts.

text_all : bool

Enable all text notifications.

text_dnd : bool

Enable do-not-disturb override for texts.

text_future : bool

Enable future delivery text notifications.

text_oa : bool

Enable out-for-delivery text notifications.

text_pickup : bool

Enable pickup-available text notifications.

text_today : bool

Enable today’s delivery text notifications.

raise_for_status : bool

Raise if any individual request fails.

Raises:

TextServiceError – If the USPS text service returns an error.

Indices and tables