1.0.8 • Published 6 years ago

oebb-api v1.0.8

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

OEBB-API (ÖBB-API)

A collection of functions fore node.js to acess train shedules, arrivals/departures, station search and ticketinformation from the OEBB(ÖBB)

I had a lot of help help from these great ressources

and a documentation file I found on the web

Installation

npm --save install oebb-api

Functions

searchStationsNew(name)

It returns an promise that resolves to an array of possible stations matching name

const oebb = require('oebb-api');

oebb.searchStationsNew("Wien").then(console.log);

returns

[{ number: 1190100,
    longitude: 16372134,
    latitude: 48208547,
    name: '',
    meta: 'Wien' },
  { number: 1290401,
    longitude: 16375326,
    latitude: 48185507,
    name: 'Wien Hbf (U)',
    meta: '' },
...
...
...]

searchStations(options)

searchStation is very similar to searchStationsNew it however can take more options and returns more information. You can call getStationSearchOptions to get a prefilled options object.

const oebb = require('oebb-api');

var options = oebb.getStationSearchOptions();
options.S="wien h";
oebb.searchStations(options).then(console.log);

It returns an array with matching stations, POIs, etc.

[ { value: 'Wien Hbf (U)',
    id: 'A=1@O=Wien Hbf (U)@X=16375326@Y=48185507@U=181@L=001290401@B=1@p=1513853468@',
    extId: '001290401',
    type: '1',
    typeStr: '[Bhf/Hst]',
    xcoord: '16375326',
    ycoord: '48185507',
    state: 'id',
    prodClass: '6013',
    weight: '32767' },
  { value: 'Wien Meidling',
    id: 'A=1@O=Wien Meidling@X=16333211@Y=48174559@U=181@L=001191201@B=1@p=1513853468@',
    extId: '001191201',
    type: '1',
    typeStr: '[Bhf/Hst]',
    xcoord: '16333211',
    ycoord: '48174559',
    state: 'id',
    prodClass: '4989',
    weight: '32588' },
...
...
...]
Namedescription
value:name of the station
idno idea
extIdused in other queries; same as number (not quite shure if the really are the same all the time)
typeint representing the type
typeStrthe type as string
xcoordlongitude
ycoordlatitude
stateno idea
prodClassno idea
weightI am guessing it represents how close a match the station is to the string

getStationSearchOptions()

It returns an object containing the options for searchStations

const oebb = require('oebb-api');

var options = oebb.getStationSearchOptions();

options

Namedefault valuevaluedescription
REQ0JourneyStopsS0A1An int between 1 and 255.It selects the type of station to return e.g. 1 is Bhf/Hst
REQ0JourneyStopsB12An int greater 0the amount of results which are returned
Sa stringthe string to match
jstruebooleanno idea what it does

getStationBoardData(options)

It returns a promise resolving to an object containing arrival or depature information for a specific station. You can get a prefilled options object, by calling getStationBoardDataOptions

const oebb = require('oebb-api');

var options = oebb.getStationBoardDataOptions();
options.evaId=1191601;//Ottakring (Wien)
oebb.getStationBoardData(options).then(console.log);

returns:

{ headTexts:
   [ 'Zeit',
     'Fahrt',
     'Nach',
     'Steig',
     'Abfahrten',
     'Aktuell',
     'Ankunft' ],
  stationName: 'Ottakring (Wien)',
  stationEvaId: '1191601',
  boardType: 'dep',
  imgPath: '/img/',
  iconProductsSubPath: 'vs_oebb/',
  rtInfo: true,
  journey:
   [ { id: '875171810',
       ti: '19:46',
       da: '23.12.2017',
       pr: 'U3',
       st: 'Wien Simmering',
       lastStop: 'Wien Simmering Bahnhof (U3)',
       ati: '20:12',
       tr: '1',
       trChg: false,
       rt: false,
       rta: false },
     { id: '836641815',
       ti: '19:46',
       da: '23.12.2017',
       pr: 'Tram 46',
       st: 'Wien Ring/Volkstheater U',
       lastStop: 'Wien Dr.-K.-Renner-Ring/Volkstheater (Schleife)',
       ati: '20:00',
       tr: '',
       trChg: ,
       rt: { status: null, dlm: '2', dlt: '19:47' , dld:'23.12.2017'},
       rta: false },
       ...
       ...
       ...
 ],
  maxJ: 18 }

element description

general:
Namedescription
headTextsheadings for arrivals depatures screen
stationNamename of station
stationEvaIdId of station
boardTypedepatures or arrivals (dep/arr)
imgPath?
iconProductsSubPath?
rtInfo?
maxJnumber of returned entries -1
journey:
Namedescription
id?
tiarrvial/depature time
daarrival/depature date
prname of transport
st?
lastStoplast stop
atiwehn arrivals depature time from first stop ; when depatures expected time to reach last stop
trtrack identifier
trChgdid the track change
rt :

