Skip to main content

Websocket events

SWAT APIs provide websocket interface to subscribe for simulation events in the system. Client can subscribe to real-time feed of events to build interactive ridesharing applications.

Obtaining a token

First, client should obtain a token by API:

HTTP GET /api/v2/user/token/

Token response will look like this:

Access token for websocket requests
{
token: "<uuid>"
}

And then subscribe to the websocket stream using some of the following URLs

All simulation events

WSS GET /simulation_events/

This endpoint returns a websocket channel subscribed for all simulation events available for the current user.

Events from single simulation

WSS GET /simulation_events/{simulation_id}

Here the {simulation_id} is a simulation ID to be subscribed. This endpoint returns a websocket channel subscribed for all events for the particular {simulation_id}, if the simulation is visible for the current user.

Simulation events of the particular type

WSS GET /simulation_events/{type}

Here the {type} is a simulation event type to be subscribed (lowercase). This endpoint returns a websocket channel subscribed for all events for the particular {type}, on all simulations visible for the current user.

Events from single simulation of the particular message type

WSS GET /simulation_events/{simulation_id}/{type}

or

WSS GET /simulation_events/{type}/{simulation_id}

(both variants supported)

Here the Integer {simulation_id} is a simulation ID to be subscribed, and the string {type} is a simulation event type to be subscribed.

Available message types

Message TypeDescription
assignmentMessages about new vehicle assignment
bookingsMessages about new bookings
bookings_cancellationMessage about bookings cancellation
fail_to_boardFail to board messages
gps_dataGPS data messages
offersNew Offers
no_offerNo offer messages for booking
node_statusNode status updates
offer_acceptedOffer acceptance messages
offer_rejectedOffer rejection messages
scheduler_resultScheduler results
vehicle_statesMessage about vehicle state (GPS and Nodes together)
vehicle_useVehicle can/can not be used in simulation, for various reasons

This endpoint returns a websocket channel subscribed to all events from the simulation {simulation_id} for the particular {type}.