Metadapi Blog

Articles that help developers get up and running quickly on all of the API's available on Metadapi.


Ricardo Rangel
Ricardo Rangel

Metadapi's Blog

Getting Started Zip Code API

Overview

These instructions describe how to get started with the Zip Code API. The examples in this article use Postman. You can get postman here 

  1. Pre-Requisites for Zip Code API
  2. Making a request for a single Zip Code
  3. Evaluating single zip code response
  4. Making a request for Zip Codes in California
  5. Evaluating search response

Pre-Requisites for Zip Code API

Before you start using this API, you have to complete the following:

  1. Register to Metadapi.com
  2. Subscribe to the Zip Code API using any available tier (if you are just trying this API the “free” tier is available).
  3. Get your API Key
  4. Make sure you have Postman installed.

Making a request for a single zip code

To get started, let’s get the Zip Code of the famous US city Beverly Hills 90210. We are interested in all of the details of that zip code.

The Zip Code api host is https://global.metadapi.com/zipc/v1/zipcodes/{zipCode} and the API Key must be included as part of the header. Let’s get the call started in Postman.

First create a new GET request
Graphical user interface, text, application, chat or text message, email

Description automatically generated

Enter the request url to get a zip code


Graphical user interface, text, application

Description automatically generated

Enter the API Key header where the key name is Ocp-Apim-Subscription-Key and the Value is you API key. (get your API key).

Graphical user interface, text, application, email

Description automatically generated

After you have the request and API Key you can click the “Send” button to execute the request.

Graphical user interface, text, application, email

Description automatically generated

That’s it. you’ve executed the GET request for the Beverly Hills Zip Code 90210.  The JSON response contains the details of the zip code.

Evaluating the single Zip Code response

The following is the response from the Zip Code object. The response object has 2 properties: links , with a representation of the resouce, and data with the zip code object model. To see the definition of each property of the zip code response visit this link

Text, letter

Description automatically generated


4. Making a request for Zip Codes in California

The endpoint https://global.metadapi.com/zipc/v1/zipcodes has several query parameter options. Let’s use the stateCode query parameter to get a list of all zip codes in California. (Click here for more information on the available query parameters)

Create a new GET request using the following endpoint:


Graphical user interface, text, application

Description automatically generated

Make sure the API Key authorization is set:
Graphical user interface, text, application, email

Description automatically generated

Click the Send button to execute the request

The request is executed and we get the JSON response.

Graphical user interface, text, application, email

Description automatically generated

  1. Evaluating search response

The following is the response from the Zip Code object. The response object has 3 properties: links , with a representation of the resource and links to the result pages.
meta with the following objects, count (how many zip codes match the criteria), offset (where in the result set the returned records start) and limit (how many zip code objects are displayed per page. Note: the zip code API always paginates the results with a Max limit of 50 zip codes per page.
Data is an array of zip code objects. The limit response has the total number of zip codes in the array.
Note: When no Offset or Limit query parameters are added to the request, the defaults are set to offset = 0 and limit = 10

Get the Zip Code API and start building an awesome solution!

Comment (0)



Comments are closed.

Join our Newsletter

Get the latest information about API products, tutorials and much more. Join now.

    About Our Company

    Metadapi is based in SW Florida.

    Get in touch

    Follow Us