Giter Club home page Giter Club logo

db-prices's Introduction

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.

db-prices's People

Contributors

derhuerst avatar greenkeeper[bot] avatar juliuste avatar madebyfabian avatar tordans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

db-prices's Issues

An in-range update of db-stations is breaking the build 🚨

Version 2.8.0 of db-stations was just published.

Branch Build failing 🚨
Dependency db-stations
Current Version 2.7.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

db-stations is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 1 commits.

  • 484d10e chore(package): update through2-concurrent to version 2.0.0

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of moment-timezone is breaking the build 🚨

Version 0.5.18 of moment-timezone was just published.

Branch Build failing 🚨
Dependency [moment-timezone](https://github.com/moment/moment-timezone)
Current Version 0.5.17
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

moment-timezone is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 10 commits.

  • 1c465b7 Added more node.js versions to .travis.yml
  • ccb4174 Fix grunt version to 1.0.2
  • a237e9a Updated version to 0.5.18
  • c3598f4 prefer nodejs to amd declaration
  • 66d8f40 Move moment to peerDependencies
  • 8a35aff Return error if timezone name is not a string
  • ae6eaaa Return more self-explaining error messages when timezone name is not a string
  • 05a93be Ignore latest unpacked data
  • cce8fa6 Update changelog.md
  • 9307dfe Ignore .idea files

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

doesn't work

Hello,

I tried but it doesn't work, is this normal? I see that the repo is from 2019

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.