Tracking API

Real-Time Vehicle & Asset Location Streaming via WebSockets

Overview


The Tracking API enables real-time location streaming between drivers (or mobile agents) and offices (or control centers) using secure WebSocket connections.

This API is designed for fleet tracking, delivery monitoring, dispatch systems, and live map visualization, allowing multiple roles to communicate through a single persistent connection.

With support for authentication, subscriptions, and continuous location updates, the Tracking API ensures low-latency, scalable, and reliable tracking across your organization.




Key Features


  • πŸš— Real-time driver location updates

  • 🏒 Office subscriptions to specific drivers or all drivers

  • πŸ“‘ Low-latency WebSocket streaming




Connection Endpoint

wss://track.gebeta.app/v1/track



Roles


RoleDescription
driverSends live location updates
officeSubscribes to driver locations



Use Cases


🚚

Fleet Tracking

Monitor all active drivers in real time from a central office dashboard.

  • Live vehicle movement on maps
  • Instant visibility into fleet status
  • Improved operational awareness
πŸ“¦

Delivery Monitoring

Track individual delivery drivers to ensure accurate ETAs and route compliance.

  • Subscribe to specific drivers
  • Detect delays or route deviations
  • Improve customer satisfaction
🏒

Dispatch & Control Centers

Allow offices to observe and manage driver activity efficiently.

  • Subscribe to all drivers or selected drivers
  • Real-time decision making
  • Seamless coordination between teams
πŸ—ΊοΈ

Live Map Visualization

Integrate real-time location data into web or mobile maps.

  • Smooth marker updates
  • Accurate vehicle positioning
  • Enhanced user experience



Authentication Flow


All clients must authenticate immediately after connection.

Authenticate Message


{
  "action": "authenticate",
  "payload": {
    "user_id": "DR_1",
    "role": "driver",
    "token": "<JWT_TOKEN>"
  }
}

Parameters


FieldTypeDescriptionRequired
user_idstringUnique identifier of the useryes
rolestringdriver or officeyes
tokenstringValid JWT access tokenyes



Driver: Sending Location Updates


Once authenticated, a driver can continuously send location updates.

Location Update Message


{
  "action": "driver_location",
  "id": "DR_1",
  "payload": {
    "lat": 9.01234,
    "lng": 38.70321,
    "speed": 14.5,
    "bearing": 90
  }
}

Payload Fields


FieldTypeDescription
latnumberLatitude
lngnumberLongitude
speednumberSpeed (km/h)
bearingnumberDirection in degrees

πŸ“Œ Recommended update interval: 2–5 seconds




Office: Subscribing to Drivers


Offices can subscribe to specific drivers or all drivers.


Subscribe to a Specific Driver

{
  "action": "subscribe",
  "entity": "driver:DR_1"
}

Subscribe to All Drivers in the Company

{
  "action": "subscribe",
  "entity": "company:drivers"
}



Receiving Location Updates (Office)


Subscribed offices receive real-time updates in the following format:

{
  "type": "location_update",
  "id": "DR_1",
  "payload": {
    "lat": 9.01345,
    "lng": 38.70412,
    "speed": 13.2,
    "bearing": 90
  }
}



Heartbeat (Ping / Pong)


The server may send WebSocket ping frames to ensure connection health.

Clients must respond with pong:

ws.on("ping", () => {
  ws.pong();
});



Example Implementations


const WebSocket = require("ws");
const ws = new WebSocket("wss://track.gebeta.app/v1/track");
 
ws.on("open", () => {
  ws.send(JSON.stringify({
    action: "authenticate",
    payload: {
      user_id: "DR_1",
      role: "driver",
      token: "<JWT_TOKEN>"
    }
  }));
 
  setInterval(() => {
    ws.send(JSON.stringify({
      action: "driver_location",
      id: "DR_1",
      payload: {
        lat: 9.01 + Math.random() * 0.01,
        lng: 38.70 + Math.random() * 0.01,
        speed: 12,
        bearing: 90
      }
    }));
  }, 3000);
});



Error Handling


ErrorDescription
UnauthorizedInvalid or missing token
InvalidActionUnsupported action type
ForbiddenUnauthorized subscription
BadPayloadMissing or malformed fields



Limits & Restrictions


  • πŸ”„ Max connections: Configurable per company

  • πŸ“‘ Location update rate: Max 1 update per second per driver

  • πŸ” Token expiration: Connections close automatically on expiry

  • 🏒 Company isolation: Offices only receive data from their company