oebb.transport.rest docs

Readable reference

OEBB Transport API Documentation

This API wraps HAFAS OEBB data behind predictable REST endpoints. Use it for station search, departures, arrivals, journeys, trip details, and radar. The documentation below focuses on clarity and practical integration patterns.

API Function Analysis

The server flow is compact: create profile-aware HAFAS client, generate REST handlers, mount handlers under /api. This architecture keeps behavior consistent while exposing many transport functions.

1) HAFAS Client Initialization

createHafas(dbProfile, userAgent) configures a client for OEBB semantics such as station identifiers, line products, and request conventions.

2) REST Factory Mapping

createApi(hafas, config) maps HAFAS capabilities like journeys, departures, and radar to HTTP routes with normalized JSON output.

3) Route Mounting

expApp.use('/api', api) groups all transport endpoints under one base path, simplifying reverse proxies and integration setup.

4) Static + API Separation

Routes / and /docs serve human-readable pages while /api remains machine-oriented JSON.

Request flow: client -> Express route on /api -> hafas-rest-api handler -> HAFAS OEBB profile request -> normalized JSON response.

Quick Start

Host: http://localhost:3000 Base path: /api Format: JSON
curl "http://localhost:3000/api/locations?query=Wien"

curl "http://localhost:3000/api/stops/8103000/departures?duration=90&results=8"

curl "http://localhost:3000/api/journeys?from=Wien%20Hbf&to=Salzburg%20Hbf&results=3"

Endpoint Reference

GET /api/locations?query=STRING

Search stations, addresses, and points of interest from user text.

ParameterTypeDescription
querystringSearch term such as Wien Hbf or Graz.
resultsnumberOptional maximum number of entries.
curl "http://localhost:3000/api/locations?query=Innsbruck&results=5"
GET /api/locations/nearby?latitude=...&longitude=...

Find stops and places around a coordinate, useful for map pickers and station suggestions.

ParameterTypeDescription
latitudenumberCenter latitude.
longitudenumberCenter longitude.
distancenumberOptional radius in meters.
curl "http://localhost:3000/api/locations/nearby?latitude=48.2082&longitude=16.3738&distance=600"
GET /api/stops/:id/departures

Read upcoming departures for a stop, including line and direction details.

ParameterTypeDescription
idstringStop ID, for example 8103000.
durationnumberOptional time window in minutes.
resultsnumberOptional number of departures.
curl "http://localhost:3000/api/stops/8103000/departures?duration=120&results=10"
GET /api/journeys?from=...&to=...

Plan connections between two locations with transfer and timing information.

ParameterTypeDescription
fromstringOrigin stop name or ID.
tostringDestination stop name or ID.
departureISO datetimeOptional desired departure time.
resultsnumberOptional number of journey options.
curl "http://localhost:3000/api/journeys?from=Wien%20Hbf&to=Salzburg%20Hbf&results=4"
GET /api/trips/:id and /api/radar

Trip details provide stopovers for one service. Radar provides moving vehicles in a bounding box.

curl "http://localhost:3000/api/trips/TRIP_ID_HERE"

curl "http://localhost:3000/api/radar?north=48.35&west=16.15&south=48.10&east=16.55&results=25"

Examples

1) Live departure board

Call one stop endpoint, then render when, line, direction, platform, and delay. Refresh on a short interval for active stations.

const res = await fetch('http://localhost:3000/api/stops/8103000/departures?results=6');
const data = await res.json();

for (const dep of data.departures) {
  console.log(dep.when, dep.line?.name, dep.direction, dep.platform, dep.delay);
}

2) Search and route

Resolve user input with location search first, then call journeys with stable IDs where available.

const fromCandidates = await fetch('http://localhost:3000/api/locations?query=Linz').then(r => r.json());
const toCandidates = await fetch('http://localhost:3000/api/locations?query=Graz').then(r => r.json());

const from = fromCandidates[0]?.id || 'Linz Hbf';
const to = toCandidates[0]?.id || 'Graz Hbf';

const journeyUrl = 'http://localhost:3000/api/journeys?from=' + encodeURIComponent(from) + '&to=' + encodeURIComponent(to) + '&results=3';
const journeyData = await fetch(journeyUrl).then(r => r.json());
console.log(journeyData.journeys?.length || 0);

3) Response shape sample

Most responses provide timing fields, line metadata, and identifiers suitable for caching and follow-up calls.

{
  "departures": [
    {
      "tripId": "...",
      "when": "2026-05-11T09:42:00+02:00",
      "plannedWhen": "2026-05-11T09:40:00+02:00",
      "delay": 120,
      "platform": "7",
      "direction": "Salzburg Hbf",
      "line": {
        "name": "RJX 168",
        "product": "nationalExpress"
      }
    }
  ]
}