A node.js module designed to retrieve status information from the DublinBikes bike-sharing service. The API provides methods to:
- Get the list of all stations
- Get status information for a station
- Find the nearest stations to a given latitude/longitude
- Find the nearest available bike to a given latitude/longitude
This is an unofficial module and the author/contributors are in no way connected to the DublinBikes organisation.
npm install dublinbikes_js
It's really easy to use. All methods return JSON objects.
(Use eyes) to preview results):
var bike_api = require('dublinbikes_js');
var eyes = require('eyes');
bike_api.getAllStations((x)=>{console.log(x)});
(Returns a long list of stations)
var stationID = 2;
bike_api.getStationStatus(stationID, (x)=>{eyes.inspect(x)});
Returns something like:
{
available: [ '14' ],
free: [ '6' ],
total: [ '20' ],
ticket: [ '1' ],
open: [ '1' ],
updated: [ '1505761025' ],
connected: [ '1' ]
}
Location in decimal latitude/longitude. Optionally we can restrict the search to only stations which are currently open, and limit the search to return the n closest stations.
bike_api.findClosestStation(53.342451, -6.266667, true, 1, (x)=>{eyes.inspect(x)});
Returns something like:
[
{
name: 'DAME STREET',
number: '10',
address: 'Dame Street',
fullAddress: 'Dame Street ',
lat: '53.344007',
lng: '-6.266802',
open: '1',
ticket: '1',
bonus: '0'
}
]
Location in decimal latitude/longitude. We can show the n closest stations that have bikes available, and we can also filter to only show stations that have m or more bikes available.
bike_api.findClosestBike(53.342451, -6.266667, 1, 2, (x)=>{eyes.inspect(x)});
Returns a result like:
[
[
{
available: [ '2' ],
free: [ '14' ],
total: [ '16' ],
ticket: [ '1' ],
open: [ '1' ],
updated: [ '1505768043' ],
connected: [ '1' ]
},
{
name: 'DAME STREET',
number: '10',
address: 'Dame Street',
fullAddress: 'Dame Street ',
lat: '53.344007',
lng: '-6.266802',
open: '1',
ticket: '1',
bonus: '0'
}
]
]
npm test
Fork this repo, make some changes and create a new pull request!