it describes the delay or other status if there is one. If there is one it contains an object formated as follows:

Namedescription
statuscurrent status; "Ausfall" if canceled
dlmhow many minutes too late
dltactual arrival time
dldactual arrival date
rta

it is very similar to rt I think it describes the delay for the arrival, but I am not certain.

Namedescription
statuscurrent status "Ausfall" if canceled then rt too is canceld and rt.status= "Ausfall"
dlmnever seen it other than empty
dltnever seen it other than empty

getStationBoardDataOptions()

returns prefilled options for getStationBoardData

const oebb = require('oebb-api');

var options = oebb.getStationBoardDataOptions();

options

Namedefault valuevaluesdescription
Lvs_scotty.vs_livetickervs_scotty.vs_liveticker?
evaIdemptyintegerId of station; extId or number from searchStationsNew or searchStations
dirInputemptyintegerId of Station in which transportation is heading; extId or number f from searchStationsNew or searchStations. If it is set only trains which actually stop at the station specified with dirInput are shown
boardTypedepdep/arrdepatures or arrivals
timecurrent timeHH:MMtime from when to start looking
productsFilter1111111111111111binary flags?selects modes of transportation see below for more information
additionalTime0integerin minute. Is added to time
maxJourneys19integermax of returned stations
outputModetickerDataOnlytickerDataOnly?
startyesyes/nowheter to start query
selectDateperiodperiod/todyselects mode; if tody dateBegin and dateEnd are ignored.
dateBegincurrent dateString dd.mm.YYYYstart day for lookup ignored if selectDate=today
dateEndcurrent dateString dd.mm.YYYYend date for lookup ignored if selectDate=today
productsFilter

slects which modes of transports should be listed forexample if I set productsFilter to 0000110000000000 only s-bahn and regionalzüge are shown

Flag numbermode of transport
1railjet
2?
3ec and ice
4nightjet d probably also nightjet en
5regionalzüge
6s-bahn
7Bus
8?
9subway
10tram
11?
12?
13Westbahn
14?
15?
16?

getJourneys(from, to, add_offers, date)

returns a promise, that resolves to routes from to at date. To add the offers, if they exist, set add_offers to true. add_offers is by default false. date is a node-datetime object. It has to be imported through npm

const oebb = require('oebb-api');

oebb.searchStationsNew("Wien Hbf").then((res)=>{
	var from = res[0];
	oebb.searchStationsNew("Venezia Santa Lucia").then((res)=>{
		var to=res[0];
		oebb.getJourneys(from, to, true).then((res)=>{
            console.log(res);
        });
	})
});

####from and to they are formated:

from/to = { 
	number: 1190100,
    longitude: 16372134,
    latitude: 48208547,
    name: 'Wien',
};

This returns for example (connections describes the journey and offer contains the information about the price etc.): (The console output will hide most of it, but it is there)

{
	"connections": [
		{
			"connection": {
				"id": "fb8a994b473d2931b32583890559a1dcadd736a0f2016132f6d1628b8b1d68fd",
				"from": {
					"name": "Wien Hbf",
					"esn": 8103000,
					"departure": "2017-12-24T06:25:00.000",
					"departurePlatform": "7",
					"showAsResolvedMetaStation": false
				},
				"to": {
					"name": "Venezia Santa Lucia",
					"esn": 8300094,
					"arrival": "2017-12-24T14:05:00.000",
					"showAsResolvedMetaStation": false
				},
				"sections": [
					{
						"from": {
							"name": "Wien Hbf",
							"esn": 8103000,
							"departure": "2017-12-24T06:25:00.000",
							"departurePlatform": "7"
						},
						"to": {
							"name": "Venezia Santa Lucia",
							"esn": 8300094,
							"arrival": "2017-12-24T14:05:00.000"
						},
						"duration": 27600000,
						"category": {
							"name": "RJ",
							"number": "131",
							"displayName": "RJ",
							"longName": {
								"de": "Railjet",
								"en": "Railjet",
								"it": "Railjet"
							},
							"backgroundColor": "#ffffff",
							"fontColor": "#222222",
							"barColor": "#ab0020",
							"place": {
								"de": "Bahnsteig",
								"en": "Platform",
								"it": "Banchina"
							},
							"assistantIconId": "zugAssistant",
							"train": true,
							"backgroundColorDisabled": "#F0F0F0",
							"fontColorDisabled": "#878787",
							"barColorDisabled": "#878787"
						},
						"type": "journey",
						"hasRealtime": false
					}
				],
				"switches": 0,
				"duration": 27600000
			},
			"offer": {
				"connectionId": "fb8a994b473d2931b32583890559a1dcadd736a0f2016132f6d1628b8b1d68fd",
				"price": 94.6,
				"offerError": false,
				"firstClass": false,
				"availabilityState": "available"
			}
		},
		...
		...
		...
	}
]
1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago