Skip to main content
APIs Developers how-to 9 min read

Geocoding & Search API with your guide, ChatGPT...

Header

This past weekend I was discussing work-related topics with someone unfamiliar with the world of location and geo-enabled data and apps. The common generalities that go with a response to questions like “what is GIS?” or “what does an API do?”  quickly turned more instructive as the questions became more specific. After all, I respond to natural curiosity with an eagerness not dissimilar to the first meal of the day.

The questions kept coming at me:

HERE Technologies, I think I have seen one of those camera cars, so you photograph a lot of streets?

What is Geocoding? … ah a translation of a description of a location you say. So, searching for addresses … navigating right right.

So you have a product that would let someone search and determine locations in something they want to build, like in a phone app?

What’s all this about ChatGPT? Have you used it? What can it do?

 

At this point I thought it best to grab the laptop and play a little game. This activity surely would capture the zeitgeist of January 2023 and no doubt beyond. I said, “why don’t we see what we can learn with the help of ChatGPT to answer these questions! Let's assess its flex on a specific use case: What is X and how can I use it? X being the HERE Geocoding & Search API." We started with something very generic.

Note: If you haven’t used ChatGPT a disclaimer: It can sometimes spit out outdated or erroneous information. It is, however, pretty darn accurate most of the time. While ChatGPT is not a substitute for reading the latest documentation or API guides, it could help the less adept, new user or simply the curious types do “things.” Always take AI generated output with some degree of skepticism.

Question: What can you tell me about HERE Technologies and geocoding and search?

ChatGPT

ChatGPT interface. Provides a fairly complete but generic response about the company and the Geocoding & Search API without me specifying I am referring to the API.

 

Question: What are some cool things I can do with the HERE Geocoding & Search API? 

ChatGPT

A vague question yields an honest and fairly specific generalized answer.

 

A pretty good list that includes some other ideas beyond official documentation. Cool is subjective sure but nonetheless, a helpful response for the would-be app developer. Let’s dial it up a notch. Wearing our new user hat, how do I use this thing?

Question: How do I make a call to the HERE Geocoding and Search API?

Note: If you have never used HERE platform and/or generated an API key, it is a straightforward free signup. This brief tutorial covers that for new users.

ChatGPT

Not bad! While you can make an API call a few ways, this is a python snippet and ChatGPT's response also contained the appropriate disclaimer about having your own API key.

Very nice…and then? Since we can make a GET request to the API’s endpoint, surely ChatGPT can construct it for us with specific parameters. The individual I was talking with was heading to the Moda Center in Portland, OR. to watch a basketball game the following day.

ChatGPT request to construct a GET request:

Request

ChatGPT correctly references the search endpoint, thus allowing the geo-coordinate(s) of known addresses, places, admin areas, etc., to be returned even with a partial query or incorrect. The place and locality are also defined.

As I already have an API key, I will use it with this request in Postman, my API testing tool of choice. Appending my API key to the request, we get a valid (200) return with the address in json among the string array.

We can see the first result of the dozens of hotels:

