Event Detector

This endpoint provides details on the inputs and outputs of operations used to configurate detectors regarding certain events.

Content Overview:

The base URL for the endpoints specified in this article is as follows:

https://demo.ghmaritime.com/api/eventdetector

Create an Area Event Detector

To create a detector for a specific area, send a POST request to the /definition endpoint. The request body should include the detector’s name, type (in this case, ‘area’), and the area’s geometry.

The response from the API will contain the id of the detector; to then see the events that the detector has recorded, follow the steps in Get Events from an Event Detector.

The following is a list of variables that can be altered in the code:

  • <credentials>
    • Your username and password for authentication as Base64-encoding
  • <DetectorName>
    • Name of the detector to be created
  • <ShapeType>
    • The type of the shape specified in geometry
  • <Lat&Long>
    • Latitude and longitude values that define points in the coordinates.
import requests
import json

URL = f'https://demo.ghmaritime.com/api/eventdetector/definition'
headers = {
    "Authorization": "Basic <credentials>",
    "Content-Type": "application/json",
}

payload = {
    "name": "<DetectorName>",
    "type": "area",
    "geometry": {
        "type": "<ShapeType",
        "coordinates": [
            [
                <Lat&Long>
            ]
        ]
    }
}

response = requests.post(URL, json=payload, headers=headers, timeout=10)
response.raise_for_status()
print(json.dumps(response.json(), indent=2))

An example of the latitude and longitude pairs is:

[
  14.62272389125424,
  55.317776522840745
],
[
  14.626843764301114,
  54.97718058173854
],
[
  15.240704848285489,
  54.971663255365826
],
[
  15.220105483051114,
  55.317776522840745
],
[
  14.62272389125424,
  55.317776522840745
]

Response Sample:

{
  "id": "b6c30335-d1e5-42ae-bf95-cb3d83bc144b"
}

Get Events from Event Detectors

Prerequisite

As a prerequisite to getting the events of a event detector, it should be noted that an event detector should have been created beforehand and the id of the detector should also be known.

Request

To get the events of event detectors, a GET request should be constructed via the /eventdetector/event endpoint. Additionally, it should be noted that there is no need to specify anything in the request body (payload).

If none of the event detectors have signalled any events, the API will respond with an empty JSON file.

However, If the detectors have signalled any events, the API will respond with a record (array) of event detectors and their recorded events.

The following is a simple code example of such a request:

Code Example:

import requests
import json

URL = (
    f"http://mdmtest.gatehouse.local/api/eventdetector/event"
)
headers = {
    "Authorization": "Basic bWFlOiEhQUlTYWlz",
    "Content-Type": "application/json",
}

response = requests.get(URL, headers=headers)
print(response.status_code)
print(response.text)
response.raise_for_status()
print(json.dumps(response.json(), indent=2))

Response Sample:

{
    "records": [
        {
            "definition": {
                "id": "572940fd-4cfd-4e10-bd88-6e9389bf764a"
            },
            "event": {
                "activated": {
                    "coordinates": [
                        9.276185,
                        57.692275,
                        "2025-08-01T07:05:57Z",
                        74.1,
                        7.900000000000001
                    ],
                    "extensions": [
                        "time",
                        "cog",
                        "sog"
                    ],
                    "type": "Point"
                },
                "data_source_type": "ais-s",
                "id": "e0b52523-fd60-42b4-b4db-34aaf55e040f",
                "severity": "Note",
                "ship": {
                    "callsign": "XP2671",
                    "cog": 74.1,
                    "destination": "AALBAEK",
                    "mmsi": 219011136,
                    "name": "HG 345 AMANDA",
                    "navstatus": "Fishing",
                    "shiptype": "Fishing",
                    "size": [
                        11.0,
                        3.0,
                        1.0,
                        3.0
                    ],
                    "sog": 7.9,
                    "typeofmobile": "Class A"
                }
            }
        },
        {
            "definition": {
                "id": "17656425-8324-49de-9288-6680ea2d6dcb"
            },
            "event": {
                "activated": {
                    "coordinates": [
                        8.630866666666666,
                        57.18155,
                        "2025-08-01T07:02:34Z",
                        214.39999999999998,
                        null
                    ],
                    "extensions": [
                        "time",
                        "cog",
                        "sog"
                    ],
                    "type": "Point"
                },
                "data_source_type": "ais-s",
                "id": "7d346bea-d4b2-4b00-89b6-e38a7186dbd1",
                "severity": "Note",
                "ship": {
                    "callsign": "PLFQ",
                    "cog": 214.4,
                    "destination": "SIR A",
                    "draught": 1.5,
                    "eta": "2025-11-01T21:06:00Z",
                    "heading": 228,
                    "imo": 1234540,
                    "mmsi": 200000000,
                    "name": "IDN PARI 849",
                    "navstatus": "Reserved [WIG]",
                    "shiptype": "Fishing",
                    "size": [
                        6.0,
                        2.0,
                        1.0,
                        1.0
                    ],
                    "typeofmobile": "Class B"
                }
            }
        },
    ]
}

Updated on 01 August, 2025