You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Web API and dashboard for the Knight Lab Studio SensorGrid project.
3
3
4
-
## API
5
-
To get the Django REST API set up:
4
+
The API reads data in from the SensorGrid nodes, and then formats that data into JSON objects to be fed in to the dashboard. The dashboard then visualizes that data in a series of graphs and charts.
Or if you have already run it before run this to get into the virtualenv:
17
-
```
18
-
workon sgapienv
19
-
```
20
-
After you are in the correct virtualenv, run:
21
-
```
22
-
pip install -r requirements.txt
23
-
```
24
-
Now that you have your environment set up and up to date,
25
-
```
26
-
cd sensorgridapi
27
-
```
28
-
To create a basic database:
29
-
```
30
-
./manage.py makemigration <APPNAME>
31
-
./manage.py migrate
32
-
```
33
-
To start a local server and view the admin backend:
34
-
```
35
-
./manage.py runserver
36
-
```
37
-
To add an administrator to the site:
38
-
```
39
-
./manage.py createsuperuser
40
-
```
41
-
To work on Django in the command line:
42
-
```
43
-
./manage.py shell
44
-
```
45
-
## Dashboard
46
-
To launch the dashboard:
47
-
```
48
-
cd sensorgriddashboard
49
-
npm install
50
-
```
51
-
If the installation process runs successfully, you can start the dashboard by running:
52
-
```
53
-
npm start
54
-
```
55
-
56
-
# API endpoints
57
-
`/sensordata/?node_id=<INT>` - Returns an array of sensor data objects with the corresponding ID.
58
-
59
-
`/sensordata/created_at_lt=<EPOCH>` - Returns an array of sensor data objects created before the epoch timestamp inputted.
60
-
61
-
`/sensordata/created_at_gt=<EPOCH>` - Returns an array of sensor data objects created after the epoch timestamp inputted.
62
-
63
-
`/sensordata/?battery&node_id_include` - Returns an array of objects containing a node's ID and battery.
64
-
65
-
`/sensordata/?battery&node_id=<INT>` - Returns an array of objects containing the battery values of the specified node ID.
66
-
67
-
`/sensordata/?data&data_type&node_id=<INT>` - Returns an array of objects corresponding to the specified node ID with the value of each sensor's data point and SensorDataSerializer_timestamp corresponding data type.
68
-
69
-
`/sensordata/?data&data_type&node_id_include` - Returns an array of objects containing each node's ID, data value, and data type.
6
+
To see the documentation for the dashboard, click [here](https://github.com/NUKnightLab/SensorGridAPI/blob/master/sensorgriddashboard/README.md).
70
7
8
+
To see the documentation for the API, click [here](https://github.com/NUKnightLab/SensorGridAPI/blob/master/sensorgridapi/README.md).
Or if you have already run it before run this to get into the virtualenv:
13
+
```
14
+
workon sgapienv
15
+
```
16
+
After you are in the correct virtualenv, run:
17
+
```
18
+
pip install -r requirements.txt
19
+
```
20
+
Now that you have your environment set up and up to date,
21
+
```
22
+
cd sensorgridapi
23
+
```
24
+
To create a basic database:
25
+
```
26
+
./manage.py makemigrations <APPNAME>
27
+
./manage.py migrate
28
+
```
29
+
To start a local server and view the admin backend:
30
+
```
31
+
./manage.py runserver
32
+
```
33
+
To add an administrator to the site:
34
+
```
35
+
./manage.py createsuperuser
36
+
```
37
+
To work on Django in the command line:
38
+
```
39
+
./manage.py shell
40
+
```
41
+
42
+
# API endpoints
43
+
Note that for any endpoint you can include a `node_id=<INT>` to return only the data from that node. On the other hand, the command `node_id_include` will return a subset of the data model with `node_id` values, but will not allow you to filter that subset according to a specific `node_id`.
44
+
45
+
Below are the most vital endpoints for our SensorGrid Dashboard. To see all endpoints, go to `./sensorgridapi/sensordata/views.py`.
46
+
47
+
`/sensordata/?node_id=<INT>` - Returns an array of sensor data objects with the corresponding ID.
48
+
49
+
`/sensordata/created_at_lt=<EPOCH>` - Returns an array of sensor data objects created before the epoch timestamp inputted.
50
+
51
+
`/sensordata/created_at_gt=<EPOCH>` - Returns an array of sensor data objects created after the epoch timestamp inputted.
52
+
53
+
`/sensordata/?battery&node_id_include` - Returns an array of objects containing a node's ID and battery.
54
+
55
+
`/sensordata/?battery&node_id=<INT>` - Returns an array of objects containing the battery values of the specified node ID.
56
+
57
+
`/sensordata/?data&data_type&node_id=<INT>` - Returns an array of objects corresponding to the specified node ID with the value of each sensor's data point and SensorDataSerializer_timestamp corresponding data type.
58
+
59
+
`/sensordata/?data&data_type&node_id_include` - Returns an array of objects containing each node's ID, data value, and data type.
0 commit comments