Solutions
Resources
Pricing
Sign in
Get a free trial
Products
Solutions
Resources
Pricing
Contact us
Contact us
Developer guides
Developer guides
The Distance Matrix API
The Distance Matrix API
The Geocoding API
The Geocoding API
The Asynchronous Distance Matrix API (Beta)
The Asynchronous Distance Matrix API (Beta)
Distance Matrix API guide
Geocoding API guide
Distance Matrix API guide
Geocoding API guide
DM API application guide
DM API application guide
Taxi services
Food delivery
Taxi services
Courier services
Logistics & Transportation
Courier services
Logistics & Transportation
Distance Matrix pricing
Distance Matrix pricing
Geocoding pricing
Geocoding pricing
Our news
Our news
Useful guides
Useful guides
Case studies
Case studies

Developer Guide

The Geocoding API

Introduction
Introduction
Geocoding (Latitude/ Longitude Lookup)
Geocoding (Latitude/ Longitude Lookup)
Reverse Geocoding (Address Lookup)
Reverse Geocoding (Address Lookup)
Introduction
Before you begin
Before you begin
Request format
Request format
Before you begin
Geocoding is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain View, CA") into geographic coordinates (like latitude 37.423021 and longitude -122.083739), which you can use to place markers on a map, or position the map.

Reverse geocoding is the process of converting geographic coordinates into a human-readable address.

The Geocoding API provides a direct way to access these services via an HTTP request.

This document describes the Geocoding API web service. It is intended for website and mobile developers who want to use geocoding data within maps.
* Note: This service is generally designed for geocoding static (known in advance) addresses for placement of application content on a map.
Geocoding API Request Format
A Geocoding API request takes the following form:
GET:
https://api.distancematrix.ai/maps/api/geocode/json?parameters
The Geocoding API request was created specifically to be similar to the Google Geocoding API request format.
Request Parameters
Security is important and HTTPS is recommended whenever possible, especially for applications that include sensitive user data, such as a user's location, in requests. Using HTTPS encryption makes your application more secure, and more resistant to snooping or tampering.

Some parameters are required while some are optional. As is standard in URLs, parameters are separated using the ampersand (&) character.

The rest of this page describes geocoding and reverse geocoding separately, because different parameters are available for each type of request.
Geocoding API Request Format
A Geocoding API request takes the following form:
GET:
https://api.distancematrix.ai/maps/api/
geocode/json?parameters
The Geocoding API request was created specifically to be similar to the Google Geocoding API request format.
Request Parameters
Security is important and HTTPS is recommended whenever possible, especially for applications that include sensitive user data, such as a user's location, in requests. Using HTTPS encryption makes your application more secure, and more resistant to snooping or tampering.

Some parameters are required while some are optional. As is standard in URLs, parameters are separated using the ampersand (&) character.

