Going Online & Accepting Rides
Phase 1 — driver trip flow. API-level today; the driver app wraps these.
Prerequisites
- A driver account (phone OTP login, same as riders).
- An active vehicle registered to you (status
active— set after document verification; admin verifies in Phase 4).
1. Go online
POST /api/drivers/online
{ "vehicleId": "<your vehicle>", "lat": 12.9750, "lng": 77.6060 }
This sets you online and records your location. You must be online to
receive ride offers. Send periodic location updates while online:
POST /api/drivers/location { "lat": 12.9752, "lng": 77.6061 }
Go offline any time:
POST /api/drivers/offline
Your location while you are online
The driver app reports your position for you, from the moment you go online until you go offline or sign out — also while the app is in the background, while you navigate in Google Maps or Waze, and after you swipe it away.
- Android shows an ongoing notification ("you're online" / "on a trip") for as long as it runs. That notification is what lets Android keep the app alive; it disappears when you go offline.
- iOS shows the blue location indicator instead.
- No signal? Positions are kept on the phone and sent, in order, as soon as the signal is back — the distance you drove through a tunnel or a dead zone still counts towards a rental or metered fare.
- Battery saver. Some phones (Xiaomi, Oppo, Vivo, Realme, OnePlus, Huawei, Samsung and others) stop apps in the background to save battery. The first time you go online each day, the app checks and, if your phone may do this, offers to open the right settings screen. Allow the app to run without battery restrictions (and turn on Auto-start where your phone has it), or you may stop receiving requests when the screen is off.
The app talks to two endpoints for this; integrators building their own driver client can use them the same way:
POST /api/drivers/location/token # a location-only token, valid ~12 h
POST /api/drivers/location/batch # Authorization: Bearer <that token>
{ "fixes": [ { "lat": 12.9752, "lng": 77.6061, "accuracy": 6,
"heading": 90, "speed": 11.2, "recordedAt": 1793417220741 } ] }
Fixes are applied oldest first; anything not newer than the last applied fix, or less accurate than 100 m, is skipped, and a fix taken standing still (speed under 0.5 m/s) does not add to the odometer. Going offline or signing out revokes every location token issued before it.
Navigating to the rider
Tap Navigate on the trip screen and choose In-app navigation (or your own Google Maps, Apple Maps or Waze). In-app navigation keeps the trip buttons on the same screen: the map turns to face your direction of travel, a banner shows the next turn and how far along the road it is, and a voice reads each turn out in your app language — music from another app is lowered, not stopped, while it speaks. Tap 🔊 to mute it. Leave the route and it plans a new one by itself; tap End to go back to the overview. Distances are in kilometres or miles, whichever your market uses.
2. The trip flow
Once a rider books near you and you're matched, drive the trip through its states. Each call pushes a realtime update to the rider:
| Step | Endpoint | Ride state |
|---|---|---|
| Accept the ride | POST /api/driver/rides/:id/accept |
→ accepted |
| Reached pickup | POST /api/driver/rides/:id/arrive |
→ arrived |
| Start the trip | POST /api/driver/rides/:id/start |
→ in_progress |
| End the trip | POST /api/driver/rides/:id/complete |
→ completed |
| Pass on an offer | POST /api/driver/rides/:id/reject |
(stays open) |
On accept you become on_trip; on complete you return to
online, ready for the next ride. The state machine enforces order — you
can't start a trip you haven't accepted, or complete one twice.
3. Bidding (where enabled)
If the rider booked in bidding mode you can:
POST /api/rides/:id/bids/counter { "amountMinor": "13000" } # propose your fare
POST /api/rides/:id/bids/driver-accept # accept rider's fare
When a fare is agreed the ride is assigned to you at that price.
4. Realtime connection
Connect a Socket.IO client with your access token to receive offers and trip events:
io('https://your-host', { auth: { token: accessToken } })
.on('ride:status', e => /* trip state changes */)