- Python
- Django + SQLite
- Django REST Framework
- Create
virtualenvusingrequirements.txt - Run
python manage.py runserverin commandline. - By default, server runs on port
5000.
-
An IoT device with properties:
uid: unique id of devicename: name of device
-
A device measures humidity and temperature:
HumidityReading: one-to-manyTemperatureReading: one-to-many
device: owner devicehumidity: readingtimestamp: timestamp when reading was stored in db
device: owner devicetemperature: readingtimestamp: timestamp when reading was stored in db
- Endpoint:
POST /api/devices/ - Content-Type:
application/json - Request Payload
uidname
- Endpoint:
DELETE /api/devices/{device-uid}device-uid: uid of device to be deleted
- Endpoint:
GET /api/devices/{device-uid}device-uid: uid of device
- Endpoint:
GET /api/devices/ - Response:
json
-
Endpoint:
GET /api/devices/{device-uid}/readings/{parameter}/?start_on=yyyy-mmddTHH:MM:SS&end_on=yyyy-mm-ddTHH:MM:SSdevice-uid: uid of deviceparameter: temperature or humiditystart_onandend_on: query parameters which are compulsary and should be used to filter the result to only include data betweenstart_onandend_on.yyyy-mm-ddTHH:MM:SS: year-monthdateThour:minute:second
-
Response:
json
App can be improved on following:
- Payload cleaning.
- Date range matching using timezones.