Complete USPS API v3 (OAuth2) for Laravel 10–13 — 20 API domains, 80+ endpoints, REST routes, input validation
The legacy USPS Web Tools XML API was retired January 2026. This package uses the new OAuth2-based REST/JSON API at apis.usps.com with automatic token management and per-scope caching.
composer require johnpaulmedina/laravel-usps
php artisan vendor:publish --tag=usps-config
USPS_CLIENT_ID=your-client-id
USPS_CLIENT_SECRET=your-client-secret
Register at developer.usps.com for credentials.
# Validate an address
php artisan usps:validate "1600 Pennsylvania Ave NW" --state=DC --zip=20500
# Track packages
php artisan usps:track 9400111899223456789012
# ZIP code lookup
php artisan usps:zip 33101
# Calculate shipping rates
php artisan usps:price 20500 33101 16 --mail-class=PRIORITY_MAIL
# Delivery estimates
php artisan usps:standards 20500 33101
# Find USPS locations
php artisan usps:locations 33101 --type=post-office --radius=5
All commands output formatted tables to the console.
Publish routes to your app:
php artisan vendor:publish --tag=usps-routes
27 routes under /api/usps/ with Form Request validation. 13 controllers, 26 request classes.
All inputs are automatically normalized and validated:
{
"address": {
"Address2": "1600 PENNSYLVANIA AVE NW",
"Address1": "",
"City": "WASHINGTON",
"State": "DC",
"Zip5": "20500",
"Zip4": "0005"
},
"additionalInfo": {
"DPVConfirmation": "Y",
"business": "Y",
"vacant": "N"
}
}
{
"address": { "Address2": "100 S BISCAYNE BLVD", ... },
"corrections": [{
"code": "32",
"text": "...more information is needed (apartment, suite, or box number)..."
}],
"additionalInfo": { "DPVConfirmation": "D" }
}
Confirms whether the address is a real USPS deliverable location — down to the apartment/suite level.
| Code | Meaning |
|---|---|
| Y | Full match — street and unit confirmed |
| D | Primary confirmed, apartment/suite missing |
| S | Primary confirmed, apartment/suite doesn't match |
| N | Not a valid delivery point |
Correction codes: 32 = apartment needed, 22 = multiple addresses found
{ "city": "WASHINGTON", "state": "DC", "ZIPCode": "20500" }
{
"address": {
"streetAddress": "1600 PENNSYLVANIA AVE NW",
"city": "WASHINGTON",
"state": "DC",
"ZIPCode": "20500",
"ZIPPlus4": "0005"
}
}
State names auto-convert (Florida → FL). ZIP+4 auto-splits (20500-0005 → 20500 + 0005).
Full USPS Address API docs →
| PHP | 8.1+ |
| Laravel | 10, 11, 12, 13 |
| USPS Credentials | developer.usps.com |