-
Notifications
You must be signed in to change notification settings - Fork 6
API routes to be implemented
POST /api/v1/sensors
Authentication required
-
name
: string Sensor identification name -
latitude
: number Sensor location latitude -
longitude
: number Sensor location longitude
Status codes:
-
201
Created successfully -
400
Bad request -
401
Unauthorized
On success, returns the created sensor
PUT /api/v1/sensors/:id
Authentication required
-
name
: string Sensor identification name -
latitude
: number Sensor location latitude -
longitude
: number Sensor location longitude
Status codes:
-
200
Ok -
400
Bad request -
401
Unauthorized -
404
Not found
On success, returns the updated sensor
Warning: deletes a sensor and all of its readings
DELETE /api/v1/sensors/:id
Authentication required
Status codes:
-
204
Sensor deleted successfully -
401
Unauthorized -
404
Not found
GET /api/v1/sensors
-
per_page
: number default: 10. maximum: 20 (optional) -
page
: number (optional)
Status codes:
-
200
Ok -
400
Bad request
Response body:
-
count
int -
page
int -
data
[sensor]
Response body example:
{
"count": 32,
"page": 1,
"data": [
{
"id": 1,
"name": "Belterra #1",
"location": [-3.53198127, -10.3964720]
},
...
]
}
GET /api/v1/sensors/:id
Object containing sensor data
Response body:
-
id
int -
name
string -
location
[lon, lat] pair of location coordinates
Response body example:
{
"id": 1,
"name": "Belterra #1",
"location": [-3.53198127, -10.3964720]
}
POST /api/v1/readings
Authentication required
-
sensor_id
: int Reader sensor identifier -
timestamp
: string ISO 8601 formatted string -
water_temp
: number Water temperature in celsius -
luminosity
: To be defined -
water_conductivity
: To be defined -
turbidity
: To be defined -
ph
: number -
orp
: To be defined -
acceleration
: To be defined -
barometric_pressure
: To be defined
Status codes:
-
201
Created successfully -
400
Bad request -
401
Unauthorized
On success, returns the created reading
DELETE /api/v1/readings/:id
Authentication required
Status codes:
-
204
Reading deleted successfully -
401
Unauthorized -
404
Not found
GET /api/v1/readings
-
sensor_id
int (optional) -
since_date
string (ISO 8601) (optional) -
max_date
string (ISO 8601) (optional) -
count
int default: 20 maximum: 100 (optional) -
since_id
int (optional) -
max_id
int (optional)
Status codes:
-
200
Ok -
400
Bad request
Response body:
- data array of reading
Response body example:
{
"data": [
{
"id": 2,
"sensor_id": 59,
"timestamp": "2015-03-01T13:00:00Z",
"water_temp": 22,
"luminosity": null,
"water_conductivity": null,
"turbidity": null,
"ph": 4,
"orp": null,
"acceleration": null,
"barometric_pressure": null
},
...
]
}
GET /api/v1/readings/:id
Object containing reading data
Response body:
-
id
: int -
sensor_id
: int Reader sensor identifier -
timestamp
: string ISO 8601 formatted string -
water_temp
: number Water temperature in celsius -
luminosity
: To be defined -
water_conductivity
: To be defined -
turbidity
: To be defined -
ph
: number -
orp
: To be defined -
acceleration
: To be defined -
barometric_pressure
: To be defined
Response body example:
{
"id": 2,
"sensor_id": 59,
"timestamp": "2015-03-01T13:00:00Z",
"water_temp": 22,
"luminosity": null,
"water_conductivity": null,
"turbidity": null,
"ph": 4,
"orp": null,
"acceleration": null,
"barometric_pressure": null
}
If you are a registered user you will receive an API Key to manage your sensors and readings. For an authenticated request you must include in your request the parameter api_key
, the value being the key sent to you.