Resources

The resources use a data model that is supported by a set of client-side libraries that are made available on the files and libraries page.

name path methods description
AlertPatcher
  • /otp/patch/patch
  • /otp/patch/routePatches
  • /otp/patch/stopPatches
  • POST
  • GET
  • GET
BikeRental
  • /otp/routers/{routerId}/bike_rental
  • GET
ExternalGeocoderResource
  • /otp/geocode
  • GET
Maybe the internal geocoder resource should just chain to defined external geocoders?
GeocoderResource
  • /otp/routers/{routerId}/geocode
  • GET
OTP simple built-in geocoder. Client geocoder modules usually read XML, but GeocoderBuiltin reads JSON.
GraphInspectorTileResource
  • /otp/routers/{routerId}/inspector/layers
  • /otp/routers/{routerId}/inspector/tile/{layer}/{z}/{x}/{y}.{ext}
  • GET
  • GET
Slippy map tile API for rendering various graph information for inspection/debugging purpose (bike safety factor, connectivity...). One can easily add a new layer by adding the following kind of code to a leaflet map:
   var bikesafety = new L.TileLayer(
      'http://localhost:8080/otp/routers/default/inspector/tile/bike-safety/{z}/{x}/{y}.png',
      { maxZoom : 22 });
   var map = L.map(...);
   L.control.layers(null, { "Bike safety": bikesafety }).addTo(map);
 
Tile rendering goes through TileRendererManager which select the appropriate renderer for the given layer.
IndexAPI
  • /otp/routers/{routerId}/index/clusters
  • /otp/routers/{routerId}/index/feeds
  • /otp/routers/{routerId}/index/flexAreas
  • /otp/routers/{routerId}/index/graphql
  • /otp/routers/{routerId}/index/patterns
  • /otp/routers/{routerId}/index/routes
  • /otp/routers/{routerId}/index/services
  • /otp/routers/{routerId}/index/stops
  • /otp/routers/{routerId}/index/agencies/{feedId}
  • /otp/routers/{routerId}/index/clusters/{clusterId}
  • /otp/routers/{routerId}/index/feeds/{feedId}
  • /otp/routers/{routerId}/index/flexAreas/{id}
  • /otp/routers/{routerId}/index/patterns/{patternId}
  • /otp/routers/{routerId}/index/routes/{routeId}
  • /otp/routers/{routerId}/index/services/{serviceId}
  • /otp/routers/{routerId}/index/stops/{stopId}
  • /otp/routers/{routerId}/index/trips/{tripId}
  • /otp/routers/{routerId}/index/agencies/{feedId}/{agencyId}
  • /otp/routers/{routerId}/index/patterns/{patternId}/geometry
  • /otp/routers/{routerId}/index/patterns/{patternId}/semanticHash
  • /otp/routers/{routerId}/index/patterns/{patternId}/stops
  • /otp/routers/{routerId}/index/patterns/{patternId}/trips
  • /otp/routers/{routerId}/index/routes/{routeId}/patterns
  • /otp/routers/{routerId}/index/routes/{routeId}/stops
  • /otp/routers/{routerId}/index/routes/{routeId}/trips
  • /otp/routers/{routerId}/index/stops/{stopId}/patterns
  • /otp/routers/{routerId}/index/stops/{stopId}/routes
  • /otp/routers/{routerId}/index/stops/{stopId}/stoptimes
  • /otp/routers/{routerId}/index/stops/{stopId}/transfers
  • /otp/routers/{routerId}/index/trips/{tripId}/geometry
  • /otp/routers/{routerId}/index/trips/{tripId}/semanticHash
  • /otp/routers/{routerId}/index/trips/{tripId}/stops
  • /otp/routers/{routerId}/index/trips/{tripId}/stoptimes
  • /otp/routers/{routerId}/index/agencies/{feedId}/{agencyId}/routes
  • /otp/routers/{routerId}/index/stops/{stopId}/stoptimes/{date}
  • GET
  • GET
  • GET
  • POST
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
LIsochrone
  • /otp/routers/{routerId}/isochrone
  • GET
