Skip to content

Getting data via WebSocket protocol#

To obtain information about events and incidents using the web socket protocol, you can use the tool built into LUNA CARS Analytics - Swagger REST-API CARS.Analytics

To enter the Swagger web interface, open the following address in your browser (Figure 5).

http://IP_ADDRESS:ANALYTICS_FRONTEND_PORT/api/v1-cars/doc#/
  • IP_ADDRESS - IP address of the target server where the LUNA CARS product is installed;
  • ANALYTICS_FRONTEND_PORT - port for connecting to the frontend component of CARS Analytics (default value is 8080, for more details see the LUNA CARS Installation Manual documentation, Appendix 2. Description of «.env» variables).
Swagger page view
Figure 5. Swagger page view

In the WebSocket section there are two sections available for receiving data using GET requests (Figure 6)

1․ "/ws/cars/1/0/events" - getting scenarios data with the Event type; 2․ "/ws/cars/1/0/incidents" - getting scenarios data with the Incident type;

View of the WebSocket section
Figure 6. View of the WebSocket section

Getting scenarios data with the Event type (Figure 7):

1․ Expand the item "/ws/cars/1/0/events" and go to the Parameters block; 2․ Click on the Try it out button; 3․ Enter the required camId and scenarioId values into the fields; 4․ Click the Execute button.

Getting scenarios data with the Event type
Figure 7. Getting scenarios data with the Event type

In the Responses block, you will get a Curl query to get data about the selected scenarios.

In the Server response item, you will get a response to this request in json format. An example of a server response:

{
  "data": [
    {
      "id": "2a245cad-29ad-403e-b84d-c372880be4bf",
      "cam": {
        "id": "9ccf654b-55fc-4862-9f69-cc58e2998733",
        "name": "Варшавка",
        "watchUri": "http://carstream:port/api/1/streams/preview/a1fef9db-6efc-4af2-9eb8-453bd4829bfb",
        "status": 1
      },
      "scenarioId": "74d3218d-a5c5-4a4d-a083-76371ada25c2",
      "indicatorTypeId": "22d3218d-a5c5-4a4d-a083-76371ada25c2",
      "registeredAt": "2017-07-21T17:32:28Z",
      "vehicleTypeId": "74d3218d-a5c5-4a4d-a083-76371ada65c2",
      "vehicleBrandId": "e0abe8da-e354-4f6a-9645-5f581aeacc3f",
      "vehicleModelId": "2a245cad-29ad-403e-b84d-c372880be4bf",
      "vehicleColorId": "e30df9a6-3505-4787-8e64-93af73708f43",
      "countryId": "9db92e75-52d3-4ed6-ab32-7cfb28671ac0",
      "vehicleEmergencyTypeId": "e30df9a6-3505-4787-8e64-93af71238f43",
      "vehicleLicensePlate": "е777кх77",
      "vehicleTypeAccuracy": 0.75,
      "vehicleBrandAccuracy": 0.75,
      "vehicleModelAccuracy": 0.75,
      "vehicleColorAccuracy": 0.75,
      "countryAccuracy": 0.75,
      "vehicleEmergencyTypeAccuracy": 0.75,
      "vehicleLicensePlateAccuracy": 0.75,
      "licensePlateSymbolsAccuracy": [
        0.9,
        0.75,
        1,
        0.01
      ],
      "licensePlateFeatures": [
        {
          "type": "rus_spec_type",
          "title": "police",
          "score": 0.5
        }
      ],
      "vehicleBestshot": "/images/bestshotId",
      "vehicleLicensePlateBestshot": "/images/bestshotId",
      "vehicleTrackId": "156",
      "frameId": "5002",
      "fragmentGroups": [
        {
          "id": "track_frames",
          "label": "Фреймы трека",
          "fragments": [
            {
              "image": "/images/bestshotId",
              "frameId": "4001",
              "ts": "2017-07-21T17:30:00Z",
              "label": "Фрейм начала трека",
              "type": "track_begin_frame",
              "detections": [
                {
                  "x": 20,
                  "y": 10,
                  "width": 500,
                  "height": 400
                }
              ]
            }
          ]
        }
      ],
      "specialTransportTypeId": "e30df9a6-3505-4787-8e64-93af71238f43",
      "publicTransportTypeId": "e30df9a6-3505-4787-8e64-93af71238f43",
      "specialTransportTypeAccuracy": 0.75,
      "publicTransportTypeAccuracy": 0.75,
      "vehicleAxlesAmount": 2,
      "vehicleAxlesAccuracy": 0.75,
      "trackEnd": false,
      "detections": [
        {
          "x": 20,
          "y": 10,
          "width": 500,
          "height": 400
        }
      ],
      "numberOfObjects": 1,
      "speeds": [
        {
          "created": "2023-09-28T11:58:14.307487+03:00",
          "speed": 19,
          "title": "traffic lane 1"
        }
      ],
      "userNotes": "Ещё одна заметка пользователя"
    }
  ],
  "meta": [
    {
      "operation": "create"
    }
  ]
}

