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

International Address Autocomplete API - reference

This page describes how to use the Smarty International Address Autocomplete API. (Free testing accounts available.)

Contents

  1. Overview
    1. Features
  2. HTTP request
    1. URL composition
    2. Request methods
    3. Request headers
    4. Input fields
  3. HTTP response
    1. Status codes and results
    2. Example response
  4. Supplementary material
    1. Supported character sets
    2. Supported countries
    3. Subscription usage
    4. SSL/TLS information
    5. Try the live API

Features

  • Returns suggestions that are fully verified global addresses.
  • Uses fuzzy logic during searching to:
    • Allow for missing directionals and street suffixes.
    • Allow substitution of street suffixes and unit designators. E.g., ST is accepted for AVE; APT is accepted for UNIT, etc.
    • Allow full or partial spelling of street suffixes and unit designators. E.g., ST can be spelled as STR or STREET and still match.
    • Filters allow for multiple cities or postal codes in a single country.

Note: Effective with the adoption of the V2 version of International Address Autocomplete, lookup usage will be based on the final selection of an address rather than per keystroke.

HTTP request: URL composition

Proper URL construction is required for all API requests. Here is an example URL (with line breaks for readability):

https://international-autocomplete.api.smarty.com/v2/lookup[/{address_id}]?
key=YOUR+EMBEDDED+KEY+HERE

Here is a more granular examination of the example above:

URL componentsValuesNotes
SchemehttpsNon-secure http requests are not supported.
Hostnameinternational-autocomplete.api.smarty.com 
Path/v2/lookup 
Address ID The Address ID is used to get further information about a particular result. This value will be supplied by a previous call to the API. This parameter should not be supplied when the search query parameter is used. See Address ID in the URL for usage information.
Query string

?key=YOUR+EMBEDDED+KEY+HERE

OR

?auth-id=YOUR+AUTH-ID+HERE&auth-token=YOUR+AUTH-TOKEN+HERE

You may use either "embedded key" or "secret key" authentication. Remember to be careful how you use "secret key" authentication. See our authentication documentation. 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 which are not supported in this API.

The following methods are supported by this API:

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

