Autocomplete
GEThttps://api.uber.com/maps/beta/autocomplete¶ Use Case
The Autocomplete endpoint returns location suggestions as a user is typing based on their input text string. Autocomplete is a performant search intended to provide suggestions based on fragments of text.
The locations returned from Autocomplete contain an ID that can be used to call the Details endpoint to hydrate additional information such as coordinates, address components, and other location information. By comparison, Autocomplete returns a location name and address but not a coordinate or address components.
¶ Authorization
OAuth 2.0 Bearer token with the maps-apis scope.
¶ Request Parameters
| Name | Type | Description | Required? |
|---|---|---|---|
query |
string | The partial or complete text string used to generate location suggestions. For example, the string “san fran” or “sfo”. | Yes |
locale |
string | The preferred language of the suggestions. For example, the string “en-US”. This should follow the BCP47 standards. | No |
latitude |
double | The point around which to generate location suggestions expressed as a latitude and longitude. | No |
longitude |
double | The point around which to generate location suggestions expressed as a latitude and longitude. | No |
num_results |
int | The number of suggestions to return. By default, a single result will be returned. | No |
context |
string | Provide information on the search context. Possible values are destination and origin. This can help with accuracy of results. |
No |
¶ Notes on latitude, longitude
This parameter geobiases the request to a specific area which instructs the search to prefer locations within a certain distance of the coordinate. This can greatly improve the quality of the suggestions provided. However, suggestions outside of this defined area may still be returned.
¶ Example Request
curl -X GET \
-H "authorization: Bearer $UBER_TOKEN" \
-H 'content-type: application/json' \
https://$api_url/maps/beta/autocomplete?locale=en&query=McDonald&country_code=US&latitude=37.3641014&longitude=-122.0269649&num_results=5 | jq .
¶ Response body parameters
| Name | Type | Description | Required? |
|---|---|---|---|
entities[i].id |
string | The unique identifier for the suggested location | Yes |
addresses[i].location |
object | The location data for the place | Yes |
addresses[i].location.name |
string | The name of the suggested location | No |
addresses[i].location.address |
string | The full address for the suggested location | Yes |
addresses[i].location.locale |
string | The locale used for the response | Yes |
addresses[i].location.categories |
string | The list of categories the place belong to (i.e. Restaurant) | No |
addresses[i].location.distanceMeters |
long | The distance, in meters from the input location, if one was supplied | No |
For an overview of available categories, refer to Categories
Status-code: 200 OK
{
"entities":[
{
"id":"u01:01:ca4cbd41-1618-ce27-346e-87311810e8f4",
"location":{
"name":"McDonald's",
"address":"2801 Mission St, San Francisco, CA",
"locale":"en",
"categories":[
"FAST_FOOD",
"RESTAURANT",
"FOOD_AND_BEVERAGE",
"SHOPS_AND_SERVICES",
"place"
]
}
},
{
"id":"u01:01:7fbcc96b-79fe-5226-0667-8c4806ec33fd",
"location":{
"name":"McDonald's",
"address":"302 Potrero Ave, San Francisco, CA",
"locale":"en",
"categories":[
"FAST_FOOD",
"RESTAURANT",
"FOOD_AND_BEVERAGE",
"SHOPS_AND_SERVICES",
"place"
]
}
},
{
"id":"u01:01:54aa2aa2-0ab6-6a60-7fdf-4ef2568e2630",
"location":{
"name":"McDonald's",
"address":"345 Bayshore Blvd, San Francisco, CA",
"locale":"en",
"categories":[
"FAST_FOOD",
"RESTAURANT",
"FOOD_AND_BEVERAGE",
"SHOPS_AND_SERVICES",
"place"
]
}
},
{
"id":"u01:01:30a18b78-698b-6809-9f75-85cccff222a3",
"location":{
"name":"McDonald's",
"address":"1100 Fillmore St, San Francisco, CA",
"locale":"en",
"categories":[
"FAST_FOOD",
"RESTAURANT",
"FOOD_AND_BEVERAGE",
"SHOPS_AND_SERVICES",
"place"
]
}
},
{
"id":"u01:01:58f6b5c1-92bd-097c-7caf-78cfc9108708",
"location":{
"name":"McDonald's",
"address":"441 Sutter St, San Francisco, CA",
"locale":"en",
"categories":[
"FAST_FOOD",
"AMERICAN",
"BURGERS",
"RESTAURANT",
"FOOD_AND_BEVERAGE",
"SHOPS_AND_SERVICES",
"place"
]
}
}
]
}