Return isochrone geometry as a set of GeoJSON or zipped-shapefile multi-polygons. Example of request: http://localhost:8080/otp-rest-servlet/ws/isochrone?routerId=bordeaux&algorithm=accSampling&fromPlace=47.059,-0.880&date=2013/10/01&time=12:00:00&maxWalkDistance=1000&mode=WALK,TRANSIT&cutoffSec=1800&cutoffSec=3600
LegendResource
  • /otp/analyst/legend.{format}
  • GET
MunicoderServer
  • /otp/municoder
  • GET
PlannerResource
  • /otp/routers/{routerId}/plan
  • GET
This is the primary entry point for the trip planning web service. All parameters are passed in the query string. These parameters are defined as fields in the abstract RoutingResource superclass, which also has methods for building routing requests from query parameters. This allows multiple web services to have the same set of query parameters. In order for inheritance to work, the REST resources are request-scoped (constructed at each request) rather than singleton-scoped (a single instance existing for the lifetime of the OTP server).
PointSetResource
  • /otp/pointsets
  • /otp/pointsets/{pointSetId}
  • GET
  • GET
This Jersey REST Resource creates and lists PointSets. PointSets serve as destinations in web analyst one-to-many indicators. They can also serve as origins in many-to-many indicators. PointSets are one of the three main web analyst resources: Pointsets Indicators TimeSurfaces
ProfileResource
  • /otp/routers/{routerId}/profile
  • GET
A Jersey resource class which exposes OTP profile routing functionality as a web service.
RepeatedRaptorTestResource
  • /otp/routers/{routerId}/rrtr
  • GET
For debugging
Routers
  • /otp/routers
  • /otp/routers/save
  • /otp/routers/{routerId}
  • DELETE GET PUT
  • POST
  • DELETE GET POST PUT
This REST API endpoint allows remotely loading, reloading, and evicting graphs on a running server. A GraphService maintains a mapping between routerIds and specific Graph objects. The HTTP verbs are used as follows to manipulate that mapping: GET - see the registered routerIds and Graphs, verify whether a particular routerId is registered PUT - create or replace a mapping from a routerId to a Graph loaded from the server filesystem POST - create or replace a mapping from a routerId to a serialized Graph sent in the request DELETE - de-register a routerId, releasing the reference to the associated graph The HTTP request URLs are of the form /ws/routers/{routerId}, where the routerId is optional. If a routerId is supplied in the URL, the verb will act upon the mapping for that specific routerId. If no routerId is given, the verb will act upon all routerIds currently registered. For example: GET http://localhost/otp-rest-servlet/ws/routers will retrieve a list of all registered routerId -> Graph mappings and their geographic bounds. GET http://localhost/otp-rest-servlet/ws/routers/london will return status code 200 and a brief description of the 'london' graph including geographic bounds, or 404 if the 'london' routerId is not registered. PUT http://localhost/otp-rest-servlet/ws/routers will reload the graphs for all currently registered routerIds from disk. PUT http://localhost/otp-rest-servlet/ws/routers/paris will load a Graph from a sub-directory called 'paris' and associate it with the routerId 'paris'. DELETE http://localhost/otp-rest-servlet/ws/routers/paris will release the Paris Graph and de-register the 'paris' routerId. DELETE http://localhost/otp-rest-servlet/ws/routers will de-register all currently registered routerIds. The GET methods are not secured, but all other methods are secured under ROLE_ROUTERS. See documentation for individual methods for additional parameters.
SIsochrone
  • /otp/routers/{routerId}/isochroneOld
  • GET
This is the original Isochrone class provided by Stefan Steineger. Another implementation has been provided by Laurent Grégoire (isochrone2).
ScenarioResource
  • /otp/routers/{routerId}/scenarios
  • /otp/routers/{routerId}/scenarios/{scenarioId}
  • GET
  • GET
Presents saved non-destructive transit analysis scenarios as a document tree for manipulation via HTTP.
ScriptResource
  • /otp/scripting/run
  • POST
