API Autocomplete
Giới thiệu
Autocomplete là API cho phép người dùng nhập vào một từ khoá, hệ thống sẽ gợi ý danh sách địa chỉ tương ứng với từ khoá nhập vào.
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
| Parameter | Type | Description |
|---|---|---|
key | string | Required. API Key lấy từ TOPTOP Maps |
location | float | Optional. Kinh độ, Vĩ độ |
input | string | Required. Địa điểm người dùng nhập vào |
radius | float | Optional. Bán kính tìm kiếm. Nếu không được nhập vào thì location sẽ bị bỏ qua |
components | string | Optional. Quốc gia sẽ được lấy dữ liệu |
Request mẫu
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 Code | Description |
|---|---|
| 200 | OK |
| 400 | BAD REQUEST |
| 404 | NOT FOUND |
| 500 | INTERNAL SERVER ERROR |