Documentation

 

Local US Autocomplete API

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

Contents

  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. Automation

Glossary

Throughout this document we use the following consistently formatted terms:

  • US Autocomplete API

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

  • us-autocomplete-data

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

  • us-autocomplete-api

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

  • us-autocomplete-api

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

API Documentation

A local installation of the US Autocomplete API performs identically to the cloud version hosted by SmartyStreets. 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.

Prerequisites

Access to local US Autocomplete 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 Autocomplete 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 Autocomplete 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 Autocomplete API binaries should match the following criteria:

  • 1+ gigabytes of RAM
  • Multiple 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 Autocomplete API requires two packages that are available for download via the SmartyStreets Download API:

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

  • us-autocomplete-api
  • Includes the compiled program (redundantly named us-autocomplete-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-autocomplete-api program expects the extracted contents of the data package to be found at ./data.

Managing the Local API Process

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

NOTE: Running the us-autocomplete-api program starts a process that is designed to run continuously until killed.

Connecting to the Local API Process

Connecting to the local us-autocomplete-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 us-autocomplete.api.smartystreets.com. The examples below use localhost. Finally, the default port for the local installation is 8080 rather than 80.

Once the us-autocomplete-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/suggest?prefix=123+mai" | python -m json.tool

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

{
    "suggestions": [
        {
            "city": "Haiku",
            "state": "HI",
            "street_line": "123 Mai Pl",
            "text": "123 Mai Pl, Haiku HI"
        },
        {
            "city": "Amston",
            "state": "CT",
            "street_line": "123 Mai Rd",
            "text": "123 Mai Rd, Amston CT"
        },
        {
            "city": "Desoto",
            "state": "TX",
            "street_line": "123 Mai Ave",
            "text": "123 Mai Ave, Desoto TX"
        },
        {
            "city": "Lutz",
            "state": "FL",
            "street_line": "123 Mai Estates Ln",
            "text": "123 Mai Estates Ln, Lutz FL"
        },
        {
            "city": "Fort Mill",
            "state": "SC",
            "street_line": "123 Mai Kai Way",
            "text": "123 Mai Kai Way, Fort Mill SC"
        },
        {
            "city": "Jbsa Lackland",
            "state": "TX",
            "street_line": "123 Mai Kai Dr",
            "text": "123 Mai Kai Dr, Jbsa Lackland TX"
        },
        {
            "city": "Bonita Springs",
            "state": "FL",
            "street_line": "123 Mai Kai Ln",
            "text": "123 Mai Kai Ln, Bonita Springs FL"
        },
        {
            "city": "Baton Rouge",
            "state": "LA",
            "street_line": "123 Mai Frances Pl",
            "text": "123 Mai Frances Pl, Baton Rouge LA"
        },
        {
            "city": "Wisconsin Rapids",
            "state": "WI",
            "street_line": "123 Mai Chee Trl",
            "text": "123 Mai Chee Trl, Wisconsin Rapids WI"
        },
        {
            "city": "Jbsa Ft Sam Houston",
            "state": "TX",
            "street_line": "123 Mai Kai Dr",
            "text": "123 Mai Kai Dr, Jbsa Ft Sam Houston TX"
        }
    ]
}

Updates

SmartyStreets publishes regular updates to both the us-autocomplete-api and us-autocomplete-data packages. We recommend that you download and install these updates on at least a monthly basis.

Automation

What follows is a script that you may use to download, install, and run a local instance of the US Autocomplete 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.

#!/bin/bash

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

# Download the us-autocomplete-api package from the download API:
wget -O us-autocomplete-api.tar.gz "https://download.api.smartystreets.com/us-autocomplete-api/linux-amd64/latest.tar.gz?auth-id=YOUR_AUTH_ID&auth-token=YOUR_AUTH_TOKEN"

# Download the us-autocomplete-api data package from the download API:
wget -O us-autocomplete-data.tar.gz "https://download.api.smartystreets.com/us-autocomplete-api/data/latest.tar.gz?auth-id=YOUR_AUTH_ID&auth-token=YOUR_AUTH_TOKEN"

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

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

# Run the us-autocomplete-api:
./us-autocomplete-api