Run an uploaded script. This is unsafe, enable it with care. TODO Enable role-based permissions.
ServerInfo
  • /otp
  • GET
SimpleIsochrone
  • /otp/routers/{routerId}/simpleIsochrone
  • GET
This class provides a vector isochrone generator for places without good OSM street connectivity, or for graphs that are too large-scale to bother with modeling streets (e.g. all of China). It assumes constant speed through both streets and "free space" around vertices, yielding isochrones that are the union of many circles. The origin snapping option used here (connect to all stations within M meters of a lat/lon) should be made into a standard query option in OTP. Instead of specifying an origin station search radius, it could be more coherent to use all stations within (maxIsochroneTime * speed) meters, and apply a travel time to reach them. The GET methods both use makeContours which in turn uses makePoints (where range checking occurs). Putting "@Setter" on all the parameters would allow resource classes to be used outside Jersey.
SurfaceResource
  • /otp/surfaces
  • /otp/surfaces/{surfaceId}
  • /otp/surfaces/{surfaceId}/indicator
  • /otp/surfaces/{surfaceId}/isochrone
  • /otp/surfaces/{surfaceId}/raster
  • /otp/surfaces/{surfaceId}/isotiles/{z}/{x}/{y}.png
  • /otp/surfaces/{surfaceId}/differencetiles/{compareToSurfaceId}/{z}/{x}/{y}.png
  • GET POST
  • GET
  • GET
  • GET
  • GET
  • GET
  • GET
Surfaces cannot be isolated per-router because sometimes you want to compare two surfaces from different router IDs. Though one could question whether that really makes sense (perhaps alternative scenarios should be "within" the same router)
TileService
  • /otp/routers/{routerId}/analyst/tile/{z}/{x}/{y}.png
  • GET
NOTE This way of fetching travel time tiles does not currently work. It relied on an SPT cache which would find existing SPTs based on search request parameters. Server side stored search results are now done explicitly with TimeSurfaces. See org.opentripplanner.api.resource.SurfaceResource, functions createSurface and tileGet The basic idea is to create a surface for a "batch" or one-to-many OTP search, then using the returned ID fetch the tiles from a URL under that surface ID.
TimeGridWs
  • /otp/routers/{routerId}/timegrid
  • GET
A Jersey web service resource class that returns a grid with time for a set of points. Example of request: http://localhost:8080/otp/routers/bordeaux/timegrid?fromPlace=47.059,-0.880&date=2013/10/01&time=12:00:00&maxWalkDistance=1000&maxTimeSec=3600&mode=WALK,TRANSIT
UpdaterStatusResource
  • /otp/routers/{routerId}/updaters
  • /otp/routers/{routerId}/updaters/{updaterId}
  • GET
  • GET
Report the status of the graph updaters via a web service.

Data Types

JSON

type description
AbsoluteDirection An absolute cardinal or intermediate direction.
Alert
AlertPatch This adds a note to all boardings of a given route or stop (optionally, in a given direction)
AlertPatchCreationResponse
AlertPatchResponse
AlertPatchSet
BikeRentalStation
BikeRentalStationList
BoardAlightType Distinguish between special ways a passenger may board or alight at a stop. The majority of boardings and alightings will be of type "default" -- a regular boarding or alighting at a regular transit stop. Currently, the only non-default types are related to GTFS-Flex, but this pattern can be extended as necessary.
Coordinate
CoordinateArrayListSequence An instance of CoordinateSequence that can be efficiently extended
CoordinateSequence
CoordinateSequenceFactory
DebugOutput Holds information to be included in the REST Response for debugging and profiling purposes. startedCalculating is called in the routingContext constructor. finishedCalculating and finishedRendering are all called in PlanGenerator.generate(). finishedPrecalculating and foundPaths are called in the SPTService implementations.
ElevationMetadata Contains elevation-specific metadata to be included in the response Created by demory on 2/16/17.
EncodedPolylineBean A list of coordinates encoded as a string. See Encoded polyline algorithm format
EntryOfStringAndString
Envelope
Fare

