Enable the profile, places, ride_widgets, history_lite and history scopes. </ul>
With the resulting Client ID and Client Secret you’ll be ready to authenticate. I’ve stored mine as environment variables but you can just hard code them into the script for starters.
We can immediately use uber_me() to retrieve information about the authenticated user.
Clearly I haven’t made enough effort in personalising my Uber account.
Uber allows you to specify predefined locations for “home” and “work”. These are accessible via uber_places_get().
These addresses can be modified using uber_places_put().
You can access data for recent rides using uber_history().
The response includes a wide range of fields, we’ll just pick out just a few of them for closer inspection.
We can get a list of cars near to a specified location using uber_products().
Information for a particular car can also be accessed.
It’s good to have a rough idea of how much a ride is going to cost you. What about a trip from Mouille Point to the Old Biscuit Mill?
Not quite sure why the API is returning the distance in such obscure units. (Note to self: convert those to metric equivalent in next release!) The data above are based on the car nearest to the start location. What about prices for a selection of other cars?
The time of arrival for each of those cars can be accessed via uber_estimate_time().
So, for example, the uberXL would be expected to arrive in 7 minutes, while the uberX would pick you up in only 3 minutes.
Requesting a Ride
It’s also possible to request a ride. At present these requests are directed to the Uber API Sandbox. After we have done further testing we’ll retarget the requests to the API proper.
A new ride is requested using uber_requests().
Let’s find out the details of the result.
Information about the currently requested ride can be accessed using uber_requests_current(). If we decide to walk instead, then it’s also possible to cancel the pickup.
For more information about units of measurement, limits and parameters of the Uber API, have a look at the API Overview.
We’ll be extending the package to cover the remaining API endpoints. But, for the moment, most of the core functionality is already covered.