Please note that all query string parameter values must be UTF-8 characters, which are then url-encoded (spaces become + or %20, for example) to ensure that the data is transferred correctly. Common mistakes we see are non-encoded commas, semicolons, and pound signs. Pound signs (#) like in an apartment number (# 409), when properly encoded in a URL, become %23. When not encoded, this character functions as the fragment identifier, which is ignored by our API servers.

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: international-autocomplete.api.smarty.com
RefererThe Referer is required when an embedded key is used for authentication. Its value is in the form of a URL, where 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, so you may need to add it manually.Referer: https://mycoolwebsite.com

Input Fields

NameTypeDefault valueDescription
countrystring(empty)Required. The ISO3 Alpha-3 country code where the desired address is located. Only uppercase values are allowed. See supported country codes. Maximum length is 3 bytes.
searchstring(empty)The part of the address that has already been typed. Maximum character count is 32 characters. Required when Address ID is not specified in the URL.
max_resultsinteger5Maximum number of address suggestions to return; range [1, 10].
max_group_resultsinteger100Maximum number of address suggestions to return when expanding address groups with an Address ID; range [1, 100].
geolocationstring(empty)Bias (prefer) results based on the location of the sender's IP address (IPv4 only).
Valid value: on

Supported countries: CAN, AUS, DEU.
If the request to the API goes through a proxy, you will need to set an X-Forwarded-For header specifying the desired IP address for the request.
 
include_only_localitystring(empty)Limit the results to only the localities provided. A locality is a significant population center (i.e. city, town, or village). When this parameter is used, include_only_postal_code cannot be used. Separate multiple values with a comma.
Example: Paris,Versailles
 
include_only_postal_codestring(empty)Limit the results to only the postal codes provided. When this parameter is used, include_only_locality cannot be used. Separate multiple values with a comma.
Example: 29200,29201
 

All input field parameters must be UTF-8 and then URL encoded.

Address ID in the URL

All summary results are returned with an address_id which allows you to get more details on known entries for that result.

You specify the address_id in the URL following the /v2/lookup path as in the following example. This should not be provided when the search parameter is used in the query string.

curl 'https://international-autocomplete.api.smarty.com/v2/lookup/PD4DPC8DPgNORk9MTQ?key=YOUR+EMBEDDED+KEY+HERE&country=FRA'

You must still specify a country and your authentication information in the query string. Additionally, the max_results parameter will be disregarded in order to provide more subunit results, up to the first 100 entries.

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 embedded key was provided incorrectly or did not match any existing, active embedded keys. Or the host in the referer header did not match a host assigned to your embedded key.
402Payment required: There is no active subscription for the account associated with the credentials submitted with the request.
400Bad request (malformed payload): The request was malformed in some way and could not be parsed.
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 of a time. You can avoid this error by adding your IP address as an authorized host for the embedded key in question.
200OK (success!): The response body is a JSON object with a suggestions array containing suggestions based on the supplied input parameters.

Example response

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. In addition, the address_id returned in each result isn’t considered to be persistent. They are not to be stored and reused at a later time, as they’re only guaranteed to be valid for the duration of a user session.

The resulting JSON from a query contains a candidates array of suggestions. There are two types of results you can receive depending on the query.

Summary results

curl 'https://international-autocomplete.api.smarty.com/v2/lookup?search=123+main&country=CAN&key=YOUR+EMBEDDED+KEY+HERE' -H 'referer: https://myneatwebsite.com'

These results are designed to be displayed in a dropdown select list, allowing the user to continue typing to narrow the search. Calls of this type won’t be charged to your account.

The fields in these results are as follows:

  • entries
  • address_text
  • address_id

Here is an example of an actual response JSON based on the above query:


{
	"candidates": [
		{
			"entries": 12,
			"address_text": "123 Main St Winnipeg, MB, R3C",
			"address_id": "PD4DPC8DOjE4AzI9Uig2MTE2Lzo4UjI+NjEgLCtSTk1M"
		},
		{
			"entries": 5,
			"address_text": "123 Main St Ottawa, ON, K1S 1B9",
			"address_id": "PD4DPC8DOjE4AzAxUjArKz4oPlIyPjYxICwrUk5NTA"
		},
		{
			"entries": 1,
			"address_text": "123 Main St Fredericton, NB, E3A 1C6",
			"address_id": "PD4DPC8DPgNHRkxMTEhO"
		}
	]
}

The entries field indicates how many addresses are associated with the specific address_id.

When entries has a value greater than 1, it means that when you query again using the address_id in the URL, you will get results associated with that address_id, such as subunits (secondaries). These results will also be Summary Results, and you will receive the first 100 results.

When entries has a value of 1, it means that when you query again using the address_id in the URL you will receive a Detailed Result.

Detailed results

curl 'https://international-autocomplete.api.smarty.com/v2/lookup/PD4DPC8DPgNHRkxMTEhO?country=CAN&key=YOUR+EMBEDDED+KEY+HERE' -H 'referer: https://myneatwebsite.com'

When you query using an address_id on a result where entries equals 1, you will receive a detailed result. Your account will be charged for each call of this type.

The fields in these results are as follows:

  • street
  • locality
  • administrative_area
  • administrative_area_short
  • administrative_area_long
  • postal_code
  • country_iso3

...which you can use to fill form fields.

Depending on the country, some components may not be returned. Here is an example of an actual response JSON:


{
	"candidates": [
		{
			"street": "1-123 Main St",
			"locality": "Fredericton",
			"administrative_area": "NB",
			"administrative_area_short": "NB",
			"administrative_area_long": "New Brunswick",
			"postal_code": "E3A 1C7",
			"country_iso3": "CAN"
		}
	]
}

Supported character sets

By default, the character set returned will be the native set for that country. If any Latin characters are provided in the input (excluding numerics), the Latin character set will be returned.

  • Cyrillic
  • Greek
  • Hebrew
  • Kanji (Japanese)
  • Simplified Chinese
  • Arabic
  • Thai
  • Hangul (Korean)

Supported countries

  • Supports the following countries:

    CountryISO3 Alpha-3
    Country Code
    AfghanistanAFG
    AlbaniaALB
    AlgeriaDZA
    AndorraAND
    AngolaAGO
    AnguillaAIA
    AntarcticaATA
    Antigua and BarbudaATG
    ArgentinaARG
    ArmeniaARM
    ArubaABW
    AustraliaAUS
    AustriaAUT
    AzerbaijanAZE
    BahamasBHS
    BahrainBHR
    BangladeshBGD
    BarbadosBRB
    BelarusBLR
    BelgiumBEL
    BelizeBLZ
    BeninBEN
    BermudaBMU
    BhutanBTN
    BoliviaBOL
    Bonaire, Sint Eustatius, and SabaBES
    Bosnia and HerzegovinaBIH
    BotswanaBWA
    Bouvet IslandBVT
    BrazilBRA
    British Indian Ocean TerritoryIOT
    Brunei DarussalamBRN
    BulgariaBGR
    Burkina FasoBFA
    BurundiBDI
    CambodiaKHM
    CameroonCMR
    CanadaCAN
    Cabo VerdeCPV
    Cayman IslandsCYM
    Central African RepublicCAF
    ChadTCD
    ChileCHL
    ChinaCHN
    Christmas IslandCXR
    Cocos (Keeling) IslandsCCK
    ColombiaCOL
    ComorosCOM
    CongoCOG
    Democratic Republic of the CongoCOD
    Cook IslandsCOK
    Costa RicaCRI
    CroatiaHRV
    CubaCUB
    CuraçaoCUW
    CyprusCYP
    CzechiaCZE
    Ivory CoastCIV
    DenmarkDNK
    DjiboutiDJI
    DominicaDMA
    Dominican RepublicDOM
    EcuadorECU
    EgyptEGY
    El SalvadorSLV
    Equatorial GuineaGNQ
    EritreaERI
    EstoniaEST
    EswatiniSWZ
    EthiopiaETH
    Falkland IslandsFLK
    Faroe IslandsFRO
    FijiFJI
    FinlandFIN
    FranceFRA
    French GuianaGUF
    French PolynesiaPYF
    French Southern TerritoriesATF
    GabonGAB
    GambiaGMB
    GeorgiaGEO
    GermanyDEU
    GhanaGHA
    GibraltarGIB
    GreeceGRC
    GreenlandGRL
    GrenadaGRD
    GuadeloupeGLP
    GuatemalaGTM
    GuernseyGGY
    GuineaGIN
    Guinea-BissauGNB
    GuyanaGUY
    HaitiHTI
    Heard Island and McDonald IslandsHMD
    Holy SeeVAT
    HondurasHND
    Hong KongHKG
    HungaryHUN
    IcelandISL
    IndiaIND
    IndonesiaIDN
    Islamic Republic of IranIRN
    IraqIRQ
    IrelandIRL
    Isle of ManIMN
    IsraelISR
    ItalyITA
    JamaicaJAM
    JapanJPN
    JerseyJEY
    JordanJOR
    KazakhstanKAZ
    KenyaKEN
    KiribatiKIR
    Democratic People's Republic of Korea (North Korea)PRK
    Republic of KoreaKOR
    KosovoXKX
    KuwaitKWT
    KyrgyzstanKGZ
    Lao People's Democratic RepublicLAO
    LatviaLVA
    LebanonLBN
    LesothoLSO
    LiberiaLBR
    LibyaLBY
    LiechtensteinLIE
    LithuaniaLTU
    LuxembourgLUX
    MacaoMAC
    Republic of North MacedoniaMKD
    MadagascarMDG
    MalawiMWI
    MalaysiaMYS
    MaldivesMDV
    MaliMLI
    MaltaMLT
    MartiniqueMTQ
    MauritaniaMRT
    MauritiusMUS
    MayotteMYT
    MexicoMEX
    Republic of MoldovaMDA
    MonacoMCO
    MongoliaMNG
    MontenegroMNE
    MontserratMSR
    MoroccoMAR
    MozambiqueMOZ
    MyanmarMMR
    NamibiaNAM
    NauruNRU
    NepalNPL
    NetherlandsNLD
    New CaledoniaNCL
    New ZealandNZL
    NicaraguaNIC
    NigerNER
    NigeriaNGA
    NiueNIU
    Norfolk IslandNFK
    NorwayNOR
    OmanOMN
    PakistanPAK
    State of PalestinePSE
    PanamaPAN
    Papua New GuineaPNG
    ParaguayPRY
    PeruPER
    PhilippinesPHL
    PitcairnPCN
    PolandPOL
    PortugalPRT
    QatarQAT
    South SudanSSD
    RomaniaROU
    Russian FederationRUS
    RwandaRWA
    RéunionREU
    Saint BarthélemyBLM
    Saint Helena, Ascension, and Tristan da CunhaSHN
    Saint Kitts and NevisKNA
    Saint LuciaLCA
    Saint MartinMAF
    Saint Pierre and MiquelonSPM
    Saint Vincent and the GrenadinesVCT
    SamoaWSM
    San MarinoSMR
    São Tomé and PríncipeSTP
    Saudi ArabiaSAU
    SenegalSEN
    SerbiaSRB
    SeychellesSYC
    Sierra LeoneSLE
    SingaporeSGP
    Sint Maarten (Dutch)SXM
    SlovakiaSVK
    SloveniaSVN
    Solomon IslandsSLB
    SomaliaSOM
    South AfricaZAF
    South Georgia and the South Sandwich IslandsSGS
    SpainESP
    Sri LankaLKA
    SudanSDN
    SurinameSUR
    Svalbard and Jan Mayen IslandsSJM
    SwedenSWE
    SwitzerlandCHE
    Syrian Arab RepublicSYR
    TaiwanTWN
    TajikistanTJK
    United Republic of TanzaniaTZA
    ThailandTHA
    Timor-LesteTLS
    TogoTGO
    TokelauTKL
    TongaTON
    Trinidad and TobagoTTO
    TunisiaTUN
    Türkiye (Turkey)TUR
    TurkmenistanTKM
    Turks and Caicos IslandsTCA
    TuvaluTUV
    UgandaUGA
    UkraineUKR
    United Arab EmiratesARE
    United KingdomGBR
    UruguayURY
    UzbekistanUZB
    VanuatuVUT
    Bolivarian Republic of VenezuelaVEN
    Viet NamVNM
    British Virgin IslandsVGB
    Wallis and FutunaWLF
    Western SaharaESH
    YemenYEM
    ZambiaZMB
    ZimbabweZWE
    Åland IslandsALA

Subscription usage

Beyond ensuring that requests include proper authentication, clients of the International Address Autocomplete API must maintain an active API 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