2021-10-21 23:00:44 +02:00
|
|
|
# `tripsByName([lineNameOrFahrtNr], [opt])`
|
2019-12-17 14:12:35 +01:00
|
|
|
|
2021-10-21 23:00:44 +02:00
|
|
|
Get all trips matching one or more criteria, e.g. a specific name.
|
2019-12-17 14:12:35 +01:00
|
|
|
|
|
|
|
## Response
|
|
|
|
|
|
|
|
As an example, we're going to use the [VBB profile](../p/vbb):
|
|
|
|
|
|
|
|
```js
|
2022-05-07 16:17:37 +02:00
|
|
|
import {createClient} from 'hafas-client'
|
2022-11-22 21:08:08 +01:00
|
|
|
import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js'
|
2019-12-17 14:12:35 +01:00
|
|
|
|
|
|
|
const client = createClient(vbbProfile, 'my-awesome-program')
|
|
|
|
|
2021-12-29 21:23:28 +01:00
|
|
|
const {
|
|
|
|
trips,
|
|
|
|
realtimeDataUpdatedAt,
|
|
|
|
} = await client.tripsByName('S1')
|
2019-12-17 14:12:35 +01:00
|
|
|
```
|
|
|
|
|
2021-10-21 23:00:44 +02:00
|
|
|
With `opt`, you can override the default options, which look like this:
|
|
|
|
|
|
|
|
```js
|
|
|
|
{
|
|
|
|
// use either this
|
|
|
|
when: null,
|
|
|
|
// or these
|
|
|
|
fromWhen: null, untilWhen: null,
|
|
|
|
|
|
|
|
onlyCurrentlyRunning: true,
|
2021-10-22 19:27:29 +02:00
|
|
|
products: {
|
|
|
|
// these entries may vary from profile to profile
|
|
|
|
suburban: true,
|
|
|
|
subway: true,
|
|
|
|
tram: true,
|
|
|
|
bus: true,
|
|
|
|
ferry: true,
|
|
|
|
express: true,
|
|
|
|
regional: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
currentlyStoppingAt: null, // only show trips currently stopping at a stop/station, string
|
|
|
|
lineName: null, // only show trips with this line name, string
|
|
|
|
operatorNames: null, // only show trips with these operator names, array of strings
|
2021-10-21 23:00:44 +02:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-12-29 21:23:28 +01:00
|
|
|
`realtimeDataUpdatedAt` is a UNIX timestamp reflecting the latest moment when (at least some of) the response's realtime data have been updated.
|
|
|
|
|
|
|
|
`trips` may look like this:
|
2019-12-17 14:12:35 +01:00
|
|
|
|
|
|
|
```js
|
|
|
|
[
|
|
|
|
{
|
|
|
|
id: '1|1214|0|86|16092020'
|
|
|
|
direction: null,
|
|
|
|
line: {
|
|
|
|
type: 'line',
|
|
|
|
id: 's1',
|
|
|
|
fahrtNr: '325',
|
|
|
|
name: 'S1',
|
|
|
|
mode: 'train',
|
|
|
|
product: 'suburban',
|
|
|
|
// …
|
|
|
|
},
|
|
|
|
|
|
|
|
origin: {
|
|
|
|
type: 'stop',
|
|
|
|
id: '900000550239',
|
|
|
|
name: 'Warnemünde, Bhf',
|
|
|
|
location: { /* … */ },
|
|
|
|
products: { /* … */ },
|
|
|
|
},
|
|
|
|
departure: '2020-09-16T04:03:00+02:00',
|
|
|
|
plannedDeparture: '2020-09-16T04:03:00+02:00',
|
|
|
|
departureDelay: null,
|
|
|
|
departurePlatform: null,
|
|
|
|
plannedDeparturePlatform: null,
|
|
|
|
|
|
|
|
destination: {
|
|
|
|
type: 'stop',
|
|
|
|
id: '900000550002',
|
|
|
|
name: 'Rostock, Hbf',
|
|
|
|
location: { /* … */ },
|
|
|
|
products: { /* … */ },
|
|
|
|
},
|
|
|
|
arrival: '2020-09-16T04:24:00+02:00',
|
|
|
|
plannedArrival: '2020-09-16T04:24:00+02:00',
|
|
|
|
arrivalDelay: null,
|
|
|
|
arrivalPlatform: null,
|
|
|
|
plannedArrivalPlatform: null,
|
|
|
|
},
|
|
|
|
// …
|
|
|
|
{
|
|
|
|
id: '1|62554|0|86|16092020'
|
|
|
|
direction: null,
|
|
|
|
line: {
|
|
|
|
type: 'line',
|
|
|
|
id: 's1',
|
|
|
|
fahrtNr: '2001',
|
|
|
|
name: 'S1',
|
|
|
|
public: true,
|
|
|
|
mode: 'train',
|
|
|
|
product: 'suburban',
|
|
|
|
// …
|
|
|
|
},
|
|
|
|
|
|
|
|
origin: { /* … */ },
|
|
|
|
destination: { /* … */ },
|
|
|
|
// …
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|