Fare is a set of fares for different classes of users.

FareComponent

FareComponent is a sequence of routes for a particular fare.

FareType
FeedScopedId
GeocoderResult
GeocoderResults
Geometry
GeometryFactory
I18NString This interface is used when providing translations on server side.
InspectorLayer
InspectorLayersList
Itinerary An Itinerary is one complete way of getting from the start location to the end location.
Leg One leg of a trip -- that is, a temporally continuous piece of the journey that takes place on a particular vehicle (or on foot).
LocalizedAlert
LocalizedString This is used to localize strings for which localization are known beforehand. Those are local names for: unanamedStreet, corner of x and y, path, bike_path etc. Translations are in src/main/resources/WayProperties_lang.properties and internals_lang.properties locale is set in request.
MavenVersion
Message The purpose of Messages is to read supply Message.properties to underlying calling code... The ENUM's enumerated values should be named to reflect the property names inside of Message.properties
Money Fare support is very, very preliminary.
NonLocalizedString This is to support strings which can't be localized. It just returns string it is given in constructor.
P2 An ordered pair of objects of the same type
P2OfDouble An ordered pair of objects of the same type
PackedCoordinateSequence A CoordinateSequence implementation based on a packed arrays. In this implementation, Coordinates returned by #toArray and #get are copies of the internal values. To change the actual values, use the provided setters.

For efficiency, created Coordinate arrays are cached using a soft reference. The cache is cleared each time the coordinate sequence contents are modified through a setter method. 2009-11-25 - bdferris - This class copied from JTS (LGPL-licensed) to add Serializable to the class so that we can serialize it with our graphs

Place A Place is where a journey starts or ends, or a transit stop along the way.
PlannerError This API response element represents an error in trip planning.
Point
PrecisionModel
RelativeDirection Represents a turn direction, relative to the current heading. CIRCLE_CLOCKWISE and CIRCLE_CLOCKWISE are used to represent traffic circles.
Response Represents a trip planner response, will be serialized into XML or JSON by Jersey
RouterInfo
RouterList
Serializable2DPackedCoordinateSequenceFactory
ServerInfo
T2 An ordered pair of objects of potentially different types
TranslatedString This is for translated strings for which translations are read from OSM or GTFS alerts. This can be translated street names, GTFS alerts and notes.
TravelOption This class is used to send to client which Travel Options are possible on this server This options are used in client "Travel by" drop down. Each travel option consist of two variables: - value is a value which is sent to the server if this is chosen ("TRANSIT, WALK", "CAR", etc.) - name is a name with which client can nicely name this option even if specific value changes ("TRANSIT", "PARKRIDE", "TRANSIT_BICYCLE", etc.) Travel options are created from org.opentripplanner.routing.graph.Graph transitModes variable and based if park & ride, bike & ride, bike sharing is supported. List itself is created in TravelOptionsMaker#makeOptions(HashSet, boolean, boolean, boolean)
TraverseMode
TripPlan A TripPlan is a set of ways to get from point A to point B at time T.
Type
VertexType Represent type of vertex, used in Place aka from, to in API for easier client side localization
WalkStep Represents one instruction in walking directions. Three examples from New York City:

Turn onto Broadway from W 57th St (coming from 7th Ave):
distance = 100 (say)
walkDirection = RIGHT
streetName = Broadway
everything else null/false

Now, turn from Broadway onto Central Park S via Columbus Circle
distance = 200 (say)
walkDirection = CIRCLE_COUNTERCLOCKWISE
streetName = Central Park S
exit = 1 (first exit)
immediately everything else false

Instead, go through the circle to continue on Broadway
distance = 100 (say)
walkDirection = CIRCLE_COUNTERCLOCKWISE
streetName = Broadway
exit = 3
stayOn = true
everything else false

WrappedCurrency A Bean wrapper class for java.util.Currency

XML

