Skip to content

Using WebSocket

The API uses a single persistent WebSocket connection. You connect, send one or multiple Protobuf‑encoded PlanRequest messages, and receive a stream of PlanResult responses.

WebSocket provides a stateful, low‑overhead channel ideal for:

  • Progressive trip updates.
  • Continuous monitoring of changing travel conditions.
  • Strongly typed schemas, version‑safe.
  • Avoiding repeated HTTP handshakes.

Each connection can handle multiple requests in sequence or parallel — perfect for user interfaces showing live travel options.

Protocol Buffers offer:

  • Compact binary format (smaller payloads).
  • Strict typing — ensuring predictable decoding.
  • Strongly typed schemas, version‑safe.
  • Backwards compatibility for evolving schemas.

Example schema excerpt:

PlanRequest.proto
message PlanRequest {
string fromPlace = 1;
string toPlace = 2;
string timestamp = 7;
bool arriveBy = 8;
UserPreferences userPreferences = 19;
}