Cookie based Connection
WebSocket Connection Details
- Base URL:
wss://itsochvts.com/api/socket
- Authentication: Basic auth (automatically switches to cookie)
Important Note
- Most modern browsers do not allow setting cookies directly during a WebSocket connection to receive data from a foreign socket. In such cases, use the basic authentication method on the server side to establish the connection and receive data securely.
Example Usage with Javascript
Here's a basic example of connecting to the WebSocket and handling device updates:
// Example WebSocket client
const socket = new WebSocket("wss://itsochvts.com/api/socket");
// Connection opened
socket.onopen = () => {
console.log("Connected to WebSocket");
};
// Listen for messages
socket.onmessage = (event) => {
const data = JSON.parse(event.data);
// Handle device updates
if (data.devices) {
handleDevices(data.devices);
}
// Handle position updates
if (data.positions) {
handlePositions(data.positions);
}
// Handle events
if (data.events) {
handleEvents(data.events);
}
};
// Connection closed
socket.onclose = () => {
console.log("Disconnected from WebSocket");
};
Message Events
The server can send the following message types:
Devices Data
- For more information about devices Device API v1 and Devices API v2
vehicle information Example response:
{
"devices": [
{
"id": 5709,
"name": "Car",
"uniqueId": "biratexpocar",
"status": "online",
"disabled": false,
"lastUpdate": "2025-02-20T09:02:39.847+00:00",
"positionId": 1182220637,
"category": "car",
"model": "Toyota Camry",
"contact": "John Doe",
"phone": "+1234567890",
"expirationTime": null,
"attributes": {
"speedLimit": 60,
"fuelType": "petrol",
"engineType": "2.5L",
"yearModel": "2024"
},
"groupId": 0,
"calendarId": 0
},
{
"id": 5710,
"name": "Truck",
"uniqueId": "biratexpotruck",
"status": "offline",
"disabled": false,
"lastUpdate": "2025-02-20T08:45:12.123+00:00",
"positionId": 1182220638,
"category": "truck",
"model": "Volvo FH",
"contact": "Jane Smith",
"phone": "+9876543210",
"expirationTime": "2026-02-20T00:00:00.000+00:00",
"attributes": {
"speedLimit": 40,
"fuelType": "diesel",
"cargoCapacity": "20tons",
"temperatureControl": true
},
"groupId": 1,
"calendarId": 1
}
]
}
Positions Data
- For more information about position data consider Position API v1 Contains real-time vehicle position dat Example response:
{
"positions": [
{
"id": 1183596450,
"deviceId": 1381,
"protocol": "gt06",
"deviceTime": "2025-02-20T09:00:16.000+00:00",
"fixTime": "2025-02-20T07:13:15.000+00:00",
"serverTime": "2025-02-20T09:00:16.000+00:00",
"outdated": false,
"valid": true,
"latitude": 26.669095555555558,
"longitude": 87.2735438888889,
"altitude": 0,
"speed": 0,
"course": 207,
"address": "इटहरी, कोशी प्रदेश, NP",
"accuracy": 0,
"network": null,
"geofenceIds": [892],
"attributes": {
"type": 19,
"status": 5,
"ignition": false,
"charge": true,
"blocked": false,
"batteryLevel": 66,
"rssi": 3
}
},
{
"id": 1183596451,
"deviceId": 1382,
"protocol": "gt06",
"deviceTime": "2025-02-20T09:00:16.000+00:00",
"fixTime": "2025-02-20T07:13:15.000+00:00",
"serverTime": "2025-02-20T09:00:16.000+00:00",
"outdated": false,
"valid": true,
"latitude": 26.669095555555558,
"longitude": 87.2735438888889,
"altitude": 0,
"speed": 0,
"course": 207,
"address": "इटहरी, कोशी प्रदेश, NP",
"accuracy": 0,
"network": null,
"geofenceIds": [892],
"attributes": {
"type": 19,
"status": 5,
"ignition": false,
"charge": true,
"blocked": false,
"batteryLevel": 66,
"rssi": 3
}
}
]
}
Events Data
- For more information about events data see consider Events API v1
Contains vehicle notifications and alerts Example response:
{
"events": [
{
"id": 240852851,
"type": "geofenceExit",
"deviceId": 1234,
"eventTime": "2025-02-20T09:04:41.000+00:00",
"geofenceId": 910,
"positionId": 1183609850,
"maintenanceId": 0,
"attributes": {
"message": "Car has exited geofence Tinkune at 2025-02-20 14:49:41"
}
}
]
}