Skip to main content

API Autocomplete

Introduce

Autocomplete is an API that allows users to enter a keyword, the system will suggest a list of addresses corresponding to the entered keyword.

Params

GET https://dev.toptopmap.com/api/v1/maps/autocomplete?key=APIKey&input=2 P. Nguyễn Hoàng&location=21.0296938,105.7749161&radius=2000&components=country:vn
ParameterTypeDescription
keystringRequired. API Key obtained from TOPTOP Maps
locationfloatOptional. Longitude, Latitude
inputstringRequired. The location entered by the user
radiusfloatOptional. Radius of search. If not provided, location will be ignored.
componentsstringOptional. Country from which data will be taken

Sample request

curl --location 'https://dev.toptopmap.com/api/v1/maps/autocomplete?key=APIKey&input=2%20P.%20Nguy%E1%BB%85n%20Ho%C3%A0ng&location=21.0296938%2C105.7749161&radius=2000&components=country%3Avn'

Responses

{
"status": "OK",
"predictions": [
{
"gate": null,
"location": null,
"matched_substrings": [
{
"length": 1,
"offset": 0
},
{
"length": 15,
"offset": 2
}
],
"reference": "ChIJ84s8z7NUNDERkyqa_aq1GBM",
"structured_formatting": {
"main_text": "2 P. Nguyễn Hoàng",
"main_text_matched_substrings": [
{
"length": 1,
"offset": 0
},
{
"length": 15,
"offset": 2
}
],
"secondary_text": "Mỹ Đình 2, Nam Từ Liêm, Hà Nội, Việt Nam"
},
"description": "2 P. Nguyễn Hoàng, Mỹ Đình 2, Nam Từ Liêm, Hà Nội, Việt Nam",
"place_id": "ChIJ84s8z7NUNDERkyqa_aq1GBM",
"terms": [
{
"offset": 0,
"value": "2"
},
{
"offset": 2,
"value": "P. Nguyễn Hoàng"
},
{
"offset": 19,
"value": "Mỹ Đình 2"
},
{
"offset": 30,
"value": "Nam Từ Liêm"
},
{
"offset": 43,
"value": "Hà Nội"
},
{
"offset": 51,
"value": "Việt Nam"
}
],
"type": [
"street_address",
"geocode"
]
},
{
"gate": null,
"location": null,
"matched_substrings": [
{
"length": 17,
"offset": 4
}
],
"reference": "EkxOZy4gMiBQLiBOZ3V54buFbiBIb8OgbmcsIE3hu7kgxJDDrG5oIDIsIEPhuqd1IEdp4bqleSwgSMOgIE7hu5lpLCBWaeG7h3QgTmFtIi4qLAoUChIJAfVOyrNUNDERfTpoOim2STgSFAoSCTvnxbi6VDQxEcRmuqaNMPMV",
"structured_formatting": {
"main_text": "Ng. 2 P. Nguyễn Hoàng",
"main_text_matched_substrings": [
{
"length": 17,
"offset": 4
}
],
"secondary_text": "Mỹ Đình 2, Cầu Giấy, Hà Nội, Việt Nam"
},
"description": "Ng. 2 P. Nguyễn Hoàng, Mỹ Đình 2, Cầu Giấy, Hà Nội, Việt Nam",
"place_id": "EkxOZy4gMiBQLiBOZ3V54buFbiBIb8OgbmcsIE3hu7kgxJDDrG5oIDIsIEPhuqd1IEdp4bqleSwgSMOgIE7hu5lpLCBWaeG7h3QgTmFtIi4qLAoUChIJAfVOyrNUNDERfTpoOim2STgSFAoSCTvnxbi6VDQxEcRmuqaNMPMV",
"terms": [
{
"offset": 0,
"value": "Ng. 2 P. Nguyễn Hoàng"
},
{
"offset": 23,
"value": "Mỹ Đình 2"
},
{
"offset": 34,
"value": "Cầu Giấy"
},
{
"offset": 44,
"value": "Hà Nội"
},
{
"offset": 52,
"value": "Việt Nam"
}
],
"type": [
"route",
"geocode"
]
},
{
"gate": null,
"location": null,
"matched_substrings": [
{
"length": 17,
"offset": 0
}
],
"reference": "EkEyIFAuIE5ndXnhu4VuIEhvw6BuZyBOZ2jhu4ssIFbDtSBDxrDhu51uZywgQuG6r2MgTmluaCwgVmnhu4d0IE5hbSIwEi4KFAoSCe02bVNXCTUxEblr5xBJdnzbEAIqFAoSCcU-yw1aCTUxESzqbU7sTggL",
"structured_formatting": {
"main_text": "2 P. Nguyễn Hoàng Nghị",
"main_text_matched_substrings": [
{
"length": 17,
"offset": 0
}
],
"secondary_text": "Võ Cường, Bắc Ninh, Việt Nam"
},
"description": "2 P. Nguyễn Hoàng Nghị, Võ Cường, Bắc Ninh, Việt Nam",
"place_id": "EkEyIFAuIE5ndXnhu4VuIEhvw6BuZyBOZ2jhu4ssIFbDtSBDxrDhu51uZywgQuG6r2MgTmluaCwgVmnhu4d0IE5hbSIwEi4KFAoSCe02bVNXCTUxEblr5xBJdnzbEAIqFAoSCcU-yw1aCTUxESzqbU7sTggL",
"terms": [
{
"offset": 0,
"value": "2 P. Nguyễn Hoàng Nghị"
},
{
"offset": 24,
"value": "Võ Cường"
},
{
"offset": 34,
"value": "Bắc Ninh"
},
{
"offset": 44,
"value": "Việt Nam"
}
],
"type": [
"street_address",
"geocode"
]
}
]
}

Status Codes

Status CodeDescription
200OK
400BAD REQUEST
404NOT FOUND
500INTERNAL SERVER ERROR