WebSocket lifecycle
Connect, send, receive
Section titled “Connect, send, receive”- Open
wss://api.infoplaza.com/v1/transit/implannerwith yourapi_keyquery parameter. Protobuf is the default; addmode=jsonfor JSON. - Send a planning request.
- Add each result to your journey list as it arrives.
- Finish the loading state when the server closes the completed search.
A successful search ends with a normal close (code 1000). Open a new connection for the next search.
Choose a format
Section titled “Choose a format”| Format | Send | Receive |
|---|---|---|
| JSON | A text planTrip envelope | Text PlanResult objects |
| Protobuf | An encoded PlanRequest | Binary PlanResult messages |
Protobuf is recommended for applications: its compact binary messages reduce data transfer and support efficient encoding and decoding. See Protobuf & TypeScript to generate your client.
Both formats can receive a text JSON error envelope. Check the frame type first, then decode the message.
Handle the outcome
Section titled “Handle the outcome”| Outcome | Show |
|---|---|
| Result message | The returned journeys |
| More work in progress | Finding more options… |
| Completed with no journeys | A suggestion to change the time or preferences |
| Error message or failed connection | The error and a retry action |
Start another search
Section titled “Start another search”Close the previous connection and start a new one when the traveller changes their search. If you reuse an active connection, a newly submitted request replaces the in-progress request.