npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

uber-ride-request

v1.0.1

Published

Uber API calls to automate a ride request

Downloads

2

Readme

Uber Ride Request

Request an UberX ride by only setting the starting and ending GPS coordinates.

Installing

Using npm:

$ npm install --save uber-ride-request

Usage

Create a new application on the Uber developer web platform.

Under the "AUTHORIZATION" tab:

  • Initially, you need to get a Bearer access token (used to authenticate the requests we make to the Uber API). The easiest way I found was to generate it on the Uber developer web platform. This token will be valid for 30 days, but a refresh token can be used to extend its validity. You can also generate it with the oAuth2 authentication provided.
  • Make sure to enable (at least) the request scope .

Have a look at the API docs for more detailed information on how to authenticate, make API calls, etc...

Example

Every method on the client returns a promise, so they can be chained together. You can order a ride as following:

const Client = require('uber-ride-request').Uber;

const access_token = "YOUR_ACCESS_TOKEN"; // Retrieve it by generating a token under the "authorization" tab in https://developer.uber.com/dashboard/
const isSandbox = true; // Set to 'false' if you wish to order a real UberX

const uber = new Client(access_token, isSandbox);

uber.start_lat = 48.870694;
uber.start_lng = 2.317030;
uber.end_lat = 48.871405;
uber.end_lng = 2.301235;
uber.seats = 2;

uber.getUberXEstimate().then(result => {
    if(result != null){
        let distance_estimate = (result.trip.distance_estimate * 1.60934).toFixed(2);
        console.log("Estimated distance: " + distance_estimate + " km");
        uber.getRequest().then(result => {
            console.log("Ordered Uber successfully!");
            // Notify user about the ride process after one minute
            setTimeout(function(){
                getCurrentRide();
            }, 60000);
        });
    } else {
        console.warn("No UberX arround you.");
    }
});

function getCurrentRide(){
    uber.getCurrent().then(result =>{
        let status = result.status;
        let eta = result.pickup.eta;
        console.log("Current status: " + status + ". Driver arrives in: " + eta + " minutes.");
    });
}

You can also cancel an Uber ride requested by using:

uber.cancelCurrent().then(result => {
    if(result == 204){
        console.log("Canceled order successfully!");
    } else {
        res.send("No ride to cancel.");
    }
});

License

MIT

Antoine de Chassey