Skip to main content
Pinpoint - Smarty's free user conference - October 22nd and 23rdRegister now (opens in new tab)
Smarty

US Reverse Geocoding API - reference

This page describes how to discover the closest street addresses to a latitude/longitude coordinate, a process called "reverse geocoding".

Contents

  1. HTTP request
    1. URL composition
    2. Request methods
    3. Input fields
    4. Headers
  2. HTTP response
    1. Status codes and results
    2. Output field definitions
  3. Supplementary materials
    1. SSL/TLS information

HTTP request: URL composition

Proper URL construction is required for all API requests. Here is an example URL:

https://us-reverse-geo.api.smarty.com/lookup?auth-id=123&auth-token=abc

Here is a more granular examination of the example above:

URL componentsValuesNotes
SchemehttpsNOTE: Non-secure http requests are not supported.
Hostnameus-reverse-geo.api.smarty.com 
Path/lookup 
Query string?auth-id=123&auth-token=abcAuthentication information, inputs, etc. Additional query string parameters are introduced in the next section.
 

For additional information about URLs, please read our article about URL components.

HTTP request: Supported methods/verbs

HTTP requests can be categorized according to their HTTP method. Most HTTP requests are defined using the GET method. We call these "get requests." Other common methods are PUT, POST, and DELETE.

The following methods are supported by this API:

Note: When calling any of our APIs using embedded key authentication, only the HTTP GET method is allowed.

HTTP request: Headers

You must include the following required HTTP headers in all requests:

HeaderDescriptionExample
HostThe Host request header field specifies the Internet host and port number of the resource being requested. Note: Most HTTP clients, such as the browser or programming language HTTP libraries, will add this header automatically.Host: us-reverse-geo.api.smarty.com
RefererThe Referer is required when an embedded key is used for authentication. Its value is a URL, and the host component must match a host value assigned to your embedded key. Note: Some HTTP clients, such as a browser or programming language HTTP libraries, will add this header automatically. However, some interfaces, such as cURL, do not support it, so you may need to add it manually.Referer: https://mycoolwebsite.com

Input fields (Query string parameters)

NameTypeDefault valueDescription
latitudedecimal(empty)Required. The latitude portion of the coordinate. The latitude must be specified as a decimal between -90.0 and 90.0.
longitudedecimal(empty)Required. The longitude portion of the coordinate. The longitude must be specified as a decimal between -180.0 and 180.0.
sourcestringpostalInclude results from alternate data sources. Allowed values are:
all — will include non-postal addresses in the results
postal — will limit the results to postal addresses only

If this parameter is used, an additional field named source will be returned for each result.

Please note that all query string parameter values must be URL-encoded (spaces become + or %20, for example) to ensure that the data is transferred correctly. A common mistake we see is a non-encoded pound sign (#) like in an apartment number (# 409). This character, when properly encoded in a URL, becomes %23. When not encoded, this character serves as the fragment identifier, which our API servers ignore.

HTTP response: Status codes and results

Responses will have a status header with a numeric value. This value is what you should check for when writing code to parse the response. The only response body that should be read and parsed is a 200 response.

Status codeResponse and explanation
401Unauthorized: The credentials were provided incorrectly or did not match any existing, active credentials. Additionally, a unique situation can trigger a 401 error when embedded keys are used server-side from a cloud environment or VPN.
402Payment Required: There is no active subscription for the account associated with the credentials submitted with the request.
400Bad request (malformed payload): The request body was blank or otherwise malformed.
422Unprocessable entity (unsuitable parameters): Returns errors describing what needs to be corrected.
429Too many requests: When using public embedded key authentication, we restrict the number of requests coming from a given source over too short a time. If you use embedded key authentication, you can avoid this error by adding your IP address as an authorized host for the relevant embedded key.
200OK (success!): The response body is a JSON object containing metadata about the results and zero or more addresses derived from the input provided with the request. See the example below for details.

HTTP response body

Rather than writing your own code to parse the JSON response, we recommend using a tried and tested JSON parser that’s specific to your programming language. There is a very comprehensive list of such tools (as well as the complete JSON specification) at json.org.

NOTE: Any returned fields that are not defined within this document should be considered experimental and may be changed or discontinued at any time without notice.

curl -v 'https://us-reverse-geo.api.smarty.com/lookup?
	auth-id=YOUR+AUTH-ID+HERE&
	auth-token=YOUR+AUTH-TOKEN+HERE&
	latitude=40.202605&longitude=-111.621959'

The above sample request yields the following JSON output:

{
	"results": [
		{
			"address": {
				"street": "2335 S State St",
				"city": "Provo",
				"state_abbreviation": "UT",
				"zipcode": "84606",
				"smarty_key": "1649988050"
			},
			"coordinate": {
				"latitude": 40.202583,
				"longitude": -111.621964,
				"license": 1,
				"accuracy": "Rooftop"
			},
			"distance": 2.626235
		},
		{
			"address": {
				"street": "2324 Mountain View Pkwy",
				"city": "Provo",
				"state_abbreviation": "UT",
				"zipcode": "84606",
				"smarty_key": "629428386"
			},
			"coordinate": {
				"latitude": 40.20314,
				"longitude": -111.622162,
				"license": 1,
				"accuracy": "Rooftop"
			},
			"distance": 61.907761
		},
		{
			"address": {
				"street": "2333 Tennessee Ave",
				"city": "Provo",
				"state_abbreviation": "UT",
				"zipcode": "84606",
				"smarty_key": "1319793564"
			},
			"coordinate": {
				"latitude": 40.202518,
				"longitude": -111.621063,
				"license": 1,
				"accuracy": "Rooftop"
			},
			"distance": 76.43438
		},
		{
			"address": {
				"street": "2272 Mountain View Pkwy",
				"city": "Provo",
				"state_abbreviation": "UT",
				"zipcode": "84606",
				"smarty_key": "371916805"
			},
			"coordinate": {
				"latitude": 40.203278,
				"longitude": -111.621552,
				"license": 1,
				"accuracy": "Rooftop"
			},
			"distance": 82.174355
		},
		{
			"address": {
				"street": "2097 Ironton Blvd",
				"city": "Provo",
				"state_abbreviation": "UT",
				"zipcode": "84606",
				"smarty_key": "1606973392"
			},
			"coordinate": {
				"latitude": 40.201946,
				"longitude": -111.622475,
				"license": 1,
				"accuracy": "Rooftop"
			},
			"distance": 85.59359
		},
		{
			"address": {
				"street": "2097 Billings Ave",
				"city": "Provo",
				"state_abbreviation": "UT",
				"zipcode": "84606",
				"smarty_key": "1606973392"
			},	
			"coordinate": {
				"latitude": 40.201946,
				"longitude": -111.622475,
				"license": 1,
				"accuracy": "Rooftop"
			},
			"distance": 85.59359
		},
		{
			"address": {
				"street": "2070 Arizona Ave",
				"city": "Provo",
				"state_abbreviation": "UT",
				"zipcode": "84606",
				"smarty_key": "1815382140"
			},
			"coordinate": {
				"latitude": 40.203026,
				"longitude": -111.62281,
				"license": 1,
				"accuracy": "Parcel"
			},
			"distance": 86.275002
		},
		{
			"address": {
				"street": "2342 Tennessee Ave",
				"city": "Provo",
				"state_abbreviation": "UT",
				"zipcode": "84606",
				"smarty_key": "854839548"
			},
			"coordinate": {
				"latitude": 40.202034,
				"longitude": -111.621262,
				"license": 1,
				"accuracy": "Rooftop"
			},
			"distance": 86.74633
		},
		{
			"address": {
				"street": "2345 Tennessee Ave",
				"city": "Provo",
				"state_abbreviation": "UT",
				"zipcode": "84606",
				"smarty_key": "413612042"
			},
			"coordinate": {
				"latitude": 40.202354,
				"longitude": -111.620903,
				"license": 1,
				"accuracy": "Rooftop"
			},
			"distance": 93.696243
		},
		{
			"address": {
				"street": "2315 S State St",
				"city": "Provo",
				"state_abbreviation": "UT",
				"zipcode": "84606",
				"smarty_key": "1015965304"
			},
			"coordinate": {
				"latitude": 40.203106,
				"longitude": -111.622871,
				"license": 1,
				"accuracy": "Rooftop"
			},
			"distance": 95.567581
		}
	]
}

HTTP response body: Output field definitions

Only non-blank fields will be returned.

Root

Field nameTypeDefinition
resultsarrayThe array of result objects. Each object contains the fields described below in the result section.

Result

Field nameTypeDefinition
distancedecimalThe distance in meters of this address to the input latitude/longitude values, expressed in decimal degrees.
address[Object]See the Address table below.
coordinate[Object]See the Coordinate table below.

Address

Field nameTypeDefinition
streetvarchar(64)The street name of this address.
cityvarchar(64)The city name of this address.
state_abbreviationvarchar(2)The state abbreviation of this address.
zipcodevarchar(5)The 5-digit ZIP Code of this address.
sourcevarchar(6)This field is only returned if the request contained the source parameter. When it is returned, it indicates the data source for this address.

postal — the address is deliverable by the USPS
other — the address was obtained from an alternate source (non-postal)
smarty_keyvarchar(10)Smarty's unique identifier for an address.

Coordinate

Field nameTypeDefinition
latitudedecimalThe latitude value of this address.
longitudedecimalThe longitude value of this address.
accuracyvarchar(18)Indicates the accuracy of the latitude and longitude values.

Unknown — Coordinates not known. Reasons could include: lat/lon coordinates not available.
Zip5 — Accurate to a 5-digit ZIP Code level (least accurate)
Zip6 — Accurate to a 6-digit ZIP Code level
Zip7 — Accurate to a 7-digit ZIP Code level
Zip8 — Accurate to an 8-digit ZIP Code level
Zip9 — Accurate to a 9-digit ZIP Code level
Parcel — Accurate to the centroid of a property parcel.
Rooftop — Accurate to the rooftop of a structure for this address.

Note: Concerning addresses for which the ZIP9 accuracy is not available, the ZIP# accuracy is interpolated based on neighboring addresses. Thus, ZIP7 is an average of all the lat/long coordinates of nearby ZIP Codes that share those first 7 digits.
licenseintThe license ID for the geographic coordinate returned. See the licensing table below for more details.

Geographic coordinate data licenses

IDNameDescription
0SmartyResults with this coordinate license are provided with an open/unrestricted license. Attribution is optional.
1Smarty proprietarySmarty hereby grants a limited, worldwide, non-exclusive, non-transferable (except as authorized herein), revocable license to use this geocoding coordinate consisting of latitude and longitude values and associated metadata for internal business use purposes only and for the duration of the term stated for the online subscription.

SSL/TLS information

Use modern security software and cipher suites

Ready to get started?

Share feedback
What kind?

Use this form to share ideas or feedback for improving our website and products. For help using or implementing a Smarty product, contact support.

This chat is powered by Help Scout. Chats are recorded. Privacy Policy