Getting scenarios data with the Incident type (Figure 8):

1․ Expand the item "/ws/cars/1/0/incidents" and go to the Parameters block; 2․ Click on the Try it out button; 3․ Enter the required camId and scenarioId values into the fields; 4․ Click the Execute button.

Getting scenarios data with the Incident type
Figure 8. Getting scenarios data with the Incident type

In the Responses block, you will get a Curl query to get data about the selected scenarios.

In the Server response item, you will get a response to this request in json format. An example of a server response:

{
  "data": [
    {
      "id": "2a245cad-29ad-403e-b84d-c372880be4bf",
      "cam": {
        "id": "9ccf654b-55fc-4862-9f69-cc58e2998733",
        "name": "Варшавка",
        "watchUri": "http://carstream:port/api/1/streams/preview/a1fef9db-6efc-4af2-9eb8-453bd4829bfb",
        "status": 1
      },
      "scenarioId": "74d3218d-a5c5-4a4d-a083-76371ada25c2",
      "indicatorTypeId": "22d3218d-a5c5-4a4d-a083-76371ada25c2",
      "registeredAt": "2017-07-21T17:32:28Z",
      "vehicleTypeId": "74d3218d-a5c5-4a4d-a083-76371ada65c2",
      "vehicleBrandId": "e0abe8da-e354-4f6a-9645-5f581aeacc3f",
      "vehicleModelId": "2a245cad-29ad-403e-b84d-c372880be4bf",
      "vehicleColorId": "e30df9a6-3505-4787-8e64-93af73708f43",
      "countryId": "9db92e75-52d3-4ed6-ab32-7cfb28671ac0",
      "vehicleEmergencyTypeId": "e30df9a6-3505-4787-8e64-93af71238f43",
      "vehicleLicensePlate": "е777кх77",
      "vehicleTypeAccuracy": 0.75,
      "vehicleBrandAccuracy": 0.75,
      "vehicleModelAccuracy": 0.75,
      "vehicleColorAccuracy": 0.75,
      "countryAccuracy": 0.75,
      "vehicleEmergencyTypeAccuracy": 0.75,
      "vehicleLicensePlateAccuracy": 0.75,
      "licensePlateSymbolsAccuracy": [
        0.9,
        0.75,
        1,
        0.01
      ],
      "licensePlateFeatures": [
        {
          "type": "rus_spec_type",
          "title": "police",
          "score": 0.5
        }
      ],
      "vehicleBestshot": "/images/bestshotId",
      "vehicleLicensePlateBestshot": "/images/bestshotId",
      "vehicleTrackId": "156",
      "frameId": "5002",
      "fragmentGroups": [
        {
          "id": "track_frames",
          "label": "Фреймы трека",
          "fragments": [
            {
              "image": "/images/bestshotId",
              "frameId": "4001",
              "ts": "2017-07-21T17:30:00Z",
              "label": "Фрейм начала трека",
              "type": "track_begin_frame",
              "detections": [
                {
                  "x": 20,
                  "y": 10,
                  "width": 500,
                  "height": 400
                }
              ]
            }
          ]
        }
      ],
      "specialTransportTypeId": "e30df9a6-3505-4787-8e64-93af71238f43",
      "publicTransportTypeId": "e30df9a6-3505-4787-8e64-93af71238f43",
      "specialTransportTypeAccuracy": 0.75,
      "publicTransportTypeAccuracy": 0.75,
      "vehicleAxlesAmount": 2,
      "vehicleAxlesAccuracy": 0.75,
      "trackEnd": false,
      "detections": [
        {
          "x": 20,
          "y": 10,
          "width": 500,
          "height": 400
        }
      ],
      "numberOfObjects": 1,
      "speeds": [
        {
          "created": "2023-09-28T11:58:14.307487+03:00",
          "speed": 19,
          "title": "traffic lane 1"
        }
      ],
      "userNotes": "Ещё одна заметка пользователя",
      "isUnread": true
    }
  ],
  "meta": [
    {
      "operation": "create",
      "unreadCount": 5
    }
  ]
}