Get started
The following API is provided by the Eco saver developer team. It allows you to get Location and Sensor and Sensor Data from the Eco saver database.
To use this API, you need an API key.
Get all location
To get all location of sensors you need to make a GET call to the following url :
https://ecosaver.teeseng.uk/api/v0/location
Return Response :
{"status":"200"}
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | Your API key. | (Required) Example: curl https://ecosaver.teeseng.uk/api/v0/location -H "auth-token: {provide your API key here}" |
Get location by ID
To get Location you need to make a GET call to the following url :
https://ecosaver.teeseng.uk/api/v0/location/{id}
Return Response :
{"status":"200"}
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | (Required) Your API key. | Example: curl https://ecosaver.teeseng.uk/api/v0/location/1 -H "auth-token: {provide your API key here}" |
Get location by name
To get Location you need to make a GET call to the following url :
https://ecosaver.teeseng.uk/api/v0/location/{location name}
Return Response :
{"status":"200"}
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | (Required) Your API key. | Example: curl https://ecosaver.teeseng.uk/api/v0/location/ang mo kio -H "auth-token: {provide your API key here}" |
Add Location (Only for system or admin API key)
To add an Location you need to make a POST call to the following url :
https://ecosaver.teeseng.uk/api/v0/location/new
Example :
curl https://ecosaver.teeseng.uk/api/v0/location/new -H "Content-Type: application/json" -H "auth-token: {provide your API key here}" -X POST -d '{"name": "SAMPLE", "added_by": "system", "description": "test"}'
Return Response :
{"status":"200"}
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | Your API key. | (Required) Example: curl https://ecosaver.teeseng.uk/api/v0/location/new -H "auth-token: {provide your API key here}" |
Location name | JSON | Location name. | (Required) Location name. Example: curl https://ecosaver.teeseng.uk/api/v0/location/new -H "auth-token: provide your API key here" -d '{"name":"Location name"}' |
Added by | JSON | System or Admin | (Required) Added_by Example: curl https://ecosaver.teeseng.uk/api/v0/location/new -H "auth-token: provide your API key here" -d '{"added_by":"system"}' |
Description | JSON | Description of Location | (Required) Description Example: curl https://ecosaver.teeseng.uk/api/v0/location/new -H "auth-token: provide your API key here" -d '{"description":"test"}' |
Update Location (Only for system or admin API key)
To update an Location you need to make a PUT call to the following url :
https://ecosaver.teeseng.uk/api/v0/location/update
Example :
curl https://ecosaver.teeseng.uk/api/v0/location/update -H "Content-Type: application/json" -H "auth-token: {provide your API key here}" -X POST -d '{"id": "7" , "name": "SAMPLE", "added_by": "system" , "description": "test"}'
Return Response :
{"status":"200","message":"Location 7 updated"}
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | Your API key. | (Required) example: curl https://ecosaver.teeseng.uk/api/v0/location/update -H "auth-token: {provide your API key here}" |
ID | JSON | Location ID | (Required) Location ID Example: curl https://ecosaver.teeseng.uk/api/v0/location/update -H "auth-token: provide your API key here" -d '{"id": "7"}' |
Location name | JSON | Location name. | (Optional) Location name. Example: curl https://ecosaver.teeseng.uk/api/v0/location/new -H "auth-token: provide your API key here" -d '{"name":"Location name"}' |
Added by | JSON | System or Admin | (Optiona) Added_by Example: curl https://ecosaver.teeseng.uk/api/v0/location/new -H "auth-token: provide your API key here" -d '{"added_by":"system"}' |
Description | JSON | Description of Location | (Optional) System or Admin Example: curl https://ecosaver.teeseng.uk/api/v0/location/new -H "Authorization: provide your API key here" -d '{"description":"test"}' |
Delete Location (Only for system or admin API key)
To delete an Location you need to make a DELETE call to the following url :
https://ecosaver.teeseng.uk/api/v0/location/delete
Example :
curl https://ecosaver.teeseng.uk/api/v0/location/delete -H "Content-Type: application/json" -X POST -d '{"id": "7"}'
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | Your API key. | (Required) example: curl https://ecosaver.teeseng.uk/api/v0/location/delete -H "auth-token: {provide your API key here}" |
ID | JSON | Location ID | (Required) Location ID Example: curl https://ecosaver.teeseng.uk/api/v0/location/delete -H "auth-token: provide your API key here" -d '{"id": "7"}' |
Get all sensor
To get sensors you need to make a GET call to the following url :
https://ecosaver.teeseng.uk/api/v0/sensor
Return Response :
{"status":"200"}
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | Your API key. | (Required) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor -H "auth-token: {provide your API key here}" |
Get sensor by ID
To get Sensor you need to make a GET call to the following url :
https://ecosaver.teeseng.uk/api/v0/sensor/{id}
Return Response :
{"status":"200"}
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | (Required) Your API key. | Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/{id} -H "Authorization: {provide your API key here}" |
Get sensor by name
To get sensor by name you need to make a GET call to the following url :
https://ecosaver.teeseng.uk/api/v0/sensor/{sensor name}
Return Response :
{"status":"200"}
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | (Required) Your API key. | Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/AQI -H "auth-token: {provide your API key here}" |
Add Sensor (Only for system or admin API key)
To add a Sensor you need to make a POST call to the following url :
https://ecosaver.teeseng.uk/api/v0/sensor/new
Example :
curl https://ecosaver.teeseng.uk/api/v0/sensor/new -H "Content-Type: application/json" -H "auth-token: {provide your API key here}" -X POST -d '{"sensorname": "test", "added_by": "system" , "mac_address": "99-6A-F8-7D-B4-94", "description": "test" , "location": "11"}'
Return Response :
{"status":"200"}
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | Your API key. | (Required) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/new -H "auth-token: {provide your API key here}" |
Sensor name | JSON | Sensor name. | (Required) Location name. Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/new -H "auth-token: provide your API key here" -d '{"sensorname": "test"}' |
Added by | JSON | System or Admin | (Required) System or Admin Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/new -H "auth-token: provide your API key here" -d '{"added_by":"system"}' |
Mac Address | JSON | Mac Address | (Required) Mac Address Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/new -H "auth-token: provide your API key here" -d '{"mac_address": "99-6A-F8-7D-B4-94"}' |
Description | JSON | Description of Sensor | (Required) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/new -H "auth-token: provide your API key here" -d '{"description":"test"}' |
Location ID | JSON | Location ID | (Required) Location Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/new -H "auth-token: provide your API key here" -d '{"location": "11"}' |
Update Sensor (Only for system or admin API key)
To update a Sensor you need to make a PUT call to the following url :
https://ecosaver.teeseng.uk/api/v0/sensor/update
Example :
curl https://ecosaver.teeseng.uk/api/v0/sensor/update -H "Content-Type: application/json" -X POST -d '{"id": "2" ,"sensorname": "test", "added_by": "system" , "mac_address": "99-6A-F8-7D-B4-94" , "description": "test123" , "location": "11" }'
Return Response :
{"status":"200","message":"Sensor 2 updated"}
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | Your API key. | (Required) example: curl https://ecosaver.teeseng.uk/api/v0/sensor/update -H "auth-token: {provide your API key here}" |
ID | JSON | Sensor ID | (Required) Sensor ID Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/update -H "auth-token: provide your API key here" -d '{"id": "7"}' |
Sensor name | JSON | Sensor name. | (Optional) Sensor name. Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/update -H "auth-token: provide your API key here" -d '{"sensorname": "test"}' |
Added by | JSON | System or Admin | (Optional) System or Admin Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/update -H "auth-token: provide your API key here" -d '{"added_by":"system"}' |
Mac Address | JSON | Mac Address | (Optional) Mac Address Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/update -H "auth-token: provide your API key here" -d '{"mac_address": "99-6A-F8-7D-B4-94"}' |
Description | JSON | Description of Sensor | (Optional) Description of Sensor Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/update -H "auth-token: provide your API key here" -d '{"description":"test"}' |
Location | JSON | Location of Sensor | (Optional) Location of Sensor Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/update -H "auth-token: provide your API key here" -d '{"location": "11"}' |
Delete Sensor (Only for system or admin API key)
To delete a sensor you need to make a DELETE call to the following url :
https://ecosaver.teeseng.uk/api/v0/sensor/delete
Example :
curl https://ecosaver.teeseng.uk/api/v0/sensor/delete -H "Content-Type: application/json" -X POST -d '{"id": "7"}'
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | Your API key. | (Required) example: curl https://ecosaver.teeseng.uk/api/v0/sensor/delete -H "auth-token: {provide your API key here}" |
ID | JSON | Sensor ID | (Required) Sensor ID Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/delete -H "auth-token: provide your API key here" -d '{"id": "7"}' |
Get all sensor data
To get all location of sensors you need to make a GET call to the following url :
https://ecosaver.teeseng.uk/api/v0/sensor-data
Return Response :
{"status":"200"}
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | Your API key. | (Required) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data -H "auth-token: {provide your API key here}" |
Get sensor data by ID
To get all location of sensors you need to make a GET call to the following url :
https://ecosaver.teeseng.uk/api/v0/sensor-data/1
Return Response :
{"status":"200"}
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | Your API key. | (Required) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/{id} -H "auth-token: {provide your API key here}" |
Add Sensor data (Only for system or admin API key)
To add a Sensor data you need to make a POST call to the following url :
https://ecosaver.teeseng.uk/api/v0/sensor-data/new
Example :
curl https://ecosaver.teeseng.uk/api/v0/sensor-data/new -H "Content-Type: application/json"
-H "auth-token: {provide your API key here}" -X POST -d '
{"sensorid": "1" , "locationid": "1" , "measurement": {
"psi": "31",
"humidity": "90",
"o3": "5",
"no2": "5",
"so2": "5",
"co": "5",
"temperature": "31",
"windspeed": "8",
}}'
Return Response :
{"status":"200"}
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | Your API key. | (Required) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/new -H "auth-token: {provide your API key here}" |
Sensor ID | JSON | Sensor ID. | (Required) . Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/new -H "auth-token: provide your API key here" -d '{"sensorid": "1"}' |
Location ID | JSON | Location ID. | (Required) . Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/new -H "auth-token: provide your API key here" -d '{"locationid": "1"}' |
sensor Measrement | JSON | Measurement. | (Required) . Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/new -H "auth-token: provide your API key here" -d '{"measurement": {"psi": "31", "humidity": "90", "o3": "5", "no2": "5", "so2": "5", "co": "5", "temperature": "31", "windspeed": "8"} }' |
Update Sensor data (Only for system or admin API key)
To update a Sensor data you need to make a PUT call to the following url :
https://ecosaver.teeseng.uk/api/v0/sensor-data/update
Example :
curl https://ecosaver.teeseng.uk/api/v0/sensor-data/update -H "Content-Type: application/json"
-H "auth-token: {provide your API key here}" -X POST -d '
{"id": "1" , "sensorid": "1" , "locationid": "1" , "measurement": {
"psi": "31",
"humidity": "90",
"o3": "6",
"no2": "6",
"so2": "6",
"co": "6",
"temperature": "32",
"windspeed": "6",
}}'
Return Response :
{"status":"200"}
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | Your API key. | (Required) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/new -H "auth-token: {provide your API key here}" |
Data ID | JSON | ID. | (Required) . Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/new -H "auth-token: provide your API key here" -d '{"id": "1"}' |
Sensor ID | JSON | Sesnsor ID. | (Required) . Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/new -H "auth-token: provide your API key here" -d '{"sensorid": "1"}' |
Location ID | JSON | Location ID. | (Required) . Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/new -H "auth-token: provide your API key here" -d '{"locationid": "1"}' |
sensor Measurement | JSON | Measurement. | (Required) . Example: curl https://ecosaver.teeseng.uk/api/v0/sensor/new -H "auth-token: provide your API key here" -d '{"measurement": {"psi": "31", "humidity": "90", "o3": "5", "no2": "5", "so2": "5", "co": "5", "temperature": "31", "windspeed": "8"} }' |
Delete Sensor Data (Only for system or admin API key)
To delete a sensor Data you need to make a DELETE call to the following url :
https://ecosaver.teeseng.uk/api/v0/sensor-data/delete
Example :
curl https://ecosaver.teeseng.uk/api/v0/sensor-data/delete -H "Content-Type: application/json" -X POST -d '{"id": "7"}'
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | Your API key. | (Required) example: curl https://ecosaver.teeseng.uk/api/v0/location/delete -H "auth-token: {provide your API key here}" |
ID | JSON | Sensor data ID | (Required) Sensor data ID Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/delete -H "auth-token: provide your API key here" -d '{"id": "1"}' |
Get Sensor Data based on Querys
To get sensor Data based on queries you need to make a GET call to the following url :
https://ecosaver.teeseng.uk/api/v0/sensor-data/data?
Example :
curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?order=desc&limit=1
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | Your API key. | (Required) example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data? -H "auth-token: {provide your API key here}" |
Limit | JSON | Limit the size of output | (Optional) Location ID Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?limit=1 -H "auth-token: provide your API key here" |
Order | JSON | Order the data from ascending or descending order. | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?order=asc -H "auth-token: provide your API key here" |
Year | JSON | Query data by year it was created | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?year=2023 -H "auth-token: provide your API key here" |
Month | JSON | Query data by month it was created | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?month=1 or month=jan -H "auth-token: provide your API key here" |
Week | JSON | Query data by week it was created | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?week=1 -H "auth-token: provide your API key here" |
Day | JSON | Query data by day it was created | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?day=1 -H "auth-token: provide your API key here" |
Hour | JSON | Query data by specific hour it was created | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?hour=1 -H "auth-token: provide your API key here" |
Minute | JSON | Query data by specific minute it was created | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?minute=1 -H "auth-token: provide your API key here" |
Sensorid | JSON | Query data by specific sensor id | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?sensorid=1 -H "auth-token: provide your API key here" |
Location id | JSON | Query data by specific location id | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?locationid=1 -H "auth-token: provide your API key here" |
Highest metric | JSON | Get highest value of certain metric | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?hightest=psi -H "auth-token: provide your API key here" |
Lowest metric | JSON | Get lowest value of certain metric | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?lowest=psi -H "auth-token: provide your API key here" |
Average of metric | JSON | Get average of certain metric | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?avg=psi -H "auth-token: provide your API key here" |
Sum of metric | JSON | Get total sum of certain metric | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?sum=psi -H "auth-token: provide your API key here" |
Amount of metric | JSON | Get total amount of certain metric | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?total=psi -H "auth-token: provide your API key here" |
Page | JSON | Get specific page | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?page=2 -H "auth-token: provide your API key here" |
Page Size | JSON | Get specific page size | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/data?pagesize=10 -H "auth-token: provide your API key here" |
Get Sensor Data based on date range Querys
To get sensor Data based on queries you need to make a GET call to the following url :
https://ecosaver.teeseng.uk/api/v0/sensor-data/range?
Example :
curl https://ecosaver.teeseng.uk/api/v0/sensor-data/range?startdate=2024-01-01&enddate=2024-01-02
QUERY PARAMETERS
Field | Type | Description | |
---|---|---|---|
Authorization | JSON | Your API key. | (Required) example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/range? -H "auth-token: {provide your API key here}" |
Limit | JSON | Limit the size of output | (Optional) Location ID Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/range?limit=1 -H "auth-token: provide your API key here" |
Start Date | JSON | Start date you wish to query by | (Optional) Location ID Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/range?startdate=2021-01-01 -H "auth-token: provide your API key here" |
End Date | JSON | End date you wish to query by | (Optional) Location ID Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/range?enddate=2021-01-01 -H "auth-token: provide your API key here" |
Amount of metric | JSON | Get total amount of certain metric | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/range?total=psi -H "auth-token: provide your API key here" |
Average of metric | JSON | Get average of certain metric | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/range?avg=psi -H "auth-token: provide your API key here" |
Sum of metric | JSON | Get total sum of certain metric | (Optional) Example: curl https://ecosaver.teeseng.uk/api/v0/sensor-data/range?sum=psi -H "auth-token: provide your API key here" |
API Keys
You can generate API Keys here:
Errors
The EcoSaver API uses the following error codes:
Error Code | Meaning |
---|---|
200 | Sucessful request. |
401 |
Unknown or unvalid secret_key . This error
appears if
you use an unknown API key or if your API key expired or you didnt provide one.
|
500 |
Unvalid secret_key No API key was supplied.
Invalid request.
|