PHPackages                             multidimensional/usps - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. multidimensional/usps

ActiveLibrary[API Development](/categories/api)

multidimensional/usps
=====================

A USPS API Library for PHP.

012[1 issues](https://github.com/multidimension-al/usps/issues)PHP

Since Feb 24Pushed 7y ago1 watchersCompare

[ Source](https://github.com/multidimension-al/usps)[ Packagist](https://packagist.org/packages/multidimensional/usps)[ RSS](/packages/multidimensional-usps/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

USPS API PHP Library
====================

[](#usps-api-php-library)

[![Build Status](https://camo.githubusercontent.com/c72a787431422e106c52e36a6e6a81f0050400668b17d6c052ec5c7e8542d20c/68747470733a2f2f7472617669732d63692e6f72672f6d756c746964696d656e73696f6e2d616c2f757370732e737667)](https://travis-ci.org/multidimension-al/usps)[![Latest Stable Version](https://camo.githubusercontent.com/8fccaaf3b86d7b65697025a431a999c68e5cffd89a0e6a9103f0251c0ee0e1e9/68747470733a2f2f706f7365722e707567782e6f72672f6d756c746964696d656e73696f6e616c2f757370732f762f737461626c652e737667)](https://packagist.org/packages/multidimensional/usps)[![Code Coverage](https://camo.githubusercontent.com/d0ae6b5e8f27fe4f8b0ce8d68c856aa74425168290ecd827130c23d35685f385/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d756c746964696d656e73696f6e2d616c2f757370732f6261646765732f636f7665726167652e706e67)](https://scrutinizer-ci.com/g/multidimension-al/usps/)[![Minimum PHP Version](https://camo.githubusercontent.com/dd6bad85ee03cf570f4cf82ab69a80396fdbf48050af932f8f23aa551b0d1e5a/687474703a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230352e352d3838393242462e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/3303e1eb8d79ea09d992bd3d15c793256fc45289e3803b18afa6e1aa70025eaf/68747470733a2f2f706f7365722e707567782e6f72672f6d756c746964696d656e73696f6e616c2f757370732f6c6963656e73652e737667)](https://packagist.org/packages/multidimensional/usps)[![Total Downloads](https://camo.githubusercontent.com/e1cc1f564844063015bdb2f8bbd113be1f5c2f46d7c8da2d63e3c626ae4fa7fb/68747470733a2f2f706f7365722e707567782e6f72672f6d756c746964696d656e73696f6e616c2f757370732f642f746f74616c2e737667)](https://packagist.org/packages/multidimensional/usps)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0b3382270e63c937597785930ac18242e37eb5eec72acc44fc8a725180c9847a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d756c746964696d656e73696f6e2d616c2f757370732f6261646765732f7175616c6974792d73636f72652e706e67)](https://scrutinizer-ci.com/g/multidimension-al/usps/)

Requirements
------------

[](#requirements)

- PHP 5.6+
- [Array Validation Library](https://github.com/multidimension-al/array-validation)
- [Array Sanitization Library](https://github.com/multidimension-al/array-sanitization)
- [DOM Array Library](https://github.com/multidimension-al/dom-array)
- [XML Array Library](https://github.com/multidimension-al/xml-array)

### Address Object Example

[](#address-object-example)

There are multiple ways to create an Address object.

```
//Method 1
$address1 = new Address([
    'ID' => 1,
    'Address2' => '123 Fake St.',
    'City' => 'Springfield',
    'State' => 'CA',
    'Zip4' => 90210
]);

//Method 2
$address2 = new Address();

$address2->setID('1');
$address2->setAddress2('123 Fake St.');
$address2->setCity('Springfield');
$address2->setState('CA');
$address2->setZip4(90210);
```

Both methods can be used, and address objects can be updated or overridden on the fly using the 'set' methods.

### ZipCode Object Example

[](#zipcode-object-example)

There are multiple ways to make a ZipCode object.

```
//Method 1
$zipCode = new ZipCode(['ID' => 123, 'Zip5' => '90210']);

//Method 2
$zipCode = new ZipCode();
$zipCode->setID(123);
$zipCode->setZip5(90210)
```

Both methods can be used, and ZipCode objects can be updated or overridden on the fly using the 'set' methods.

### AddressValidate Example

[](#addressvalidate-example)

AddressValidate is a USPS API method that will confirm or correct a submitted address. Up to 5 addresses can be added and validated at one time.

```
$address = new Address([
    '@ID' => 1,
    'Address2' => '123 Fake St.',
    'City' => 'Springfield',
    'State' => 'CA',
    'Zip4' => 90210
]);
$addressValidate = new AddressValidate();
$addressValidate->addAddress($address);

$response = $addressValidate->validate();

if ($addressValidate->isSuccess()) {

    //do stuff

} else {

    $addressValidate->getErrorMessage();

}
```

The response will include the corrected address, but may also return possible other addresses if the address is not 100% valid.

### CityStateLookup Example

[](#citystatelookup-example)

CityStateLookup is a USPS API method for looking up the city and state when provided with a ZipCode object.

```
$zipCode = new ZipCode(['ID' => 123, 'Zip5' => 20500]);
$cityStateLookup = new CityStateLookup(['userID' => $_ENV['USPS_USERID']]);
$cityStateLookup->addZipCode($zipCode);
$result = $cityStateLookup->lookup();
```

The result includes City and State information that can be referenced back to the ID included with the ZipCode object.

### ZipCodeLookup Example

[](#zipcodelookup-example)

```
$address = new Address([
    '@ID' => 1,
    'Address2' => '123 Fake St.',
    'City' => 'Springfield',
    'State' => 'CA',
    'Zip4' => 90210
]);
$zipCodeLookup = new ZipCodeLookup();
$zipCodeLookup->addAddress($address);
$result = $zipCodeLookup->lookup();
```

The results provided will return a ZipCode and a +4 Code if it is available.

### Track Example

[](#track-example)

```
$track = new Track('TrackID' => '940000000000000012345');
$result = $track->track();
```

The results provided will be a summary of the tracking information as well as a step by step listing of all the details.

License
=======

[](#license)

```
     __  ___      ____  _     ___                           _                    __
    /  |/  /_  __/ / /_(_)___/ (_)___ ___  ___  ____  _____(_)___  ____   ____ _/ /
   / /|_/ / / / / / __/ / __  / / __ `__ \/ _ \/ __ \/ ___/ / __ \/ __ \ / __ `/ /
  / /  / / /_/ / / /_/ / /_/ / / / / / / /  __/ / / (__  ) / /_/ / / / // /_/ / /
 /_/  /_/\__,_/_/\__/_/\__,_/_/_/ /_/ /_/\___/_/ /_/____/_/\____/_/ /_(_)__,_/_/

USPS API PHP Library
Copyright (c) Multidimension.al (http://multidimension.al)
Github : https://github.com/multidimension-al/usps

Licensed under The MIT License
For full copyright and license information, please see the LICENSE file
Redistributions of files must retain the above copyright notice.

@copyright  Copyright © 2017-2019 Multidimension.al (http://multidimension.al)
@link       https://github.com/multidimension-al/usps Github
@license    http://www.opensource.org/licenses/mit-license.php MIT License

```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6588235?v=4)[AJ Quick](/maintainers/ajquick)[@ajquick](https://github.com/ajquick)

---

Top Contributors

[![ajquick](https://avatars.githubusercontent.com/u/6588235?v=4)](https://github.com/ajquick "ajquick (170 commits)")

### Embed Badge

![Health badge](/badges/multidimensional-usps/health.svg)

```
[![Health](https://phpackages.com/badges/multidimensional-usps/health.svg)](https://phpackages.com/packages/multidimensional-usps)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
