chrishardie/laravel-usps-addresses

Laravel package that provides a simple facade to the USPS Addresses API

Fund package maintenance!
Chris Hardie

Installs: 6

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/chrishardie/laravel-usps-addresses

v0.1.1 2026-01-08 21:50 UTC

This package is auto-updated.

Last update: 2026-01-08 21:53:33 UTC


README

Latest Version on Packagist Total Downloads

Laravel package that provides a simple facade to the USPS Addresses API

Installation

You can install the package via composer:

composer require chrishardie/laravel-usps-addresses

Define required variables in .env, available from your app's configuration in the USPS Developers Dashboard:

USPS_CLIENT_ID=
USPS_CLIENT_SECRET=

You can optionally publish the config file with:

php artisan vendor:publish --tag="laravel-usps-addresses-config"

This is the contents of the published config file:

return [
    'base_url' => env('USPS_ADDRESSES_BASE_URL', 'https://apis.usps.com/addresses/v3'),

    'oauth' => [
        'token_url' => env('USPS_OAUTH_TOKEN_URL', 'https://apis.usps.com/oauth2/v3/token'),
        'client_id' => env('USPS_CLIENT_ID'),
        'client_secret' => env('USPS_CLIENT_SECRET'),
        'scope' => 'addresses',
    ],

    'timeout' => 10,
];

Usage

use UspsAddress;

$result = UspsAddress::verify([
    'streetAddress' => '2704 Erie Ave',
    'city' => 'Cincinnati',
    'state' => 'OH',
]);

if ($result->isValid()) {
    echo $result->address->streetAddress;
};

Methods available correspond to available API endpoints:

  • UspsAddress::verify(): Returns the best standardized address for a given address.
  • UspsAddress::cityState(): Returns the city and state for a given ZIP Code.
  • UspsAddress::zipCode(): Returns the ZIP Code for a given address.

View the USPS API documentation for details about available parameters and responses.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.