shernshiou / node-uber Goto Github PK
View Code? Open in Web Editor NEWUber API nodejs wrapper
License: MIT License
Uber API nodejs wrapper
License: MIT License
The module works well with open internet, but it is not working on internet with proxies. Also there are no options available to mention proxy settings. Please implement the option to add proxy setting too.
Need supports for the OAuth revoke call to revoke a bearer token. I'm calling the API endpoint directly for now, but it would be nice to use this package to do it. If there is anyone else interested in this I could take a stab at implementing it as it is really straight-forward, just call the revoke endpoint with client-id, client-secret, and token. I've never worked on a NPM so not entirely sure how to go about building one, but Google is my friend and it can't be that hard.
Uber object should store the token expiration date and renew the OAuth 2.0 access_token if date is reached
Right now, the testing architecture is not suitable for more and advanced tests. For instance, nock responses are stored in variables in testing files. Those files should be stored separately.
Also, all nock instructions should be encapsulated to avoid duplicated calls (e.g. authorization is needed in almost every case).
To be added soon
@shernshiou mind adding me as the second owner for the published npm package? Described here: https://docs.npmjs.com/cli/owner.
Would allow me to push new versions for critical bug fixes, like the #25
Is there any plans to add support for the drivers api? We are using it now and would love to have the support
hi
am trying create to app for sales. my is made on nodejs with angularjs .i just want track field person like tracking cab in real time. so i decided to use uber tracking api only..!!
is that possible to use like that?
does uber has separate api for tracking purpose only.?
kindly explain flow of the process and how to make use of it..
thank you Team
@shernshiou could you please add @dawsbot as maintainer? He's eager to help drive this development :)
Currently the library does not check the HTTP status code returned from Uber API requests. The data.statusCode property would tell you whether there was a non 200 response. Uber will, for example, return a 409 when there is surge pricing in response to POST /requests
. The response body contains enough info to determine that there is a surge w/o using the status code, but the status code may be nice to have as well.
The smallest change would be to pass data
into the callback in Uber.js
. Another option is to check the statusCode in the response handler and create an error if the code is non-200.
request.get({
url: url,
//auth: accessToken,
json: true
}, function (err, data, res) {
// TODO: non-200 data.statusCode handling here!
if (err) {
callback(err);
} else {
callback(null, res, data); // include `data` in callback
}
});
When installing using yarn add, the following error is shown:
error [email protected]: The engine "node" is incompatible with this module. Expected version "6.10".
Node version: 7.8.0
yarn version: 0.24.5
@shernshiou would you mind to either add me as an admin to this repo or follow this instructions to enable code coverage reports for this project? Would be nice to see where we at :)
The supported methods should not be maintained in the future. This will decrease the complexity of the package, especially since new Async (premise-based) methods will be coming with v.1.0.0
@shernshiou do you think you could publish a new release @ https://www.npmjs.com/package/node-uber ? The latest version there is 0.9.0, while our repo version is already up to 0.9.2. Thanks :)
What is the simplest example to estimate ride, assuming that pick location is 28.5662241,77.2088588
and drop location 28.6115458,77.227003
.
The uber developer site shows implementations for Curl, Python, Java and iOS only.
I would like to know for node.
I have the next error, run example
{ statusCode: 401, data: '{"error": "invalid_grant"}' }
Thanks
To be added soon
This may not be an issue or may be required to improve reusability of code, shouldn't there be a way to update the access_token? I've many users using the same Uber back end and upon hitting the Node js app I need to override the Uber object's access token. This will help anybody accessing the system to get their information from the APIs and won't be restricted to single User.
As documented here: https://developer.uber.com/docs/rush ... Might make sense to create a new repo for that, e.g. node-uber-rush
Implements methods to ease usage with multiple users
Add support for use of promises instead of callbacks
What do you guys think - would it make sense to integrate node-geocoder to e.g. easily get products by address? I think most people will use it anyways to get lat & lon values for the calls...
I'd propose adding 3 new methods, e.g.:
uber.products.getAllForAddress(address)
uber.estimates.getPriceForRouteByAddress(start_address, end_address, [, seats])
uber.estimates.getETAForAddress(address [, product_id])
In addition to that, some methods might need to be revisited:
uber.requests.create(parameter)
uber.requests.getEstimates(parameter)
uber.requests.updateByID(request_id, parameter)
uber.reminders.create(parameter)
uber.reminders.updateByID(reminder_id, parameter)
.To escape callback hell
First off, thank you very much for node-uber!!
I was wondering how do I set an access_token
on requests that require OAuth?
As described here: https://developer.uber.com.cn/docs/sandbox
Thanks to this post on ST, a bug was identified:
The methods requests.setStatusByID
, products.setDriversAvailabilityByID
and products.setSurgeMultiplierByID
send HTTP requests to the wrong URL, e.g.:
https://sandbox-api.uber.com/v1/requests/{request_id}
While the base URL is correct, the endpoint requires another hierarchy, like that:
https://sandbox-api.uber.com/v1/sandbox/requests/{request_id}
This might seem like a dumb question, but this is my first node_module I have used or am using.
i get this error: Uncaught ReferenceError: require is not defined.
'node-uber' is listed in my devDependencies section of my package.json file.
What am I doing wrong?
requests.getReceiptByID
seems to send the access_token in the query string instead of the header which causes Uber to deny the request.
The ride reminders endpoints are not documented anymore. Removing them as part of #51
Can somebody provide an example of how to authorize? I dont know what to use for redirect URL
Would love to have the functionality for surge pricing, which would include:
-Getting surge pricing confirmation id from HTTP 409 error
-Ability to pass back surge confirmation id in request
Thanks!
As of right now there is no PUT
method provided for the /request endpoint. Documented here: https://developer.uber.com/docs/sandbox
As reported by a user, requests.create
returns a 401 error code after authentification.
from my cordova 4.3.0 application directory I installed this plugin
C:\appdev/appTest>npm install -g node-uber
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
[email protected] node_modules\node-uber
โโโ [email protected]
โโโ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected].
0, [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], form-data@0.
2.0, [email protected], [email protected], [email protected], [email protected])
Then: \appdev\appTest > npm test
C:\appdev\appTest>npm test
[email protected] test C:\appdev\appTest
echo "Error: no test specified"
"Error: no test specified"
However, I do see all the node-uber files instilled within my project and I added the basic call to the uber api with:
var Uber = require('node-uber');
And I get the following error: Uncaught ReferenceError: require is not defined
Hey @shernshiou,
I can't find a promotions endpoint and I'm assuming it's left-over from a deprecated endpoint, correct? If so, I'd create a PR removing it.
After MUCH learning I finally am implementing node-uber the correct way. Apologies for the many reported issues previously - they were not your app and were my fault.
That being said, in the /test folder I have replaced your "var key" in index.js and key.json info with my own registered uber keys/tokens, and am now getting the following errors. Please advise:
[08:48:38] Using gulpfile ~\dev\WHIPSTER\node_modules\node-uber\gulpfile.js
[08:48:38] Starting 'test'...
Uber client general test
โ should load the key from a key.json
โ should initiate Uber client with the key
OAuth2 authorization methods
OAuth2 authorization url
โ generate OAuth2 correct authorization url
โ should return error if scope is not an array
โ should return error if scope is not an empty array
Exchange authorization code into access token
createCredentials() is deprecated, use tls.createSecureContext instead
โ should able to get access token and refresh token using authorization code
โ should able to get access token and refresh token using refresh token
โ should return error if there is no authorization_code or refresh_token
Products Resource
Products List
1) should list down all the product types
โ should return error if there is no required params
Estimates Resource
Price Estimates
2) should list all the price estimates from server
โ should return error if there is no required params
Time Estimates
3) should list all the price estimates from server
โ should return error if there is no required params
User Resource
User Profile
โ should get user profile after authentication
โ should get user profile after authentication by explicitly passing access token
โ should return invalid access token error when no token found
14 passing (125ms)
3 failing
Products Resource Products List should list down all the product types:
Uncaught AssertionError: expected [Error: Nock: No match for request GET https://api.uber.com/v1/products?server_token=XXXXXXPaPcEE0cHb
whKiF_sl_ZUYvEHHO_f6U6dr&latitude=3.1357&longitude=101.688 ] to not exist
Estimates Resource Price Estimates should list all the price estimates from server:
Uncaught AssertionError: expected [Error: Nock: No match for request GET https://api.uber.com/v1/estimates/price?server_token=XXXXXXPaP
cEE0cHbwhKiF_sl_ZUYvEHHO_f6U6dr&start_latitude=3.1357&start_longitude=101.688&end_latitude=3.0833&end_longitude=101.65 ] to not exist
Estimates Resource Time Estimates should list all the price estimates from server:
Uncaught AssertionError: expected [Error: Nock: No match for request GET https://api.uber.com/v1/estimates/time?server_token=XXXXXXPaPc
EE0cHbwhKiF_sl_ZUYvEHHO_f6U6dr&start_latitude=3.1357&start_longitude=101.688&end_latitude=3.0833&end_longitude=101.65 ] to not exist
The npm version currently deployed 0.9.7
is not the same as master
, which is 1.0.0
. This is critical to keep in sync because hackers have vague errors due to expecting a promise-based API when it's still callback based.
Might I suggest keeping master
and the currently deployed npm version in sync always?
Cheers ๐ป๐
To be added soon
To ensure a user is authorized with the right scopes (limited to OAuth2 tokens), scopes should be checked before a call is send to the Uber API.
Hi there,
Just wondering if we are legally allowed to use this API? e.g. is this Uber supported or will we be at risk of getting banned?
It seems this lib is using geocoder version 0.2.2. Unfortunately when google started requiring users to use an API key for their geocoder API, all functions in the lib that relayed on geocoder stopped working. I do see #24 where it seems node-geocoder was going to be added to the project, looking at the commit history I only ever see geocoder as being part of the project. It seems that we would need to replace geocoder with node-geocoder and add methods to pass API keys to the lib.
Thoughts?
I am trying to execute the following Uber Api endpoint
Note: startLat=24.8793259&startLon=67.0570063 is coord of Karachi Pakistan
http://localhost:8000/api/getETAForLocation?startLat=24.8793259&startLon=67.0570063
here is the code
app.get('/api/getETAForLocation', function(request, response) {
// extract the query from the request URL
var query = url.parse(request.url, true).query;
// if no query params sent, respond with Bad Request
if (!query || !query.startLat || !query.startLon ) {
response.sendStatus(400);
} else {
uber.estimates.getETAForAddressAsync(query.startLat, query.startLon)
.then(function(res) {
response.json(res);
})
.error(function(err) {
console.error(err);
response.sendStatus(500);
});
}
})
I am getting this Error log on my console
{ Error: No coordinates found for: "24.8793259"
at /Users/qadirhussain/Desktop/Development/nodeJS/Uber/node_modules/node-uber/lib/Uber.js:64:42
at Request._callback (/Users/qadirhussain/Desktop/Development/nodeJS/Uber/node_modules/geocoder/providers/google.js:20:5)
at Request.self.callback (/Users/qadirhussain/Desktop/Development/nodeJS/Uber/node_modules/request/request.js:188:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/Users/qadirhussain/Desktop/Development/nodeJS/Uber/node_modules/request/request.js:1171:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous> (/Users/qadirhussain/Desktop/Development/nodeJS/Uber/node_modules/request/request.js:1091:12)
at IncomingMessage.g (events.js:286:16)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:973:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
cause:
Error: No coordinates found for: "24.8793259"
at /Users/qadirhussain/Desktop/Development/nodeJS/Uber/node_modules/node-uber/lib/Uber.js:64:42
at Request._callback (/Users/qadirhussain/Desktop/Development/nodeJS/Uber/node_modules/geocoder/providers/google.js:20:5)
at Request.self.callback (/Users/qadirhussain/Desktop/Development/nodeJS/Uber/node_modules/request/request.js:188:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/Users/qadirhussain/Desktop/Development/nodeJS/Uber/node_modules/request/request.js:1171:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous> (/Users/qadirhussain/Desktop/Development/nodeJS/Uber/node_modules/request/request.js:1091:12)
at IncomingMessage.g (events.js:286:16)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:973:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9),
isOperational: true }
And on browser I get
Internal Server Error
But when I try same Api with Zurich Coords. i.e 47.3769ยฐ N, 8.5417ยฐ E
http://localhost:8000/api/getETAForLocation?startLat=47.3769&startLon=8.5417
Its returns no any error but empty response on browser
{"times":[]}
When I'm calling uber.getAuthorizeUrl(['request']);
I'm getting an url. But after loging in getting an error "invalid_scope". I also tried to call the uber api directly from a cordova app, and also getting the same error. Maybe this is not your issue. I opened this issue to discuss and find the solution.
As announced here: https://www.uber.com/info/scheduled-rides/
Hello,
I have an iOS App where I use SSO to authenticate the user and then save the accessToken & refreshToken locally to keychain on my device. Then I'm calling my server who uses a javascript background function to call your library to make a request to Uber.
So far, I'm trying to set up your library with my 2 local tokens like this:
var uber = new uberClient({
client_id: '...',
client_secret: '...',
server_token: '...',
name: 'My App',
sandbox: true, //optional
access_token: accessToken,
refresh_token: refreshToken
});
afterwards I want to call the uber.requests.getEstimatesAsync endpoint like this:
uber.requests.getEstimatesAsync({
"start_latitude": pickupLocation["lat"],
"start_longitude": pickupLocation["lng"],
"end_latitude": dropoffLocation["lat"],
"end_longitude": dropoffLocation["lng"]
})
.then(function(res) {
console.log(JSON.stringify(res));
})
.error(function(err) {
console.error(err);
});
})
Though every time I get an "invalid_grant" error while doing this. Did I make a mistake authenticating myself or setting up the Uber client wrong? Is it even possible to add my local accessToken & refreshToken manually to your uber client?
I'm using a Developer account for doing this, therefore I should actually have all the required permissions for the request endpoint, but I also obtained them previously in the App.
Best regards,
Matt
Right now, our tests in TravisCI cover (and pass) older versions of Node (0.10, 0.11, 0.12, iojs). I'm considering to use some ES6 features and wanted to understand you think there would be a tremendous drawback if we remove backward compatibility.
@shernshiou @puzzlehe4d
Uber recently announced v1.2 endpoints for the Rides API. The following changes would be required to upgrade:
https://api.uber.com/v1.2/
. Sample endpoint.X-Rate-Limit-Limit
, X-Rate-Limit-Remaining
, X-Rate-Limit-Reset
.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.