PHPackages                             jamesvweston/usps-php - 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. jamesvweston/usps-php

ActiveLibrary[API Development](/categories/api)

jamesvweston/usps-php
=====================

A PHP Wrapper For The USPS API

037PHP

Since Jul 29Pushed 9y ago1 watchersCompare

[ Source](https://github.com/jamesvweston/usps-php)[ Packagist](https://packagist.org/packages/jamesvweston/usps-php)[ RSS](/packages/jamesvweston-usps-php/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

usps-php
========

[](#usps-php)

An Object-Oriented And Well Documented PHP Wrapper For The USPS API Based on

Features
--------

[](#features)

- An object-oriented PHP wrapper for the USPS API
- Your USPS USER\_ID and selection of environment (production or development) is the only required values
- Properly documented, PHP doc blocks, and simple to use
- Full suite of PHP unit tests

Active API Integrations
-----------------------

[](#active-api-integrations)

- Address validation
- City and state look up with zip code
- Zip code look up with street address, city, and state

Example Address Look Up
-----------------------

[](#example-address-look-up)

```
use jamesvweston\USPS\USPSClient;
use jamesvweston\USPS\Models\Address;
use jamesvweston\USPS\Models\Requests\AddressValidateRequest;

//  Instantiate the client with the path that the .env is located
$uspsClient             = new USPSClient('./');
$addressApi             = $uspsClient->getAddressApi();

//  Construct an address object to validate
$address                = new Address();
$address->setAddress2('111 W Harbor Dr');
$address->setCity('San Diego');
$address->setState('CA');
$address->setZip5('92101');

//  Construct the request
$addressValidateRequest = new AddressValidateRequest();

//  Add the address to the request
$addressValidateRequest->addAddress($address);

//  Make the request
$response               = $addressApi->validateAddress($addressValidateRequest);
```

Installation
------------

[](#installation)

```
composer require jamesvweston/usps-php

```

Configuration
-------------

[](#configuration)

The following variables are required by the USPSClient

- **USPS\_USER\_ID** - User id provided by the USPS
- **USPS\_ENVIRONMENT** - production or development

Example USPSClient Instantiation With .env File
-----------------------------------------------

[](#example-uspsclient-instantiation-with-env-file)

```
use jamesvweston\USPS\USPSClient;

//  Instantiate the client with the path that the .env is located
$uspsClient             = new USPSClient('./');
```

Example USPSClient Instantiation With Array
-------------------------------------------

[](#example-uspsclient-instantiation-with-array)

```
use jamesvweston\USPS\USPSClient;

//  Build the array
$config = [
    'USPS_USER_ID'      => 'xxxxx',
    'USPS_ENVIRONMENT'  => 'production',
];

//  Instantiate the USPSClient with the $config array
$uspsClient             = new USPSClient($config);
```

Unit Testing
------------

[](#unit-testing)

From the command line run the following

```
vendor/bin/phpunit -c phpunit.xml

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

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/12530200?v=4)[jamesvweston](/maintainers/jamesvweston)[@jamesvweston](https://github.com/jamesvweston)

### Embed Badge

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

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

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

94452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

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