Skip to content

General Bikeshare Feed Specification (GBFS) client, compatible with Citibike NYC API

License

Notifications You must be signed in to change notification settings

mnkhouri/node-gbfs-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

General Bikeshare Feed Specification (GBFS) client, compatible with Citibike NYC API

Resources

License

Stars

Watchers

Forks

Packages

No packages published