PHP Classes

PHP USPS API Address Validation: Get the details of a given address using USPS API

Recommend this page to a friend!
  Info   View files Example   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2023-12-20 (5 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 136 All time: 9,264 This week: 71Up
Version License PHP version Categories
usps-address-valid 3GNU General Publi...7.4E-Commerce, Web services, PHP 7


This package is specific mainly for applications used in United States United States .

This class can get the details of a given address using USPS API.

It can send an HTTP request to the USPS API Web server to get the details of a given United States address.

The class returns an array with the street address, city, state, and the five-digit postal code.

This package is updated to support the latest USPS API v3 (as of 2023).

Picture of Jason Olson
  Performance   Level  
Name: Jason Olson is available for providing paid consulting. Contact Jason Olson .
Classes: 4 packages by
Country: United States United States
Age: ???
All time rank: 3216434 in United States United States
Week rank: 305 Up35 in United States United States Up
Innovation award
Innovation award
Nominee: 1x


 * Copyright (c) 2019. ReddingWebPro / Jason J. Olson, This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 3
 * of the License.
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 * for more details. You should have received a copy of the GNU General Public License along with this program. If not,
 * see <>.

 * Created by ReddingWebPro/ReddingWebDev
 * User: Jason J. Olson
 * License: GNU GPLv3
 * GitHub:
 * Version 2.0
 * Date: 3/6/2019 (rev. 9/19/23)

// example code shown below:



$uspsZip = new USPS('Consumer Key','Consumer Secret'); // insert your api key from USPS

$address = '1600 Amphitheatre Parkway'; // address line is required
$city = 'Mountain View';
$state = 'CA'; //looking for the two character state

$return = $uspsZip->getNormalized($address, $city, $state);

"<li>Address: " . $return['address']['streetAddress'];
"<li>Address 2: " . $return['address']['secondaryAddress'];
"<li>City: " . $return['address']['city'];
"<li>State: " . $return['address']['state'];
"<li>Zip: " . $return['address']['ZIPCode'];



This CLASS is designed to take advantage of the USPS API for looking up the corrected (normalized) address for a given physical address. There is very little examples of implementing the USPS API in PHP.


When you instantiate the class, include the API key. See the example.php file for usage. If you don't have a valid API, you can get one free at

Revision History:

  • 1.0 Initial Release
  • 1.1 Bugfix 500 error.
  • 2.0 Updated for new USPS API V3 & PHP 8 coding standards

This code was written by request by another developer on because Streetlayers is going away very soon.


GNU General Public License v3.0 (GNU GPLv3)

  Files folder image Files  
File Role Description
Files folder imagedemo (1 file)
Files folder imagesrc (1 file)
Accessible without login Plain text file Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file Doc. Documentation

  Files folder image Files  /  demo  
File Role Description
  Accessible without login Plain text file example.php Example Example script

  Files folder image Files  /  src  
File Role Description
  Plain text file USPS.php Class Class source 14KB
Downloadusps-address-valid-2023-12-20.tar.gz 13KB
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
cURL Download .zip .tar.gz Required for making API call Required
 Version Control Unique User Downloads Download Rankings  
This week:0
All time:9,264
This week:71Up