1

I've been using the Herepy package for using the Here Maps API on python and I finally managed to get some of the results. I'm having a hard time accessing the next page of results in the PlacesResponse I got.

Code:

response = geocoderApi.onebox_search([12.8797, 121.7740], 'mall')

Result:

{'results': {'next': 'https://places.ls.hereapi.com/places/v1/discover/search;context=Zmxvdy1pZD1jNDhkZGI5ZC1hY2E0LTU3MDctOTEzOS1jOTk3MmU1NWFkNDdfMTU3OTIzNDM1MjU3N18xNDM1XzQ2MzAmb2Zmc2V0PTIwJnNpemU9MjA?at=12.8797%2C121.774&q=mall','items': [{'position': [12.57726, 122.26888],
'distance': 63341,
'title': 'Romblon Shopping Center',
'averageRating': 0.0,
'category': {'id': 'mall',
 'title': 'Shopping Centre',
 'href': 'https://places.ls.hereapi.com/places/v1/categories/places/mall',
 'type': 'urn:nlp-types:category',
 'system': 'places'},
'icon': 'https://download.vcdn.data.here.com/p/d/places2/icons/categories/09.icon',
'vicinity': 'Bagacay, Romblon<br/>Philippines',
'having': [],
'type': 'urn:nlp-types:place',
'href': 'https://places.ls.hereapi.com/places/v1/places/608jx7ps-e037893cbff505fbef78dc1294497c1d;context=Zmxvdy1pZD1jNDhkZGI5ZC1hY2E0LTU3MDctOTEzOS1jOTk3MmU1NWFkNDdfMTU3OTIzNDM1MjU3N18xNDM1XzQ2MzAmcmFuaz0w',
'id': '608jx7ps-e037893cbff505fbef78dc1294497c1d'}
...

I tried accessing the next link by adding my API Key on the request but I can't seem to get the next list of results.

next_results = requests.get('https://places.ls.hereapi.com/places/v1/discover/search?apiKey={API_KEY_HERE};context=Zmxvdy1pZD1jNDhkZGI5ZC1hY2E0LTU3MDctOTEzOS1jOTk3MmU1NWFkNDdfMTU3OTIzNDM1MjU3N18xNDM1XzQ2MzAmb2Zmc2V0PTIwJnNpemU9MjA?at=12.8797%2C121.774&q=mall')
AminoAcid
  • 188
  • 9

1 Answers1

1

https://places.ls.hereapi.com/places/v1/discover/search?apiKey={API_KEY_HERE};context=Zmxvdy1pZD1jNDhkZGI5ZC1hY2E0LTU3MDctOTEzOS1jOTk3MmU1NWFkNDdfMTU3OTIzNDM1MjU3N18xNDM1XzQ2MzAmb2Zmc2V0PTIwJnNpemU9MjA?at=12.8797,121.774&q=mall

Your next url is malformed. The apiKey should be along with the other query string parameters at and q:

https://places.ls.hereapi.com/places/v1/discover/search;context=Zmxvdy1pZD1jNDhkZGI5ZC1hY2E0LTU3MDctOTEzOS1jOTk3MmU1NWFkNDdfMTU3OTIzNDM1MjU3N18xNDM1XzQ2MzAmb2Zmc2V0PTIwJnNpemU9MjA?apiKey=API_KEY_HERE&at=12.8797,121.774&q=mall

With a properly formed next url, I get the following response for the coordinates you used and the mall search word:

{
    "previous": "https://places.ls.hereapi.com/places/v1/discover/search;context=Zmxvdy1pZD01NWRiOTk5NC0zM2ZmLTUwMjctOWRmOC01MmE5YzMyZmJhM2RfMTU3OTI1OTczODg3NF84MjYxXzE3NDQmb2Zmc2V0PTAmc2l6ZT0yMA?at=12.8797%2C121.774&q=mall",
    "next": "https://places.ls.hereapi.com/places/v1/discover/search;context=Zmxvdy1pZD01NWRiOTk5NC0zM2ZmLTUwMjctOWRmOC01MmE5YzMyZmJhM2RfMTU3OTI1OTczODg3NF84MjYxXzE3NDQmb2Zmc2V0PTQwJnNpemU9MjA?at=12.8797%2C121.774&q=mall",
    "offset": 20,
    "items": [
        {
            "position": [
                11.962863,
                121.925928
            ],
            "distance": 103274,
            "title": "Mit",
            "averageRating": 0.0,
            "category": {
                "id": "mall",
                "title": "Shopping Centre",
                "href": "https://places.ls.hereapi.com/places/v1/categories/places/mall",
                "type": "urn:nlp-types:category",
                "system": "places"
            },
            "icon": "https://download.vcdn.data.here.com/p/d/places2/icons/categories/09.icon",
            "vicinity": "Balabag, Malay, 5608<br/>Philippines",
            "having": [],
            "type": "urn:nlp-types:place",
            "href": "https://places.ls.hereapi.com/places/v1/places/608wdnsn-d3edd5c804da4698bc913e04da8ca891;context=Zmxvdy1pZD01NWRiOTk5NC0zM2ZmLTUwMjctOWRmOC01MmE5YzMyZmJhM2RfMTU3OTI1OTczODg3NF84MjYxXzE3NDQmcmFuaz0yMA",
            "id": "608wdnsn-d3edd5c804da4698bc913e04da8ca891"
        },
        ...
    ]
}
Michel
  • 26,600
  • 6
  • 64
  • 69