Skip to content

rolinger/node-uber

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-uber

Build Status

A Node.js wrapper for Uber API

Version

0.0.4 Mocha tests

0.0.3 Error handling

0.0.2 Support User Profile

0.0.1 Support Product Types, Time Estimates & Price Estimates

License

MIT

Installation

npm install node-uber

Test

npm test

Usage

var Uber = require('node-uber');

var uber = new Uber({
  client_id: 'CLIENT_ID',
  client_secret: 'CLIENT_SECRET',
  server_token: 'SERVER_TOKEN',
  redirect_uri: 'REDIRECT URL',
  name: 'APP_NAME'
});

Resources / Endpoints

Authorization (OAuth 2.0)

Authrorize Url

After getting the authorize url, the user will be redirected to the redirect url with authorization code used in the next function.

uber.getAuthorizeUrl(params);
Params
  • scope (array)

NOTE: history scope is still not working

Example
uber.getAuthorizeUrl(['profile']);

Authorization

Used to convert authorization code or refresh token into access token.

uber.authorization(params, callback);
Params
  • authorization_code OR
  • refresh_token
Example
uber.authorization({ refresh_token: 'REFRESH_TOKEN' }, 
  function (err, access_token, refresh_token) {
    if (err) console.error(err);
    else {
      console.log(access_token);
      console.log(refresh_token);
    }
  });

Product

Types

uber.products.list(params, callback);
Params
  • latitude
  • longitude
Example
uber.products.list({ latitude: 3.1357, longitude: 101.6880 }, function (err, res) {
  if (err) console.error(err);
  else console.log(res);
});

Estimates

Price

uber.estimates.price(params, callback);
Params
  • start_latitude
  • start_longitude
  • end_latitude
  • end_longitude
Example
uber.estimates.price({ 
  start_latitude: 3.1357, start_longitude: 101.6880, 
  end_latitude: 3.0833, end_longitude: 101.6500 
}, function (err, res) {
  if (err) console.error(err);
  else console.log(res);
});

Time

uber.estimates.time(params, callback);
Params
  • start_latitude
  • start_longitude
  • customer_uuid (not implemented)
  • product_id (not implemented)
Example
uber.estimates.time({ 
  start_latitude: 3.1357, start_longitude: 101.6880
}, function (err, res) {
  if (err) console.error(err);
  else console.log(res);
});

User

Activity

NOTE: Have not tested yet because unable to get history scope

Profile

uber.user.profile(params, callback);
Params (optional)
  • access_token

If this params is unable, the object will try to retrieve access_token inside

Example
uber.user.profile(params, function (err, res) {
  if (err) console.log(err);
  else console.log(res);
});

About

Uber API nodejs wrapper

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%