Skip to content

Real time API

Aleksei Maslakov edited this page Feb 7, 2019 · 5 revisions

Table of Contents

Real-time interaction is based on WeSockets and includes only one endpoint.

WS /stream

  • Payload:
{
  "type": <EVENT_TYPE>,
  "data": {...}  // message payload
}

From Client to Backend


LOCATION

Current user location

Payload

{
  "latitude": 34.67,
  "longitude": 33.04, 
  "course": 179.9,  // The direction in which the device is traveling, measured in degrees and relative to due north
}

From Backend to Client

MAP

List of current drivers and hitchhikers. This event sends every N seconds

Payload

[
  {
    "user_uid": "5b7ba7d7-d7c5-4633-9821-e813e19faf25",
    "role": "driver",
    "location": {
        "user_uid": "5b7ba7d7-d7c5-4633-9821-e813e19faf25",
        "latitude": 34.67,
        "longitude": 33.04,
        "course": 179.9,
        "ts": 1547753273.231171
    },
    "has_same_ride": true  // indicates whether this member has same ride with current user
  },
  ...
]

RIDE_REQUESTED

Notifies user he's been requested a ride.

  • sender is profile of who requested/offered a ride
  • receiver is profile to whom ride was requested (this is profile of the user who receive this message)

Payload

{
  "ride_uid": "2afbd91e-16ea-4e21-ac91-2fdb1c526f5f",
  "sender": {
    "uid": "5b7ba7d7-d7c5-4633-9821-e813e19faf25",
    "name": "User full name",
    "avatar": "https://path.to.avatar",
    "role": "driver",
    "destination": {
      "name": "Destination Name",
      "latitude": 34.06,
      "longitude": 33.03,
    }
  },
  "receiver": {
    "uid": "0962e92e-3221-4c26-9746-7b4d4d9bd174",
    "name": "User full name",
    "avatar": "https://path.to.avatar",
    "role": "hitchhiker",
    "destination": {
      "name": "Destination Name",
      "latitude": 34.06,
      "longitude": 33.03,
    }
  }
}

RIDE_REQUEST_ACCEPTED

Notifies user his offer/request has been accepted. Payload is the same as in RIDE_REQUESTED

  • sender is profile of who requested ride (this is profile of the user who receive this message)
  • receiver is profile to whom ride was requested and who accepted ride request

RIDE_REQUEST_DECLINED

Notifies user his offer/request has been declined. Payload is the same as in RIDE_REQUESTED

  • sender is profile of who requested/offered a ride (this is profile of the user who receive this message)
  • receiver is profile to whom ride was requested and who declined ride request

RIDE_UPDATED

Notifies passengers that ride has been updated, usually when there is new passenger joined.

Payload

{
  "ride_uid": "2afbd91e-16ea-4e21-ac91-2fdb1c526f5f"
}

RIDE_CANCELLED

Notifies passengers that ride has been updated, usually when driver leaves ride.

Payload

{
  "ride_uid": "2afbd91e-16ea-4e21-ac91-2fdb1c526f5f"
}