# Trip

## Description

The overall approach behind DriveQuant’s trip analysis service is based on vehicle dynamics and powertrain modeling. Using vehicle or smartphone sensors, our services estimate the efforts applied to the powertrain enabling us, for example, to remodel the efforts between the road and the wheels or to estimate the exhaust pollutants.

DriveQuant’s data analysis service delivers a wide range of indicators describing vehicle usage and driver behavior. For a single trip, DriveQuant’s trip analysis service retrieves:

1. eco-driving indicators,
2. an estimate of the fuel consumption,
3. safety indicators,
4. tire and brake wear measurements,
5. pollutant emissions estimation,
6. a distraction score (phone use),
7. and a speed limit score.

The trip analysis API is automatically requested by the DriveKit SDK at the end of each trip.&#x20;

This API can also be used without the DriveKit SDK if you have your own GPS data collection system (OBD dongle, black box, vehicle data).

{% hint style="info" %}
The distraction score (phone use) is only available for SDK users.

An additional cost is required for the use of the speed limit score, which is calculated using data coming from map data providers.
{% endhint %}

This section explains how to query the trip analysis API, how driving indicators are computed and how they are structured.

DriveQuant services provide additional data by collecting all vehicle trips so you can easily retrieve statistics for each of your vehicles. We recommend to [add a new vehicle](https://docs.drivequant.com/backend/vehicle/create-a-vehicle) before requesting the trip analysis API if you target a vehicule mantenance use case.

## Trip

<mark style="color:green;">`POST`</mark> `https://service.drivequant.com/v2/trip`

This method returns all driving analytics calculated by DriveQuant for a trip.&#x20;

#### Request Body

| Name          | Type   | Description                               |
| ------------- | ------ | ----------------------------------------- |
| account       | object | Identification data for the trip          |
| route         | object | GPS or vehicle recorded data for the trip |
| vehicle       | object | Vehicle characteristics used for the trip |
| itineraryData | object | Data of the trip                          |
| metaData      | object | Customer specific data                    |

{% tabs %}
{% tab title="200 This is an example of trip API response. A detailed description of value is available below." %}

```javascript
  {
    "status": true,
    "itinId": "6030ebe4ea60426b34e9b3bf",
    "userId": "<UNIQUE USER OR ASSET ID>",
    "comments": [{
      "errorCode": 16,
      "comment": "Engine speed not available"
      },
      {
        "errorCode": 0,
        "comment": "OK"
      }
    ],
    "itineraryStatistics": {
        "tripDuration": 1996.0,
        "drivingDuration": 1737.0,
        "idlingDuration": 259.0,
        "drivingPercentage": 87.0,
        "idlingPercentage": 13.0,
        "distance": 15801.0,
        "speedMean": 30.5,
        "subdispNb": 60,
        "meteo": 2,
        "day": true,
        "weekDay": false,
        "transportationMode": 1
    },
    "ecoDriving": {
        "score": 7.1,
        "scoreAccel": -1.7,
        "scoreMain": 0.9,
        "scoreDecel": -0.5,
        "stdDevAccel": 2.2006383,
        "stdDevMain": 0.99105114,
        "stdDevDecel": 3.797757,
        "energyClass": 2
    },
    "fuelEstimation": {
        "co2Mass": 2.691,
        "co2Emission": 170.0,
        "fuelVolume": 1.153,
        "fuelConsumption": 7.3,
        "idleFuelVolume": 0.049,
        "idleFuelPercentage": 4.28,
        "idleFuelConsumption": 0.696,
        "idleCo2Emission": 1.625,
        "idleCo2Mass": 0.115,
        "engineTempStatus": true,
        "coldFuelVolume": 0.018
    },
    "safety": {
        "safetyScore": 9.1,
        "nbAdh": 2,
        "nbAccel": 0,
        "nbDecel": 3,
        "nbAdhCrit": 0,
        "nbAccelCrit": 0,
        "nbDecelCrit": 1
    },
    "advancedEcoDriving": {
        "ecoDrivingContext": [
            {
                "contextId": 0,
                "distance": 6.9,
                "duration": 19.1,
                "efficiencyScore": 11.0,
                "scoreAccel": 6.0,
                "scoreMain": 6.0,
                "scoreDecel": 6.0
            },
            {
                "contextId": 1,
                "distance": 3.7,
                "duration": 6.5,
                "efficiencyScore": 6.1,
                "scoreAccel": -2.8,
                "scoreMain": 0.3,
                "scoreDecel": 1.3
            },
            {
                "contextId": 2,
                "distance": 64.8,
                "duration": 61.8,
                "efficiencyScore": 6.7,
                "scoreAccel": -1.7,
                "scoreMain": 0.6,
                "scoreDecel": -1.3
            },
            {
                "contextId": 3,
                "distance": 12.7,
                "duration": 7.8,
                "efficiencyScore": 6.6,
                "scoreAccel": -1.8,
                "scoreMain": 1.6,
                "scoreDecel": 0.8
            },
            {
                "contextId": 4,
                "distance": 11.8,
                "duration": 4.9,
                "efficiencyScore": 8.4,
                "scoreAccel": -1.1,
                "scoreMain": 0.1,
                "scoreDecel": -2.9
            }
        ]
    },
    "advancedFuelEstimation": {
        "fuelEstimationContext": [
            {
                "contextId": 0,
                "distance": 6.9,
                "duration": 19.1,
                "co2Mass": 0.199,
                "co2Emission": 179.0,
                "fuelVolume": 0.085,
                "fuelConsumption": 7.69
            },
            {
                "contextId": 1,
                "distance": 3.7,
                "duration": 6.5,
                "co2Mass": 0.099,
                "co2Emission": 167.0,
                "fuelVolume": 0.042,
                "fuelConsumption": 7.139
            },
            {
                "contextId": 2,
                "distance": 64.8,
                "duration": 61.8,
                "co2Mass": 1.832,
                "co2Emission": 176.0,
                "fuelVolume": 0.785,
                "fuelConsumption": 7.535
            },
            {
                "contextId": 3,
                "distance": 12.7,
                "duration": 7.8,
                "co2Mass": 0.264,
                "co2Emission": 130.0,
                "fuelVolume": 0.113,
                "fuelConsumption": 5.549
            },
            {
                "contextId": 4,
                "distance": 11.8,
                "duration": 4.9,
                "co2Mass": 0.182,
                "co2Emission": 96.0,
                "fuelVolume": 0.078,
                "fuelConsumption": 4.107
            }
        ]
    },
    "advancedSafety": {
        "safetyContext": [
            {
                "contextId": 0,
                "distance": 6.9,
                "duration": 19.1,
                "nbAdh": 0,
                "nbAccel": 0,
                "nbDecel": 0,
                "nbAdhCrit": 0,
                "nbAccelCrit": 0,
                "nbDecelCrit": 0,
                "safetyScore": 11.0
            },
            {
                "contextId": 1,
                "distance": 3.7,
                "duration": 6.5,
                "nbAdh": 0,
                "nbAccel": 0,
                "nbDecel": 0,
                "nbAdhCrit": 0,
                "nbAccelCrit": 0,
                "nbDecelCrit": 0,
                "safetyScore": 11.0
            },
            {
                "contextId": 2,
                "distance": 64.8,
                "duration": 61.8,
                "nbAdh": 2,
                "nbAccel": 0,
                "nbDecel": 2,
                "nbAdhCrit": 0,
                "nbAccelCrit": 0,
                "nbDecelCrit": 1,
                "safetyScore": 9.1
            },
            {
                "contextId": 3,
                "distance": 12.7,
                "duration": 7.8,
                "nbAdh": 0,
                "nbAccel": 0,
                "nbDecel": 0,
                "nbAdhCrit": 0,
                "nbAccelCrit": 0,
                "nbDecelCrit": 0,
                "safetyScore": 10.0
            },
            {
                "contextId": 4,
                "distance": 11.8,
                "duration": 4.9,
                "nbAdh": 0,
                "nbAccel": 0,
                "nbDecel": 1,
                "nbAdhCrit": 0,
                "nbAccelCrit": 0,
                "nbDecelCrit": 0,
                "safetyScore": 8.0
            }
        ]
    },
    "pollutants": {
        "co": 436.34,
        "hc": 105.19,
        "nox": 43.45,
        "soot": 0.01
    },
    "tireWear": {
        "frontTireWear": 625151,
        "rearTireWear": 194424,
        "frontTireDistance": 6522,
        "rearTireDistance": 6522,
        "frontTireAutonomy": 25010,
        "rearTireAutonomy": 159958,
        "frontTireTotalWear": 20.6847961834131,
        "rearTireTotalWear": 3.917838643900801,
        "frontTireWearRate": 3.1593584519985076,
        "rearTireWearRate": 0.5879650354629268
    },
    "brakeWear": {
        "frontBrakePadWear": 652316,
        "rearBrakePadWear": 490585,
        "frontBrakeDistance": 6522,
        "rearBrakeDistance": 6522,
        "frontBrakeAutonomy": 51081,
        "rearBrakeAutonomy": 70712,
        "frontBrakeTotalWear": 11.322879923360654,
        "rearBrakeTotalWear": 8.444911708095175,
        "frontBrakeWearRate": 1.6040543118399773,
        "rearBrakeWearRate": 1.1953688298028098
    },
    "safetyEvents": [
        {
            "time": 198.0,
            "longitude": 2.2345499992370605,
            "latitude": 48.865421295166016,
            "velocity": 27.597404310389447,
            "heading": 181.3752105740906,
            "elevation": 21.428831625626,
            "distance": 1803.0,
            "type": 3,
            "level": 1,
            "value": -1.9984114049011923
        },
        {
            "time": 886.0,
            "longitude": 2.228440046310425,
            "latitude": 48.829158782958984,
            "velocity": 9.322159013829488,
            "heading": 115.71003406053404,
            "elevation": 35.0165024497636,
            "distance": 5811.0,
            "type": 1,
            "level": 1,
            "value": 0.2091391662960067
        },
        {
            "time": 1179.0,
            "longitude": 2.2220299243927,
            "latitude": 48.776981353759766,
            "velocity": 59.56077714321047,
            "heading": 196.14873235105892,
            "elevation": 169.4896656907427,
            "distance": 8721.0,
            "type": 3,
            "level": 1,
            "value": -1.851640380003413
        },
        {
            "time": 1352.0,
            "longitude": 2.2241098880767822,
            "latitude": 48.76197814941406,
            "velocity": 23.478607191677995,
            "heading": 231.66262821151452,
            "elevation": 96.56055945085538,
            "distance": 11036.0,
            "type": 1,
            "level": 1,
            "value": 0.2596086644093922
        },
        {
            "time": 1352.0,
            "longitude": 2.2241098880767822,
            "latitude": 48.76197814941406,
            "velocity": 23.478607191677995,
            "heading": 231.66262821151452,
            "elevation": 96.56055945085538,
            "distance": 11036.0,
            "type": 3,
            "level": 2,
            "value": -3.1478373502646355
        },
        {
            "time": 1902.0,
            "longitude": 2.2364699840545654,
            "latitude": 48.742130279541016,
            "velocity": 29.11161620369841,
            "heading": 127.70357513427746,
            "elevation": 76.72611043725985,
            "distance": 14436.0,
            "type": 3,
            "level": 1,
            "value": -2.095731316728654
        }
    ],
    "endDate": "2021-02-20T10:56:37.188+0000",
    "itineraryData": {
        "endDate": "2021-02-20T10:56:37.188+0000",
        "startDate": "2021-02-20T10:23:22.188+0000",
        "departureCity": "<DEPARTURE CITY>",
        "arrivalCity": "<ARRIVAL CITY>",
        "departureAddress": "<DEPARTURE ADDRESS>",
        "arrivalAddress": "<ARRIVAL ADDRESS>",
        "departureState": "<DEPARTURE STATE>",
        "arrivalState": "<ARRIVAL STATE>",
        "departurePostalCode": "<DEPARTURE POSTAL CODE>",
        "arrivalPostalCode": "<ARRIVAL POSTAL CODE>",
        "departureCountry": "<DEPARTURE COUNTRY>",
        "arrivalCountry": "<ARRIVAL COUNTRY>"
    },
    "driverDistraction": {
        "nbUnlock": 1,
        "durationUnlock": 97.0,
        "durationPercentUnlock": 4.86002640172576,
        "distanceUnlock": 403.68833585416337,
        "distancePercentUnlock": 2.5548277694713204,
        "score": 1.9159997325752993,
        "scoreUnlock": 6.7627283707197705,
        "scoreCall": 1.9159997325752993,
        "calls": [
            {
                "id": 0,
                "start": 544.0035407543182,
                "end": 634.0030286312103,
                "durationS": 89,
                "duration": 5,
                "distanceM": 456,
                "distance": 3,
                "status": "OUTGOING",
                "audioSystem": "SPEAKER",
                "forbidden": true
            }
        ]
    },
    "distractionEvents": [
        {
            "time": 539.0,
            "latitude": 48.85495,
            "longitude": 2.22616,
            "velocity": 12.168000411987304,
            "heading": -1.616703658463509,
            "elevation": 23.05337370577991,
            "distance": 3245.3746307904125,
            "type": 1,
            "duration": 97,
            "index": 539
        },
        {
            "time": 636.0,
            "latitude": 48.85034,
            "longitude": 2.22683,
            "velocity": 45.22616824022174,
            "heading": -1.3488582653419061,
            "elevation": 29.8860134067469,
            "distance": 3746.5653789286157,
            "type": 2,
            "duration": 1360,
            "index": 636
        }
    ],
    "callEvents": [
        {
            "time": 544.0035407543182,
            "latitude": 48.85475,
            "longitude": 2.22616,
            "velocity": 12.456000137329102,
            "heading": -1.5768984084633124,
            "elevation": 23.53374615925395,
            "distance": 0.0,
            "type": 3,
            "duration": 1,
            "index": 544,
            "audioSystem": "SPEAKER",
            "callType": "OUTGOING",
            "forbidden": true
        },
        {
            "time": 634.0030286312103,
            "latitude": 48.85059,
            "longitude": 2.22674,
            "velocity": 46.44316055270816,
            "heading": -1.3482454261409265,
            "elevation": 30.170426377189013,
            "distance": 456.0,
            "type": 4,
            "duration": 89,
            "index": 634,
            "audioSystem": "SPEAKER",
            "callType": "OUTGOING",
            "forbidden": true
        }
    ],
    "speedingEvents": [
        {
            "longitude": 2.240690719770278,
            "latitude": 48.87119316290749,
            "time": 96.0,
            "type": 1,
            "index": 36
        },
        {
            "longitude": 2.2389993413999454,
            "latitude": 48.87022711541927,
            "time": 106.0,
            "type": 0,
            "index": 39
        },
        {
            "longitude": 2.226948759849819,
            "latitude": 48.8285248546614,
            "time": 899.0,
            "type": 1,
            "index": 220
        },
        {
            "longitude": 2.2247798257606703,
            "latitude": 48.82771252373621,
            "time": 910.0,
            "type": 0,
            "index": 229
        },
        {
            "longitude": 2.220820796904408,
            "latitude": 48.790306020720436,
            "time": 1121.87393116951,
            "type": 1,
            "index": 374
        },
        {
            "longitude": 2.222806342988146,
            "latitude": 48.781090574187054,
            "time": 1158.87393116951,
            "type": 0,
            "index": 409
        },
        {
            "longitude": 2.221726988867627,
            "latitude": 48.776698917142845,
            "time": 1181.87393116951,
            "type": 1,
            "index": 428
        },
        {
            "longitude": 2.221415682498137,
            "latitude": 48.77728241347195,
            "time": 1198.87393116951,
            "type": 0,
            "index": 449
        },
        {
            "longitude": 2.2259807317602576,
            "latitude": 48.77630605611952,
            "time": 1222.87393116951,
            "type": 1,
            "index": 472
        },
        {
            "longitude": 2.229023362169593,
            "latitude": 48.77273423930304,
            "time": 1252.87393116951,
            "type": 0,
            "index": 499
        },
        {
            "longitude": 2.2291619672238197,
            "latitude": 48.77164365290039,
            "time": 1259.87393116951,
            "type": 1,
            "index": 502
        },
        {
            "longitude": 2.229596580809962,
            "latitude": 48.76831710988511,
            "time": 1281.87393116951,
            "type": 0,
            "index": 525
        }
    ],
    "speedingStatistics": {
        "distance": 15857,
        "duration": 1727,
        "speedingDistance": 1956,
        "speedingDuration": 105,
        "score": 4.82,
        "speedLimitContexts": [
            {
                "speedLimit": 30,
                "distance": 966,
                "duration": 138,
                "speedingDistance": 188,
                "speedingDuration": 16,
                "score": 1.09
            },
            {
                "speedLimit": 50,
                "distance": 11115,
                "duration": 1367,
                "speedingDistance": 1112,
                "speedingDuration": 65,
                "score": 3.0
            },
            {
                "speedLimit": 70,
                "distance": 1504,
                "duration": 95,
                "speedingDistance": 0,
                "speedingDuration": 0,
                "score": 10.0
            },
            {
                "speedLimit": 80,
                "distance": 655,
                "duration": 62,
                "speedingDistance": 0,
                "speedingDuration": 0,
                "score": 10.0
            },
            {
                "speedLimit": 90,
                "distance": 1617,
                "duration": 65,
                "speedingDistance": 656,
                "speedingDuration": 24,
                "score": 0.0
            }
        ]
    },
    "energyEstimation":{
    "energy": 0.0,
    "energyConsumption": 0.0,
    "energyOpti": 0.0,
    "energyOptiConsumption": 0.0
  },
  "advancedEnergyEstimation": [
    {
      "contextId": 0,
      "distance": 6.9,
      "duration": 19.1,
      "energy": 0.0,
      "energyConsumption": 0.0,
      "energyOpti": 0.0,
      "energyOptiConsumption": 0.0
    },
    {
      "contextId": 1,
      "distance": 3.7,
      "duration": 6.5,
      "energy": 0.0,
      "energyConsumption": 0.0,
      "energyOpti": 0.0,
      "energyOptiConsumption": 0.0
    },
    {
      "contextId": 2,
      "distance": 64.8,
      "duration": 61.8,
      "energy": 0.0,
      "energyConsumption": 0.0,
      "energyOpti": 0.0,
      "energyOptiConsumption": 0.0
    },
    {
      "contextId": 3,
      "distance": 12.7,
      "duration": 7.8,
      "energy": 0.0,
      "energyConsumption": 0.0,
      "energyOpti": 0.0,
      "energyOptiConsumption": 0.0
    },
    {
      "contextId": 4,
      "distance": 11.8,
      "duration": 4.9,
      "energy": 0.0,
      "energyConsumption": 0.0,
      "energyOpti": 0.0,
      "energyOptiConsumption": 0.0
    }
  ]
  }
```

{% endtab %}

{% tab title="201 " %}

```
```

{% endtab %}
{% endtabs %}

## Request

### Account

| Field     | Type     | Description               |
| --------- | -------- | ------------------------- |
| account   | `string` | API key                   |
| userId    | `string` | User unique identifier    |
| vehicleId | `string` | Vehicle unique identifier |

DriveQuant counts the number of active assets per customer. The DriveQuant API is a pay-per-active-asset API. An asset is considered active if it has performed at least one trip on a monthly basis. An asset can be a driver (identified with its driverId)  or a vehicle (identified by a vehicleId).&#x20;

Three main use cases can be considered:

1. **The request includes only a driverId:** This is common when the data collected comes from a mobile application installed on a driver's phone. The total number of assets per customer is equal to the number of unique driverId's.
2. **The request includes only a vehicleId:** This is common when the data collected comes from a telematics device plugged into the vehicle. The total number of assets per customer is equal to the number of unique vehicleId's.
3. **The request includes a driverId and a vehicleId:** This is common when a group of drivers can use several vehicle within a fleet. The total number of assets may be the number of unique vehicleId's or driverId's. Billing and counting will depend on your business model and the difference between the number of drivers and vehicles. Please [contact DriveQuant](mailto:contact@drivequant.com) sales department to find out the best pricing model.

{% hint style="warning" %}
The Account object must contain the **account** and the **userId** or **vehicleId** attributes.
{% endhint %}

### Route

<table><thead><tr><th width="187.66666666666666">Field</th><th width="178">Type</th><th>Description</th></tr></thead><tbody><tr><td>gpsVelocity</td><td><code>array[double]</code></td><td>GPS speed vector in km/h</td></tr><tr><td>latitude</td><td><code>array[double]</code></td><td>Latitude vector in degree</td></tr><tr><td>longitude</td><td><code>array[double]</code></td><td>Longitude vector in degree</td></tr><tr><td>gpsAccuracy</td><td><code>array[double]</code></td><td>GPS accuracy vector in meter</td></tr><tr><td>gpsElevation</td><td><code>array[double]</code></td><td>Elevation vector in meter</td></tr><tr><td>gpsHeading</td><td><code>array[double]</code></td><td>Heading vector in degree</td></tr><tr><td>gpsDate</td><td><code>array[double]</code></td><td>GPS timestamp vector in second</td></tr><tr><td>vehVelocity</td><td><code>array[double]</code></td><td>Vehicle speed vector in km/h</td></tr><tr><td>vehEngineSpeed</td><td><code>array[double]</code></td><td>Engine speed vector in rotation per minute</td></tr><tr><td>vehTankLevel</td><td><code>array[double]</code></td><td>Fuel tank volume in liter</td></tr><tr><td>vehWheelAngle</td><td><code>array[double]</code></td><td>Steering angle vector in degree</td></tr><tr><td>batteryVoltage</td><td><code>array[double]</code></td><td>Measurement of the car battery voltage vector in volt</td></tr><tr><td>vehDate</td><td><code>array[double]</code></td><td>Vehicle date timestamp vector in second</td></tr></tbody></table>

{% hint style="warning" %}

* A request must contain all the data corresponding to a single trip. The trip data analysis cannot be cut into multiple queries. It is not recommended to merge data from several trips into a single request.
* Route object must contain at least the **vehDate** or **gpsDate** and at least **gpsVelocity** or **vehVelocity** attributes.
* The input variables included into Route object are arrays which must contain the **same number of data points**.
* **The sample period for all input vectors must be 1 second**. The sampling frequency of 1Hz is a standard for GPS sensors. in case your telematics device does not satisfy this constraint, please [contact us](mailto:%20contact@drivequant.com) to determine what alternative can be applied.
  {% endhint %}

### Vehicle

<table><thead><tr><th width="235.66666666666666">Field</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td>carTypeIndex</td><td><code>int</code></td><td><a href="../references#vehicle-body-type">Vehicle body type</a></td></tr><tr><td>carEngineIndex</td><td><code>int</code></td><td><a href="../references#engine-type">Engine type</a></td></tr><tr><td>carPower</td><td><code>double</code></td><td>Vehicle power in hp. This value must be entered in horsepower. In case you only have the engine power in kW you can apply the following formula: <span class="math">P [hp] = P [kW] / 0.7355</span></td></tr><tr><td>carMass</td><td><code>double</code></td><td>Vehicle mass in kg</td></tr><tr><td>carGearboxIndex</td><td><code>int</code></td><td><a href="../references#gearbox-type">Gearbox type</a></td></tr><tr><td>carConsumption</td><td><code>double</code></td><td>Combined fuel consumption [l/100km] measured during the New European Driving Cycle (NEDC)</td></tr><tr><td>carAutoGearboxNumber</td><td><code>int</code></td><td>Number of gear ratios for the automatic gearbox. This parameter is taken into account only if <code>carGearboxIndex</code> is set to 1</td></tr></tbody></table>

Some parameters have a default value if not set, and a min and max limitations:

| Field           | Default value      | Min | Max  |
| --------------- | ------------------ | --- | ---- |
| carTypeIndex    | 1 (compact)        | -   | -    |
| carEngineIndex  | 1 (gasoline)       | -   | -    |
| carPower        | 150                | 40  | 450  |
| carMass         | 1400               | 700 | 3500 |
| carGearboxIndex | 2 (manual 5-speed) | -   | -    |
| carConsumption  | 4.5                | 3   | 20   |

### ItineraryData

Itinerary object is optional.

<table><thead><tr><th width="195">Field</th><th width="137.66666666666666">Type</th><th>Description</th></tr></thead><tbody><tr><td>startDate</td><td><code>date</code></td><td>Trip start date<br><em>Date format: <code>YYYY-MM-dd’T’HH:mm:ss.SSSZ</code></em></td></tr><tr><td>endDate</td><td><code>date</code></td><td>Trip end date<br><em>Date format: <code>YYYY-MM-dd’T’HH:mm:ss.SSSZ</code></em></td></tr><tr><td>departureCity</td><td><code>string</code></td><td>Name of the departure city</td></tr><tr><td>arrivalCity</td><td><code>string</code></td><td>Name of the arrival city</td></tr><tr><td>departureAddress</td><td><code>string</code></td><td>Departure full address</td></tr><tr><td>arrivalAddress</td><td><code>string</code></td><td>Arrival full address</td></tr><tr><td>departureState</td><td><code>string</code></td><td>Name of the departure state</td></tr><tr><td>arrivalState</td><td><code>string</code></td><td>Name of the arrival state</td></tr><tr><td>departurePostalCode</td><td><code>string</code></td><td>Postal code of the departure</td></tr><tr><td>arrivalPostalCode</td><td><code>string</code></td><td>Postal code of the arrival</td></tr><tr><td>departureCountry</td><td><code>string</code></td><td>Name of the departure country</td></tr><tr><td>arrivalCountry</td><td><code>string</code></td><td>Name of the arrival country</td></tr></tbody></table>

### MetaData

Metadata can be used if you want to add some of your specific data in a trip. They can be added to the Trip API as a key/value object where the key and value have a String type

### Example of JSON body request

```javascript
{
	"account": {
		"account": "<API KEY>",
		"userId": "<UNIQUE USER ID>",
		"vehicleId": "<UNIQUE VEHICLE ID>" 
	},
	"vehicle": {
		"carTypeIndex": 4,
		"carEngineIndex": 1,
		"carPower": 205.0,
		"carMass": 1430.0,
		"engineDisplacement": 1618.0,
		"carGearboxIndex": 2,
		"carConsumption": 6.0
	},
	"itineraryData": {
    		"startDate": "2018-02-15T15:20:00.000+0200",
		"endDate": "2018-02-15T15:50:00.000+0200",
		"departureCity": "<DEPARTURE CITY>",
	        "arrivalCity": "<ARRIVAL CITY>",
	        "departureAddress": "<DEPARTURE ADDRESS>",
	        "arrivalAddress": "<ARRIVAL ADDRESS>",
	        "departureState": "<DEPARTURE STATE>",
	        "arrivalState": "<ARRIVAL STATE>",
	        "departurePostalCode": "<DEPARTURE POSTAL CODE>",
	        "arrivalPostalCode": "<ARRIVAL POSTAL CODE>",
	        "departureCountry": "<DEPARTURE COUNTRY>",
	        "arrivalCountry": "<ARRIVAL COUNTRY>"
	},
	"route": {
		"gpsVelocity": [...],
		"latitude": [...],
		"longitude": [...],
		"gpsHeading": [...],
		"gpsElevation": [...],
		"gpsDate": [...],
		"gpsAccuracy": [...]
	},
	"metaData" : {
		"customerStringData" : "<CUSTOMER STRING DATA>",
		"customerJsonData" : "{\"customerTestNumber\" : 1, \"customerTestString\" : \"<CUSTOMER TEXT>\"}"
  }
}
```

## Response

The table below summarizes the list of driving data analysis modules. The comments and itinerary statistics modules are included by default. All other modules are optional and can be combined as needed.

<table><thead><tr><th width="261.66666666666663">Field</th><th width="169">Type</th><th>Description</th></tr></thead><tbody><tr><td>itinId</td><td><code>string</code></td><td>Trip unique identifier</td></tr><tr><td>status</td><td><code>boolean</code></td><td><code>true</code> if no problem, <code>false</code> otherwise</td></tr><tr><td>comments</td><td><code>array[object]</code></td><td>see <a href="#comment">Comment</a></td></tr><tr><td>itineraryStatistics</td><td><code>object</code></td><td><a href="#itinerarystatistics">ItineraryStatistics</a></td></tr><tr><td>itineraryData</td><td><code>object</code></td><td><a href="#itinerarydata">ItineraryData</a></td></tr><tr><td>ecoDriving</td><td><code>object</code></td><td><a href="#eco-driving">EcoDriving</a></td></tr><tr><td>advancedEcoDriving</td><td><code>object</code></td><td><a href="#advanced-eco-driving">AdvancedEcoDriving</a></td></tr><tr><td>fuelEstimation</td><td><code>object</code></td><td><a href="#fuel-estimation">FuelEstimation</a></td></tr><tr><td>advancedFuelEstimation</td><td><code>object</code></td><td><a href="#advanced-fuel-estimation">AdvancedFuelEstimation</a></td></tr><tr><td>safety</td><td><code>object</code></td><td><a href="#safety">Safety</a></td></tr><tr><td>advancedSafety</td><td><code>object</code></td><td><a href="#advanced-safety">AdvancedSafety</a></td></tr><tr><td>safetyEvents</td><td><code>array[object]</code></td><td>see <a href="#safetyevents">SafetyEvent</a></td></tr><tr><td>tireWear</td><td><code>object</code></td><td><a href="#tire-and-brake-wear-estimates">TireWear</a></td></tr><tr><td>brakeWear</td><td><code>object</code></td><td><a href="#tire-and-brake-wear-estimates">BrakeWear</a></td></tr><tr><td>pollutants</td><td><code>object</code></td><td><a href="#pollutants">Pollutants</a></td></tr><tr><td>userId</td><td><code>string</code></td><td>unique id of the user</td></tr><tr><td>firstname</td><td><code>string</code></td><td>first name of the user</td></tr><tr><td>lastname</td><td><code>string</code></td><td>Last name of the user</td></tr><tr><td>endDate</td><td><code>string</code></td><td>End date  of the trip</td></tr><tr><td>driverDistraction</td><td><code>object</code></td><td><a href="#driver-distraction-score">DriverDistraction</a></td></tr><tr><td>distractionEvents</td><td><code>array[object]</code></td><td>see <a href="#driver-distraction-events">DistractionEvents</a></td></tr><tr><td>callEvents</td><td><code>array[object]</code></td><td>see <a href="#call">CallEvent</a></td></tr><tr><td>speedingStatistics</td><td><code>object</code></td><td><a href="https://docs.drivequant.com/trip-analysis/rest-services/trip#speed-limit">Speed Limit</a></td></tr><tr><td>speedingEvents</td><td><code>array[object]</code></td><td>see <a href="https://docs.drivequant.com/trip-analysis/rest-services/trip#speedingevents">SpeedingEvents</a></td></tr><tr><td>energyEstimation</td><td><code>object</code></td><td><a href="#energyestimation">EnergyEstimation</a></td></tr><tr><td>advancedEnergyEstimation</td><td><code>array[object]</code></td><td>see <a href="#advancedenergyestimation">AdvancedEnergyEstimation</a></td></tr></tbody></table>

### Comment

| Field     | Type     | Description       |
| --------- | -------- | ----------------- |
| errorCode | `int`    | Error code        |
| comment   | `string` | Error description |

{% hint style="success" %}
Possible values are described [here](https://docs.drivequant.com/trip-analysis/references#error-codes).
{% endhint %}

### ItineraryStatistics

Itinerary Statistics module provides several indicators that characterize the trip conditions: the trip distance, the vehicle movement duration and the idle duration. We also compute the number of sub-displacements. A trip can be characterized as a succession of events either dictated by the driver’s will or by external factors. These events, called breakpoints, are indicated with black dots in the figure below. Each section of a trip between two breakpoints is called sub-displacement. The figure illustrates these concepts for a short trip with one traffic light (vehicle stopped) and one intersection with priority (vehicle deceleration followed by acceleration).

![](https://lh4.googleusercontent.com/OTBTQqMP7kWCcv8AuyBp5bOdMVXA0PYuHjMWgZnwoKbW6cMptE13H8ck1QkvjJY71um4Mm77d7S9K1jGe6Rfql6ln7cUQe2gpHZusCf1vUhuOpw8PK10xE27XSByAn1X5W5fHJzI)

<table><thead><tr><th width="207">Field</th><th width="113.66666666666666">Type</th><th>Description</th></tr></thead><tbody><tr><td>distance</td><td><code>double</code></td><td>Distance travelled in meter</td></tr><tr><td>speedMean</td><td><code>double</code></td><td>Mean vehicle speed in km/h</td></tr><tr><td>tripDuration</td><td><code>double</code></td><td>Total trip duration in second</td></tr><tr><td>drivingDuration</td><td><code>double</code></td><td>Vehicle movement duration in second</td></tr><tr><td>idlingDuration</td><td><code>double</code></td><td><p>Total duration of idling phases (vehicle stopped)</p><p> in second</p></td></tr><tr><td>drivingPercentage</td><td><code>double</code></td><td>Percentage of vehicle movement</td></tr><tr><td>idlingPercentage</td><td><code>double</code></td><td>Percentage of idling phases</td></tr><tr><td>subdispNb</td><td><code>int</code></td><td>Number of sub-displacements detected during the trip</td></tr><tr><td>meteo</td><td><code>int</code></td><td><a href="../references#weather-code">Weather code</a></td></tr><tr><td>day</td><td><code>boolean</code></td><td><code>true</code> if day, <code>false</code> if night</td></tr><tr><td>weekDay</td><td><code>boolean</code></td><td><code>true</code>: Monday to Friday, <code>false</code>: Saturday to Sunday</td></tr><tr><td>transportationMode</td><td><code>int</code></td><td><a href="../references#transportation-mode">Transportation mode</a></td></tr></tbody></table>

### ItineraryData

<table><thead><tr><th width="195">Field</th><th width="137.66666666666666">Type</th><th>Description</th></tr></thead><tbody><tr><td>startDate</td><td><code>date</code></td><td>Trip start date<br><em>Date format: <code>YYYY-MM-dd’T’HH:mm:ss.SSSZ</code></em></td></tr><tr><td>endDate</td><td><code>date</code></td><td>Trip end date<br><em>Date format: <code>YYYY-MM-dd’T’HH:mm:ss.SSSZ</code></em></td></tr><tr><td>departureCity</td><td><code>string</code></td><td>Name of the departure city</td></tr><tr><td>arrivalCity</td><td><code>string</code></td><td>Name of the arrival city</td></tr><tr><td>departureAddress</td><td><code>string</code></td><td>Departure full address</td></tr><tr><td>arrivalAddress</td><td><code>string</code></td><td>Arrival full address</td></tr><tr><td>departureState</td><td><code>string</code></td><td>Name of the departure state</td></tr><tr><td>arrivalState</td><td><code>string</code></td><td>Name of the arrival state</td></tr><tr><td>departurePostalCode</td><td><code>string</code></td><td>Postal code of the departure</td></tr><tr><td>arrivalPostalCode</td><td><code>string</code></td><td>Postal code of the arrival</td></tr><tr><td>departureCountry</td><td><code>string</code></td><td>Name of the departure country</td></tr><tr><td>arrivalCountry</td><td><code>string</code></td><td>Name of the arrival country</td></tr></tbody></table>

### Eco-driving

#### Description

Eco-driving module performs an analysis of the entire trip, characterized by a succession of events and road segments. The driving efficiency is computed by comparing the vehicle speed recorded with an optimal speed profile, for each segment. This calculation takes into account the actual driving conditions and a physical vehicle model that captures the inertial dynamics of the vehicle and the efficiency of the powertrain components. The eco-driving score ranges from 0 and 10, and is calculated by comparing the actual energy consumed during the trip with the energy that would have been consumed using the optimal speed profile. The best eco-driving score corresponds to the highest driving efficiency.

<table><thead><tr><th width="162.66666666666666">Field</th><th width="137">Type</th><th>Description</th></tr></thead><tbody><tr><td>score</td><td><code>double</code></td><td>Eco-driving score (min: 0, max: 10). If trip is too short to be scored, score is set to 11.</td></tr><tr><td>scoreAccel</td><td><code>double</code></td><td>Score of the acceleration phases. If trip is too short to be scored, score is set to 6.</td></tr><tr><td>scoreMain</td><td><code>double</code></td><td>Score of the stabilized speed phases. If trip is too short to be scored, score is set to 6.</td></tr><tr><td>scoreDecel</td><td><code>double</code></td><td>Score of the deceleration phases. If trip is too short to be scored, score is set to 6.</td></tr><tr><td>stdDevAccel</td><td><code>double</code></td><td>Standard deviation of acceleration score</td></tr><tr><td>stdDevMain</td><td><code>double</code></td><td>Standard deviation of stabilized speed score</td></tr><tr><td>stdDevDecel</td><td><code>double</code></td><td>Standard deviation of deceleration score</td></tr><tr><td>energyClass</td><td><code>int</code></td><td><p>See <a href="#energy-class">Energy Class</a>:</p><p>0: energy class A </p><p>1: energy class B</p><p>2: energy class C</p><p>3: energy class D</p><p>4: energy class E</p></td></tr></tbody></table>

#### Scores definitions

Acceleration, deceleration and speed maintain phases have a large impact on the vehicle’s fuel consumption. As a consequence, by comparing the real and the optimal speed profiles, eco-driving analysis module returns 3 key driving indicators.

The acceleration and deceleration scores range from -5 to +5. For a value of (-5), your acceleration or deceleration is too slow. For the highest value (+5) you are accelerating or decelerating too fast. A score of (0) indicates that your acceleration or deceleration perfectly matches with an eco-driving style.

The speed maintain score ranges from 0 to 5. The minimum value (0) indicates that the driver has an appropriate behavior and drives at a constant speed. On the other hand, if the driving analysis module detects an oscillating speed profile, this score increases. The highest value (+5) indicates that you can improve to keep a constant speed to reduce your fuel consumption.

These indicators will help you improve your driving efficiency and reduce your energy consumption. They can also illustrate the level of anticipation that the drivers should adopt to avoid harsh accelerations and brakings.

The numerical values of driving scores can be transformed into driving tips. The tables below give examples of content that can be returned to a driver based on the driving notes of a trip:

| scoreAccel | Description              |
| ---------- | ------------------------ |
| -5 to -4   | Acceleration is too low  |
| -4 to -2   | Weak acceleration        |
| -2 to 1    | Good acceleration        |
| 1 to 3     | Strong acceleration      |
| 3 to 5     | Acceleration is too high |

| scoreMain  | Description            |
| ---------- | ---------------------- |
| 0 to 1.5   | Good speed maintain    |
| 1.5 to 3.5 | Irregular speed        |
| 3.5 to 5   | Very fluctuating speed |

| scoreDecel | Description              |
| ---------- | ------------------------ |
| -5 to -4   | Deceleration is too low  |
| -4 to -2   | Weak deceleration        |
| -2 to 1    | Good deceleration        |
| 1 to 3     | Strong deceleration      |
| 3 to 5     | Deceleration is too high |

{% hint style="warning" %}
The eco-driving analysis is performed for vehicle displacement greater than 100 meters and speed higher than 10 km/h. This avoids providing inaccurate driving scores during vehicle maneuvers (slow driving in traffic jams or in parking lots...). In that case, eco-driving analysis module returns the following error codes:

* 11 for the eco-driving score
* 6 for acceleration phase, stabilized speed phase and deceleration phase
  {% endhint %}

#### Energy class

The energy class « energyClass » depends on the average fuel consumption of the vehicle. It positions the trip fuel consumption with respect to the average consumption of the vehicle.

* Class A corresponds to 0.5 x the NEDC consumption of the vehicle expressed in $$\mathrm{gCO\_2/km}$$.
* Class E corresponds to 1.5 x the NEDC consumption of the vehicle expressed in $$\mathrm{gCO\_2/km}$$

Then we defined the 5 classes with a uniform distribution between class A and class E. The energy class « energyClass » is calculated from the trip $$\mathrm{CO\_2}$$ emission « co2Emission » and the function below:

![Energy class definition](https://lh3.googleusercontent.com/o7zeQ4fozZs6TYCtPglmJlV-zaQ2cmq_qNLKyJsWbV-MkL-_s6lJj_l1J0evkI1qXekhyWly4xZX6TlofZw_-i8K9PY6aN801sW2v8xhJIH-csAkJJ4n6j9AOn_1V4G3guE-BdI2)

### Advanced eco-driving

<table><thead><tr><th width="193">Field</th><th width="168.66666666666666">Type</th><th>Description</th></tr></thead><tbody><tr><td>ecoDrivingContext</td><td><code>array[object]</code></td><td>Array of <a href="#ecodrivingcontext">EcoDrivingContext</a></td></tr></tbody></table>

In order to provide fair scoring and to facilitate drivers comparison, the trip scores can be accompanied by road class scores. These scores are included in the EcoDrivingContext class into the Advanced Modules. This service differentiates 5 types of road conditions (contextId) to contextualize the driving scores:

* 0 - Traffic jam: This corresponds to vehicle displacements of less than 100 meters and performed with speeds below 10 km/h. In traffic jams, it is obviously not possible to improve your driving, that is why scoring are not provided for this type of road.
* 1 - Heavy urban traffic
* 2 - City
* 3 - Suburban
* 4 - Expressways

{% hint style="warning" %}
In case a road type is not included in the trip, the distance and duration percentages are equal to zero, the efficiency score is set to 11 and the driving scores (Accel/Main/Decel) are set to 6.
{% endhint %}

#### EcoDrivingContext

<table><thead><tr><th width="174">Field</th><th width="121.66666666666666">Type</th><th>Description</th></tr></thead><tbody><tr><td>distance</td><td><code>double</code></td><td>Percentage of distance travelled in a road type</td></tr><tr><td>duration</td><td><code>double</code></td><td>Percentage of elapsed time in a road type</td></tr><tr><td>efficiencyScore</td><td><code>double</code></td><td>Eco-driving score</td></tr><tr><td>scoreAccel</td><td><code>double</code></td><td>Score of the acceleration phases</td></tr><tr><td>scoreMain</td><td><code>double</code></td><td>Score of the stabilized speed phases</td></tr><tr><td>scoreDecel</td><td><code>double</code></td><td>Score of the deceleration phases</td></tr><tr><td>contextId</td><td><code>int</code></td><td><a href="../references#road-conditions">Road conditions</a></td></tr></tbody></table>

### Fuel estimation

#### Description

The fuel consumption is obtained from a backward computation based on a mathematical modeling of the vehicle and powertrain. Fuel consumption estimation asseses the mechanical traction power from the vehicle speed and mass. A power transfer is performed between each component of the powertrain to compute the engine torque. Finally, the engine torque combined with the vehicle speed help to process the fuel mass from an engine consumption map developed by IFPEN. This fuel mapping is adapted according to the vehicle parameters and is valid for any type of vehicle or fleet of vehicles.

This approach is particularly adapted to estimate real-driving fuel consumption which can be more than 20% above the homologation data provided by car manufacturers. The main advantage lies in the accuracy of the estimate that can reach 5% when all input variables are available and the vehicle parameters set. The estimation method accounts for the physical fuel characteristics. These parameters are listed below:

<table><thead><tr><th width="153">Fuel type</th><th width="138">Density (kg/l)</th><th>Lower heating value (GJ/t)</th><th>CO2 emission factor (tCO2/TJ)</th><th>CO2 emission factor (kgCO2/l)</th></tr></thead><tbody><tr><td>Gasoline</td><td>0.755</td><td>44</td><td>70.26</td><td>2.3340</td></tr><tr><td>Diesel</td><td>0.845</td><td>42</td><td>75.70</td><td>2.6866</td></tr></tbody></table>

Values calculated by fuel estimation module are described below:

<table><thead><tr><th width="215">Field</th><th width="114.66666666666666">Type</th><th>Description</th></tr></thead><tbody><tr><td>co2Mass</td><td><code>double</code></td><td>Total Mass of <span class="math">\mathrm{CO_2}</span> in kg</td></tr><tr><td>co2Emission</td><td><code>double</code></td><td>Average Mass of <span class="math">\mathrm{CO_2}</span> per unit of distance in g/km</td></tr><tr><td>fuelConsumption</td><td><code>double</code></td><td>Average fuel consumption per unit of distance in l/100km</td></tr><tr><td>fuelVolume</td><td><code>double</code></td><td>Total fuel consumption in liter</td></tr><tr><td>idleFuelPercentage</td><td><code>double</code></td><td>Idle fuel consumption percentage</td></tr><tr><td>idleFuelConsumption</td><td><code>double</code></td><td>Idle fuel consumption per unit of time in l/h</td></tr><tr><td>idleCo2Emission</td><td><code>double</code></td><td>Idle <span class="math">\mathrm{CO_2}</span> emission in g/km</td></tr><tr><td>idleCo2Mass</td><td><code>double</code></td><td>Idle <span class="math">\mathrm{CO_2}</span> mass in kg</td></tr><tr><td>engineTempStatus</td><td><code>boolean</code></td><td>Engine cold start?</td></tr><tr><td>coldFuelVolume</td><td><code>double</code></td><td>Cold engine fuel volume</td></tr></tbody></table>

### Advanced fuel estimation

<table><thead><tr><th width="216">Field</th><th width="182.66666666666666">Type</th><th>Description</th></tr></thead><tbody><tr><td>fuelEstimationContext</td><td><code>array[object]</code></td><td>Array of <a href="#fuelestimationcontext">FuelEstimationContext</a></td></tr></tbody></table>

In order to provide detailed fuel consumption estimation across the vehicle trips, the advanced fuel estimation service may return the fuel consumption for each driving context of the vehicle. This service differentiates 5 types of road conditions (contextId):&#x20;

* 0 - Traffic jam
* 1 - Heavy urban traffic
* 2 - City
* 3 - Suburban
* 4 - Expressways

{% hint style="warning" %}
In case a road type is not included in the trip, the percentages of distance and duration are equals to zero as well as the co2Mass, co2Emission, fuelVolume and fuelConsumption.
{% endhint %}

#### FuelEstimationContext

<table><thead><tr><th width="182.66666666666666">Field</th><th width="120">Type</th><th>Description</th></tr></thead><tbody><tr><td>contextId</td><td><code>int</code></td><td>Road conditions</td></tr><tr><td>distance</td><td><code>double</code></td><td>Percentage of distance travelled in a road type</td></tr><tr><td>duration</td><td><code>double</code></td><td>Percentage of elapsed time in a road type</td></tr><tr><td>co2Mass</td><td><code>double</code></td><td>Total Mass of  <span class="math">\mathrm{CO_2}</span> in kg</td></tr><tr><td>co2Emission</td><td><code>double</code></td><td>Average <span class="math">\mathrm{CO_2}</span> emissions in g/km</td></tr><tr><td>fuelVolume</td><td><code>double</code></td><td>Total fuel consumption in liter</td></tr><tr><td>fuelConsumption</td><td><code>double</code></td><td>Average fuel consumption in l/100km</td></tr></tbody></table>

### **EnergyEstimation**

For electric vehicles, DriveQuant provides energy information instead of fuel estimation.

<table><thead><tr><th width="242">Field</th><th width="99.66666666666666">Type</th><th>Description</th></tr></thead><tbody><tr><td>energy</td><td><code>double</code></td><td>Estimated energy in kWh</td></tr><tr><td>energyConsumption</td><td><code>double</code></td><td>Estimated energy consumption in kWh/100km</td></tr><tr><td>energyOpti</td><td><code>double</code></td><td>Optimal energy in kWh</td></tr><tr><td>energyOptiConsumption</td><td><code>double</code></td><td>Optimal energy consumption in kWh/100km</td></tr></tbody></table>

{% hint style="info" %}
The **EnergyEstimation** sub-document is only present in the response body for electric vehicles. If the configured vehicle is a conventional vehicle, the energy estimation is not added in the response body.
{% endhint %}

### **AdvancedEnergyEstimation**

To provide more details on the energy consumption, the service may return the energy data for each driving context of the vehicle.

<table><thead><tr><th width="243.66666666666666">Field</th><th width="117">Type</th><th>Description</th></tr></thead><tbody><tr><td>energy</td><td><code>double</code></td><td>Estimated energy in kWh</td></tr><tr><td>energyConsumption</td><td><code>double</code></td><td>Estimated energy consumption in kWh/100km</td></tr><tr><td>energyOpti</td><td><code>double</code></td><td>Optimal energy in kWh</td></tr><tr><td>energyOptiConsumption</td><td><code>double</code></td><td>Optimal energy in kWh/100km</td></tr><tr><td>contextId</td><td><code>int</code></td><td>Road conditions</td></tr><tr><td>distance</td><td><code>double</code></td><td>Percentage of distance travelled in a road type</td></tr><tr><td>duration</td><td><code>double</code></td><td>Percentage of elapsed time in a road type</td></tr></tbody></table>

{% hint style="info" %}
The **AdvancedEnergyEstimation** sub-document is only present in the response body for electric vehicles. If the configured vehicle is a conventional vehicle, the energy estimation is not added in the response body.
{% endhint %}

### Safety

<table><thead><tr><th width="178">Field</th><th width="117.66666666666666">Type</th><th>Description</th></tr></thead><tbody><tr><td>safetyScore</td><td><code>double</code></td><td><p>Driver risk index for a given itinerary</p><p>Ranges from 3 to 10</p></td></tr><tr><td>nbAdh</td><td><code>int</code></td><td>Number of adherence threshold crossing</td></tr><tr><td>nbAccel</td><td><code>int</code></td><td>Number of strong accelerations</td></tr><tr><td>nbDecel</td><td><code>int</code></td><td>Number of strong decelerations</td></tr><tr><td>nbAdhCrit</td><td><code>int</code></td><td>Number of adherence threshold crossing (critical)</td></tr><tr><td>nbAccelCrit</td><td><code>int</code></td><td>Number of critical accelerations (critical)</td></tr><tr><td>nbDecelCrit</td><td><code>int</code></td><td>Number of critical decelerations (critical)</td></tr></tbody></table>

{% hint style="warning" %}
&#x20;If trip is too short to be scored, `safetyScore` is set to 11.
{% endhint %}

### Advanced safety

| Field         | Type            | Description                              |
| ------------- | --------------- | ---------------------------------------- |
| safetyContext | `array[object]` | Array of [SafetyContext](#safetycontext) |

#### SafetyContext

<table><thead><tr><th width="164.66666666666666">Field</th><th width="113">Type</th><th>Percentage of distance travelled in a road type</th></tr></thead><tbody><tr><td>distance</td><td><code>double</code></td><td>Percentage of distance travelled in a road type</td></tr><tr><td>duration</td><td><code>double</code></td><td>Percentage of elapsed time in a road type</td></tr><tr><td>safetyScore</td><td><code>double</code></td><td>Ranges from 3 to 10</td></tr><tr><td>nbAdh</td><td><code>int</code></td><td>Number of adherence threshold crossing</td></tr><tr><td>nbAccel</td><td><code>int</code></td><td>Number of strong accelerations</td></tr><tr><td>nbDecel</td><td><code>int</code></td><td>Number of strong decelerations</td></tr><tr><td>nbAdhCrit</td><td><code>int</code></td><td>Number of adherence threshold crossing (critical)</td></tr><tr><td>nbAccelCrit</td><td><code>int</code></td><td>Number of critical accelerations (critical)</td></tr><tr><td>nbDecelCrit</td><td><code>int</code></td><td>Number of critical decelerations (critical)</td></tr><tr><td>contextId</td><td><code>int</code></td><td>Road conditions</td></tr></tbody></table>

{% hint style="warning" %}
In case a road type is no included in the trip, the distance and duration percentages are equal to zero and the safety score is set to 11.
{% endhint %}

### SafetyEvents

The data provided in the following table helps to display safety events on your map system and deliver the locations of harsh braking or acceleration as well as the coordinates where a tire to road adherence threshold has been crossed.

<table><thead><tr><th width="136.66666666666666">Field</th><th width="116">Type</th><th>Description</th></tr></thead><tbody><tr><td>time</td><td><code>double</code></td><td>Time since the beginning of the trip in second</td></tr><tr><td>latitude</td><td><code>double</code></td><td>Latitude in degree</td></tr><tr><td>longitude</td><td><code>double</code></td><td>Longitude in degree</td></tr><tr><td>velocity</td><td><code>double</code></td><td>Vehicle speed in km/h</td></tr><tr><td>heading</td><td><code>double</code></td><td>Vehicle heading in degree</td></tr><tr><td>elevation</td><td><code>double</code></td><td>Altitude in meter</td></tr><tr><td>distance</td><td><code>double</code></td><td>Distance travelled since the beginning of the trip in meter</td></tr><tr><td>type</td><td><code>int</code></td><td>Type of event<br>    1. Adherence<br>    2. Acceleration<br>    3. Braking</td></tr><tr><td>level</td><td><code>int</code></td><td>Intensity related to the event<br>    1. Strong<br>    2. Harsh</td></tr><tr><td>value</td><td><code>int</code></td><td><p>Absolute value of the event:</p><ul><li>in m/s2 for acceleration and braking events</li><li>normalized between 0 and 1 for the adherence events</li></ul></td></tr></tbody></table>

The service provides the time, coordinate and severity level of each event. Two levels of severity are calculated using specific threshold values for each event.

<table><thead><tr><th>Type of event</th><th width="98">Unit</th><th width="101">Strong</th><th>Harsh</th></tr></thead><tbody><tr><td>Acceleration </td><td>m/s2</td><td>2.0</td><td>2.5</td></tr><tr><td>Braking</td><td>m/s2</td><td>-1.8</td><td>-2.4</td></tr><tr><td>Adherence limit</td><td>-</td><td>0.2</td><td>0.3</td></tr></tbody></table>

### Pollutants

<table><thead><tr><th width="106.66666666666666">Field</th><th width="117">Type</th><th>Description</th></tr></thead><tbody><tr><td>co</td><td><code>double</code></td><td>Carbon monoxide (CO) emissions expressed in mg/km</td></tr><tr><td>hc</td><td><code>double</code></td><td>Hydrocarbons (HC) emissions expressed in mg/km</td></tr><tr><td>nox</td><td><code>double</code></td><td>Nitrogen oxide emissions (NOx) expressed in mg/km</td></tr><tr><td>soot</td><td><code>double</code></td><td>Soot emissions expressed in mg/km</td></tr></tbody></table>

### Tire and brake wear estimates

#### Description

The wear analysis service has been designed to monitor the brake pads and tires wear levels. This service was designed to improve vehicle maintenance solutions and can be used to create maintenance alerts.

The wear estimation relates to the power dissipated in the tire - road or brake disc - brake contact. To compute this variable our service relies on the vehicle’s dynamic modelling that estimates the braking efforts and the efforts at the contact between the tire and the road.&#x20;

For each trip, the service gives for each components (front/rear brakes/tires):

* The worn mass fraction during the trip.
* The total worn percentage since the installation of new tires or brakes.

**Tire and brake wear indicators for a single trip**

The wear analysis service measures tire wear and brake pad wear. The service allows to distinguish the front and rear axles of the vehicle. The wear is assumed to be the same for the right tire and the left tire of the vehicle. A similar assumption is made for the brake pads.

The output value corresponds to a mass fraction of the worn component (tire or brake pad). This value is expressed in thousandth part of parts-per-million (ppm) which is a unit equivalent to a parts-per-billion (ppb).&#x20;

The worn mass fraction (tire or brake pad) is given for each individual trip. To obtain the total worn mass fraction, the sum of all the trip’s values must be done. The total worn mass fraction value is bounded between a minimum and a maximum value:&#x20;

* Minimum value = 0 ppb. If the total worn mass fraction is 0, the component (tire or brake pad) is assumed to have no wear.
* Maximum value = $$10^9$$ppb. If the total worn mass fraction reaches the maximum value, this means that the component (tire or brake pad) is fully worn and must be replaced.

For a tire, the maximum value for the mass fraction ($$10^9$$ppb) indicates that the tire has lost all its usable mass of rubber. This corresponds to a minimum tire tread height of 1.6 mm. *In France, a tire must legally have a minimum tread height of 1.6 mm over its entire circumference.*

The wear calculation service estimates for each trip:

* The worn fraction of front tires
* The worn fraction of the rear tire
* The worn fraction of the front brakes
* The worn fraction of the rear brakes.

Example of tire autonomy calculation:&#x20;

Assuming a vehicle that has performed $$N$$ trips, the tire autonomy ( $$d\_a$$ ) in km can be computed as follow:

$$d\_a=f(w)\times\sum\_{k=1}^Nd\_i$$ with $$f(w)=\frac{1}{10^9\times\sum\_{k=1}^Nw\_i}-1$$&#x20;

where ω is the tire worn mass fraction for the trip i (in ppb) and di is the distance (in km) of the trip i. The wear function f(ω) is a decreasing function that goes from infinity to zero. When f(ω) equals zero, the tire has no longer autonomy and must be replaced. This function is displayed below:

![](https://lh5.googleusercontent.com/zEF2xgPIxXRY9o34GjFjsHqdYeRMw47MlYGe-El9YmDiOnF-z8-TMgdU2q_OVwNKSA9hBlbodW5Mo3pI2TBQyUiU6ow5AlK98XR-NpGDPJcUjR6s43Nki0KR7QyrPbsFHUZ0X-R5)

**Total tire and brake wear indicators**

In order to facilitate the integration within a vehicle maintenance service, the DriveQuant API provides for all your requests the following set of data related to any component (tires or brakes):

* The total distance traveled with a given component (Distance)
* The level of wear of the considered component (TotalWear)
* The remaining autonomy before a complete wear (Autonomy)
* The average wear speed of the considered component (WearRate)
* The total autonomy of the considered component is assumed to be equal to the total travelled distance plus the remaining autonomy (Distance + Autonomy).

The diagram below illustrates the principle and the meaning of these quantities. The figure shows the evolution of the wear as a function of the distance traveled with the component. This is a generic representation that applies to a brake pad or a tire.

![](https://lh5.googleusercontent.com/KrfZ8VA8u4gGW4PKsWnW8qQ6PSv_VzpCGIXHMdKU8W-kcr_0-vRoSjG1R9IoYaDKm2oC9mptpFvRKASmGvId5GEjWqjiXyaJVPrkLdRFKvdthTIhbXreWgDL9qDSIPkz01kMJKaW)

The autonomy of a set of tires or brakes is calculated for each axle (front and rear). For example, the most worn tire between the left tire and the right tire on the same axle is used.

<table><thead><tr><th width="210.66666666666666">Field</th><th width="110">Type</th><th>Description</th></tr></thead><tbody><tr><td>frontTireWear</td><td><code>int</code></td><td><p>Worn mass fraction of the front tires (right/ left) for current trip</p><p>Unit : thousandths part of ppm = ppb</p><p>Min. value = 0 / Max. value = <span class="math">10^9</span> </p></td></tr><tr><td>rearTireWear</td><td><code>int</code></td><td><p>Worn mass fraction of the rear tires (right/left) for current trip</p><p>Unit : thousandths part of ppm = ppb</p><p>Min. value = 0 / Max. value = <span class="math">10^9</span></p></td></tr><tr><td>frontBrakePadWear</td><td><code>int</code></td><td><p>Worn mass fraction of the front brakes (right/left) for current trip</p><p>Unit : thousandths part of ppm = ppb</p><p>Min. value = 0 / Max. value = <span class="math">10^9</span> </p></td></tr><tr><td>rearBrakePadWear</td><td><code>int</code></td><td><p>Worn mass fraction of the rear brakes (right/left) for current trip</p><p>Unit : thousandths part of ppm = ppb</p><p>Min. value = 0 / Max. value = <span class="math">10^9</span> </p></td></tr><tr><td>frontTireDistance</td><td><code>int</code></td><td><p>Total distance analyzed for the front tires (in km)</p><p>Min. value = 0 / Max. value = 1 000 000</p></td></tr><tr><td>rearTireDistance</td><td><code>int</code></td><td><p>Total distance analyzed for the rear tires (in km)</p><p>Min. value = 0 / Max. value = 1 000 000</p></td></tr><tr><td>frontBrakeDistance</td><td><code>int</code></td><td><p>Total distance analyzed for the front brakes (in km)</p><p>Min. value = 0 / Max. value = 1 000 000</p></td></tr><tr><td>rearBrakeDistance</td><td><code>int</code></td><td><p>Total distance analyzed for the rear brakes (in km)</p><p>Min. value = 0 / Max. value = 1 000 000</p></td></tr><tr><td>frontTireAutonomy</td><td><code>int</code></td><td><p>Front tires remaining distance before change (in km)</p><p>Min. value = 0 / Max. value = 1 000 000</p></td></tr><tr><td>rearTireAutonomy</td><td><code>int</code></td><td><p>Rear tires remaining distance before change (in km)</p><p>Min. value = 0 / Max. value = 1 000 000</p></td></tr><tr><td>frontBrakeAutonomy</td><td><code>int</code></td><td><p>Front brakes remaining distance before change (in km)</p><p>Min. value = 0 / Max. value = 1 000 000</p></td></tr><tr><td>rearBrakeAutonomy</td><td><code>int</code></td><td><p>Rear brakes remaining distance before change (in km)</p><p>Min. value = 0 / Max. value = 1 000 000</p></td></tr><tr><td>frontTireTotalWear</td><td><code>double</code></td><td><p>Total worn mass percentage of the front tires (right/left) </p><p>Min. value = 0% / Max. value = 100%</p></td></tr><tr><td>rearTireTotalWear</td><td><code>double</code></td><td><p>Total worn mass percentage of the rear tires (right/left) </p><p>Min. value = 0% / Max. value = 100%</p></td></tr><tr><td>frontBrakeTotalWear</td><td><code>double</code></td><td><p>Total worn mass percentage of the front brakes (right/left) </p><p>Min. value = 0% / Max. value = 100%</p></td></tr><tr><td>rearBrakeTotalWear</td><td><code>double</code></td><td><p>Total worn mass percentage of the rear brakes (right/left) </p><p>Min. value = 0% / Max. value = 100%</p></td></tr><tr><td>frontTireWearRate</td><td><code>double</code></td><td>Average wear rate for the front tires (in %/1000 km )</td></tr><tr><td>rearTireWearRate</td><td><code>double</code></td><td>Average wear rate for the rear tires (in %/1000 km )</td></tr><tr><td>frontBrakeWearRate</td><td><code>double</code></td><td>Average wear rate for the rear brakes (in %/1000 km )</td></tr><tr><td>rearBrakeWearRate</td><td><code>double</code></td><td>Average wear rate for the rear brakes (in %/1000 km )</td></tr></tbody></table>

The wear rate measures the component wear (in %) as a function of distance. This variable allows to compare vehicles and to inform a vehicle fleet manager whose components are wearing out too quickly. The wear rate is related to the type of vehicle, the driving style, the type of road used and the driving condition. This is why its value can change if the typology of trips changes and if the vehicle is driven by several drivers who have different driving styles.

### Driver distraction (score)

Distracted driving becomes a serious problem and is becoming a major road safety issue.

That's why we've developed a service that measures the driver's interactions with his smartphone while driving. The objective is to increase driver awareness through a distraction score. This can be used to compare drivers, to classify them or to organize driving challenges.

The DriveKit SDK is capable of measuring the two main indicators of distracted driving:&#x20;

1. screen unlocks,
2. and outgoing or incoming (and answered) phone calls.

The distraction score depends on 2 parameters :

* the smartphone unlocking frequency;
* the total duration of the call (or calls if there are several in the same trip).

Each parameter is giving a sub-score from 0 to 10. The distraction score is the minimum between these two sub-scores.

The sensitivity function linking the number of unlocks per 100 km to the unlock score is shown below.

<figure><img src="https://2525923625-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LXYIG5U3AO65YYFWJRK%2Fuploads%2FPdulaKNvh7oUmYk3Ywtp%2FUnlock_score_log.png?alt=media&#x26;token=536870b1-f241-4afc-8283-6a1a9dea155a" alt="" width="563"><figcaption></figcaption></figure>

The sensitivity function linking the call duration to the call score is shown below.

![](https://2525923625-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LXYIG5U3AO65YYFWJRK%2Fuploads%2Fmzc5KlowBzIBfW2diZzG%2FForbidden_call_score_log.png?alt=media\&token=5affb574-31a3-4d48-b25c-decb60d2d9d3)

{% hint style="info" %}
This service is only available with the DriveKit mobile SDK.
{% endhint %}

The response body includes the trip scores as well as detailed data related to unlocks and calls. This way you can better understand the score construction and provide clear explanations to the driver.

The data returned by the service are listed in the table below:

<table><thead><tr><th width="155.66666666666666">Field</th><th width="170">Type</th><th>Description</th></tr></thead><tbody><tr><td>nbUnlock</td><td><code>int</code></td><td>Number of phone screen unlock events</td></tr><tr><td>nbLock</td><td><code>int</code></td><td>Number of phone screen lock events</td></tr><tr><td>distance</td><td><code>double</code> </td><td>Relative distance traveled with the screen on (in %)</td></tr><tr><td>distanceM</td><td><code>double</code></td><td>Distance traveled with the screen on (in m)</td></tr><tr><td>duration</td><td><code>double</code></td><td>Relative duration traveled with the screen on (in %)</td></tr><tr><td>durationS</td><td><code>double</code></td><td>Duration traveled with the screen on (in s)</td></tr><tr><td>score</td><td><code>double</code></td><td>Phone distraction score (Min. value = 0, Max. value = 10)</td></tr><tr><td>scoreUnlock</td><td><code>double</code></td><td>Distraction sub-score which takes into account the number of locking/unlocking</td></tr><tr><td>scoreCall</td><td><code>double</code></td><td>Distraction sub-score which takes into account the number of calls during the trip</td></tr><tr><td>calls</td><td><code>array[object]</code></td><td><a href="#call">Call</a></td></tr></tbody></table>

#### Call

The Driver distraction score provides an array with all the calls answered or made by the driver. For each call, it contains information about its conditions.

<table><thead><tr><th width="155.66666666666666">Value</th><th width="124">Type</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td><code>int</code></td><td>Unique identifier of the call</td></tr><tr><td>start</td><td><code>double</code></td><td>Seconds from beginning of the trip when call starts</td></tr><tr><td>end</td><td><code>double</code></td><td>Seconds from beginning of the trip when call ends</td></tr><tr><td>durationS</td><td><code>double</code></td><td>Duration traveled in call (in s)</td></tr><tr><td>duration</td><td><code>double</code></td><td>Relative duration traveled in call (in %)</td></tr><tr><td>distanceM</td><td><code>double</code></td><td>Distance traveled in call (in m)</td></tr><tr><td>distance</td><td><code>double</code></td><td>Relative distance traveled in call (in %)</td></tr><tr><td>status</td><td><code>string</code></td><td><p>INCOMING : incoming call</p><p>OUTGOING : outgoing call</p><p>UNKNOWN : unknown call status</p></td></tr><tr><td>audioSystem</td><td><code>string</code></td><td>Audio system used to make the call (SPEAKER, LOUDSPEAKER, A2DP, HANDSFREE, HEADPHONE, CAR_AUDIO, UNKNOWN)</td></tr><tr><td>forbidden</td><td><code>boolean</code></td><td><p><code>true</code> if the call is forbidden</p><p><code>false</code> if the call is authorized (made with handsfree)</p></td></tr></tbody></table>

#### Response body example

<pre class="language-javascript"><code class="lang-javascript">"driverDistraction": {
    "nbUnlock": 0,
    "durationUnlock": 13,
    "durationPercentUnlock": 2.5,
    "distanceUnlock": 33.54196351499925,
    "distancePercentUnlock": 0.4636710466546759,
    "score": 10,
    "scoreUnlock": 10,
    "scoreCall": 10,
    "calls": [
      {
        "id": 0,
        "start": 85,
        "end": 118,
        "durationS": 33,
        "duration": 6,
        "distanceM": 734,
        "distance": 10,
        "status": "INCOMING",
        "audioSystem": "HANDSFREE",
        "forbidden": false
<strong>      },
</strong>      {
        "id": 1,
        "start": 320,
        "end": 344,
        "durationS": 24,
        "duration": 5,
        "distanceM": 295,
        "distance": 4,
        "status": "UNKNOWN",
        "audioSystem": "HANDSFREE",
        "forbidden": false
      }
    ]
  }
</code></pre>

#### &#x20;Example of use

The screenshot below shows how to display the phone use data on a mobile phone interface:

![](https://2525923625-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LXYIG5U3AO65YYFWJRK%2F-MUy-CDU7JHoSFefbjUY%2F-MUy-uxsjd1WZNEBtsqR%2Fdriver-data-distraction.png?alt=media\&token=9139e114-31e1-462e-91b1-0ce167a88886)

### Driver distraction (events)

The distraction score service provides additional information related to screen unlock and screen lock events. Thus, it is possible to get the location of events related to phone use. These informations are useful if you need to display these data on your mapping system or if you want to perform advanced data analysis.

The table below lists all the data returned by the service:

<table><thead><tr><th width="140.66666666666666">Field</th><th width="116">Type</th><th>Description</th></tr></thead><tbody><tr><td>time</td><td><code>double</code></td><td>Time since the beginning of the trip (in s)</td></tr><tr><td>latitude</td><td><code>double</code></td><td>Latitude (in deg)</td></tr><tr><td>longitude</td><td><code>double</code></td><td>Longitude (in deg)</td></tr><tr><td>velocity</td><td><code>double</code></td><td>Vehicle speed (in km/h)</td></tr><tr><td>heading</td><td><code>double</code></td><td>Vehicle heading (in deg)</td></tr><tr><td>elevation</td><td><code>double</code></td><td>Altitude (in m)</td></tr><tr><td>distance</td><td><code>double</code></td><td>Distance travelled since the beginning of the trip (in m)</td></tr><tr><td>type</td><td><code>int</code></td><td>Type of event : (1) Screen ON and (2) Screen OFF</td></tr></tbody></table>

#### Response body example

```javascript
"distractionEvents": [
        {
            "time": 248.0,
            "latitude": 48.92460229,
            "longitude": 2.38685389,
            "velocity": 0.0,
            "heading": 0.6352998743575466,
            "elevation": 79.0,
            "distance": 3157.72999073565,
            "type": 1
        },
        {
            "time": 273.0,
            "latitude": 48.92434025,
            "longitude": 2.3891527,
            "velocity": 46.5839984893799,
            "heading": 0.006233303539059223,
            "elevation": 78.85714285714286,
            "distance": 3267.4199903160334,
            "type": 2
        }
    ]
```

### CallEvents

Thanks to the distracted driving analysis service, you will be able to obtain contextualized and geolocalized data related to the detected events. This information is of great importance for the evaluation of the road risk and to help the driver to improve (by presenting this information on a map for example).

<table><thead><tr><th width="149.66666666666666">Value</th><th width="112">Type</th><th>Description</th></tr></thead><tbody><tr><td>time</td><td><code>double</code></td><td>Time in second since the beginning of the trip</td></tr><tr><td>latitude</td><td><code>double</code></td><td>Latitude in degree</td></tr><tr><td>longitude</td><td><code>double</code></td><td>Longitude  in degree</td></tr><tr><td>velocity</td><td><code>double</code></td><td>Vehicle speed in km/h</td></tr><tr><td>heading</td><td><code>double</code></td><td>Vehicle heading in degree</td></tr><tr><td>elevation</td><td><code>double</code></td><td>Altitude in meter</td></tr><tr><td>distance</td><td><code>double</code></td><td>Distance travelled during the call in meter</td></tr><tr><td>type</td><td><code>int</code></td><td><p>3: Call start</p><p>4: Call end</p></td></tr><tr><td>duration</td><td><code>int</code></td><td>Call duration in seconds</td></tr><tr><td>index</td><td><code>int</code></td><td>Position of the beginning of the event  in the route date (phone call beginning of phone unlocking)</td></tr><tr><td>audioSystem</td><td><code>string</code></td><td>Audio system used to make the call (<code>SPEAKER</code>, <code>LOUDSPEAKER</code>, <code>A2DP</code>, <code>HANDSFREE</code>, <code>HEADPHONE</code>, <code>CAR_AUDIO</code>, <code>UNKNOWN</code>)</td></tr><tr><td>callType </td><td><code>string</code></td><td><p>Call type</p><p>Allowed values: <code>INCOMING</code>, <code>OUTGOING</code>, <code>UNKNOWN</code></p></td></tr><tr><td>forbidden</td><td><code>boolean</code></td><td><p><code>true</code> if the call is forbidden</p><p><code>false</code> if the call  is authorized (made with handsfree)</p></td></tr></tbody></table>

#### Response body example

```javascript
"callEvents": [
   {
     "time": 85,
     "latitude": 46.90593,
     "longitude": -0.23254,
     "velocity": 77.03999862670898,
     "heading": -4.978726223953685,
     "elevation": 142.34007335844495,
     "distance": 0,
     "type": 3,
     "duration": 1,
     "index": 85,
     "audioSystem": "HANDSFREE",
     "callType": "INCOMING",
     "forbidden": false
   }, {
     "time": 118,
     "latitude": 46.91235,
     "longitude": -0.23023,
     "velocity": 85.60800247192383,
     "heading": -4.889215763272453,
     "elevation": 145.41845121837798,
     "distance": 734,
     "type": 4,
     "duration": 33,
     "index": 118,
     "audioSystem": "HANDSFREE",
     "callType": "INCOMING",
     "forbidden": false
   }, {
     "time": 320,
     "latitude": 46.90536,
     "longitude": -0.22448,
     "velocity": 45.93600082397461,
     "heading": -9.696301173649006,
     "elevation": 147.3037109375,
     "distance": 0,
     "type": 3,
     "duration": 1,
     "index": 320,
     "audioSystem": "HANDSFREE",
     "callType": "UNKNOWN",
     "forbidden": false
   },{
     "time": 344,
     "latitude": 46.90387,
     "longitude": -0.22633,
     "velocity": 34.23600082397461,
     "heading": -7.896966651865014,
     "elevation": 142.9379156203497,
     "distance": 295,
     "type": 4,
     "duration": 24,
     "index": 344,
     "audioSystem": "HANDSFREE",
     "callType": "UNKNOWN",
     "forbidden": false
   }
 ]
```

### Speed Limit

This service measures distance and driving time when the vehicle speed exceeds the speed limit.

From this information, a speed limit score is calculated. The speed limit score is 10 if the overspeed distance is zero. The speed limit score decreases with the increase in the percentage of distance spent in overspeeding.

The sensitivity function linking the relative speeding distance (in %) with the speeding score is shown below.

<figure><img src="https://2525923625-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LXYIG5U3AO65YYFWJRK%2Fuploads%2Fj8T1DV0CRcHhi46a8rTS%2Fspeeding_score_log_en.png?alt=media&#x26;token=956b102f-3035-45ee-9b65-55ad849ecb38" alt="" width="563"><figcaption><p>Log scale sensitivity function for speeding score</p></figcaption></figure>

<figure><img src="https://2525923625-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LXYIG5U3AO65YYFWJRK%2Fuploads%2FdnKxH0c3iHvInU4O17NP%2Fspeeding_score_dec.png?alt=media&#x26;token=2cc39e7f-ad26-44cf-8b4f-57211534919f" alt="" width="563"><figcaption><p>Speed score sensitivity function in decimal scale</p></figcaption></figure>

This service returns a global (or trip) score for the entire trip as well as several sub-scores corresponding to each of the legal speed portions traveled during the trip.&#x20;

The global (or trip) score is the average of the sub-scores weighted by distance.

<table><thead><tr><th width="200.66666666666666">Field</th><th width="168">Type</th><th>Description</th></tr></thead><tbody><tr><td>distance</td><td><code>int</code></td><td>trip distance (m)</td></tr><tr><td>duration</td><td><code>int</code></td><td>trip duration (s)</td></tr><tr><td>speedingDistance</td><td><code>int</code></td><td>Distance travelled at a speed above the limit (m)</td></tr><tr><td>speedingDuration</td><td><code>int</code></td><td>Duration spent at a speed above the limit (s)</td></tr><tr><td>score</td><td><code>double</code></td><td>Speeding score</td></tr><tr><td>speedLimitContexts</td><td><code>array[object]</code></td><td>Array of <a href="#speedlimitcontexts">SpeedLimitContexts</a></td></tr></tbody></table>

#### SpeedLimitContexts

<table><thead><tr><th width="195">Field</th><th width="106.66666666666666">Type</th><th>Description</th></tr></thead><tbody><tr><td>speedLimit</td><td><code>int</code></td><td>Speed limit (in km/h) for the portion of the trip</td></tr><tr><td>distance</td><td><code>int</code></td><td>Total distance (in m) for the portion of the trip limited at the speed limit value</td></tr><tr><td>duration</td><td><code>int</code></td><td>Total duration (in s) for the portion of the trip limited at the speed limit value</td></tr><tr><td>speedingDistance</td><td><code>int</code></td><td>Distance travelled at a speed above the limit (in m) within the speed limit portion</td></tr><tr><td>speedingDuration</td><td><code>int</code></td><td>Duration spent at a speed above the limit (in s) within the speed limit portion</td></tr><tr><td>score</td><td><code>double</code></td><td>Speeding score for a given speed limit portion </td></tr></tbody></table>

#### Response body example

```javascript
{
"speedingStatistics" : {
            "distance" : 6835,
            "duration" : 613,
            "speedingDistance" : 280,
            "speedingDuration" : 14,
            "score" : 9.55,
            "speedLimitContexts" : [ 
                {
                    "speedLimit" : 30,
                    "distance" : 21,
                    "duration" : 6,
                    "speedingDistance" : 0,
                    "speedingDuration" : 0,
                    "score" : 10.0
                }, 
                {
                    "speedLimit" : 50,
                    "distance" : 2378,
                    "duration" : 352,
                    "speedingDistance" : 169,
                    "speedingDuration" : 9,
                    "score" : 8.83
                }, 
                {
                    "speedLimit" : 70,
                    "distance" : 2153,
                    "duration" : 122,
                    "speedingDistance" : 111,
                    "speedingDuration" : 5,
                    "score" : 9.38
                }, 
                {
                    "speedLimit" : 90,
                    "distance" : 2283,
                    "duration" : 133,
                    "speedingDistance" : 0,
                    "speedingDuration" : 0,
                    "score" : 10.0
                }
            ]
        }
    }
}
```

### **SpeedingEvents**

The service that computes the speeding score also returns location-based information about overspeeding events.

This type of information is used to indicate on a map the places on the trip where the speed of the vehicle exceeds the speed limit.&#x20;

The start and end positions of overspeeding segments are included in the SpeedingEvents table.

<table><thead><tr><th width="132.66666666666666">Value</th><th width="116">Type</th><th>Description</th></tr></thead><tbody><tr><td>time</td><td><code>double</code></td><td>Time in second since the beginning of the trip</td></tr><tr><td>latitude</td><td><code>double</code></td><td>Latitude in degree</td></tr><tr><td>longitude</td><td><code>double</code></td><td>Longitude in degree</td></tr><tr><td>type</td><td><code>int</code></td><td><p>1 = Overspeeding segment start point</p><p>0 = Overspeeding segment endpoint</p></td></tr><tr><td>index</td><td><code>int</code></td><td>Index of the speeding event in the matched route vector.</td></tr></tbody></table>

**Response body example**

```javascript
"speedingEvents": [
    {
      "longitude": 2.240690719770278,
      "latitude": 48.87119316290749,
      "time": 96,
      "type": 1,
      "index": 36
    },
    {
      "longitude": 2.2389993413999454,
      "latitude": 48.87022711541927,
      "time": 106,
      "type": 0,
      "index": 39
    }
]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.drivequant.com/trip-analysis/rest-services/trip.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
