Skip to content Skip to sidebar Skip to footer

Get Users End Point Location Using Uber Api

I've been looking at the UBER API and i was wondering if there was a way to have a service running in my Android / iOS app, where my app could get the users drop-off location. The

Solution 1:

Such a use case is possible and explained in more details in the following links:

To build this trip experience you have to request the all_trips OAuth scope from the user:

all_trips

Get details of the trip that the user is currently taking, regardless of how it was requested (via the Uber app or a third-party application).

Privileged

It is a privileged scope because it is required that you request access first from Uber for the scope to be usable in the application you defined in the Uber Developer Dashboard

Then after you make an Uber ride request on behalf of the user using the POST /v1/requests, you can call either the GET /v1/requests/current or GET /v1/requests/{request_id} to get the details of the trip:

{
   "request_id":"17cb78a7-b672-4d34-a288-a6c6e44d5315",
   "status":"accepted",
   "location":{
      "latitude":37.7886532015,
      "longitude":-122.3961987534,
      "bearing":135
   },
   "pickup":{
      "latitude":37.7872486012,
      "longitude":-122.4026315287,
      "eta":5
   },
   "destination":{
      "latitude":37.7766874,
      "longitude":-122.394857,
      "eta":19
   },
   "driver": {
      "phone_number": "(555)555-5555",
      "rating": 5,
      "picture_url": "https:\/\/d1w2poirtb3as9.cloudfront.net\/img.jpeg",
      "name": "Bob"
   },
   "vehicle":{
      "make": "Bugatti",
      "model": "Veyron",
      "license_plate": "I<3Uber",
      "picture_url": "https:\/\/d1w2poirtb3as9.cloudfront.net\/car.jpeg"
   },
   "surge_multiplier":1.0,
   "eta": 5
}
  • If your app doesn't make ride requests, you have to poll the GET /v1/requests/current endpoint. See this and this for best practices.

  • If your app makes ride requests, the above /v1/requests endpoints can be combined with the Webhooks event driven mechanism, so that you are notified on your server that a trip's status has been updated or the receipt is ready, instead of you having to poll every 3-5 seconds to get the most up-to-date details possible.

When you receive a notification from Uber via webhooks you then call the GET /v1/requests/current or GET /v1/requests/{request_id} endpoint.

Then with the data you received you need to inform your Android service (by a server to client communication mechanism, e.g. websocket, push notifications, etc.) that new information is available from Uber and based on that you show to the user relevant information given the 'Trip Context' data you want to use, e.g.: - Current location (latitude/longitude) - Pickup location (latitude/longitude) - ETA to pickup (while the car is arriving) - Destination location (latitude/longitude) - ETA to destination (while the user is in the car)

The webhook receives the following events:

  • REQUESTS.STATUS_CHANGED

    For all Requests made by your application on behalf of Uber riders, we will make a request to your WEBHOOK URL whenever its status changes. This can help you notify the user or change the state of your app to reflect a status change without continuously polling the /v1/requests endpoint.

  • REQUESTS.RECEIPT_READY

    For all Requests made by your application on behalf of Uber riders we will make a request to your WEBHOOK URL whenever a Request Receipt is available. This will allow you to show your user the details of their fare and how much they were charged as soon as their Receipt is available. If the rider cancels after the grace period, and they are charged, a receipt will still be available showing that charge.

    To get access to a Request Receipt resource, the user must have authorized your application to have access to the request_receipt scope.

Uber request states

Post a Comment for "Get Users End Point Location Using Uber Api"