A Postman collection containing all of the below endpoints can be found here.
Registers a device in the database.
POST /devices/register
{
"serial_number": string,
"registration_date": string,
"firmware_version": string,
"secret": string,
}
{
"id" : number,
"token": string,
}
The token in the response body will be a jwt and required on subsequent requsts to authenticate with the API.
{
"error" : string,
}
To be used when the token expires (currently expires after 7 days) to authenticate and receieve a new token.
POST /devices/login
headers: {
'Authorization': 'YOUR_TOKEN'
}
{
"secret": string,
}
{
"token": string,
}
Invalid token.
{
"error" : string,
}
Invalid secret.
{
"error" : string,
}
Inserts a new device_sensor_data
record.
POST /devices/update
headers: {
'Authorization': 'YOUR_TOKEN'
}
{
"temp_celsius": string,
"air_humidity_percentage": string,
"carbon_monoxide_level": string,
"status": string,
}
Invalid token.
{
"error" : string,
}
Inserts multiple new device_sensor_data
records. A maximum of 500 records can be past in.
POST /devices/update
headers: {
'Authorization': 'YOUR_TOKEN'
}
[
{
"temp_celsius": string,
"air_humidity_percentage": string,
"carbon_monoxide_level": string,
"status": string,
},
{
"temp_celsius": string,
"air_humidity_percentage": string,
"carbon_monoxide_level": string,
"status": string,
},
...
]
Occurs when there are too many records or the value passed in is not an array.
{
"error" : string,
}
Invalid token.
{
"error" : string,
}