1. Choose a type of geocoding
The first step is to select the geocoding service URL endpoint and operation you need to use.
https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/<request>?<parameters>&f=json&token=<ACCESS_TOKEN>
https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/<request>?<parameters>&f=json&token=<ACCESS_TOKEN>
Operation | Use case |
---|---|
Address geocoding | Geocode address text to a complete address. |
Autosuggest | Autocomplete addresses and places as you type. |
Reverse geocoding | Find the address to your nearest geographic location. Get the nearest address to your current location. |
Place geocoding | Search for places by category such as restaurants, gas stations, or schools. |
Batch geocoding | Convert a number of addresses to complete addresses. |
2. Define input parameters
The next step is to provide input such as an address, location, or text for the operation. The most common parameters are listed in the tables below.
Name | Description | Examples |
---|---|---|
address | The address or place name. Different formats are supported. | address=1600 Pennsylvania Ave NW,DC , address=Washington,DC |
out | The list of data fields to return. | out , out (return all fields) |
Name | Description | Examples |
---|---|---|
text | The partial address or place name. Different formats are supported. | text=starbutext=100 , text=New Y |
Additional parameters: Refine the search by using parameters such as location
, search
, category
, and country
.
Name | Description | Example |
---|---|---|
location | The location to search. | location=-79.3871,43.6426 ,location={x: |
Name | Description | Example |
---|---|---|
address | The address or place name string. Different formats are supported. | address=Disneyland ,address=Los Angeles Starbucks , address=-117.155579,32.703761 |
location | Use to focus the search on a specific location. | location=-117.196,34.056 |
category | Filter places by place type values. | category=food,mexican food , category=coffee shop |
out | A list of data fields to return. | out , out (return all fields) |
Name | Description | Examples |
---|---|---|
addresses | A JSON object with an address or place name. Different address formats are supported. | See example |
3. Make a request
The final step is to make a request to the geocoding service using an ArcGIS Maps SDK, scripting API, or open source library. In general, you:
- Reference the service or import the relevant packages or modules.
- Set the address, location, or text.
- Set your access token.
APIs
const geocodingServiceUrl = "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer";
const params = {
address: {
"address": "1600 Pennsylvania Ave NW, DC"
}
}
locator.addressToLocations(geocodingServiceUrl, params).then((results) => {
showResult(results);
});
REST API
curl https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates \
-d 'f=pjson' \
-d 'address=1600 Pennsylvania Ave NW, DC' \
-d 'token=<ACCESS_TOKEN>'
APIs
geocodingServiceUrl = "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer";
const params = {
text: "New Y", // Suggestion text
};
locator.suggestLocations(geocodingServiceUrl, params).then((response) => {
// Show a list of the suggestions
response.forEach((suggestion) => {
showSuggestion(suggestion.text, suggestion.magicKey);
});
// When a suggestion is selected, geocode to find its location
select.addEventListener("calciteSelectChange", (event) => {
const text = event.target.innerHTML;
const magicKey = event.target.value;
geocodeSuggestion(text, magicKey);
});
});
REST API
curl https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest \
-d 'f=pjson' \
-d 'text=New Y' \
-d 'token=<ACCESS_TOKEN>'
Response (JSON)
{
"suggestions": [
{
"text": "New York, NY, USA",
"magicKey": "dHA9MCNsb2M9NzUwOTc4OCNsbmc9MzMjcGw9MjcxNjU1MyNsYnM9MTQ6MjM4MTIyMzc=",
"isCollection": false
},
{
"text": "New York, USA",
"magicKey": "dHA9MCNsb2M9NzMxOTEwOCNsbmc9MzMjcGw9MjU5OTMyMyNsYnM9MTQ6MjM4MTIyMzc=",
"isCollection": false
},
{
APIs
const geocodingServiceUrl = "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer" ;
const params = {
location: pt
};
locator.locationToAddress(geocodingServiceUrl, params).then(
(response) => {
if (response) {
showPopup(response);
}
},
(err) => {
showPopup("No address found.", pt);
}
);
REST API
curl https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode \
-d 'f=pjson' \
-d 'location=-79.3871,43.6426' \
-d 'token=<ACCESS_TOKEN>'
Response (JSON)
{
"address": {
"Match_addr": "CN Tower",
"LongLabel": "CN Tower, 301 Front St W, Toronto, Ontario, M5V, CAN",
"ShortLabel": "CN Tower",
"Addr_type": "POI",
"Type": "Tourist Attraction",
"PlaceName": "CN Tower",
"AddNum": "301",
"Address": "301 Front St W",
"Block": "",
"Sector": "",
"Neighborhood": "Waterfront Communities-the Island",
APIs
function findPlaces(pt) {
const geocodingServiceUrl = "http://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer";
const params = {
categories: ["gas station"],
location: pt, // Paris (2.34602,48.85880)
outFields: ["PlaceName","Place_addr"]
}
locator.addressToLocations(geocodingServiceUrl, params).then((results)=> {
showResults(results);
});
REST API
curl https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates \
-d 'f=pjson' \
-d 'category=gas station' \
-d 'location=2.34602,48.85880' \
-d 'outfields=PlaceName,Place_addr' \
-d 'token=<ACCESS_TOKEN>'
APIs
const geocodingServiceUrl =
"http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"
const params = {
addresses: [
{
objectid: 1,
address: "Buckingham Palace",
},
{
objectid: 2,
address: "Abeno Restaurant London",
},
{
objectid: 3,
address: "58 Brewer Street, London, England",
},
],
}
locator.addressesToLocations(geocodingServiceUrl, params).then(
results => {
if (results.length) {
results.forEach(result => {
addGraphic(result)
})
}
},
function(error) {
console.log(error)
}
)
REST API
curl https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/geocodeAddresses \
-d 'f=pjson' \
-d 'addresses=
{
"records": [
{
"attributes": {
"objectid": 1,
"address": "Buckingham Palace"
}
},
{
"attributes": {
"objectid": 2,
"address": "Bernardis Restaurant London"
}
},
{
"attributes": {
"objectid": 3,
"address": "58 Brewer Street, London, England"
}
}
]
}' \
-d 'token=<ACCESS_TOKEN>'
Additional resources
Tutorials
![](/documentation/static/search-for-an-address-3daa8b2ba415f9b2bb6dae0d8e5eeb12.png)
Search for an address
Convert an address or place to a location with the geocoding service.
![](/documentation/static/reverse-geocode-ac10868894ca815332d253cf94cdaa03.png)
Reverse geocode
Get an address, business, or place from coordinates with the geocoding service.
JavaScript Maps SDK Esri Leaflet MapLibre GL JS OpenLayers CesiumJS REST API
![](/documentation/static/find-places-d4c010129deb1fe01fffcd82105d5631.png)
Find place addresses
Find an address, business, or place with the geocoding service.
![](/documentation/static/display-location-2fea33ea6f776ab4387d446bcb6897ba.png)
Display your location
Find and track your device location on a map.