Skip to content

Latest commit

 

History

History
61 lines (44 loc) · 2.82 KB

reference.md

File metadata and controls

61 lines (44 loc) · 2.82 KB

OJP SDK Reference

OJP APIs Request

Define/Choose API Stage

For all requests a StageConfig object is needed.

export interface StageConfig {
    key: string
    apiEndpoint: string
    authBearerKey: string
}

For convenience the SDK is providing a default stage DEFAULT_STAGE otherwise a key will be needed from opentransportdata.swiss. For possible endpoints check app-config.ts in OJP Demo App.

import * as OJP from 'ojp-sdk'

const stage = OJP.DEFAULT_STAGE;

SDK members

  • this SDK doesnt implement all members from VDVde/OJP schema
  • this SDK doesnt implement 1-1 members and properties from the schema

OJP API related objects

Path Classes
src/location Location, GeoPosition, StopPlace, etc
src/request LIR, SER, TR XML fetch / request parsers
src/situation SIRI-SX elements
src/stop-event StopEvent
src/trip Trip, TripTimedLeg, TripContinousLeg, LegTrack + other trip, trip legs related methods
src/journey JourneyService TripTimedLeg related
  • these objects are instantiated from the XML parser using initWithTreeNode static initializers by supplying TreeNode structs
  • some of these objects (i.e. Location) can be instantiated using static initializers for coords, reference stops, etc
const locationBern = OJP.Location.initWithStopPlaceRef('8507000');

OJP Requests

XML fetch / parsing

  • plain Fetch API is used for network requests to OJP API backend
  • all the requests are using sax-js for XML parsing
  • XML parsing is done in an event-based (pull-parsing) manner
  • see src/request/base-parser.ts base parser implementation and LIR, TR, SER child classes implementation for the events used

Back to Documentation