Skip to content

🚲 An unofficial NodeJS module to access station status information for the DublinBikes bike-sharing service.

License

Notifications You must be signed in to change notification settings

skhg/dublinbikes_nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dublinbikes_nodejs

Coverage Status Dependencies Known Vulnerabilities npm

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.

Installation

npm install dublinbikes_js

Usage

It's really easy to use. All methods return JSON objects.

Require it and create a new instance.

(Use eyes) to preview results):

var bike_api = require('dublinbikes_js');
var eyes = require('eyes');

Get the list of all stations:

bike_api.getAllStations((x)=>{console.log(x)});

(Returns a long list of stations)

Get the current status for a station:

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' ]
}

Find the closest station to a location:

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'
    }
]

Find the closest station that has available bikes:

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'
        }
    ]
]

Tests

npm test

Contributing

Fork this repo, make some changes and create a new pull request!

About

🚲 An unofficial NodeJS module to access station status information for the DublinBikes bike-sharing service.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published