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

International Postal Code API - reference

Contents

  1. HTTP request
    1. URL composition
    2. Request methods
    3. Headers
    4. Input fields
  2. HTTP response
    1. Status codes and results
    2. Output field definitions
  3. Supplementary material
    1. Full examples
    2. Supported countries
    3. SSL/TLS information
    4. Try the API

HTTP request: URL composition

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

https://international-postal-code.api.smarty.com/lookup?auth-id=123&auth-token=abc

URL components:

  • Scheme: https
    (Required; non-secure http requests are not supported.)
  • Hostname: international-postal-code.api.smarty.com
  • Path: /lookup
  • Query string: ?auth-id=123&auth-token=abc
    Note #1: Additional query string parameters are required; consult the next section.

For additional information, 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:

HTTP GET

To send one (and only one) address to our API, simply encode the input field names from the table below along with the corresponding input values as query string parameters in the URL of your request. Here's an example that uses locality, administrative_area, postal_code, and country fields:

curl -v 'https://international-postal-code.api.smarty.com/lookup?
	auth-id=YOUR+AUTH-ID+HERE&
	auth-token=YOUR+AUTH-TOKEN+HERE&

	locality=Sao+Paulo&
	administrative_area=SP&
	postal_code=02516-040&
	country=Brazil'

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 non-encoded pound sign (#), like in an apartment number (# 409), is a common mistake we see. This character, when properly encoded in a URL, becomes %23. When not encoded, this character functions as the fragment identifier, which our API servers ignore.

HTTP request: Headers

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

HostThe Host request header field specifies the Internet host and port number of the resource being requestedHost: international-postal-code.api.smarty.com

Input fields

Each query submitted must have non-blank values for one of the following field combinations to be processed. Any combination of parameters may be submitted to narrow the search criterion.

  • country + locality
  • country + administrative_area
  • country + postal_code

A maximum of 1,000 results will be returned for each query. Since there’s no paging capability to return more than the maximum number of results, you will need to refine your search to return fewer results.

Transliteration isn’t available in this API. All results will be returned using the Latin character set.

NameTypeMax charactersDescription
input_idstring36A unique identifier generated by you for this address for use within your application; this field will be copied into the output.
(e.g., 123456)
countrystring64(required) This must be entered with every address. Country Name or ISO classification (ISO-3, ISO-2, or ISO-N). Address validation will fail if this is missing.
(e.g., Brazil, BRA, BR, or 076)
languagestring6Supported values are: "latin" and "native". When set to "native" (JPN only), it will return results in the native character set for that country. When set to "latin", the results will always be returned using a Latin character set with accents and other diacritics removed. 
localitystring64The city name
(e.g., Paris).
administrative_areastring32The state or province name or abbreviation
(e.g., Alberta or AB)
postal_codestring16The postal code
(e.g., T4B 5M7). You may submit a postal code prefix to widen your search. (e.g., T4B 5)
licensestring64The license or licenses (comma-separated) to use for this lookup. Valid values can be found in the account dashboard under the appropriate subscription. If multiple licenses are specified, they are considered in left-to-right order.

HTTP response: Status codes and results

Responses will have a status header with a numeric value. You should check for this value 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 in a cloud environment or via a VPN.
402Payment required: There is no active subscription associated with the credentials submitted with the request.
400Bad request (malformed payload): The request inputs couldn’t be interpreted.
422Unprocessable entity: A GET request lacked required fields.
429Too many requests: Too many requests with exactly the same input values were submitted within too short a period. This status code indicates that the input was not processed to prevent runaway charges caused by conditions such as a misbehaving (infinite) loop that sends the same record over and over to the API. You're welcome.
429 (again)Too 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.
504Gateway timeout: Our upstream data provider did not respond in a timely manner, so the request failed. A serious, yet rare occurrence indeed.
200OK (success!): A JSON object containing zero or more matches for the input provided with the request. If the input is not valid or no matches are found, the object will contain an empty array {"results":[]}.

Full example: Query by locality and administrative area

Request

curl -v 'https://international-postal-code.api.smarty.com/lookup?
	auth-id=YOUR+AUTH-ID+HERE&
	auth-token=YOUR+AUTH-TOKEN+HERE&

	locality=Sao+Paulo&
	administrative_area=SP&
	country=Brazil'

Response

Only the first three results are shown. The API may return up to 1,000 results.

{
	"results": [
		{
			"administrative_area": "SP",
			"country_iso_3": "BRA",
			"locality": "São Paulo",
			"postal_code": "02245-000"
		},
		{
			"administrative_area": "SP",
			"country_iso_3": "BRA",
			"locality": "São Paulo",
			"postal_code": "02418-140"
		},
		{
			"administrative_area": "SP",
			"country_iso_3": "BRA",
			"locality": "São Paulo",
			"postal_code": "02478-000"
		}
		... results truncated ...
	]
}

Full example: Query by postal code

Request

curl -v 'https://international-postal-code.api.smarty.com/lookup?
	input_id=1234&
	auth-id=YOUR+AUTH-ID+HERE&
	auth-token=YOUR+AUTH-TOKEN+HERE&

	postal_code=02516-040&
	country=Brazil

Response

{
	"results": [
		{
			"input_id": "1234",
			"administrative_area": "SP",
			"country_iso_3": "BRA",
			"locality": "São Paulo",
			"dependent_locality": "Casa Verde",
			"postal_code": "02516-040"
		}
	]
}

Full example: Query by postal code with language parameter (JPN only)

Request

curl -v 'https://international-postal-code.api.smarty.com/lookup?
	input_id=1234&
	auth-id=YOUR+AUTH-ID+HERE&
	auth-token=YOUR+AUTH-TOKEN+HERE&
    postal_code=891-3607&
	country=JPN&
    language=native

Response

[
  {
    "input_id": "1234",
    "administrative_area": "鹿児島県",
    "country_iso_3": "JPN",
    "locality": "熊毛郡",
    "dependent_locality": "中種子町",
    "thoroughfare": "田島",
    "postal_code": "891-3607"
  }
]

Output fields

A maximum of 1,000 results will be returned for each query. Since there’s no paging capability to return more than the maximum number of results, you will need to refine your search to return fewer results.

Transliteration isn’t available in this API. All results will be returned using the Latin character set.

Field nameTypeDefinition
input_idvarchar(16)A unique identifier generated by you for this address for use within your application. The output will be identical to the value you provided in the request input_id.
administrative_areavarchar(64)The most common administrative division within a country
(e.g., province in Canada)
super_administrative_areavarchar(64)The largest administrative division within a country
(e.g., region in France)
sub_administrative_areavarchar(64)The smallest administrative division within a country
(e.g., a county in Germany)
localityvarchar(64)Within a country, this is the most common population center.
(e.g., a city in Chile)
dependent_localityvarchar(64)If there is additional information about the locality, it will be here.
(e.g., neighborhood in Turkey)
dependent_locality_namevarchar(64)If the dependent_locality has a name, you'll find it here.
(E.g., the dependent_locality "Dong Cheng Qu" is named "Dong Cheng.")
double_dependent_localityvarchar(64)If there is additional information about the dependent_locality, you'll find it here.
(e.g., village in the United Kingdom)
postal_codevarchar(64)The complete postal code for the delivery point
(e.g., V6G1V9 in Canada)
postal_code_extravarchar(64)Secondary postal code information
(e.g., 3425 in the United States)
thoroughfarevarchar(64)Returns the equivalent of a neighborhood for some countries. This is currently only returned for Japan (JPN).
country_iso_3varchar(3)The ISO 3166-1 alpha-3 country code. See our full listing for details.

Supported countries

For a list of supported countries, see our international Address Autocomplete API documentation.

SSL/TLS information

Use modern security software and cipher suites.

Was this helpful?

Ready to get started?

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