gbfs-client
TypeScript icon, indicating that this package has built-in type declarations

0.8.1 • Public • Published

Node GBFS Client (CitiBike and others)

Build Status NPM Status Greenkeeper badge

Lightweight client for General Bikeshare Feed Specification (GBFS) feeds, with a Promise-based API and full type definitions (Typescript).

Compatible with the CitiBike NYC API.

Installation

npm install gbfs-client --save

Usage

const GbfsClient = require('gbfs-client');
const gbfsClient = new GbfsClient('https://gbfs.citibikenyc.com/gbfs/en/');
 
gbfsClient.system()
    .then(system => console.log(system));
    /* { system_id: 'NYC',
          language: 'en',
          name: 'Citi Bike',
          ... */
 
gbfsClient.stationInfo()
    .then(stations => console.log(stations));
    /* [ { station_id: '72',
            name: 'W 52 St & 11 Ave',
            short_name: '6926.01',
            lat: 40.76727216,
            lon: -73.99392888,
            ...
        ] */
gbfsClient.stationInfo('72')
    .then(stationInfo => console.log(stationInfo));
    /* { station_id: '72',
            name: 'W 52 St & 11 Ave',
            short_name: '6926.01',
            lat: 40.76727216,
            lon: -73.99392888,
            ... */
 
gbfsClient.stationStatus('72')
    .then(stationStatus => console.log(stationStatus));
    /*  { station_id: '72',
            num_bikes_available: 12,
            num_docks_available: 26,
            ... */

new GbfsClient(baseUrl)

  • baseUrl: optional url for the GBFS API. Defaults to 'https://gbfs.citibikenyc.com/gbfs/en/', for NYC's CitiBike.

gbfsClient.system()

gbfsClient.stationInfo(stationId)

  • stationId: optional id for a specific station. If this parameter is not provided, an array of info for all stations will be returned.
  • Returns a promise for a JSON object with station information for one or all stations. See the GBFS station information spec for a list of the JSON fields.

gbfsClient.stationStatus(stationId)

  • stationId: optional id for a specific station. If this parameter is not provided, an array of status for all stations will be returned.
  • Returns a promise for a JSON object with station status for one or all stations. See the GBFS station status spec for a list of the JSON fields.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.8.1
    0
    • latest

Version History

Package Sidebar

Install

npm i gbfs-client

Weekly Downloads

0

Version

0.8.1

License

MIT

Unpacked Size

8.9 kB

Total Files

10

Last publish

Collaborators

  • mnkhouri