Introduction
HERE Technologies is a global company that provides a number of map data and geolocation information services platform. As the API services that HERE provides have an amazing amount of functions, I would like to introduce a part of those functions to you.
https://www.here.com
Table of contents
- Preparations
- HERE Routing API
- An amazing amount of parameters
- Official demo site
Preparations
To use the API, there are 3 preparations
- Register in the Developer section for HERE
- Issue an API key
As there is a guide for registering in the official Routing API documents, let’s register!
It is free of charge to register for an API key.
Below is the reference page for the Routing API:
HERE Routing API reference
There is also a document for swagger API references.
Swagger API reference page
HERE Routing API
You might ask, what is a Routing API.
Explaining simply, a routing API is an API for searching routes between a starting position and a goal position.
So, the most basic usage of the API requires us to set the
- Starting position
- Goal positon
- Method of movement parameters.
After that, we can call the API with curl
curl -X GET \
'https://router.hereapi.com/v8/routes?transportMode=car&origin=43.068411,141.350900&destination=43.064631,141.362023&apikey={YOUR_KEY}'
*Please replace {YOUR_KEY} with your API key
The starting position: origin
The goal position: destination
The mode of movement: transportMode
The modes of movement (transportation) are
- Pedestrian
- Car
- Truck
- Bicycle
- Scooter
Although being able to select scooter as the mode of transportation may be unique to the HERE API, the contents introduced here are mostly available in other Routing API as well.
The response that we receive is as below:
{"routes":[{
"id":"fd8bf9ac-6994-4da6-bd19-65bf43ad6360",
"sections":[{
"id":"e60d4705-43bc-452e-bd40-cde37d6f005f",
"type":"vehicle",
"departure":{
"time":"2022-06-24T17:20:33+09:00",
"place":{
"type":"place",
"location":{
"lat":43.0668075,
"lng":141.3507903
},
"originalLocation"{
"lat":43.0684109,
"lng":141.3509
}
}
},
"arrival":{
"time":"2022-06-24T17:24:10+09:00",
"place":{
"type":"place",
"location":{
"lat":43.0646414,
"lng":141.3620202
},
"originalLocation":{
"lat":43.064631,
"lng":141.3620229
}
}
},
"transport":{"mode":"car"}
}]
}]
}
A rich number of parameters
From here on is the special thing about the HERE Routing API.
Even only by simply looking at the documents, it can be seen that the API has the following optional parameters:
- Getting the shape of the route
- Taking into consideration the elevation for the route
- Getting directions on when to turn
- Getting the name of the road
- Considering whether the destination is on the right or the left side of the road
- Considering whether there is a median barrier
- Calculating routes with multiple destinations
- Caching a previously calculated route and using it for calculation of a new route
- Changing the language and timezone
- Adding the usage of a ferry
- Setting the speed limit
- Setting places to avoid
- etc…
In the parameters, there are also some that are specialized for EVs (electric vehicles), such as the setting the charging situation of the vehicle.
It can be said that the API is customized for being used in the logistics industry.
As conclusion, I would like to show you the result for waking from Sapporo station to our office.
(Please replace YOUR_KEY with your API key)
curl -X GET \
'https://router.hereapi.com/v8/routes?transportMode=pedestrian&origin=43.068411,141.350900&destination=43.064631,141.362023&return=polyline,actions,instructions&lang=ja&apikey={YOUR_KEY}'
Following is the response
{
"routes": [
{
"id": "e9942278-2dc3-42e9-8801-3e9b6c84f3fb",
"sections": [
{
"id": "faeea7a2-d775-4eb9-8287-2244707457d3",
"type": "pedestrian",
"actions": [
{
"action": "depart",
"duration": 56,
"length": 56,
"instruction": "Head south. Go for 56 m.",
"offset": 0
},
{
"action": "turn",
"duration": 70,
"length": 59,
"instruction": "Turn right. Go for 59 m.",
"offset": 1,
"direction": "right",
"severity": "quite"
},
{
"action": "turn",
"duration": 415,
"length": 405,
"instruction": "Turn left onto Kita 5Jo Teine-dori Street. Go for 405 m.",
"offset": 5,
"direction": "left",
"severity": "quite"
},
{
"action": "turn",
"duration": 267,
"length": 267,
"instruction": "Turn right onto Soseigawa-dori Street. Go for 267 m.",
"offset": 9,
"direction": "right",
"severity": "quite"
},
{
"action": "turn",
"duration": 142,
"length": 133,
"instruction": "Turn slightly left. Go for 133 m.",
"offset": 12,
"direction": "left",
"severity": "light"
},
{
"action": "turn",
"duration": 444,
"length": 444,
"instruction": "Turn left onto Kita 2Jo-dori Street. Go for 444 m.",
"offset": 15,
"direction": "left",
"severity": "quite"
},
{
"action": "arrive",
"duration": 0,
"length": 0,
"instruction": "Arrive at Kita 2Jo-dori Street.",
"offset": 23
}
],
"departure": {
"time": "2022-11-22T10:34:38+09:00",
"place": {
"type": "place",
"location": {
"lat": 43.0675835,
"lng": 141.3511245
},
"originalLocation": {
"lat": 43.0684109,
"lng": 141.3509
}
}
},
"arrival": {
"time": "2022-11-22T10:57:52+09:00",
"place": {
"type": "place",
"location": {
"lat": 43.0646414,
"lng": 141.3620202
},
"originalLocation": {
"lat": 43.064631,
"lng": 141.3620229
}
}
},
"polyline": "BG-r0kyCqtsztI3eyH3BpV1CvEzF5B1HbiLgyCyMuiDqM0lDyDwYzoCyS7xB4MrZ2G5J6FnIgC72BiO2GywBoG4vBoGyuBqH8xBkGqwBiHkxB8BuMsE6gB",
"language": "en-us",
"transport": {
"mode": "pedestrian"
}
}
]
}
]
}
Official demo site
By the way, there is a website where you can try out the HERE API.
HERE Routing API demo site
Although it requires an authenticated HERE account, there is also an official page where support demos are shown.
HERE support site
As the APIs can be tried out for free, I recommend everyone who is interested to try out the API.
Original article:
https://qiita.com/northprint/items/837312c5ea7d0fd0966c
Top comments (0)