Safety Events

List Safety Events

Endpoint:

GET /safety-events

Description:

Retrieve all safety events recorded by the system, such as harsh braking, speeding, or 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., "Crash").
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=Crash" \
  --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., "Crash") 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": "Crash",
    "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.

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
Copy code
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.