Hands On

HERE with Postman

By Shruti Kuber | 05 June 2020

Try HERE Maps

Create a free API key to build location-aware apps and services.

Get Started

RESTful APIs or REST APIs are one of the easiest ways to communicate with services to build your application. HERE provides developers with over 20 APIs through a freemium account. These APIs are available as REST APIs along with their JS wrappers. What is amazing about REST APIs is the fact that they are independent of platforms, frameworks and languages. So you can call them in many different ways. Moreover there are several tools available to test out the responses of REST APIs. One such tool is Postman.

Postman is not merely a way to test REST APIs, but you can do a lot with it. You can also use it to build your own APIs and write documentation around it. Today I am going to talk about tips and tricks to  call HERE REST APIs efficiently with Postman. First, let's create a simple request with my favorite Geocoding and Search API.

Creating a request

If you take a look at the structure of the Postman window, there are several components to make a REST call. To make a simple call, we are going to look at the three main ones:- Request type, Request URL and Response. Now if you go to the Construct a Request section of the Geocoding and Search API, you will notice that the API call has the same structure. By following the documentation, we select GET as our request type. The next important thing is the request URL. In this case, it will be https://geocode.search.hereapi.com/v1/geocode as we want to make a simple geocoding request. This is followed by parameters to make this call. The minimum required parameter to make a geocoding request is the free form text query q for what you want to get the location for. So lets add that to our URL.
The URL should look like https://geocode.search.hereapi.com/v1/geocode?q=Brandenburg gate, Berlin. The most important parameter to make any HERE API call is authentication. For this request, I will use the REST API Key from the projects page of my freemium developer account with HERE. On adding my API Key, my URL now looks like https://geocode.search.hereapi.com/v1/geocode?q=Brandenburg gate, Berlin&apiKey={MY_REST_API_KEY}. Now copy this into the request URL bar of the Postman window and click on Send. You will see the response of this API in the Response section.

Postman witrndow with components

Parameters

In the previous step, the parameters that we added to the URL after the main API resource are reflected in the params section of the Postman window. So instead of creating the request URL with all the parameters and then entering it, you can simply add the base URL of the API and then keep adding the parameters in the params section with their respective values. You can also disable or enable a parameter by toggling the check-box next to it. With the Geocoding and Search request above, I am going to add the parameter limit as I want just one result in the response.

params

Environments

You might have already noticed that you can't see my API Key in the screen grabs above. This is because I have saved them in the Postman Environment. Environments in Postman let you store your API keys or other authentication keys so you don't have to enter them every time you create a request. This is also super handy when you are using APIs from different companies and platforms. You can then have several environments for each of the API platforms.

environment

Collections

After creating several requests for several different API endpoints, you may want to use them in the future. I may want to search the location of the fernsehturm this time and I don't want to construct the whole request from scratch. With Postman you can save your requests and group them as Collections. So I can save the requests for all the endpoints of the Geocoding and Search API, namely: Geocoding, Reverse geocoding, Discover, Autosuggest, Browse and Lookup in a collection called HERE Geocoding and Search and reference it whenever I want to test any of the endpoints. You can also share these collections and import other collections into your window.

collections

Bonus- Creating Bearer Tokens

In the above examples, I have used an API Key to authenticate my call to the Geoocoding and Search API. HERE also provides authentication with OAuth 2.0 tokens. You can generate these bearer tokens with Postman. Head over to this tutorial to check out how. Have fun creating your HERE API Collections on Postman!