RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts</strong | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.69% (5.89%*) • Home Loan Fixed: 5.39% (6.59%*) • Fixed: 5.39% (6.59%*) • Variable: 5.69% (5.89%*) • Investment IO: 5.69% (6.48%*) • Investment PI: 5.39% (6.59%*)

Can I Still Use The USA Zipcode XML API?

When we were building a website for a US based organisation we encountered all sorts of issues with reliable access to a zipcode API. In the end, we figured it'd be easier if we built our own.

March, 2022: Note that this API is all but deprecated. Certain functions are preserved for limited applications but it should not be used. Refer the various JSON APIs made available.

Postcodez is a very simple site that gives our readers access to a simple zipcode API with various functions. It's easy to create a fully functioning zipcode search website based upon the information the API provides. In fact, the simple Postcodez website is itself API-centric - meaning that all our own requests are made via the API.

This post will show you how to:

  • Determine the distance Between two zip codes with PHP.
  • Retrieve information on a single zip code.
  • Retrieve information on multiple zip codes.
  • Retrieve zip codes within a radius of another zip.
  • Retrieve zip codes within a radius of geographic coordinates

Note: This API is now unsupported.

Determine the Distance Between Two Zipcodes with PHP

This function will calculate the distance between two zipcodes. With an input of two zipcodes, the returned XML includes the distance (in miles, kilometers and nautical miles), the two placenames, counties, state codes and state.

Endpoint

postcodez.com/api/distance/[zipcode]/[zipcode]/api.xml

Retrieve Information on a Single Zip Code

The following function is used to generate information on a single zip code.

Endpoint

postcodez.com/api/zip/[zipcode]/api.xml

Retrieve Information on Multiple Zip Codes

The request we make to the API for multiple zip codes is the same as if we were making a request for a single zip code. We're using two functions so that you have more flexibility when formatting text.

Endpoint

postcodez.com/api/zip/[zipcode],[zipcode]/api.xml

There are a few checks in the function that'll basically check if each zip is 5 characters in length and a number. If not, it's removed from the string of zipcodes that are included in the XML request.

Retrieve Zip Codes within a Radius of another Zip

.

This function will retrieve zip codes that are in a defined radius of another.

Endpoint

postcodez.com/api/nearby/[zip]/[dist][unit]/api.xml

Retrieve Zip Codes within a Radius of Geographic Coordinates

Endpoint

postcodez.com/api/geo/[lat]/[lng]/[dist][unit]/api.xml

This function will retrieve zip codes that are in a defined radius of a geographic coordinate. Available units are miles and kilometers (miles by default).

Considerations

More information on the basic API and error codes can be found here . If you use this API in a project, it is expected that you would provide appropriate attribution.

Share this content?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

■ ■ ■

 
Download our complimentary 650-page guide on marketing for mortgage brokers. We'll show you exactly how we generate billions in volume for our clients.
Finance Guide, Cropped Top and Bottom
  Timezone: 1 · [ CHANGE ]

Leave a comment