{"id":17367989,"url":"https://github.com/juliuste/db-prices","last_synced_at":"2025-04-08T03:34:43.928Z","repository":{"id":66219643,"uuid":"65435539","full_name":"juliuste/db-prices","owner":"juliuste","description":"Find journey prices using the DB Sparpreise API.","archived":false,"fork":false,"pushed_at":"2020-05-31T09:29:19.000Z","size":76,"stargazers_count":103,"open_issues_count":5,"forks_count":9,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-01T02:04:28.920Z","etag":null,"topics":["library","public-transport","railway"],"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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-11T03:29:54.000Z","updated_at":"2024-10-21T21:38:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"d59a51c5-5133-4e97-b149-4c1614646310","html_url":"https://github.com/juliuste/db-prices","commit_stats":{"total_commits":74,"total_committers":7,"mean_commits":"10.571428571428571","dds":0.6351351351351351,"last_synced_commit":"526232e86c929b4de4a1d857dbc8bc6719f44ed9"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fdb-prices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fdb-prices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fdb-prices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fdb-prices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliuste","download_url":"https://codeload.github.com/juliuste/db-prices/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223300818,"owners_count":17122694,"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":["library","public-transport","railway"],"created_at":"2024-10-15T23:11:56.718Z","updated_at":"2024-11-06T07:32:48.749Z","avatar_url":"https://github.com/juliuste.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# db-prices\n\nJavaScript module for finding the cheapest railway connections using the Deutsche Bahn Sparpreise API. Inofficial, using an endpoint by *Deutsche Bahn*. Ask them for permission before using this module in production.\n\n[![npm version](https://img.shields.io/npm/v/db-prices.svg)](https://www.npmjs.com/package/db-prices)\n[![Build Status](https://travis-ci.org/juliuste/db-prices.svg?branch=master)](https://travis-ci.org/juliuste/db-prices)\n[![Greenkeeper badge](https://badges.greenkeeper.io/juliuste/db-prices.svg)](https://greenkeeper.io/)\n[![dependency status](https://img.shields.io/david/juliuste/db-prices.svg)](https://david-dm.org/juliuste/db-prices)\n[![license](https://img.shields.io/github/license/juliuste/db-prices.svg?style=flat)](LICENSE)\n[![chat on gitter](https://badges.gitter.im/public-transport/Lobby.svg)](https://gitter.im/public-transport/Lobby)\n\n## Installation\n\n```bash\nnpm install db-prices\n```\n\n## Usage\n\n`prices()` returns a `Promise` that will resolve with a list of offers.\n\n```javascript\nconst prices = require('db-prices')\n\nprices(from, to, [date], [opt]).then(…)\n```\n\n`from` and `to` must be station IDs like `'8000105'`.\n`date` must be a `Date` object; if empty, the current datetime will be used.\n\nWith `opt`, you can override the default options, which look like this:\n\n```javascript\n{\n\tclass: \t\t\t2, \t// 1st class or 2nd class\n\tnoICETrains: \t\tfalse,\n\ttransferTime: \t\t0, \t// in minutes\n\tduration: \t\t1440, \t// search for routes in the next n minutes\n\tpreferFastRoutes: \ttrue,\n\ttravellers: [{ \t\t// one or more\n\t\tbc:\t0, \t// BahnCard ID (see https://gist.github.com/juliuste/202bb04f450a79f8fa12a2ec3abcd72d)\n\t\ttyp: \t\"E\", \t// E: adult: K: child; B: baby -- BUG: child and baby dont work ATM\n\t\talter: \t30 \t// age\n\t}],\n}\n```\n\n## Response\n\nThe result will be a list of [*Friendly Public Transport Format*](https://github.com/public-transport/friendly-public-transport-format) `journey` objects.\n\nWith `from = '8000105'`, `to = '8011160'` and `date = new Date('2016-08-17T00:00:00.000Z')`, the result looked like this:\n\n```javascript\n[\n\t{\n\t\ttype: 'journey',\n\t\tid: '0',\n\t\torigin: {\n\t\t\ttype: 'station',\n\t\t\tid: '8000105',\n\t\t\tname: 'Frankfurt(Main)Hbf'\n\t\t},\n\t\tdestination: {\n\t\t\ttype: 'station',\n\t\t\tid: '8098160',\n\t\t\tname: 'Berlin Hbf (tief)'\n\t\t},\n\t\tlegs: [{\n\t\t\torigin: {\n\t\t\t\ttype: 'station',\n\t\t\t\tid: '8000105',\n\t\t\t\tname: 'Frankfurt(Main)Hbf'\n\t\t\t},\n\t\t\tdeparture: '2017-06-05T08:53:00.000Z',\n\t\t\tdeparturePlatform: '13',\n\t\t\tdestination: {\n\t\t\t\ttype: 'station',\n\t\t\t\tid: '8098160',\n\t\t\t\tname: 'Berlin Hbf (tief)'\n\t\t\t},\n\t\t\tarrival: '2017-06-05T13:17:00.000Z',\n\t\t\tarrivalPlatform: '7',\n\t\t\tline: {\n\t\t\t\ttype: 'line',\n\t\t\t\tid: 'ice-1537',\n\t\t\t\tname: 'ICE 1537',\n\t\t\t\tproduct: 'ICE'\n\t\t\t}\n\t\t}],\n\t\tprice: {\n\t\t\tcurrency: 'EUR',\n\t\t\tamount: 126,\n\t\t\tdiscount: false,\n\t\t\tname: 'Flexpreis',\n\t\t\tdescription: 'Fully flexible (not bound to a specific train / not dependent on the connection indicated on the selected route). Exchanges and refunds free of charge; on or after the first day of validity subject to a fee.'\n\t\t},\n\t\tnightTrain: false\n\t}\n\t// …\n]\n```\n\n## Similar Projects\n\n- [db-hafas](https://github.com/derhuerst/db-hafas/) – \"JavaScript client for the DB HAFAS API.\"\n- [db-hafas-rest](https://github.com/juliuste/db-hafas-rest/) – \"DB Hafas REST API\"\n- [db-stations](https://github.com/derhuerst/db-stations/) – \"A list of DB stations.\"\n\n## Contributing\n\nIf you found a bug, want to propose a feature or feel the urge to complain about your life, feel free to visit [the issues page](https://github.com/juliuste/db-prices/issues).\n\nCheers to [Jannis R](https://github.com/derhuerst) for contributing.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliuste%2Fdb-prices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliuste%2Fdb-prices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliuste%2Fdb-prices/lists"}