Safety Events

List Safety Events

Endpoint:

GET /safety-events

Description:

Retrieve all safety events recorded by the system, such as harsh braking, speeding, or near collisions, within a specified date range. Use optional filters to narrow results by vehicle, driver, or event type. Enhanced filtering and sorting are available through additional query parameters.

Query Parameters:

ParameterTypeDescription
fromdate-timeStart date for fetching events. Example: 2024-10-01T00:00:00Z.
todate-timeEnd date for fetching events. Example: 2024-10-12T23:59:59Z.
vehicleIdsArray(string)(Optional) Filter events by specific vehicle IDs.
driverIdsArray(string)(Optional) Filter events by specific driver IDs.
eventTypeString(Optional) Filter events by specific safety event types (e.g., "Near Collision").
minIntensityinteger(Optional) Minimum intensity for filtering events.
minRiskScoreinteger(Optional) Minimum risk score for filtering events.
limitinteger(Optional) Number of results to return per page. Defaults to 50.
cursorstring(Optional) Pagination cursor for retrieving the next page of results.

Headers:

HeaderTypeDescription
x-api-keystringRequired for API authentication.
Connection-IdUUIDIdentifies the specific connection.

Example Request (cURL):

bash
Copy code
curl --request GET \
  --url "https://api.analytics.autos/safety-events?from=2024-10-01T00:00:00Z&to=2024-10-12T23:59:59Z&minRiskScore=70&eventTypes=speeding" \
  --header 'x-api-key: YOUR-API-KEY' \
  --header 'Connection-Id: YOUR-CONNECTION-ID'

Response:

json
Copy code
{
  "status": 200,
  "message": "Success",
  "data": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "rawIncidentId": "raw_incident_1",
      "connectionId": "123e4567-e89b-12d3-a456-426614174000",
      "startedAt": "2024-10-13T16:12:52.505Z",
      "endedAt": "2024-10-13T16:12:52.505Z",
      "startLatitude": 34.052235,
      "startLongitude": -118.243683,
      "endLatitude": 34.052245,
      "endLongitude": -118.243695,
      "type": "Harsh Braking",
      "durationSeconds": 1,
      "acceleration": 5.2,
      "maxSpeed": 80,
      "minSpeed": 30
    }
  ],
  "next": "eyJvZmZzZXQiOjEwMH0"
}

Response Fields Explained:

FieldTypeDescription
idstringUnique ID of the safety event.
rawIncidentIdstringIdentifier from the original data source.
connectionIdstringLinks the event to the specific connection.
startedAtdate-timeStart timestamp of the event.
endedAtdate-timeEnd timestamp of the event.
startLatitudenumberLatitude of the event’s starting location.
startLongitudenumberLongitude of the event’s starting location.
endLatitudenumberLatitude of the event’s ending location.
endLongitudenumberLongitude of the event’s ending location.
typestringType of safety event (e.g., "Harsh Braking").
durationSecondsintegerDuration of the event in seconds.
accelerationnumberAcceleration during the event (m/s²).
maxSpeednumberMaximum speed during the event.
minSpeednumberMinimum speed during the event.
nextstringPagination cursor for retrieving the next page of results. If absent, no additional pages are available.

List Safety Event Types

Endpoint:

GET /safety-events/types

Description:

Retrieve a list of all possible safety event types. This endpoint provides details about supported event types (e.g., "Near Collision") to help categorize and analyze incidents.

Headers:

HeaderTypeDescription
x-api-keystringRequired for API authentication.
Connection-IdUUIDIdentifies the specific connection.

Example Request (cURL):

bash
Copy code
curl --request GET \
  --url https://api.analytics.autos/safety-events/types \
  --header 'x-api-key: YOUR-API-KEY' \
  --header 'Connection-Id: YOUR-CONNECTION-ID'

Response:

json
Copy code
[
  {
    "type": "Harsh Braking",
    "logo": "https://example.com/logo.png",
    "isExtended": true},
  {
    "type": "Near Collision",
    "logo": "https://example.com/logo.png",
    "isExtended": false}
]

Response Fields Explained:

FieldTypeDescription
typestringName of the safety event type.
logostringURL of the logo representing the event type.
isExtendedbooleanIndicates if the event type includes extended metadata.

Supported Safety Event Types

The following safety event types may be returned by the Safety Events API.

Event TypeDescription
Harsh BrakingA sudden or aggressive braking event.
Hard AccelerationA sudden or aggressive acceleration event.
Harsh CorneringA sharp or aggressive turning/cornering event.
Harsh MotionA sudden vehicle movement or jolt that may indicate unsafe driving behavior.
SpeedingVehicle speed exceeded the applicable speed threshold or speed limit.
TailgatingVehicle followed another vehicle too closely.
Lane DepartureVehicle drifted or moved out of its lane unexpectedly.
Near CollisionA near-miss or close-proximity event with another object, vehicle, or road user.
AccidentA detected collision or crash-related event.
Distracted DrivingDriver appears distracted or not focused on the road.
No SeatbeltDriver is not wearing a seatbelt while the vehicle is in motion.
Partial SeatbeltDriver appears to be wearing the seatbelt incorrectly or only partially.
Camera ObstructionCamera view is physically blocked or obstructed.
Camera MisalignmentCamera angle or position is incorrect and does not show the expected view.
Driver MissingInterior camera does not show the driver when the driver is expected to be visible.
TamperingCamera or device appears to have been intentionally blocked, moved, covered, or interfered with.

To retrieve the event types available for a specific connection, use:

curl --request GET \
  --url "https://api.analytics.autos/safety-events/types" \
  --header 'x-api-key: YOUR-API-KEY' \
  --header 'Connection-Id: YOUR-CONNECTION-ID'

Example response:

[
  {
    "type": "Harsh Braking",
    "logo": "https://example.com/logo.png",
    "isExtended": true
  },
  {
    "type": "Near Collision",
    "logo": "https://example.com/logo.png",
    "isExtended": false
  },
  {
    "type": "No Seatbelt",
    "logo": "https://example.com/logo.png",
    "isExtended": true
  }
]

Incident Thumbnail URL

Endpoint:

GET /safety-events/{id}/thumbnails/{camPos}

Description:

Retrieve a thumbnail image of a safety event recorded by the system. Useful for quickly visualizing incidents.

Path Parameters:

ParameterTypeDescription
idstringUnique ID of the safety event.
camPosstringCamera position (e.g., "front", "rear").

Example Request (cURL):

bash
curl --request GET \
  --url "https://api.analytics.autos/safety-events/123e4567-e89b-12d3-a456-426614174000/thumbnails/front" \
  --header 'x-api-key: YOUR-API-KEY' \
  --header 'Connection-Id: YOUR-CONNECTION-ID'

Response:
Returns a thumbnail image URL.