apiusps

How to Test USPS Package Tracking API without test tracking numbers


USPS recommends testing their API with test tracking numbers but doesn't provide any. How can the USPS API be tested without valid testing tracking numbers.


I've been looking for USPS tracking API test tracking numbers to see USPS tracking API responses with different situation (eg, shipment delayed, or shipment signed off by [name], shipment returned to sender, etc).


I've looked everywhere I can think of, including USPS website, several years of USPS API documentation (near useless; can provide links on request), I've called USPS customer service for the API, and I've looked on SO/Google, to no avail.

I've run into this FedEx Tracking Number Question as well as this SO question for UPS test tracking numbers.


Solution

  • Unfortunately the USPS doesn't offer test tracking numbers. You could theoretically use a bunch of different real tracking numbers - you can track any package with your own Web Tools account. This is not easy though, given that the USPS has hundreds of different tracking events. The best options you have:

    1. Try to build your own mapping system (from the USPS status to your own) by getting access to many production tracking numbers.
    2. Use the "unstructured" USPS tracking API, which returns a human-readable description of the tracking status. Without a lot of parsing you wouldn't be able to map this to your own status.
    3. Use a tracking API like Shippo, which returns mapped status values for you, after going through millions of their own tracking numbers.

    Hope that helps!