0.1.5 • Published 4 years ago

dublinbikes_js v0.1.5

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

dublinbikes_nodejs

Build Status 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!

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago