API Specification

Environments

TEST environment

  • URL: https://dev.dashboard.smapplab.com
  • This environment contains data from the PRODUCTION environment and is updated periodically. Please exercise caution, as the data may be outdated.
  • Access token expiry: 5 days

PRODUCTION environment:

  • URL: https://dashboard.smapplab.com
  • Accesstoken expiry: 5 hours

Authentication endpoint

Description

Authentication endpoint for obtaining an access token to access data endpoints.

Get auth token

API Endpoint: POST api/auth/

Request body

				
					{
    "username": "clientusername",
    "password": "clientpassword"
}
				
			

example response:

				
					{
    "refresh": "exampleaccesstoken",
    "access": "examplerefreshtoken"
}
				
			

Data endpoints

General description

Response format

				
					{
  "meta": {
      "next": "/api/devices/?page=3&page_size=20", // null, if there is no more page
      "previous": "/api/devices/?page=1&page_size=20", // null, if there is no more page
      "count": 420, // total size of elements
      "page": 2,
      "page_size": 20
  },
  "data": [
      {
      ...
      }
  ]
}
				
			

Devices

API Endpoint: GET /api/devices/

 

Description

Devices endpoint for retrieving data specifically related to trap devices.

Request body

No request body

Authorization header

				
					'Authorization: Bearer EXAMPLEACCESSTOKEN'
				
			

Example response:

				
					{
	"id": "exampledeviceUUID",
	"most_relevant_geo_point": {
		"latitude": "47.5118305060",
		"longitude": "19.0377206591"
	},
	"smapp_id": "SMP-0000",
	"name": "Name of device",
	"current_pest": "exampleuuid",
	"current_crop": "exampleuuid",
	"last_measurement": "exampleuuid",
	"last_network_diagnostic": "exampleuuid",
}
				
			

Pests

API Endpoint: GET /api/pests/

Description

Pest endpoint for retrieving detailed pest data by pest id.

Querystring parameters:

				
					id__in=id1,id2 // ids are the current_pest uuids from the devices endpoint
				
			

Authorization header

				
					'Authorization: Bearer EXAMPLEACCESSTOKEN'
				
			

Example response:

				
					 [
			{
				"id": "1903ec84-2fb0-4c9c-8fb3-c27ac4a2eb03",
				"created_at": 0,
				"updated_at": 0,
				"comment": "string",
				"name": "string"
			}
	]
				
			

Crops

API Endpoint: GET /api/crops

Description

Crops endpoint for retrieving detailed crop data by crop id.

Querystring parameters:

				
					id__in=id1,id2 // ids are the current_crop uuids from the devices endpoint
				
			

Authorization header

				
					'Authorization: Bearer EXAMPLEACCESSTOKEN'
				
			

Example response:

				
					[
	{
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "created_at": 0,
    "updated_at": 0,
    "comment": "string",
    "name": "string"
  }
]
				
			

Images

Get list of images and detection counts related to image

API Endpoint: GET /api/devices/images

Description

Images endpoint for retrieving images by device id.

Querystring parameters:

				
					device__id=exampledeviceid // ids are the id uuids from the devices endpoint
				
			

Authorization header

				
					'Authorization: Bearer EXAMPLEACCESSTOKEN'
				
			

Example response:

				
					[
	{
    "id": "example image uuid",
    "created_at": 0,
    "detection_count": "number",
    "detection_count_delta": "number",
    "device": "device_id"
	}
]
				
			

Download image by image id

API Endpoint: GET /api/devices/images/{image_id}/download

Description

Images endpoint for downloading specific image by image id.

Querystring parameters:

				
					type=validated
				
			

Authorization header

				
					'Authorization: Bearer EXAMPLEACCESSTOKEN'
				
			

Example response:

Blob image (type: image/jpeg)

Measurements

API Endpoint: GET /api/devices/measurements

Description

Measurements endpoint for retrieving measurements by device ids.

Querystring parameters:

				
					device__id__in=id1,id2 // ids are the last_measurement uuids from the devices endpoint
				
			

Authorization header

				
					'Authorization: Bearer EXAMPLEACCESSTOKEN'
				
			

Example response:

				
					{
  "id": "measurementuuid",
  "battery_voltage": "4.2",
  "solar_cell_voltage": "4.3",
  "temperature": 0, // celsius, not provided by mini devices
  "humidity": 34, // percentage, not provided by mini devices
  "light": 0, // percentage
  "created_at": 0,
	"device": "deviceuuid"
}
				
			

Network diagnostics

API Endpoint: GET /api/devices/network-diagnostics

Description

Network diagnostics endpoint for retrieving network diagnostic by device ids.

Querystring parameters:

				
					device__id__in=id1,id2 // ids are the last_measurement uuids from the devices endpoint
				
			

Authorization header

				
					'Authorization: Bearer EXAMPLEACCESSTOKEN'
				
			

Example response:

				
					{
    "id": "networkdiagnosticsuuid",
    "created_at": 0,
    "service": "egsmmode", // service for device modem
    "operator": "21630",
    "band": "EUTRAN-BAND28",
    "channel": "352",
    "cell": "111628",
    "rssi": -55.0,
    "ip": "ipaddress",
    "device": "ca65ab35-6112-4831-ac47-a7f4848e0958"
},
				
			

Catch count deltas

API Endpoint: GET /api/devices/one-and-seven-day-detection-counts

Description

Catch count deltas endpoint for retrieving catch count and catch count deltas on a daily and weekly bases by device ids.

Querystring parameters:

				
					device_ids=id1,id2 // ids are the id uuids from the devices endpoint
				
			

Authorization header

				
					'Authorization: Bearer EXAMPLEACCESSTOKEN'
				
			

Example response:

				
					[
  {
      "id": "deviceuuid",
      "day": {
          "dc": 0, // today detection count
          "dcd": 0 // today detection count delta
      },
      "week": {
          "dc": 0, // 7 days detection count
          "dcd": 0 // 7 days detection count delta
      }
  }
]