{"id":17370423,"url":"https://github.com/public-transport/flix","last_synced_at":"2025-04-08T03:34:50.205Z","repository":{"id":57148761,"uuid":"66115407","full_name":"juliuste/flix","owner":"juliuste","description":"JavaScript client for the FlixBus (Meinfernbus) / FlixTrain API.","archived":false,"fork":false,"pushed_at":"2023-06-24T11:11:19.000Z","size":111,"stargazers_count":27,"open_issues_count":7,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-10-17T05:29:17.885Z","etag":null,"topics":["bus","coach","library","public-transport"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juliuste.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-08-19T22:10:43.000Z","updated_at":"2023-12-08T10:00:52.000Z","dependencies_parsed_at":"2023-09-24T05:08:23.552Z","dependency_job_id":null,"html_url":"https://github.com/juliuste/flix","commit_stats":{"total_commits":108,"total_committers":6,"mean_commits":18.0,"dds":"0.43518518518518523","last_synced_commit":"cf310296ef876a68a79aadb5331858cb0aeee4f3"},"previous_names":["juliuste/meinfernbus"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fflix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fflix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fflix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fflix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliuste","download_url":"https://codeload.github.com/juliuste/flix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223300841,"owners_count":17122701,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bus","coach","library","public-transport"],"created_at":"2024-10-16T00:58:01.201Z","updated_at":"2025-04-08T03:34:44.925Z","avatar_url":"https://github.com/juliuste.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flix\n\nJavaScript client for the [FlixBus (Meinfernbus) / FlixTrain](https://www.flixbus.de/) API. Inofficial, using endpoints by *FlixMobility*. [Ask them for permission](https://www.flixbus.com/company/partners/affiliate-partners) before using this module in production.\n\nThis module conforms to the [FPTI-JS `0.3.2` standard](https://github.com/public-transport/fpti-js/tree/0.3.2) for JavaScript public transportation modules.\n\n[![npm version](https://img.shields.io/npm/v/flix.svg)](https://www.npmjs.com/package/flix)\n[![Build Status](https://travis-ci.org/juliuste/flix.svg?branch=master)](https://travis-ci.org/juliuste/flix)\n[![license](https://img.shields.io/github/license/juliuste/flix.svg?style=flat)](LICENSE)\n[![fpti-js version](https://fpti-js.badges.juliustens.eu/badge/juliuste/flix)](https://fpti-js.badges.juliustens.eu/link/juliuste/flix)\n[![chat on gitter](https://badges.gitter.im/public-transport.svg)](https://gitter.im/public-transport)\n\n## Installation\n\n```shell\nnpm install flix\n```\n\n## Usage\n\n```javascript\nconst flix = require('flix')\n```\n\nThe `flix` module conforms to the [FPTI-JS `0.3.2` standard](https://github.com/public-transport/fpti-js/tree/0.3.2) for JavaScript public transportation modules and exposes the following methods:\n\nMethod | Feature description | [FPTI-JS `0.3.2`](https://github.com/public-transport/fpti-js/tree/0.3.2)\n-------|---------------------|--------------------------------------------------------------------\n[`stations.all([opt])`](#stationsallopt) | All stations of the *Flix* network, such as `Berlin central bus station` or `Frankfurt Hbf` | [✅ yes](https://github.com/public-transport/fpti-js/blob/0.3.2/docs/stations-stops-regions.all.md)\n[`regions.all([opt])`](#regionsallopt) | All regions (cities) of the *Flix* network, such as `Berlin` or `Frankfurt` | [✅ yes](https://github.com/public-transport/fpti-js/blob/0.3.2/docs/stations-stops-regions.all.md)\n[`journeys(origin, destination, [opt])`](#journeysorigin-destination-opt) | Journeys between stations or regions | [✅ yes](https://github.com/public-transport/fpti-js/blob/0.3.2/docs/journeys.md)\n\n---\n\n### `stations.all([opt])`\n\nGet **all** stations of the *Flix* network, such as `Berlin central bus station` or `Frankfurt Hbf`. See [this method in the FPTI-JS `0.3.2` spec](https://github.com/public-transport/fpti-js/blob/0.3.2/docs/stations-stops-regions.all.md).\n\n#### Supported Options\n\nAttribute | Description | FPTI-spec | Value type | Default\n----------|-------------|------------|------------|--------\n`apiKey` | Custom Flix API key | ❌ | `String` | *default api key*\n\n#### Example\n\n```js\nconst flix = require('flix')\nconst stationStream = flix.stations.all()\n\nstationStream.on('data', item =\u003e {\n    // item is an FPTF station object\n    console.log(item)\n})\n```\n\n```js\n{\n    type: \"station\",\n    id: \"1\",\n    name: \"Berlin central bus station\",\n    location: {\n        type: \"location\",\n        longitude: 13.279399,\n        latitude: 52.507171,\n        address: \"Masurenallee 4-6, 14057 Berlin, Germany\",\n        country: {\n            name: \"Germany\",\n            code: \"DE\"\n        },\n        zip: \"14057\",\n        street: \"Masurenallee 4-6\"\n    },\n    slug: \"berlin-zob\",\n    aliases: [],\n    regions: [\n        \"88\"\n    ],\n    connections: [\n        2,\n        3,\n        4,\n        5,\n        8,\n        9\n        // …\n    ],\n    importance: 100\n}\n```\n\n---\n\n### `regions.all([opt])`\n\nGet **all** regions of the *Flix* network, such as `Berlin` or `Frankfurt`. See [this method in the FPTI-JS `0.3.2` spec](https://github.com/public-transport/fpti-js/blob/0.3.2/docs/stations-stops-regions.all.md).\n\n#### Supported Options\n\nAttribute | Description | FPTI-spec | Value type | Default\n----------|-------------|------------|------------|--------\n`apiKey` | Custom Flix API key | ❌ | `String` | *default api key*\n\n#### Example\n\n```js\nconst flix = require('flix')\nconst regionStream = flix.regions.all()\n\nregionStream.on('data', item =\u003e {\n    // item is an FPTF region object\n    console.log(item)\n})\n```\n\n```js\n{\n    type: \"region\",\n    id: \"88\",\n    name: \"Berlin\",\n    location: {\n        type: \"location\",\n        longitude: 13.404616,\n        latitude: 52.486081,\n        country: {\n            name: \"Germany\",\n            code: \"DE\"\n        }\n    },\n    class: \"A\",\n    stations: [\n        \"1\",\n        \"20688\",\n        \"1224\",\n        \"20678\",\n        \"481\"\n        // …\n    ],\n    connections: [\n        89,\n        90,\n        91,\n        92,\n        93,\n        94,\n        96,\n        97,\n        98\n        // …\n    ],\n    slug: \"berlin\"\n}\n```\n\n---\n\n### `journeys(origin, destination, [opt])`\n\nFind journeys between stations or regions. See [this method in the FPTI-JS `0.3.2` spec](https://github.com/public-transport/fpti-js/blob/0.3.2/docs/journeys.md). Note that origin and destination must have the same type (so either both `region` or both `station`).\n\n#### Supported Options\n\nAttribute | Description | FPTI-spec | Value type | Default\n----------|-------------|------------|------------|--------\n`when` | Journey date, synonym to `departureAfter` | ✅ | [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/date) | `new Date()`\n`departureAfter` | List journeys with a departure (first leg) after this date | ✅ | [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/date) | `new Date()`\n`results` | Max. number of results returned | ✅ | `Number` | `null`\n`interval` | Results for how many minutes after `when`/`departureAfter` | ✅ | `Number` | `null`\n`transfers` | Max. number of transfers | ✅ | `Number` | `null`\n`currency` | Currency for `journey.price` | ✅ | [ISO 4217 code](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) | `EUR`\n`language` | Language of the results | ❌ | [ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) | `en`\n`adults` | Number of traveling adults | ❌ | `Number` | `1`\n`children` | Number of traveling children | ❌ | `Number` | `0`\n`bicycles` | Number of traveling bicycles | ❌ | `Number` | `0`\n`apiKey` | Custom Flix API key | ❌ | `String` | *default api key*\n\nNote that, unless `opt.interval` is specified, the module will return journeys that start after `when`/`departureAfter`, but before the beginning of the following calendar day.\n\n#### Example\n\n```js\n// journeys between stations\nconst berlinZOB = '1' // station id\nconst hamburgCentral = { // FPTF station\n\ttype: 'station',\n\tid: '36'\n\t// …\n}\nflix.journeys(berlinZOB, hamburgCentral, { when: new Date('2019-06-27T05:00:00+0200'), currency: 'PLN' }).then(…)\n\n// journeys between regions\nconst berlin = { // FPTF region\n    type: 'region',\n    id: '88'\n    // …\n}\nconst hamburg = { // FPTF region\n\ttype: 'region',\n\tid: '118'\n\t// …\n}\nflix.journeys(berlin, hamburg, { when: new Date('2019-06-27T05:00:00+0200'), transfers: 0 }).then(…)\n```\n\n```js\n{\n    type: \"journey\",\n    id: \"direct-80979121-1-36\",\n    legs: [\n        {\n            origin: {\n                type: \"station\",\n                id: \"1\",\n                name: \"Berlin central bus station\",\n                importance: 100\n            },\n            destination: {\n                type: \"station\",\n                id: \"36\",\n                name: \"Hamburg ZOB\",\n                importance: 100\n            },\n            departure: \"2019-06-27T06:45:00+02:00\",\n            arrival: \"2019-06-27T10:00:00+02:00\",\n            operator: {\n                type: \"operator\",\n                id: \"mfb\",\n                name: \"FlixBus DACH GmbH\",\n                url: \"http://flixbus.de\",\n                address: \"Karl-Liebknecht-Straße 33, D-10178 Berlin\"\n            },\n            mode: \"bus\",\n            public: true\n        }\n    ],\n    status: \"available\",\n    borders: false,\n    info: {\n        title: null,\n        hint: null,\n        message: null,\n        warnings: []\n    },\n    price: {\n        amount: 9.99,\n        currency: \"EUR\",\n        discounts: null,\n        saleRestriction: false,\n        available: true,\n        url: \"https://shop.global.flixbus.com/s?departureCity=88\u0026arrivalCity=118\u0026departureStation=1\u0026arrivalStation=36\u0026rideDate=27.06.2019\u0026currency=EUR\u0026adult=1\u0026children=0\u0026bike_slot=0\"\n    }\n}\n```\n\n## Similar Projects\n\n- [search-flix-locations](https://github.com/derhuerst/search-flix-locations/) - Search for FlixBus (Meinfernbus) / FlixTrain cities \u0026 stations.\n- [db-flix-cities](https://github.com/juliuste/db-flix-cities/) – Get all DB stations located in the same city as the given FlixBus / FlixTrain location, and vice versa.\n- [db-hafas](https://github.com/derhuerst/db-hafas/) - JavaScript client for the DB Hafas API.\n- [db-stations](https://github.com/derhuerst/db-stations/) - A list of DB stations.\n\n## Contributing\n\nIf you found a bug or want to propose a feature, feel free to visit [the issues page](https://github.com/juliuste/flix/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpublic-transport%2Fflix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpublic-transport%2Fflix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpublic-transport%2Fflix/lists"}