Copied
        {
                "items": [
                    {
                        "title": "Dossier",
                        "id": "here:pds:place:840c20fb-031322c5e2b044a683bc130b7b6ab3ae",
                        "language": "en",
                        "ontologyId": "here:cm:ontology:hotel",
                        "resultType": "place",
                        "address": {
                            "label": "Dossier, 750 SW Alder St, Portland, OR 97205, United States",
                            "countryCode": "USA",
                            "countryName": "United States",
                            "stateCode": "OR",
                            "state": "Oregon",
                            "county": "Multnomah",
                            "city": "Portland",
                            "district": "Downtown",
                            "street": "SW Alder St",
                            "postalCode": "97205",
                            "houseNumber": "750"
                        },
                        "position": {
                            "lat": 45.51999,
                            "lng": -122.68005
                        },
                        "access": [
                            {
                                "lat": 45.52019,
                                "lng": -122.67994
                            }
                        ],
                        "distance": 4,
                        "categories": [
                            {
                                "id": "500-5000-0053",
                                "name": "Hotel",
                                "primary": true
                            }
                        ],
                        "chains": [
                            {
                                "id": "247",
                                "name": "WESTIN"
                            }
                        ],
                        "references": [
                            {
                                "supplier": {
                                    "id": "tripadvisor"
                                },
                                "id": "96164"
                            },
                            {
                                "supplier": {
                                    "id": "yelp"
                                },
                                "id": "6e8TDXNdMK4TMYwKkaylgA"
                            },
                            {
                                "supplier": {
                                    "id": "yelp"
                                },
                                "id": "KPViT0aZyIvt0TUQOBrecg"
                            }
                        ],
                        "contacts": [
                            {
                                "phone": [
                                    {
                                        "value": "+15032949000"
                                    },
                                    {
                                        "value": "+18776284408",
                                        "categories": [
                                            {
                                                "id": "500-5000-0053"
                                            }
                                        ]
                                    }
                                ],
                                "fax": [
                                    {
                                        "value": "+15032419565",
                                        "categories": [
                                            {
                                                "id": "500-5000-0053"
                                            }
                                        ]
                                    }
                                ],
                                "www": [
                                    {
                                        "value": "http://www.dossierhotel.com",
                                        "categories": [
                                            {
                                                "id": "500-5000-0053"
                                            }
                                        ]
                                    },
                                    {
                                        "value": "https://dossierhotel.com/special-offers",
                                        "categories": [
                                            {
                                                "id": "500-5000-0053"
                                            }
                                        ]
                                    },
                                    {
                                        "value": "https://dossierhotel.com"
                                    }
                                ],
                                "email": [
                                    {
                                        "value": "info@dossierhotel.com"
                                    }
                                ]
                            }
                        ],
                        "openingHours": [
                            {
                                "text": [
                                    "Mon-Sun: 00:00 - 24:00"
                                ],
                                "isOpen": true,
                                "structured": [
                                    {
                                        "start": "T000000",
                                        "duration": "PT24H00M",
                                        "recurrence": "FREQ:DAILY;BYDAY:MO,TU,WE,TH,FR,SA,SU"
                                    }
                                ]
                            }
                        ],
                        "payment": {
                            "methods": [
                                {
                                    "id": "mastercard",
                                    "accepted": true
                                }
                            ]
                        }
                    },
                    {
  

As ChatGPT handled my softballs with ease I turned toward my new friend. As a new user, maybe you deduce that there could be “other” endpoints with the API to allow access to different resources. There are actually several endpoints we can tap into using the HERE Geocoding & Search API:

Question: What endpoints make up the HERE Geocoding & Search API?

ChatGPT

I was honestly impressed by this response due to the nuance of the documentation. There are 7 services comprising the Geocoding & Search API. In addition to the above, there is also Autosuggest which provides term and query suggestions as you type (with spell correction). The documentation of the API has more detailed information on the endpoints and how to use them.

Next, we decided to experiment with Discover

Discover is a part of the search endpoint and provides users the ability to find a known place or address (partial or complete), as well as discover an unknown place. The expectation is that multiple items may be returned, and the end-user will select the most appropriate:

Input
Copied
        GET https://discover.search.hereapi.com/v1/discover?at=45.52,-122.68&q=hotel&limit=100&radius=16000&apiKey={YOUR_API_KEY}
  

ChatGPT correctly switches the endpoint to /discover, along with the parameters I gave it. Now, to throw it into Postman:

Postman

This churned out a monster list of hotels. You could work with this output any number of ways. For example, visualize the results on a map, a table in postman, export it as a raw file, or any other method to visualize this output. Below is an example of this discover request in a web mapping application:

MapView

This app takes the following inputs/parameters:

  • At- Searches at a specific center as a lat/long coordinate pair. In this example, Portland OR.: 45.52,-122.68
  • q- is the free-text query, in this example “hotel”
  • apiKey- Our authentication generated from within the HERE platform
  • limit – Max results to show. For this, we set 100
  • Radius- Circular area in meters. This example is set to 16000
  • Location- Is the actual coordinate pair in lat/long for each hotel

These obviously will match the query parameters defined in the Params tab of Postman. This asset will be dissected in a future blog next week!

In closing

This can go on forever with infinite permutations and I have yet to see ChatGPT produce an outright bad answer. If a response is off, it is usually just slightly off. The possibilities are truly endless but the takeaways here are that ChatGPT is mind-boggling, you can use it to learn just about anything (or maybe everything), including how to send requests to the HERE Geocoding & Search API. 

For a developer who wants to integrate geocoding and search functionality into an application, HERE’s Geocoding and Search API provides both a comprehensive set of endpoints plus HERE’s data/content. Plus, unlike other providers, you can also add your own datasets to enable greater flexibility in building differentiating experiences for the end-user.

Look for a follow up blog on the asset used to create the mapping visual!

ChatGPT is an AI trained model that interprets questions or instructions and answers in generated natural language. I used the ChatGPT January 30 version, Free Research Preview.

Other Resources

For reference, here is a complete list of Endpoint URLs for submitting Geocoding & Search API requests:

  • autosuggest - https://autosuggest.search.hereapi.com/v1/autosuggest
  • search - https://discover.search.hereapi.com/v1/discover
  • geocode - https://geocode.search.hereapi.com/v1/geocode
  • autocomplete - https://autocomplete.search.hereapi.com/v1/autocomplete
  • browse - https://browse.search.hereapi.com/v1/browse
  • lookup by ID - https://lookup.search.hereapi.com/v1/lookup
  • revgeocode - https://revgeocode.search.hereapi.com/v1/revgeocode

Visit the developer platform https://developer.here.com/documentation for the classic endpoint documentation:

If you have a platform account, you can also view the service endpoint docs here:

  • https://platform.here.com/services/
Aaron Falk

Aaron Falk

Principal Developer Evangelist

Have your say

Sign up for our newsletter

Why sign up:

  • Latest offers and discounts
  • Tailored content delivered weekly
  • Exclusive events
  • One click to unsubscribe