Official Uber Rides API Python SDK
Python SDK (beta) to support the Uber Rides API.
To use the Uber Rides Python SDK:
$ pip install uber_rides
Head over to pip-installer for instructions on installing pip.
To run from source, you can download the source code for uber-rides, and then run:
$ python setup.py install
We recommend using virtualenv when setting up your project environment. You may need to run the above commands with sudo if you’re not using it.
If you just need read-only access to Uber API resources, like getting a location’s available products, create a Session with the server token you received after registering your app.
from uber_rides.session import Session session = Session(server_token=YOUR_SERVER_TOKEN)
Use this Session to create an UberRidesClient and fetch API resources:
from uber_rides.client import UberRidesClient client = UberRidesClient(session) response = client.get_products(37.77, -122.41) products = response.json.get('products')
Navigate to the example folder to access the python scripts examples. Before you can run an example, you must edit the example/config.yaml file and add your app credentials.
To get an UberRidesClient through the Authorization Code flow, run:
$ python example/authorize_user.py
The example above stores user credentials in example/oauth2_session_store.yaml. To create an UberRidesClient with these credentials and go through a surge ride request run:
$ python example/request_ride.py
Get Available Products
response = client.get_products(37.77, -122.41) products = response.json.get('products') product_id = products.get('product_id')
response = client.get_user_profile() profile = response.json email = profile.get('email')
Request a Ride
response = client.request_ride( product_id=product_id, start_latitude=37.77, start_longitude=-122.41, end_latitude=37.79, end_longitude=-122.41, ) ride_details = response.json ride_id = ride_details.get('request_id')
This makes a real-world request and send an Uber driver to the specified start location.
To develop and test against request endpoints in a sandbox environment, make sure to instantiate your UberRidesClient with
client = UberRidesClient(session, sandbox_mode=True)
The default for sandbox_mode is set to False. See our documentation to read more about using the Sandbox Environment.
Update Sandbox Ride
If you are requesting sandbox rides, you will need to step through the different states of a ride.
response = client.update_sandbox_ride(ride_id, 'accepted') response = client.update_sandbox_ride(ride_id, 'in_progress')
If the update is successful, response.status_code will be 204.
The update_sandbox_ride method is not valid in normal mode, where the ride status will change automatically.
Uber developers actively monitor the Uber Tag on StackOverflow. If you need help installing or using the library, you can ask a question there. Make sure to tag your question with uber-api and python!
For full documentation about our API, visit our Developer Site.
We love contributions. If you’ve found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo. Write a test to show your bug was fixed or the feature works as expected.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size uber_rides-0.3.1-py2.py3-none-any.whl (50.9 kB)||File type Wheel||Python version 2.7||Upload date||Hashes View|
|Filename, size uber_rides-0.3.1.tar.gz (90.5 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for uber_rides-0.3.1-py2.py3-none-any.whl