Route endpoint

How to compute travel distance, time and path for a pair of origin and destination by using public transportation.

  1. Required parameters
  2. Optional Parameters
  3. Route example
  4. Response
  5. Route endpoint server side

Get distance, duration, path and public transport details between an origin and a destination, based on public tranportation between those two points. This endpoint provides all the information needed to evaluate an itinerary and display it on a map. Transit API uses data provided by transit agencies (real time, timetables, average travel times) to build itineraries. In addition pedestrian mode can be proposed in itineraries to reach starting and ending points and commute between transportation modes…

Requests should be built as follows:

        https://api.woosmap.com/transit/route?parameters

    

Required parameters

Some parameters are required to initiate a Transit Route API request. As it is standard in URLs, all parameters are separated using the ampersand (&) character. The list of parameters and their possible values are enumerated below.

        https://api.woosmap.com/transit/route?destination=47.852954,2.290887&origin=49.850077,4.311124&key={PUBLIC_API_KEY}

    

origin

The starting point for the route. It should be supplied in the form of latitude,longitude coordinates.

destination

The ending point for the route. It should be supplied in the form of latitude,longitude coordinates.

key or private_key

Your project’s API key. This key identifies your Woosmap Project for security purposes and quota management. (you should use key client side and private_key server side)

Please refer to the documentation to get an API Key if necessary.

Optional Parameters

departure_time

The date-time to base the calculation on. Valid values are date-time with or without timezone (for example, 2019-06-24T01:23:45) or timestamp. If departure_time and arrival_time are not defined, the default departure_time is set to now

arrival_time

The date-time to base the calculation on. Valid values are date-time or timestamp. If departure_time is set, arrival_time is ignored

The Transit API utilizes real-time, timetable, and estimated data to suggest itineraries according to availability). Real-time info provides current vehicle locations and disruptions, while timetables offer detailed schedules. Estimated travel times are provided when granular schedules are unavailable. However, we cannot guarantee coverage areas to be complete and that some transit options might be missing.

modes

Transit mode filter used to determine which modes of transit to include in the response. By default, all supported transit modes are permitted.
Supported modes: highSpeedTrain intercityTrain interRegionalTrain regionalTrain cityTrain bus ferry subway lightRail privateBus inclined aerial busRapid monorail flight spaceship.

This parameter also support an exclusion list: It’s sufficient to specify each mode to exclude by prefixing it with -.
Mixing of inclusive and exclusive transit modes is not allowed.

examples:

Route example

The following example requests the route between an origin to a destination:

Transit Service
        curl -L -X GET 'https://api.woosmap.com/transit/route?origin=48.73534,2.368308&destination=48.83534,2.368308&key=YOUR_PUBLIC_API_KEY' \
-H 'Referer: http://localhost'
    
        import requests

url = "https://api.woosmap.com/transit/route?origin=48.73534,2.368308&destination=48.83534,2.368308&key=YOUR_PUBLIC_API_KEY"

payload={}
headers = {
    'Referer': 'http://localhost'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

    
        var requestOptions = {
  method: 'GET',
  redirect: 'follow'
};

fetch("https://api.woosmap.com/transit/route?origin=48.73534,2.368308&destination=48.83534,2.368308&key=YOUR_PUBLIC_API_KEY", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
    

Response

Route provides a JSON response containing the following root elements:

Status Codes

Routes

Each routes contains the following fields:

Legs

Each legs contains the following fields:

In certain cases, data provided by transit agencies cannot be used without displaying copyright notices to the end user. If a routing response contains this type of data, the Transit API adds operator attribution information to the route response. Operator attribution must be displayed together with a route. This requirement is part of the terms and conditions for the Woosmap Transit API.

Route endpoint server side

As for other Woosmap APIs, if you plan to use the Route endpoint of Transit API server side you must use a private_key in your requests.

        .../transit/route?origin=48.836,2.237&destination=48.709,2.403&private_key=[Private APIKey]

    

Transit API is mostly based on the Here Public Transit API. Woosmap Transit API has been incorporated to the Woosmap platform to ease and speed-up integrations and help customers cover itinerary use cases. More details on coverage information are available here.

Was this article helpful?
Have more questions? Submit a request