Images¶
Image Data Structure¶
Image files can be added to devices in order to display sensors, surrounding areas or other information. Each image file will be saved in three versions:
- original: The original image that was uploaded.
- display: A version of the original that might be smaller (dependent on the original size) and has less quality.
- thumbnail: A thumbnail of the original image.
In responses, an image looks like this:
{
"id": "b076940e-29bc-4b07-b100-1bcccddfee73",
"inserted_at": "2024-06-07T14:26:55.673745Z",
"updated_at": "2024-06-07T14:26:55.673745Z",
"device_id": "135718b1-34c9-4f15-9bbc-ebb14bd6b485",
"urls": {
"display_image": <<some_url_1>>,
"original_image": <<some_url_2>>,
"thumbnail": <<some_url_3>>
},
"original_name": "sensor.png"
}
Key | Example | Description |
---|---|---|
id | b076940e-29bc-4b07-b100-1bcccddfee73 | Unique packet ID (UUID4) |
inserted_at | 2024-06-07T14:26:55.673745Z | Date when the image was first uploaded |
updated_at | 2024-06-07T14:26:55.673745Z | Date when the image was last changed |
device_id | 135718b1-34c9-4f15-9bbc-ebb14bd6b485 | Reference to the device the image belongs to |
urls | {"display_image": <<some_url_1>>, "original_image": <<some_url_2>>, "thumbnail": <<some_url_3>>} | Three urls that link to where each version of the file is saved |
original_name | sensor.png | Original name and file extension the image was uploaded with |
API Routes¶
Show all Images for a Device¶
Method: GET
, Endpoint: devices/:id_or_slug/images
Example Request¶
GET https://element-iot.com/api/v1/devices/my-device/images?auth=46cb688e2c0b468e26e914235d4b73ea
Upload an Image for Device¶
Method: POST
, Endpoint: /devices/id_or_slug/images
Header and Body
To send the file with the request the Content-Type
header needs to be set to multipart/form-data
. In the form-data within the body an image file can then be added as the value for the file
key.
Example Request¶
POST https://element-iot.com/api/v1/devices/my-device/images?auth=46cb688e2c0b468e26e914235d4b73ea
Delete an Image¶
Method: DELETE
, Endpoint: /images/:image_id
DELETE https://element-iot.com/api/v1/images/32f6b1de-4df4-418b-819d-0ce2650bf480?auth=46cb688e2c0b468e26e914235d4b73ea