Local US ZIP Code API

This page describes how to download, install, and run a local instance of the US ZIP Code API.


  1. Glossary
  2. API Documentation
  3. Prerequisites
  4. Minimum System Requirements
  5. Downloading the Packages
  6. Installation Procedures
  7. Managing the Local API Process
  8. Connecting to the Local API Process
  9. Updates
  10. Docker and Containers
  11. Automation


Throughout this document we use the following consistently formatted terms:

  • US ZIP Code API

    The product with the capabilities you wish to host on your local network.

  • us-zipcode-data

    The first of two packages you will download and extract. Contains the necessary data files used by the running program.

  • us-zipcode-api

    The second of two packages you will download and extract. Contains the main program and other binary resources.

  • us-zipcode-api

    The program that you will execute. Found in the us-zipcode-api package.

API Documentation

A local installation of the US ZIP Code API performs identically to the cloud version hosted by Smarty. Please refer to the documentation for details about input and output fields.

The main difference between the local and cloud installations lies in the parts of the URL used by clients to establish a connection. (scheme://hostname:port) This will be explained in more detail later.


Access to local US ZIP Code API packages and resources is currently restricted to customers with an Enterprise account. Downloading the packages also requires a valid secret key pair for authentication.

The process of downloading, installing, and managing a local instance of the US ZIP Code API requires a system administrator or software engineer who has experience with the Linux operating system and its accompanying shell environment.

Minimum System Requirements

The US ZIP Code API is designed to run on a Linux server that can be reached by any clients you intend to call the service. Responsibility for network and server maintainence (as well as the performance of all other operations detailed in this document) rests with your organization.

The server provisioned to run the local US ZIP Code API binaries should match or exceed the following criteria:

  • 2 gigabytes of disk space / 2 gigabytes of RAM
  • 4 CPU cores
  • A relatively recent version of the Linux kernel (basically something that can run compiled Go programs). Anything later than v2.6.32 should function without issues.

Downloading the Packages

Running a local instance of the US ZIP Code API requires two packages that are available for download via the Smarty Download API:

  • us-zipcode-data

    Includes all address data accessed by the us-zipcode-api program in order to serve client requests.

  • us-zipcode-api

    Includes the compiled program (redundantly named us-zipcode-api) and several shared libraries to be installed in /usr/lib.

See the sample script below for more details.

Installation Procedures

Both downloaded packages are gzipped archives and must be extracted (using the tar command) before they can be used. Examples of how to use the tar command to extract the downloaded archives can be found below.

By default, the us-zipcode-api program expects the extracted contents of the data package to be found at ./data.

Managing the Local API Process

  • To display command-line usage and all options:
    ./us-zipcode-api -help
  • To run the program:
    ./us-zipcode-api -data "/path/to/extracted/data/package"

NOTE: Running the us-zipcode-api program starts a process that is designed to run continuously until killed. The version number is displayed when executed.

Connecting to the Local API Process

Connecting to the local us-zipcode-api process using TLS is currently not supported. This means that the URL scheme will be http instead of https. We recommend using a private network or a proxy to establish encrypted connections if desired. Also, please note that the hostname for the local installation will not be The examples below use localhost. Finally, the default port for the local installation is 8080 rather than 80.

Once the us-zipcode-api program is running, run the following command from another terminal window to send an actual HTTP request to the process:

curl "http://localhost:8080/lookup" --data-binary '[{"zipcode": "84604"}]' | python -m json.tool

If everything is functioning correctly then the output should closely resemble the following JSON object:

		"city_states": [
				"city": "Provo",
				"mailable_city": true,
				"state": "Utah",
				"state_abbreviation": "UT"
				"city": "Provo Canyon",
				"mailable_city": true,
				"state": "Utah",
				"state_abbreviation": "UT"
				"city": "Sundance",
				"mailable_city": true,
				"state": "Utah",
				"state_abbreviation": "UT"
		"input_index": 0,
		"zipcodes": [
				"alternate_counties": [
						"county_fips": "49051",
						"county_name": "Wasatch",
						"state": "Utah",
						"state_abbreviation": "UT"
				"county_fips": "49049",
				"county_name": "Utah",
				"default_city": "Provo",
				"latitude": 40.26549,
				"longitude": -111.65821,
				"precision": "Zip5",
				"state": "Utah",
				"state_abbreviation": "UT",
				"zipcode": "84604",
				"zipcode_type": "S"


Smarty publishes regular updates to both the us-zipcode-api and us-zipcode-data packages. New releases are announced in our open-source Changelog repository.

Docker and Containers

Applications are compiled with a dependency on libc. This means that any container images created must have the libc binary available. In production environments containers based upon officially maintained releases of Debian, Ubuntu, Red Hat, and Fedora base images will work. For containers based upon Alpine Linux, you will need to install the libc dependency. While Alpine Linux is typically used to drastically reduce the size of the base image layers, please remember that the host machine caches these layers so that the cost of downloading the base image is only paid once. The latest official Ubuntu base images are around 25 MB in size.


What follows is a script that you may use to download, install, and run a local instance of the US ZIP Code API. It's Bash. Use it as a starting point for putting in place your own update processes. Your mileage may vary. You're welcome.


# Pro Tip:
#   Replace the placeholder auth values in the `wget` commands
#   below with your own auth-id and auth-token.

# Download the us-zipcode-api package from the download API:
wget -O us-zipcode-api.tar.gz ""

# Download the us-zipcode-api data package from the download API:
wget -O us-zipcode-data.tar.gz ""

# Extract the api package:
tar xvf us-zipcode-api.tar.gz -C .

# Extract the data package:
mkdir ./data; tar xvf us-zipcode-data.tar.gz -C ./data

# Run the us-zipcode-api:
Ready to get started?