Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

db-prices

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

db-prices

Find the cheapest routes using the DB Sparpreise API.

Source
npmnpm
Version
0.1.3
Version published
Weekly downloads
12
-25%
Maintainers
1
Weekly downloads
 
Created
Source

db-prices

JavaScript module for finding the cheapest railway connections using the Deutsche Bahn Sparpreise API.

npm version Build Status dependency status dev dependency status license

Installation

npm install db-prices

Usage

prices() returns a Promise that will resolve with a list of offers.

const prices = require('db-prices')

prices(from, to, [date], [opt]).then(…)

from and to must be station IDs like 8000105. date must be a Date object; if empty, the current datetime will be used.

With opt, you can override the default options, which look like this:

{
	class: 				2, 		// 1st class or 2nd class
	noICETrains: 		false,
	transferTime: 		0, 		// in minutes
	duration: 			1440, 	// search for routes in the next n minutes
	preferFastRoutes: 	true
	travellers: [{ 	// one or more
		bc:	0, 		// BahnCard ID (see https://gist.github.com/juliuste/202bb04f450a79f8fa12a2ec3abcd72d)
		typ: "E", 	// E: adult: K: child; B: baby -- BUG: child and baby dont work ATM
		alter: 30 	// age
	}],
}

Response

With from = 8000105, to = 8011160 and date = new Date('2016-08-17T00:00:00.000Z'), the result looked like this:

[{
	id: '0',
	transfers: 1,
	nightTrain: false,
	trips: [{
		id: '0.0',
		start: 2016 - 08 - 17 T03: 06: 00.000 Z,
		from: {
			station: 8000105,
			name: 'Frankfurt(Main)Hbf',
			platform: '7'
		},
		end: 2016 - 08 - 17 T04: 55: 00.000 Z,
		to: {
			station: 8000128,
			name: 'Göttingen',
			platform: '4'
		},
		line: 'ICE  988',
		type: 'ICE'
	}, {
		id: '0.1',
		start: 2016 - 08 - 17 T05: 04: 00.000 Z,
		from: {
			station: 8000128,
			name: 'Göttingen',
			platform: '4'
		},
		end: 2016 - 08 - 17 T07: 58: 00.000 Z,
		to: {
			station: 8011160,
			name: 'Berlin Hbf',
			platform: '12'
		},
		line: 'ICE  876',
		type: 'ICE'
	}],
	offer: {
		ref: '72660',
		discount: true,
		price: 117.9,
		routes: [/* … */],
		anyTrain: false
	}
}, /* … */]

Similar Projects

  • db-hafas – "JavaScript client for the DB HAFAS API."
  • db-hafas-rest – "DB Hafas REST API"
  • db-stations – "A list of DB stations."

Contributing

If 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.

Cheers to Jannis R for contributing.

Keywords

train

FAQs

Package last updated on 24 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts