๐Ÿ“– Afaqy Knowledge Base / AVL / Messages / API Documentation


<aside> CONTENTS


</aside>

1. Full Integration Flow

This flow describes how to integrate your system with the AVL Message Module from authentication to signal mapping.

  1. Authenticate
  2. Retrieve Unit List
  3. Retrieve Signals
  4. Map Signals to Sensors
  5. Display or Store Data

2. Authentication

Endpoint

POST <https://api.afaqy.sa/auth/login>

Request Body

{
  "data": {
    "username": "YOUR_USERNAME",
    "password": "YOUR_PASSWORD"
  }
}

Response

{
  "status": "success",
  "message": "Login successful",
  "data": {
    "token": "YOUR_JWT_TOKEN"
  }
}

3. Unit List

Endpoint

POST <https://api.afaqy.sa/units/lists>

Request Body

{
  "data": {
    "offset": 0,
    "limit": 1000,
    "projection": ["basic", "last_update", "driver"]
  }
}

Response Fields

4. Signals

Endpoint

POST <https://api.afaqy.sa/units/signals>

Request Body Example

{
  "data": {
    "unit_id": "UNIT_ID_HERE",
    "date": {
      "interval": "interval",
      "from": "2025-08-10 00:00:00",
      "to": "2025-08-10 23:59:59",
      "interval_count": 1,
      "interval_unit": "minutes",
      "including_current": false},
    "message_type": "data_messages",
    "message_options": "parameters",
    "parameter": "raw_data",
    "limit": 1000,
    "offset": 0,
    "sensors": true,
    "with_extra": true}
}

5. Mapping & Tracing Returned Data

5.1 Where sensor definitions live

Example:

"extra": {
  "sensors": {
    "6823325e71b9d5ce20b25d7": "ACC",
    "6823325e71b9d5ce20b25d9": "Vehicle Battery",
    "6823325e71b9d5ce20b25db": "Device Battery"
  }
}

5.2 Where sensor readings live

"sensors": {
  "6823325e71b9d5ce20b25d7": {
    "prm": 0,
    "value": "OFF",
    "cValue": "0"
  }
}

Field meanings:

5.3 How to map & interpret

  1. Take the sensor ID from sensors.
  2. Look it up in extra.sensors to find the sensorโ€™s name.
  3. Use value or cValue depending on whether you want calibrated data or raw readings.
  4. prm can be used if you need the raw device output for custom processing.

5.4 Mixed parameter sources

5.5 Adjustable query parameters that affect mapping

Parameter Purpose
unit_id Selects the unit to query.
from Start datetime for the data range.
to End datetime for the data range.
sensors Must be true to return sensors data in the payload.

6. Best Practices