Suggestions displayed as characters using a widget and the geocoding service.
What is autosuggest?Autosuggest, also known as autocomplete, is the process of using incomplete text to search for place names and addresses. For example, you can search for "New Y", "Dodgers S", and "Cali" to get a list of suggested place names that match.
You can use autosuggest to build applications that:
You can get address and place name suggestions by making an HTTP request to the geocoding service suggest
operation or by using client APIs. Specify the address or place name text, and optionally, additional parameters to refine the search.
You can provide text for a partial place name or a partial address to get search results. Typically 2-3 characters are needed to start searching.
To refine the search and improve accuracy, you can provide additional information such as the location, search extent, category, and country code.
The geocoding service parses the text and uses all of the parameters provided to return a set of suggestions. Each suggestion contains text
(address or place name), isCollection
(single distinct place or multiple with the same name or category), and magicKey
(search identifier) properties.
To get the complete address and location for a suggestion, you must make an additional request to the findAddressCandidates
operation using the information from the suggestion.
Use dark colors for code blocks Copy
1
https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest?text={partialText}&f=json&token=<ACCESS_TOKEN>
Use dark colors for code blocks Copy
1
https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest?text={partialText}&f=json&token=<ACCESS_TOKEN>
Required parameters Name Description Examples f
The format of the data returned. f=json
f=pjson
token
An API key or OAuth 2.0 access token. token=<ACCESS_TOKEN>
Security and authentication guide
To get an access token for this operation, go to Get started.
Key parameters Name Description Examplestext
The partial address or place name. Different formats are supported. text=starbutext=100, main sttext=New Y
Additional parameters: Refine the search by using parameters such as location
, searchExtent
, category
, and countryCode
.
For more information about the request, parameters, and valid input values, see the Geocoding service REST API documentation.
Try it:Run the request in Postman .
Code examples Get suggestions for a stringThis example finds suggestions for the string New Y
. To find the actual address and location for a suggestion, you have to pass each text
and magicKey
value to the geocoding service. Most APIs provide a LocatorTask to access the service.
Reference the geocoding service.
Set the text to search for.
Set the API key.
The response is a set of suggestions (max of 5) containing the text
and magicKey
properties. Use these properties to search for the complete address with a location.
Suggestions displayed as characters using a widget and the geocoding service.
Security and authentication guideTo get an access token, go to Security and Authentication > Get started.
APIsArcGIS Maps SDK for JavaScript ArcGIS Maps SDK for JavaScript ArcGIS Maps SDK for .NET ArcGIS Maps SDK for Kotlin ArcGIS Maps SDK for Swift ArcGIS Maps SDK for Java ArcGIS Maps SDK for Qt ArcGIS API for Python ArcGIS REST JS Esri Leaflet MapLibre GL JS OpenLayers CesiumJS
Expand
Use dark colors for code blocks Copy1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
const 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 cURL HTTP
Use dark colors for code blocks Copy
1
2
3
4
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)
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
"suggestions": [
{
"text": "New York, NY, USA",
"magicKey": "dHA9MCNsb2M9NzUwOTc4OCNsbmc9MzMjcGw9MjcxNjU1MyNsYnM9MTQ6MjM4MTIyMzc=",
"isCollection": false
},
{
"text": "New York, USA",
"magicKey": "dHA9MCNsb2M9NzMxOTEwOCNsbmc9MzMjcGw9MjU5OTMyMyNsYnM9MTQ6MjM4MTIyMzc=",
"isCollection": false
},
{
Tutorials
Search with autosuggest
Search for an address with autosuggest using the geocoding service.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4