Lesson 4 of 15
44. Design Ride-Hailing with Surge Pricing (Uber / Rapido)

44.3 What are the doors?

3 min read+10 XP

Step 3: API and data model (10 minutes)

(driver WebSocket) → { "type": "loc", "lat": 12.97, "lng": 77.59, "ts": ..., "available": true } ← { "type": "offer", "trip_id": "t1", "pickup": {...}, "expires_in_s": 12 } → { "type": "accept", "trip_id": "t1", "event_id": "e-55" } POST /v1/quotes { "pickup": {...}, "drop": {...}, "product": "bike" } returns: { "quote_id": "q9", "price": 180, "surge": 1.5, "expires_at": "..." } POST /v1/trips Idempotency-Key: … { "quote_id": "q9" } → 201 { "trip_id": "t1", "state": "requested" } POST /v1/trips/{id}/events { "event_id": "e-61", "type": "arrived" } (driver app; idempotent) GET /v1/trips/{id} → state, driver, live location

The quote locks the price (including surge) for a few minutes, so the rider pays what they saw.