1.0.0 • Published 8 years ago
ouibus v1.0.0
ouibus
JavaScript client for the OUIBUS (formerly known as idBUS) API.
Installation
npm install ouibusUsage
const ouibus = require('ouibus')The ouibus module bundles two methods: stations() and routes().
stations()
Ouibus network. Returns a Promise that resolves in a list of all stations:
ouibus.stations().then(…)would give you
[{
	"id": "3",
	"name": "Gérone",
	"timezone": "Europe/Madrid",
	"address": "Plaça Espanya 2 17002 Girona",
	"position": {
		"longitude": "2.817476",
		"latitude": "41.97901"
	},
	"destinations": [16,29,134,35,103,112,146,116,118,149,150],
	"stops": […] // only contained by meta-stations (like "Paris - Tous les arrêts"), list of subordinate stops)
}, …]routes(fromID, toID, date, opt)
Find routes for a given date (always returns results for the entire day). Returns a Promise that resolves in a list of matching routes.
ouibus.routes(fromID, toID, date, opt).then(…)
ouibus.routes(
	90, // Paris
	13, // Montpellier
	new Date(),
	// default options
	{
		transfers: 1, // max. transfers
		currency: 'EUR', // TODO: supported currencies
		passengers: [{
			id: 1, // TODO
			age: 30
		}]
	}
).then(…)would give you
[{
	"id": "2399345",
	"from": "1",
	"to": "13",
	"departure": "2017-02-14T21:30:00.000Z", // Date() object
	"arrival": "2017-02-15T14:45:00.000Z", // Date() object
	"price": {
		"normal": {"value":44, "currency": "EUR"},
		"promo": null // would look like 'normal' if there was a promotion
	},
	"available": true,
	"parts": [{
		"from": "1",
		"to": "29",
		"departure": "2017-02-14T21:30:00.000Z", // Date() object
		"arrival": "2017-02-15T05:30:00.000Z", // Date() object
		"busNumber": "5041"
	}, …]}
, …]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.