Streaming API Quick Reference

The frontend applications receive streaming PID data from the backend on MQTT or some such lightweight protocol. It is necessary to minimize the delay between data transmission from a device in a car until its reception on a web/mobile app.

There could be other options depending on the solution chosen on the backend.

In any case, the application subscribes to different PIDs similar to the real-time event api.

If using Websockets, connect to the Websocket API at https://stream.vehiclemind.com by passing a token parameter in the query string that has the Client ID and Client Secret separated by a colon (:).

For example, if the client ID is 1234 and the client secret is 9876, the url to connect to is https://stream.vehiclemind.com?token=1234:9876.

Using socket.io, listen for any PID that the application needs and listen for error messages. See the list for PIDs available from the device for streaming.

Websocket URL

https://stream.vehiclemind.com?token={client_id}:{client_secret}

Example Listener in Javascript

var io = require('socket.io-client')

var socket = io('https://stream.vehiclemind.com?token={client_id}:{client_secret}')

// Listen for``PID_SPEED`` event
socket.on('`pid:speed`', function(eventJSON) {
  console.log('pid:speed subscribed', eventJSON);
});

// Handle`error` messages
socket.on('error', function(errorMessage) {
  console.log('Error', errorMessage);
});

PID Caching and Refreshing

NOTE: Currently there is no caching implemented on the device side. This will be part of a future iteration. Currently caching should be performed on the cloud end, and the lastest available value should be sent to the user upon request.

The first time the app requests a mode 01 PID — or if it hasn’t requested it for some time — the adapter (VehicleMind device) schedules that PID to get refreshed periodically. The value is cached each time it is refreshed, and the app sees the most recently cached value. The adapter will try to refresh PIDs at the rates listed below on CAN vehicles, and no faster than 1 Hz on non-CAN vehicles. PIDs that aren’t refreshed are cached until the next ignition-on. The adapter stops refreshing any PID that the app hasn’t requested in a while. Mode 09 PIDs are not cached, and the adapter will request them from the vehicle on demand.

Currently there is no plan to offer users the ability to modify PID sampling frequencies.