OLS Client HERE Public Transit API

The Public Transit API v8 offers three REST APIs, namely Public Transit Routing API v8, Public Transit Next Departures API v8, and Public Transit Station Search API v8.

These APIs allow you to use agency data, external services, and data collected by HERE to discover public transit options, request public transit routes, and transit-related information.

The following pages describe the per-request configuration and metrics.

Example

Public Transit Routing API v8 provides the most efficient and relevant transit routes between a given pair of locations.

Scala
Java
val client = BaseClient()
val routingApi = client.of[RoutingApi]

val result = routingApi
  .getRoutes(
    origin = "41.79457,12.25473",
    destination = "41.90096,12.50243",
    modes = List("regionalTrain")
  )
  .executeToEntity()

result
  .andThen {
    case Success(response) =>
      // do something with the departures response
      println(response)
    case Failure(ex) =>
      ex.printStackTrace()
  }

Await.result(result, Duration.Inf)
BaseClient client = BaseClientJava.instance();

RoutingApi routingApi = new RoutingApi(client);

TransitRouteResponse route =
    routingApi
        .getRoutes()
        .withOrigin("41.79457,12.25473")
        .withDestination("41.90096,12.50243")
        .withModes(Collections.singletonList("regionalTrain"))
        .build()
        .toEntity();

System.out.println(route);

Examples of responses can be found in the Developer Guide

Public Transit Next Departures API v8 provides subsequent departures from a given station.

Scala
Java
val client = BaseClient()
val nextDeparturesApi = client.of[NextDeparturesApi]

val baseBoards = BoardByLocation(
  in = "41.900138,12.501924;r=500",
  maxPlaces = Option(10)
)

val result = nextDeparturesApi
  .getDepartures(
    boardOptions = Option(baseBoards),
    modes = List("regionalTrain")
  )
  .executeToEntity()

result
  .andThen {
    case Success(response) =>
      // do something with the departures response
      println(response)
    case Failure(ex) =>
      ex.printStackTrace()
  }

Await.result(result, Duration.Inf)
BaseClient client = BaseClientJava.instance();

NextDeparturesApi nextDeparturesApi = new NextDeparturesApi(client);
BaseBoards baseBoards =
    new JBoardByLocation.Builder()
        .withIn("41.900138,12.501924;r=500")
        .withMaxPlaces(10)
        .build();

StationBoardResponse departure =
    nextDeparturesApi
        .getDepartures()
        .withBoardOptions(Optional.ofNullable(baseBoards))
        .withModes(Collections.singletonList("regionalTrain"))
        .build()
        .toEntity();

System.out.println(departure);

Examples of responses can be found in the Developer Guide

Public Transit Station Search API v8 provides transit stations within a given area.

Scala
Java
val client = BaseClient()
val stationSearchApi = client.of[StationSearchApi]

val placesByLocation = PlacesByLocation(in = "41.900138,12.501924;r=500")

val result = stationSearchApi
  .getStations(stationOptions = Option(placesByLocation))
  .executeToEntity()

result
  .andThen {
    case Success(response) =>
      // do something with the departures response
      println(response)
    case Failure(ex) =>
      ex.printStackTrace()
  }

Await.result(result, Duration.Inf)
BaseClient client = BaseClientJava.instance();

StationSearchApi stationSearchApi = new StationSearchApi(client);

PlacesByLocation placesByLocation =
    new JPlacesByLocation.Builder().withIn("41.90123,12.50091").build();

StationsInfoResponse station =
    stationSearchApi
        .getStations()
        .withStationOptions(Optional.ofNullable(placesByLocation))
        .build()
        .toEntity();

System.out.println(station);

Examples of responses can be found in the Developer Guide

results matching ""

    No results matching ""