interrail
Find european train stations and journeys. Client for the European Interrail / EuRail API. Inofficial, using endpoints by Interrail/EuRail. Ask them for permission before using this module in production.
This module conforms to the FPTI-JS 0.3.2
standard for JavaScript public transportation modules.
Installation
npm install interrail
Usage
const interrail =
The interrail
module conforms to the FPTI-JS 0.3.2
standard for JavaScript public transportation modules and exposes the following methods:
Method | Feature description | FPTI-JS 0.3.2 |
---|---|---|
stations.search(query, [opt]) |
Search stations by query. | ✅ yes |
journeys(origin, destination, [opt]) |
Journeys between stations | ✅ yes |
stations.search(query, [opt])
Search stations by query. See this method in the FPTI-JS 0.3.2
spec.
Supported Options
Attribute | Description | FPTI-spec | Value type | Default |
---|---|---|---|---|
results |
Max. number of results returned | ✅ | Number |
null |
Example
interrailstations
"type": "station" "id": "7942300" "name": "LJUBLJANA (Slovenia)" "location": "type": "location" "longitude": 1451028 "latitude": 46058057 "weight": 12185 "products": 28
journeys(origin, destination, [opt])
Find journeys between stations. See this method in the FPTI-JS 0.3.2
spec.
Supported Options
Attribute | Description | FPTI-spec | Value type | Default |
---|---|---|---|---|
when |
Journey date, synonym to departureAfter |
✅ | Date |
new Date() |
departureAfter |
List journeys with a departure (first leg) after this date | ✅ | Date |
new Date() |
results |
Max. number of results returned | ✅ | Number |
null |
interval |
Results for how many minutes after when /departureAfter |
✅ | Number |
null |
transfers |
Max. number of transfers | ✅ | Number |
null |
language |
Language of the results | ❌ | ISO 639-1 code | null |
Example
const berlin = '8065969' // station idconst ljubljana = // FPTF station type: 'station' id: '7942300' name: 'Ljubljana' // … interrail
"id": "8065969-2018-11-02t06-37-00…" "legs": "arrival": "2018-11-02T06:54:00+01:00" "departure": "2018-11-02T06:37:00+01:00" "destination": "id": "8003025" "location": "latitude": 52534722 "longitude": 13196947 "type": "location" "name": "BERLIN-SPANDAU (Germany)" "type": "station" "id": "8065969-2018-11-02t06-37-00-01-00-8003025-2018-11-02t06-54-00-01-00-rb-18604" "line": "id": "rb-18604" "mode": "train" "name": "RB 18604" "public": true "type": "line" "mode": "train" "operator": "interrail" "origin": "id": "8065969" "location": "latitude": 52525553 "longitude": 13369441 "type": "location" "name": "BERLIN HBF (Germany)" "type": "station" "public": true // … "arrival": "2018-11-02T18:32:00+01:00" "departure": "2018-11-02T12:17:00+01:00" "destination": "id": "7942300" "location": "latitude": 46058057 "longitude": 1451028 "type": "location" "name": "LJUBLJANA (Slovenia)" "type": "station" "id": "8020347-2018-11-02t12-17-00-01-00-7942300-2018-11-02t18-32-00-01-00-ec-113" "line": "id": "ec-113" "mode": "train" "name": "EC 113" "public": true "type": "line" "mode": "train" "operator": "interrail" "origin": "id": "8020347" "location": "latitude": 48140274 "longitude": 1155833 "type": "location" "name": "MUENCHEN HBF (Germany)" "type": "station" "public": true "type": "journey" // …
Contributing
If you found a bug or want to propose a feature, feel free to visit the issues page.