Calculate a Transit Route
User Story
You want to request a transit route from Terminal 1 of Roma Fiumicino International Airport to the Roma Termini central station using public transit.
Request
A transit route calculation consists of a single GET request. The only required parameters are an origin
and a destination
, given by two pairs of WGS84 coordinates in the form <latitude>,<longitude>
. The following request will calculate a transit route with default options:
GET https://transit.router.hereapi.com/v8/routes
?origin=41.79457,12.25473
&destination=41.90096,12.50243
The optional parameter alternatives
represents the number of alternative routes to return aside from the optimal route. By default, alternatives=0
, thus only one optimal route is returned if not set.
Response
If the route calculation was successful, the /routes
response contains the requested details about the calculated route:
- one optimal transit route, unless
alternatives
is greater than zero - multiple transit sections with each segment (representing either a pedestrian or a transit segment) containing departure/arrival times, duration and coordinates
- the transit segment shows the actual stops or stations of departure and arrival. Optionally, all intermediate stops in between can be also requested using the parameter
return=intermediate
- a set of operators that run the services included in the alternatives, including operator code, operator name and links to operator websites, if any.
{
"routes": [
{
"id": "R0023c9-C0",
"sections": [
{
"id": "R0023c9-C0-S0",
"type": "pedestrian",
"departure": {
"time": "2020-04-22T12:02:00+02:00",
"place": {
"type": "place",
"location": {
"lat": 41.79457,
"lng": 12.25473
}
}
},
"arrival": {
"time": "2020-04-22T12:08:00+02:00",
"place": {
"name": "Fiumicino Aeroporto",
"type": "station",
"location": {
"lat": 41.793466,
"lng": 12.251997
},
"id": "415713377"
}
}
},
{
"id": "R0023c9-C0-S1",
"type": "transit",
"departure": {
"time": "2020-04-22T12:08:00+02:00",
"place": {
"name": "Fiumicino Aeroporto",
"type": "station",
"location": {
"lat": 41.793466,
"lng": 12.251997
},
"id": "415713377"
}
},
"arrival": {
"time": "2020-04-22T12:40:00+02:00",
"place": {
"name": "Roma Termini",
"type": "station",
"location": {
"lat": 41.90054,
"lng": 12.502168
},
"id": "415712984"
}
},
"transport": {
"mode": "regionalTrain",
"name": "LE",
"category": "Regional Train",
"color": "#4C8DC1",
"textColor": "#000000",
"headsign": "Roma Termini"
},
"agency": {
"id": "aDmtre00",
"name": "Trenitalia",
"website": "http://www.trenitalia.com/"
},
"attributions": [
{
"id": "R0023c9-C0-S1-link-0",
"href": "http://creativecommons.org/licenses/by/3.0/it/",
"text": "Some line names used in this product or service were edited to align with official transportation maps.",
"type": "disclaimer"
}
]
},
{
"id": "R0023c9-C0-S2",
"type": "pedestrian",
"departure": {
"time": "2020-04-22T12:40:00+02:00",
"place": {
"name": "Roma Termini",
"type": "station",
"location": {
"lat": 41.90054,
"lng": 12.502168
},
"id": "415712984"
}
},
"arrival": {
"time": "2020-04-22T12:41:00+02:00",
"place": {
"type": "place",
"location": {
"lat": 41.90096,
"lng": 12.50243
}
}
}
}
]
}
]
}