npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

db-prices

v3.0.3

Published

Find the cheapest routes using the DB Sparpreise API.

Downloads

55

Readme

db-prices

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

npm version Build Status Greenkeeper badge dependency status license chat on gitter

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

The result will be a list of Friendly Public Transport Format journey objects.

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

[
	{
		type: 'journey',
		id: '0',
		origin: {
			type: 'station',
			id: '8000105',
			name: 'Frankfurt(Main)Hbf'
		},
		destination: {
			type: 'station',
			id: '8098160',
			name: 'Berlin Hbf (tief)'
		},
		legs: [{
			origin: {
				type: 'station',
				id: '8000105',
				name: 'Frankfurt(Main)Hbf'
			},
			departure: '2017-06-05T08:53:00.000Z',
			departurePlatform: '13',
			destination: {
				type: 'station',
				id: '8098160',
				name: 'Berlin Hbf (tief)'
			},
			arrival: '2017-06-05T13:17:00.000Z',
			arrivalPlatform: '7',
			line: {
				type: 'line',
				id: 'ice-1537',
				name: 'ICE 1537',
				product: 'ICE'
			}
		}],
		price: {
			currency: 'EUR',
			amount: 126,
			discount: false,
			name: 'Flexpreis',
			description: '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.'
		},
		nightTrain: false
	}
	// …
]

Similar Projects

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.