Help users find what they're looking for without requiring them to fully specify their search term.
Endpoint
https://sg-maps.track-asia.com/api/v2/place/autocomplete/{outputFormat}
outputFormat
| outputFormat | Description |
|---|---|
json (recommended) | indicates output in JavaScript Object Notation (JSON) |
xml | indicates output in XML |
Parameters
| Parameter | Values | Description | Example |
|---|---|---|---|
input | String (required) | The input string that you want to autocomplete. This input string could be a partial address, a place name, or any other string that you want to find a match for | KFC |
key | String (required) | API key | public_key |
bounds | {latitude},{longitude};{latitude},{longitude} | The bounding box of the viewport within which to bias geocode results more prominently. This parameter will only influence, not fully restrict, results from the geocoder | 1.36463420,103.78429379;1.37503187,103.79330227 |
size | Number | The maximum number of results to return from the search. | 5 |
location | {latitude},{longitude} | The latitude and longitude values specifying the location for which you wish to obtain the closest, human-readable address. | 1.7952219,103.7217912 |
Example Code
https://sg-maps.track-asia.com/api/v2/place/autocomplete/json?input=KFC&location=1.301998,103.81143&key=public_key
Response
JSON Response
The response is a JSON object with the following structure:
status: Status string (e.g., "OK").predictions: An array of prediction objects. Each prediction contains:place_id: Unique identifier for the place.reference: Reference for the place (may be the same asplace_id).name: Name of the place.sublabel: Additional address or context for the place.description: Full description of the place.matched_substrings: Array of objects indicating which substrings of the input matched.structured_formatting: Object withmain_text,main_text_matched_substrings, andsecondary_textfor display formatting.terms: Array of objects withoffsetandvaluefor each term in the result.geometry: Object withlocation(lat/lng),location_type, andviewport(northeast/southwest bounds).plus_code: Object withcompound_codeandglobal_code.types: Array of place types.
XML Response
The XML response has a similar structure, with elements corresponding to the JSON fields above. Notable differences:
- XML results are wrapped in a root
<AutocompletionResponse>element. - Arrays in JSON (like
predictions,terms) become repeated elements in XML (like<prediction>,<term>). - Blank elements are indicated by empty arrays in JSON, but by the absence of such elements in XML.
Status
| Status | Description |
|---|---|
OK | indicating the API request was successful. |
ZERO_RESULTS | indicating that the search was successful but returned no results. This may occur if the search was passed a bounds in a remote location. |
Next steps
- Try API playground