live-flix-website-position
v2.0.0
Published
Periodically fetch a vehicle's position from Flix(bus)'s website.
Maintainers
Readme
live-flix-website-position
Periodically fetch a vehicle's position from Flix(bus)'s website.
Installation
npm install live-flix-website-positionUsage
The Flix(bus) live tracking APIs work with trip-unique (Flix calls a trip a "ride") IDs. You must obtain the ID of your trip from another data source, e.g. the Flix(bus) website or one of their invoices.
const RIDE_UUID = '162358de-ced8-471c-928f-af9197dd3f2f'fetchTrip(rideUuid)
import {fetchTrip} from 'live-flix-website-position'
console.log(await fetchTrip(RIDE_UUID)){
id: '162358de-ced8-471c-928f-af9197dd3f2f',
status: {
segment: 1,
next_stop_sequence: 2,
has_arrived_at_next_stop: false,
progress: 'IN_PROGRESS',
deviation: {
deviation_timestamp: '2025-09-05T11:02:24Z',
deviation_seconds: -156,
reason: null,
deviation_class: 'ON_TIME',
deviation_type: 'ESTIMATED',
updated_at: '2025-09-05T10:36:24Z',
},
scheduled_timestamp: null,
},
platform: null,
line: {
code: '173',
direction: 'Copenhagen Busterminal',
name: 'Gothenburg - Copenhagen - Oldenburg',
means_of_transport: 'BUS',
brand: {
id: 'a18f138c-68fa-4b45-a42f-adb0378e10d3',
name: 'FlixBus',
},
},
location: {
coordinates: {
latitude: 53.739532,
longitude: 10.357351,
},
updated_at: '2025-09-05T10:44:05.837Z',
},
vehicle: {
id: '6b6c9105-f089-435a-b6a0-11416f7e1bc8',
license_plate: null,
type: 'BUS',
},
calls: [
{
sequence: 1,
stop: {
id: 'dcbada9a-9603-11e6-9066-549f350fcb0c',
type: 'BUS',
timezone: 'Europe/Berlin',
name: 'Hamburg central bus station',
description: 'Gate information available here: https://www.zob-hamburg.de/abfahrt.php',
city: {
id: '40d91e53-8646-11e6-9066-549f350fcb0c',
name: 'Hamburg',
},
code: 'HH',
location: {
latitude: 53.551767,
longitude: 10.011657,
},
},
arrival: null,
departure: {
scheduled: '2025-09-05T10:00:00Z',
deviation: /* … */,
platform: null,
},
},
/* … */
{
sequence: 4,
stop: {
id: 'dcbd0b4b-9603-11e6-9066-549f350fcb0c',
type: 'BUS',
timezone: 'Europe/Copenhagen',
name: 'Copenhagen Busterminal',
/* … */
},
arrival: {
scheduled: '2025-09-05T15:30:00Z',
deviation: /* … */,
platform: null,
},
departure: null,
},
],
}fetchRoute(rideUuid)
import {fetchRoute} from 'live-flix-website-position'
console.log(await fetchRoute(RIDE_UUID))The polyline fields contain Google-encoded polylines. You can use e.g. google-polyline to decode them.
{
segments: [
{
segment_sequence: 1,
polyline: 'emzeIatb|@AuAkEh@}Ak@y@eAiRwh@aEcNQkAVoAvEoKvDgGAeB}Kiu@_EgOwDcI_AqDcAyHcA_SIwHxA}|@nFe}@zAgIvAu@b@cCo@mDqCqAsGeNaCgI_BaNeCq`@_EmbAiIooA}JsdCRgZdDkf@lPkkAvKgl@rA{PwBmgA}@sMeF}\\eEgQwE_OkLqVyIeMguDsqEwKgLuIiGaNgGceAuS_LeDuKaH}IkJsxAwbCgGqMkIaYuSghAiFuP_DoHsNoUod@qp@iMaOoHaGurFgjD{dAqg@}m@w[sxDgbDy]k[syA_nBkHuMchAmdCqLiRgcAuxAoI{QstAcgDeGaLs[qe@sLoSiI}Q_JsX_GeWwEqZwCe[oAuWcBclDmAeb@cDm\\qMwm@}T__AeMsa@{|@myBcjBmhF_JsWem@urBc~@msCaH_SgKyS_BoFsAkNZ_BtCoDtHaG`Bo@lAFtG`QjUuRpCcDxPyZfCjFp@Tn@g@xB`IjADBrC',
},
// …
],
}fetchPosition(rideUuid)
fetchPosition() returns a geolocation with additional metadata. It returns null if there's no realtime data available.
import {fetchPositions} from 'live-flix-website-position'
console.log(await fetchPositions(RIDE_UUID)){
ride_uuid: '162358de-ced8-471c-928f-af9197dd3f2f',
coordinates: {
latitude: 53.739532,
longitude: 10.357351,
},
updated: 1757069045,
above_quality_threshold: null,
to_stop_uuid: 'dcbbeac7-9603-11e6-9066-549f350fcb0c',
vehicle_type: 'bus',
stale: null,
}positions(rideUuid)
positions() returns an async iterable, with each item having the same structure as fetchPosition(rideUuid)'s return value.
import {positions} from 'live-flix-website-position'
const resolveAfter = ms => new Promise(resolve => setTimeout(resolve, ms))
let i = 0
for await (const pos of positions(RIDE_UUID)) {
console.log(i++, pos)
await resolveAfter(5_000) // 5 seconds
}0, {
ride_uuid: '162358de-ced8-471c-928f-af9197dd3f2f',
coordinates: {latitude: 53.739532, longitude: 10.357351},
updated: 1757069045,
above_quality_threshold: null,
to_stop_uuid: 'dcbbeac7-9603-11e6-9066-549f350fcb0c',
vehicle_type: 'bus',
stale: null,
}
1 {
ride_uuid: '162358de-ced8-471c-928f-af9197dd3f2f',
coordinates: {latitude: 53.739533, longitude: 10.357352},
updated: 1757069050,
above_quality_threshold: null,
to_stop_uuid: 'dcbbeac7-9603-11e6-9066-549f350fcb0c',
vehicle_type: 'bus',
stale: null,
}
// …Related
live-icomera-position– Live vehicle geolocation, taken from the on-board Icomera WiFi system.live-gomedia-position– Live vehicle geolocation, taken from the GoMedia on-board WiFi entertainment system.live-cd-wifi-position– Live vehicle geolocation of Czech Railways trains, taken from the on-board WiFi system.wifi-on-ice-position-stream– A stream of positions of German Railways ICE trains, taken from the on-board WiFi.
Contributing
If you have a question or need support using live-flix-website-position, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, use the issues page.
