Giter Site home page Giter Site logo

citibiketrips-retired's Introduction

CitibikeTrips.js RETIRED

A node.js module to scrape your personal trip data from the CitiBike website.

UPDATE: this code is retired and kept as reference. All of this code broke when Citibike switched backend to motivate, resulting in completely new website html source and apis. Perhaps this code is useful for another bike sharing program. It also serves as an interesting example of logging into a website and maintaining session.

Install

TODO this has not been released to NPM yet

git clone https://github.com/elwarren/citibiketrips.git
npm install

Usage

You'll need to provide your username and password to the http://citibikenyc.com

Example config:

{
  "debug": 0,
  "citibikenyc": {
    "user": "yourusername",
    "pass": "yourpassword"
  }
}

Example code:

var config = require('etc/config.json');
var CitibikeTrips = require('CitibikeTrips');
var bt = CitibikeTrips({config});

bt.getLastTrip(function(trip) {
  // return single json object of most recent trip
  console.log(trip);
}

bt.getRecentTrips(function(trips) {
  // return json of this month's trips 
  console.log(trips);
});

bt.getAllTrips(function(trips) {
  // iterate over all history pages and return hash of complete history
  console.log(trips);
});

Example output:

{
  "startStationId": 212,
  "startTimestamp": 1406850546,
  "endStationId": 512,
  "endTimestamp": 1406851284,
  "durationSeconds": 738,
  "id": 13204503,
  "endDate": "2014-08-01T00:01:24.000Z",
  "startDate": "2014-07-31T23:49:06.000Z",
  "durationMins": 12,
  "nowSecs": 3600,
  "nowMins": 60,
  "isOpen": false
}

See Also

Example code in bin directory.

My collection of tools at https://github.com/elwarren/citibiketools.git is available seperately to avoid updates to this package.

Thanks

Special thanks to the Citibike program operated by NYC Bike Share. I ride these bikes everyday, sometimes 3-4 trips in a single day.

Please do not abuse their servers with excessive polling. I've read the Citibike TOS http://www.citibikenyc.com/assets/pdf/terms-of-use.pdf and it appears to be OK to do this for personal use.

citibiketrips-retired's People

Contributors

elwarren avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.