USPS API

Component ID

2492471

Component name

USPS API

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

US Postal Service API Module

This module is an API interface only and requires additional coding or module to interact with the data.

How To Use

  1. Find your USERID provided by your registration notice email sent from the United States Postal Service.
  2. Enter your USERID in the settings page: /admin/config/services/usps_api.
  3. Create custom code to interact with this module api.

Code Example

Instantiate a new UspsApi object with an array parameter.

The array will be the minimum required address fields to return a response from the api.

$address = new UspsApi(array(
  'address2' => '209 oak',
  'city' => '',
  'state' => '',
  'zip5' => '97204',
));

// Then call the validate method.
$valid_address = $address->validateStandardAddress();

See the api docs for minimum fields.

The response will be a complete standard USPS mailing address or an error document from the api. Check for array index 'error' to be true for other errors.

Options

  • Allows for a proxy configuration.
  • Debug options to display in the response for XML request, XML response, and cURL response.

Debug Options

Requirements

  • The call to the api service is done with cURL.

USPS API provides three services

  1. Address Standardization Verification
  2. Zip Code Lookup Tool
  3. City/State Lookup Tool

Note: This module currently only provides Address Standardization Verification service for one address.

USPS Web Tools API Guide:

https://www.usps.com/business/web-tools-apis/address-information-api.htm