The rest of this page describes geocoding and reverse geocoding separately, because different parameters are available for each type of request.
Geocoding (Latitude/Longitude Lookup)
Required Parameters
Optional Parameters
Optional Parameters
Geocoding Responses
Geocoding Responses
Status Codes
Status Codes
Error Messages
Error Messages
Results
Results
Required parameters in a geocoding request:
address — The street address that you want to geocode. Specify addresses in accordance with the format used by the national postal service of the country concerned. Additional address elements such as business names and unit, suite or floor numbers should be avoided. Street address elements should be delimited by spaces (shown here as url-escaped to %20):
key — Your application's API key. This key identifies your application for purposes of quota management.
address=24%20Sussex%20Drive%20Ottawa%20ON
Optional parameters in a Geocoding request:
language — The language in which to return results.
See the list of supported languages.
If language is not supplied, the geocoder attempts to use the preferred language as specified in the Accept-Language header, or the native language of the domain from which the request is sent.
The geocoder does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component.
If a name is not available in the preferred language, the geocoder uses the closest match.
The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and tér are synonyms for street and square respectively in Hungarian.
Show languages
Hide languages
Show languages
Language Code
Language
Language Code
Language
af
Afrikaans
ja
sq
Albanian
kn
Kannada
am
Amharic
kk
Kazakh
Japanese
ar
Arabic
km
hy
Armenian
ko
Korean
az
Azerbaijani
ky
Kyrgyz
Khmer
eu
Basque
lo
be
Belarusian
lv
Latvian
bn
Bengali
lt
Lithuanian
Lao
bs
Bosnian
mk
bg
Bulgarian
ms
Malay
my
Burmese
ml
Malayalam
Macedonian
ca
Catalan
mr
zh
Chinese
mn
Mongolian
zh-CN
Chinese (Simplified)
ne
Nepali
Marathi
zh-HK
Chinese (Hong Kong)
no
zh-TW
Chinese (Traditional)
pl
Polish
hr
Croatian
pt
Portuguese
Norwegian
cs
Czech
pt-BR
da
Danish
pt-PT
Portuguese (Portugal)
nl
Dutch
pa
Punjabi
Portuguese (Brazil)
en
English
ro
en-AU
English (Australian)
ru
Russian
en-GB
English (Great Britain)
sr
Serbian
Romanian
et
Estonian
si
Sinhalese
fa
Farsi
sk
Slovak
fi
Finnish
sl
fil
Filipino
es
Spanish
fr
French
es-419
Spanish (Latin America)
Slovenian
fr-CA
French (Canada)
sw
gl
Galician
sv
Swedish
ka
Georgian
ta
Tamil
Swahili
de
German
te
el
Greek
th
Thai
gu
Gujarati
tr
Turkish
Telugu
iw
Hebrew
uk
hi
Hindi
ur
Urdu
hu
Hungarian
uz
Uzbek
Ukrainian
is
Icelandic
vi
id
Indonesian
zu
Zulu
it
Italian
Vietnamese
region — The region code, specified as a ccTLD ("top-level domain") two-character value. This parameter will only influence, not fully restrict, results from the geocoder.
Geocoding Responses
Geocoding responses are returned in the format indicated by the output flag within the URL request's path.

In this example, the Geocoding API requests a json response for a query on "1600 Amphitheatre Parkway, Mountain View, CA".
This request demonstrates using the JSON output flag:
BODY
The sample JSON response:
BODY
https://api.distancematrix.ai/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA
&key=<your_access_token>
{ "result": [ "address_components": [ { "long_name": "1600", "short_name": "1600", "types": [ "street_number" ] } ], "formatted_address": "1600 Amphitheatre Parkway, Mountain View, CA", "geometry": { "geometry": { "lat": 37.4220579, "lng": -122.08408969999998 }, "location_type": "APPROXIMATE", "viewport": { "northeast": { "lat": 37.4220579, "lng": -122.08408969999998 }, "southwest": { "lat": 37.4220579, "lng": -122.08408969999998 } } }, "place_id": "", "plus_code": { "compound_code": "CWC8+R9 Mountain View, California, United States", "global_code": "849VCWC8+R9" }, "types": [ "locality", "political" ] ], "status": "OK" }
Geocoding Responses
Geocoding responses are returned in the format indicated by the output flag within the URL request's path.

In this example, the Geocoding API requests a json response for a query on "1600 Amphitheatre Parkway, Mountain View, CA".
This request demonstrates using the JSON output flag:
BODY
The sample JSON response:
BODY
https://api.distancematrix.ai/maps/api/
geocode/json?address=1600+Amphitheatre+
Parkway,+Mountain+View,+CA
&key=<your_access_token>
{ "result": [ "address_components": [ { "long_name": "1600", "short_name": "1600", "types": [ "street_number" ] } ], "formatted_address": "1600 Amphitheatre Parkway, Mountain View, CA", "geometry": { "geometry": { "lat": 37.4220579, "lng": -122.08408969999998 }, "location_type": "APPROXIMATE", "viewport": { "northeast": { "lat": 37.4220579, "lng": -122.08408969999998 }, "southwest": { "lat": 37.4220579, "lng": -122.08408969999998 } } }, "place_id": "", "plus_code": { "compound_code": "CWC8+R9 Mountain View, California, United States", "global_code": "849VCWC8+R9" }, "types": [ "locality", "political" ] ], "status": "OK" }
"status" contains metadata on the request. See Status Codes below.
Note that the JSON response contains two root elements:
"results" contains an array of geocoded address information and geometry information.
Generally, only one entry in the "results" array is returned for address lookups,though the geocoder may return several results when address queries are ambiguous.

