Three lines

Uber

Developers

Curl

Access to the Driver API is currently limited access. If you are interested in using this API, you can apply for access on the Drivers Product Page.

This tutorial walks you through the steps to implement the Driver API in your app using curl.

Watch for the Try It tags, so you can try the examples as you read along!

We recommend using jq to pipe curl commands through so you can view JSON responses in a clean format. After installing, append | jq '.' to the following cURL examples to get JSON formatted bliss.

Authorize a driver for your application

To fetch a driver’s profile, trips, or payments a driver must grant access to your application through the OAuth 2.0 Authorization Code flow. See the Uber API docs on authentication for more information. The key things you need to know about OAuth can all be found in your application dashboard in the Auth tab:

  • client_id
  • client_secret
  • redirect_uri
  • scope (select from the list)

The following endpoints require a driver access token:

Step 1

Try It Have the driver sign in and authorize your app to access their Uber account.

https://auth.uber.com/oauth/v2/authorize?response_type=code&client_id=<CLIENT_ID>&scope=partner.accounts%20partner.trips%20partner.payments&redirect_uri=<REDIRECT_URI>

Step 2

Try It After authorization is complete, the authorization code is exchanged for an access token. This access token is required for making calls on behalf of the user to the API.

Request

curl -F 'client_id=<CLIENT_ID>' \
     -F 'client_secret=<CLIENT_SECRET>' \
     -F 'grant_type=authorization_code' \
     -F 'redirect_uri=<REDIRECT_URI>' \
     -F 'code=<AUTHORIZATION_CODE>' \
     https://auth.uber.com/oauth/v2/token

Response

{
   "access_token": "xxx",
   "expires_in": 2592000,
   "token_type": "Bearer",
   "scope": "partner.accounts partner.trips partner.payments",
   "refresh_token": "xxx"
 }

The access token lets you make requests on behalf of a driver to the driver endpoints. You should store this token securely, so the driver doesn’t have to go through the authorization process again.

Step 3

Now that you have an access token, you can make requests to the driver endpoints.

Try It The following example calls the GET /partners/me endpoint and returns the driver’s profile information.

Request

curl -H "Authorization: Bearer <ACCESS_TOKEN>" \
     -H "Content-Type: application/json" \
     -H "Accept-Language: en_US" \
     'https://api.uber.com/v1/partners/me'

Response

{
  "driver_id": "8LvWuRAq2511gmr8EMkovekFNa2848lyMaQevIto-aXmnK9oKNRtfTxYLgPq9OSt8EzAu5pDB7XiaQIrcp-zXgOA5EyK4h00U6D1o7aZpXIQah--U77Eh7LEBiksj2rahB==",
  "first_name": "Uber",
  "last_name": "Tester",
  "email": "uber.developer+tester@example.com",
  "phone_number": "+15555550001",
  "picture": "https://d1w2poirtb3as9.cloudfront.net/16ce502f4767f17b120e.png",
  "promo_code": "ubert4544ue",
  "rating": 5,
  "activation_status": "active"
}

Get a drivers trips

Try It Get the drivers last ten trips.

Request

curl -H 'Authorization: Bearer <TOKEN>' \
'https://api.uber.com/v1/partners/trips'

Response

Status-Code: 200 OK

{
  "count": 1200,
  "limit": 1,
  "trips": [
    {
      "fare": 6.2,
      "dropoff": {
        "timestamp": 1502844378
      },
      "vehicle_id": "0082b54a-6a5e-4f6b-b999-b0649f286381",
      "distance": 0.37,
      "start_city": {
        "latitude": 38.3498,
        "display_name": "Charleston, WV",
        "longitude": -81.6326
      },
      "status_changes": [
        {
          "status": "accepted",
          "timestamp": 1502843899
        },
        {
          "status": "driver_arrived",
          "timestamp": 1502843900
        },
        {
          "status": "trip_began",
          "timestamp": 1502843903
        },
        {
          "status": "completed",
          "timestamp": 1502844378
        }
      ],
      "surge_multiplier": 1,
      "pickup": {
        "timestamp": 1502843903
      },
      "driver_id": "8LvWuRAq2511gmr8EMkovekFNa2848lyMaQevIto-aXmnK9oKNRtfTxYLgPq9OSt8EzAu5pDB7XiaQIrcp-zXgOA5EyK4h00U6D1o7aZpXIQah--U77Eh7LEBiksj2rahB==",
      "status": "completed",
      "duration": 475,
      "trip_id": "b5613b6a-fe74-4704-a637-50f8d51a8bb1",
      "currency_code": "USD"
    }
  ],
  "offset": 0
}

The possible status values are:

Status description
accepted The driver accepted the request and is enroute to the start location.
arriving The driver arrived or will shortly.
in_progress The trip is in progress from the start location to the end location.
rider_canceled The rider cancelled the request.
driver_canceled The driver cancelled the request.
completed The trip is completed by the driver.

Get a drivers payments

Try It Get the drivers last ten payments.

Request

curl -H 'Authorization: Bearer <TOKEN>' \
'https://api.uber.com/v1/partners/payments'

Response

Status-Code: 200 OK

{
  "count": 1200,
  "limit": 1,
  "payments": [
    {
      "payment_id": "5cb8304c-f3f0-4a46-b6e3-b55e020750d7",
      "category": "fare",
      "event_time": 1502842757,
      "trip_id": "5cb8304c-f3f0-4a46-b6e3-b55e020750d7",
      "cash_collected": 0,
      "amount": 3.12,
      "driver_id": "8LvWuRAq2511gmr8EMkovekFNa2848lyMaQevIto-aXmnK9oKNRtfTxYLgPq9OSt8EzAu5pDB7XiaQIrcp-zXgOA5EyK4h00U6D1o7aZpXIQah--U77Eh7LEBiksj2rahB==",
      "breakdown": {
        "other": 4.16,
        "service_fee": -1.04
      },
      "rider_fees": {},
      "partner_id": "8LvWuRAq2511gmr8EMkovekFNa2848lyMaQevIto-aXmnK9oKNRtfTxYLgPq9OSt8EzAu5pDB7XiaQIrcp-zXgOA5EyK4h00U6D1o7aZpXIQah--U77Eh7LEBiksj2rahB==",
      "currency_code": "USD"
    }
  ],
  "offset": 0
}

Congratulations! You finished the Driver API tutorial and can access trips and payments!

Uber

Developers
© 2023 Uber Technologies Inc.