Gundi's API

Pushing Data through Gundi

Gundi's API is designed to enable data providers to transmit data intended for various supported platforms (e.g., EarthRanger, SMART, Movebank, and wpsWatch).

Authentication

This API uses API key-based authentication. To authenticate, you must obtain an API key from the Connection created through the Gundi Portal. 

API Key

Once you have the key from the Gundi Portal or from our Support Team, include it in your requests as a header using the format apikey: YOUR_API_KEY. The API will verify the key with each request to confirm your access rights and identify the relevant Connection. Requests that do not include a key, or include an invalid or expired key, will be denied with an appropriate error response. Make sure to keep your API key secure and do not share it publicly, as it provides access to potentially sensitive data and operations.

apikey: {{YOUR_API_KEY}}
 
 

Events

Events can be used for reports, alerts, incidents, or any event that requires awareness or action.

https://sensors.api.gundiservice.org/v2/events/

Posting Events

Use the events endpoint to share event information. Events can be used for reports, alerts, incidents, or any event that requires awareness or action.

The following table outlines the essential properties within an event payload.

Attribute Description Required
source Identifies a unique device associated with the event.

No

title A human-friendly string as the event's title. Appears in EarthRanger's event feed and map view.

Yes

event_type Represents the appropriate EarthRanger Event Type or SMART category corresponding to the report.

Yes

recorded_at A timestamp including a timezone, recommended in ISO format (e.g., 2023-07-27T09:34-03:00 or 2023-07-27T09:34Z).

Yes

location A dictionary with lon (longitude) and lat (latitude) to indicate the event's location. The lon and lat values are decimal degrees in WGS-84.

Yes

event_details A dictionary of event properties matching the schema for the associated "event type" (in EarthRanger) or category (in SMART Connect).

No

The following example demonstrates the use of the /events/ endpoint.

curl --location 'https://sensors.api.gundiservice.org/v2/events/' \
--header 'Content-Type: application/json' \
--header 'apikey: {{API_KEY}}' \
--data '{
   "source":"none",
   "title":"Accident Report",
   "event_type": "accident_rep",
   "recorded_at":"2023-10-03T09:35Z",
   "location":{
       "lat":20.117625,
       "lon":-103.113061
   },
   "event_details":{
       "area":"1",
       "people_affected":"1",
       "tags":[
           "fall",
           "injury"
       ]
   }
}'
'

If the operation is successful, our API v2 will provide you with an Object ID, which can be utilized later for various updates and use cases. Make sure to note down this {{OBJECT_ID}} if you anticipate needing the additional functionality.

200 OK
{ 
  "object_id": {{OBJECT_ID}}, 
  "created_at": {{CREATED_AT}} 
}

Updating Events

To update an event previously sent to Gundi's API, use the PATCH method and include only the properties you want to modify.

The following example illustrates updating an event's location, status, and an additional property. Replace the {{OBJECT_ID}} placeholder with the unique ID obtained from the event creation response. For more details on how to obtain this ID, refer to the previous section.

curl --location --request PATCH 'https://sensors.api.gundiservice.org/v2/events/{{OBJECT_ID}}/' \
--header 'apikey: {{API_KEY}}' \
--header 'Content-Type: application/json' \
--data '{
   "status" : "resolved",
   "location":{
       "lat":13.527,
       "lon":13.154
   },
   "event_details":{
       "number_people_involved":"3"
   }
}'

Posting an Image

Camera trap images can be attached to events using the attachments endpoint.

This example illustrates the process of updating an event with an image through Gundi's API. Pay attention to the {{OBJECT_ID}} placeholder in the endpoint, which should be substituted with the value obtained from the event creation operation's result (refer to the "Posting Events").

curl --location 'https://sensors.api.gundiservice.org/v2/events/{{OBJECT_ID}}/attachments/' \
--header 'apikey: {{API_KEY}}' \
--form 'file1={{Blob}}'

If the operation is successful, our API will provide you with an Object ID, which can be utilized later for various updates and use cases. Make sure to note down this Object ID if you anticipate needing the additional functionality.

200 OK
{
   "object_id": {{OBJECT_ID}},
   "created_at": {{CREATED_AT}}
}
 
 

Observations

Observations can be used to track wildlife, rangers, and assets.

https://sensors.api.gundiservice.org/v2/observations/

Posting Observations 

Movement data can be posted using the observations endpoint.  Observations can be used to track wildlife, rangers, and assets.

The following table outlines the essential properties within a Position payload.

Attribute Description Required
source A unique identifier for the device reporting its position.

Yes

source_name A human-friendly name for the device. If omitted, the source identifier will be used as the default.

No

subject_type Describes the entity being tracked (e.g., 'ranger', 'elephant', 'helicopter'). In EarthRanger, this corresponds to the subject’s sub-type.

No

recorded_at The timestamp of when the position was recorded, including a timezone. Use ISO format (e.g., 2022-01-10T16:43:32Z) for consistency.

Yes

location A dictionary containing the track-point coordinates: lon (longitude) and lat (latitude) in decimal degrees (WGS-84).

Yes

additional A dictionary for custom key-value pairs specific to the tracked device, allowing storage of extra metadata beyond standard fields.

No

The following example demonstrates the use of the  /observations/ endpoint.

curl --location 'https://sensors.api.gundiservice.org/v2/observations/' \
--header 'Content-Type: application/json' \
--header 'apikey: {{API_KEY}}' \
--data '{
   "source": "ST123456789",
   "subject_type": "cow",
   "source_name": "Buttercup",   
   "recorded_at": "2023-10-04T00:44:32Z",
   "location":{
       "lat":-51.769228,
       "lon":-72.004443
   },
   "additional": {
       "speed_kmph": 3
   }
}'
 
 

 



Was this article helpful?