Skip to content

Decoding Responses

Each server message may contain either a JSON control message or a binary‑encoded PlanResult.

Example handler:

request.js
ws.on('message', (data, isBinary) => {
const buf = isBinary ? data : Buffer.from(data);
try {
const result = PlanResult.decode(buf);
handleResult(result);
} catch (e) {
console.warn('Invalid frame', e);
}
});
PlanResult.proto
message PlanResult {
repeated TripPattern trips = 1;
string timestamp = 2;
string previousPageCursor = 3;
string nextPageCursor = 4;
repeated RoutingError errors = 5;
int32 planner = 6;
bool containsOnDemand = 7;
bool containsWithSurcharge = 8;
repeated string modifiers = 9;
double grade = 10;
}

The response can contain multiple trips, along with cursors for pagination. Next page includes full detailed PlanResult proto file