Default Namespace
type description
locale
geometry
message The purpose of Messages is to read supply Message.properties to underlying calling code... The ENUM's enumerated values should be named to reflect the property names inside of Message.properties
absoluteDirection An absolute cardinal or intermediate direction.
boardAlightType Distinguish between special ways a passenger may board or alight at a stop. The majority of boardings and alightings will be of type "default" -- a regular boarding or alighting at a regular transit stop. Currently, the only non-default types are related to GTFS-Flex, but this pattern can be extended as necessary.
itinerary An Itinerary is one complete way of getting from the start location to the end location.
leg One leg of a trip -- that is, a temporally continuous piece of the journey that takes place on a particular vehicle (or on foot).
place A Place is where a journey starts or ends, or a transit stop along the way.
relativeDirection Represents a turn direction, relative to the current heading. CIRCLE_CLOCKWISE and CIRCLE_CLOCKWISE are used to represent traffic circles.
routerInfo
routerList
tripPlan A TripPlan is a set of ways to get from point A to point B at time T.
vertexType Represent type of vertex, used in Place aka from, to in API for easier client side localization
walkStep Represents one instruction in walking directions. Three examples from New York City:

Turn onto Broadway from W 57th St (coming from 7th Ave):
distance = 100 (say)
walkDirection = RIGHT
streetName = Broadway
everything else null/false

Now, turn from Broadway onto Central Park S via Columbus Circle
distance = 200 (say)
walkDirection = CIRCLE_COUNTERCLOCKWISE
streetName = Central Park S
exit = 1 (first exit)
immediately everything else false

Instead, go through the circle to continue on Broadway
distance = 100 (say)
walkDirection = CIRCLE_COUNTERCLOCKWISE
streetName = Broadway
exit = 3
stayOn = true
everything else false

alertPatchCreationResponse
alertPatchResponse
alertPatchSet
localizedAlert
plannerError This API response element represents an error in trip planning.
bikeRentalStationList
debugOutput Holds information to be included in the REST Response for debugging and profiling purposes. startedCalculating is called in the routingContext constructor. finishedCalculating and finishedRendering are all called in PlanGenerator.generate(). finishedPrecalculating and foundPaths are called in the SPTService implementations.
elevationMetadata Contains elevation-specific metadata to be included in the response Created by demory on 2/16/17.
inspectorLayersList
inspectorLayer
response Represents a trip planner response, will be serialized into XML or JSON by Jersey
serverInfo
mavenVersion
p2 An ordered pair of objects of the same type
t2 An ordered pair of objects of potentially different types
feedScopedId
alert
alertPatch This adds a note to all boardings of a given route or stop (optionally, in a given direction)
bikeRentalStation
fare

Fare is a set of fares for different classes of users.

fareType
fareComponent

FareComponent is a sequence of routes for a particular fare.

money Fare support is very, very preliminary.
TraverseMode
wrappedCurrency A Bean wrapper class for java.util.Currency
i18NString This interface is used when providing translations on server side.
localizedString This is used to localize strings for which localization are known beforehand. Those are local names for: unanamedStreet, corner of x and y, path, bike_path etc. Translations are in src/main/resources/WayProperties_lang.properties and internals_lang.properties locale is set in request.
nonLocalizedString This is to support strings which can't be localized. It just returns string it is given in constructor.
translatedString This is for translated strings for which translations are read from OSM or GTFS alerts. This can be translated street names, GTFS alerts and notes.
travelOption This class is used to send to client which Travel Options are possible on this server This options are used in client "Travel by" drop down. Each travel option consist of two variables: - value is a value which is sent to the server if this is chosen ("TRANSIT, WALK", "CAR", etc.) - name is a name with which client can nicely name this option even if specific value changes ("TRANSIT", "PARKRIDE", "TRANSIT_BICYCLE", etc.) Travel options are created from org.opentripplanner.routing.graph.Graph transitModes variable and based if park & ride, bike & ride, bike sharing is supported. List itself is created in TravelOptionsMaker#makeOptions(HashSet, boolean, boolean, boolean)
encodedPolylineBean A list of coordinates encoded as a string. See Encoded polyline algorithm format