Skip to content

Geocoder Autocomplete API

GeocoderAutoCompleteApi

A python interface into the HERE Geocoder Auto Complete API

__init__(self, api_key=None, timeout=None) special

Returns a GeocoderAutoCompleteApi instance.

Parameters:

Name Type Description Default
api_key str

API key taken from HERE Developer Portal.

None
timeout int

Timeout limit for requests.

None
Source code in herepy/geocoder_autocomplete_api.py
16
17
18
19
20
21
22
23
24
25
26
27
28
def __init__(self,
             api_key: str=None,
             timeout: int=None):
    """Returns a GeocoderAutoCompleteApi instance.
    Args:
      api_key (str):
        API key taken from HERE Developer Portal.
      timeout (int):
        Timeout limit for requests.
    """

    super(GeocoderAutoCompleteApi, self).__init__(api_key, timeout)
    self._base_url = 'https://autosuggest.search.hereapi.com/v1/autosuggest'

address_suggestion(self, query, prox, radius, lang='en-US')

Request a list of suggested addresses found within a specified area

Parameters:

Name Type Description Default
query str

Query search string

required
prox List[float]

Array including latitude and longitude in order.

required
radius int

Radius in meters

required
lang str

BCP47 compliant Language Code.

'en-US'

Returns:

Type Description
Optional[herepy.models.GeocoderAutoCompleteResponse]

GeocoderAutoCompleteResponse

Source code in herepy/geocoder_autocomplete_api.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
def address_suggestion(self, query: str, prox: List[float], radius: int, lang: str='en-US') -> Optional[GeocoderAutoCompleteResponse]:
    """Request a list of suggested addresses found within a specified area
    Args:
      query (str):
        Query search string
      prox (array):
        Array including latitude and longitude in order.
      radius (int):
        Radius in meters
      lang (str):
        BCP47 compliant Language Code.
    Returns:
      GeocoderAutoCompleteResponse
    Raises:
      HEREError"""

    data = {'q': query,
            'in': str.format('circle:{0},{1};r={2}', prox[0], prox[1], radius),
            'apikey': self._api_key,
            'lang': lang}
    return self.__get(data)

limit_results_byaddress(self, query, country_code, lang='en-US')

Request a list of suggested addresses within a single country

Parameters:

Name Type Description Default
query str

Query search string

required
countryCode str

Country code (USA etc.)

required
lang str

BCP47 compliant Language Code.

'en-US'

Returns:

Type Description
Optional[herepy.models.GeocoderAutoCompleteResponse]

GeocoderAutoCompleteResponse

Source code in herepy/geocoder_autocomplete_api.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
def limit_results_byaddress(self, query: str, country_code: str, lang: str='en-US') -> Optional[GeocoderAutoCompleteResponse]:
    """Request a list of suggested addresses within a single country
    Args:
      query (str):
        Query search string
      countryCode (str):
        Country code (USA etc.)
      lang (str):
        BCP47 compliant Language Code.
    Returns:
      GeocoderAutoCompleteResponse
    Raises:
      HEREError"""

    data = {'q': query,
            'in': 'countryCode:' + country_code,
            'apikey': self._api_key,
            'lang': lang}
    return self.__get(data)