Note that these results generally need to be parsed if you wish to extract values from the results. Parsing JSON is relatively easy.
Status Codes
The "status" field within the Geocoding response object contains the status of the request, and may contain debugging information to help you track down why geocoding is not working. The "status" field may contain the following values:
"OK" indicates that no errors occurred; the address was successfully parsed and at least one geocode was returned.
The API key is missing or invalid.
Billing has not been enabled on your account.
A self-imposed usage cap has been exceeded.
"ZERO_RESULTS" indicates that the geocode was successful but returned no results. This may occur if the geocoder was passed a non-existent address.
"OVER_DAILY_LIMIT" indicates any of the following:
"REQUEST_DENIED" indicates that your request was denied.
"INVALID_REQUEST" generally indicates that the query (address, components or latlng) is missing.
"UNKNOWN_ERROR" indicates that the request could not be processed due to a server error. The request may succeed if you try again.
"OVER_QUERY_LIMIT" indicates that you are over your quota.
Error Messages
When the geocoder returns a status code other than OK, there may be an additional error_message field within the Geocoding response object. This field contains more detailed information about the reasons behind the given status code.
* Note: This field is not guaranteed to be always present, and its content is subject to change.
Results
When the geocoder returns results, it places them within a (JSON) results array. Even if the geocoder returns no results (such as if the address doesn't exist) it still returns an empty results array.
The types[] array indicates the type of the returned result. This array contains a set of zero or more tags identifying the type of feature returned in the result. For example, a geocode of "Chicago" returns "locality" which indicates that "Chicago" is a city, and also returns "political" which indicates it is a political entity.
A typical result contains the following fields:
formatted_address is a string containing the human-readable address of this location. Often this address is equivalent to the postal address. Note that some countries, such as the United Kingdom, do not allow distribution of true postal addresses due to licensing restrictions. The formatted address is logically composed of one or more address components. For example, the address "111 8th Avenue, New York, NY" consists of the following components: "111" (the street number), "8th Avenue" (the route), "New York" (the city) and "NY" (the US state). Do not parse the formatted address programmatically. Instead you should use the individual address components, which the API response includes in addition to the formatted address field.
address_components[] is an array containing the separate components applicable to this address.
Each address component typically contains the following fields:
types[] is an array indicating the type of the address component.
long_name is the full text description or name of the address component as returned by the Geocoder.
short_name is an abbreviated textual name for the address component, if available. For example, an address component for the state of Alaska may have a long_name of "Alaska" and a short_name of "AK" using the 2-letter postal abbreviation.
Note the following facts about the address_components[] array:
The array of address components may contain more components than the formatted_address.
The array does not necessarily include all the political entities that contain an address, apart from those included in the formatted_address. To retrieve all the political entities that contain a specific address, you should use reverse geocoding, passing the latitude/longitude of the address as a parameter to the request.
The format of the response is not guaranteed to remain the same between requests. In particular, the number of address_components varies based on the address requested and can change over time for the same address. A component can change position in the array. The type of the component can change. A particular component may be missing in a later response.
To handle the array of components, you should parse the response and select appropriate values via expressions.
postcode_localities[] is an array denoting all the localities contained in a postal code. This is only present when the result is a postal code that contains multiple localities.
geometry contains the following information:
location contains the geocoded latitude, longitude value. For normal address lookups, this field is typically the most important.
location_type stores additional data about the specified location. The following values are currently supported:
"ROOFTOP" indicates that the returned result is a precise geocode for which we have location information accurate down to street address precision.
"RANGE_INTERPOLATED" indicates that the returned result reflects an approximation (usually on a road) interpolated between two precise points (such as intersections). Interpolated results are generally returned when rooftop geocodes are unavailable for a street address.
"GEOMETRIC_CENTER" indicates that the returned result is the geometric center of a result such as a polyline (for example, a street) or polygon (region).
"APPROXIMATE" indicates that the returned result is approximate.
partial_match indicates that the geocoder did not return an exact match for the original request, though it was able to match part of the requested address. You may wish to examine the original request for misspellings and/or an incomplete address.
Partial matches most often occur for street addresses that do not exist within the locality you pass in the request. Partial matches may also be returned when a request matches two or more locations in the same locality. For example, "21 Henr St, Bristol, UK" will return a partial match for both Henry Street and Henrietta Street. Note that if a request includes a misspelled address component, the geocoding service may suggest an alternative address. Suggestions triggered in this way will also be marked as a partial match.
Address Types and Address Component Types
The types[] array in the result indicates the address type. Examples of address types include a street address, a country, or a political entity. There is also a types[] array in the address_components[], indicating the type of each part of the address. Examples include street number or country. (Below is a full list of types.) Addresses may have multiple types. The types may be considered 'tags'. For example, many cities are tagged with the political and the locality type.
street_address indicates a precise street address.
The following types are supported and returned by the geocoder in both the address type and address component type arrays:
route indicates a named route (such as "US 101").
intersection indicates a major intersection, usually of two major roads.
political indicates a political entity. Usually, this type indicates a polygon of some civil administration.
country indicates the national political entity, and is typically the highest order type returned by the Geocoder.
administrative_area_level_1 indicates a first-order civil entity below the country level. Within the United States, these administrative levels are states. Not all nations exhibit these administrative levels. In most cases, administrative_area_level_1 short names will closely match ISO 3166-2 subdivisions and other widely circulated lists; however this is not guaranteed as our geocoding results are based on a variety of signals and location data.
administrative_area_level_2 indicates a second-order civil entity below the country level. Within the United States, these administrative levels are counties. Not all nations exhibit these administrative levels.
administrative_area_level_3 indicates a third-order civil entity below the country level. This type indicates a minor civil division. Not all nations exhibit these administrative levels.
administrative_area_level_4 indicates a fourth-order civil entity below the country level. This type indicates a minor civil division. Not all nations exhibit these administrative levels.
administrative_area_level_5 indicates a fifth-order civil entity below the country level. This type indicates a minor civil division. Not all nations exhibit these administrative levels.
colloquial_area indicates a commonly-used alternative name for the entity.
locality indicates an incorporated city or town political entity.
sublocality indicates a first-order civil entity below a locality. For some locations may receive one of the additional types: sublocality_level_1 to sublocality_level_5. Each sublocality level is a civil entity. Larger numbers indicate a smaller geographic area.
neighborhood indicates a named neighborhood.
premise indicates a named location, usually a building or collection of buildings with a common name.
subpremise indicates a first-order entity below a named location, usually a singular building within a collection of buildings with a common name.
postal_code indicates a postal code as used to address postal mail within the country.
natural_feature indicates a prominent natural feature.
airport indicates an airport.
park indicates a named park.
point_of_interest indicates a named point of interest. Typically, these "POI"s are prominent local entities that don't easily fit in another category, such as "Empire State Building" or "Eiffel Tower".
An empty list of types indicates there are no known types for the particular address component, for example, Lieu-dit in France.
In addition to the above, address components may include the types below.
floor indicates the floor of a building address.
establishment typically indicates a place that has not yet been categorized.
point_of_interest indicates a named point of interest.
parking indicates a parking lot or parking structure.
post_box indicates a specific postal box.
postal_town indicates a grouping of geographic areas, such as locality and sublocality, used for mailing addresses in some countries.
room indicates the room of a building address.
street_number indicates the precise street number.
bus_station, train_station and transit_station indicate the location of a bus, train or public transit stop.
Reverse Geocoding (Address Lookup)
Required Parameters
Optional Parameters
Optional Parameters
Status Codes
Status Codes
Example of Reverse Geocoding
Example of Reverse Geocoding
The term geocoding generally refers to translating a human-readable address into a location on a map. The process of doing the opposite, translating a location on the map into a human-readable address, is known as reverse geocoding.

Reverse geocoding is the process of converting geographic coordinates into a human-readable address.
Reverse Geocoding Requests
Required parameters in a Reverse Geocoding request:
latlng — The latitude and longitude values specifying the location for which you wish to obtain the closest, human-readable address.
key — Your application's API key. This key identifies your application for purposes of quota management.