-
Notifications
You must be signed in to change notification settings - Fork 2
Noise sensor monitoring API docs
Welcome to the noise-sensors-monitoring API docs
Below are available the API endpoints:
Endpoint: GET http://localhost:8000/devices/locations
Response: 200 OK
Response format:
[
{
"id": "49e879b0-f41a-4524-b383-1ab6f7354ab1",
"latitude": 0.3476,
"longitude": 32.5825,
"city": "Kampala",
"division": "N/A",
"parish": "N/A",
"village": "N/A"
},
...
]
Endpoint: GET http://localhost:8000/devices/device_recordings/
Response: 200 OK
Response format
[
{
"id": "0e3b59c9-8f97-4d25-92f6-57b31967feef",
"location_recordings": []
},
{
"id": "916c99c5-5374-4a01-84fa-3411bd4aa977",
"location_recordings": [
{
"id": 10,
"time_recorded": "2022-03-18T15:32:29.125119+03:00",
"category": null,
"audio": "https://url.something.com/audio/SB05/.....wav",
"triggering_threshold": 70
},
...
]
}
...
]
Endpoint: GET http://localhost:8000/devices/device_recordings/uuid
Sample request: GET http://localhost:8000/devices/device_recordings/6d94fb5b-e284-43e8-987b-f1cd44f070aa
Response: 200 OK
Response format
{
"id": "916c99c5-5374-4a01-84fa-3411bd4aa977",
"location_recordings": [
{
"id": 10,
"time_recorded": "2022-03-18T15:32:29.125119+03:00",
"category": null,
"audio": "https://url.something.com/audio/SB05/.....wav",
"triggering_threshold": 70
},
...
]
}
Endpoint: PATCH http://localhost:8000/audio/update/id/
Sample request: PATCH http://localhost:8000/audio/update/1/
Sample request body:
{
"category": 10
}
Response: 200 OK
Response format
{
"id": 10,
"time_recorded": "2022-03-18T15:32:29.125119+03:00",
"category": null,
"audio": "https://url.something.com/audio/SB05/.....wav",
"triggering_threshold": 70
}
This is the main endpoint used for retrieving all the locations and metrics.
Endpoint: GET http://localhost:8000/devices/location_metrics
Endpoint: GET http://localhost:8000/analysis/
Response: 200 OK
Response format:
[
{
"location": {
"city": "Entebbe",
"division": "A",
"parish": "Lugonjo",
"village": "Lugonjo",
"noise_analysis": {
"day_time_average": 61.301770193756724,
"day_time_median": 64.63844,
"highest_day_noise": 91.41908,
"night_time_average": 8.96655608040201,
"night_time_median": 0.0,
"highest_night_noise": 68.70873,
"night_time_quiet_hours": ""
}
}
},
...
]
The sensors use this endpoint to upload the metrics text file.
POST http://localhost:8000/analysis/metrics-file/
Get a list of the metrics file that were uploaded. Can filter by the number days from today using the past_days
query parameter.
GET http://localhost:8000/analysis/list-metrics/SB1001?past_days=14
.
Get a list of the hourly metrics. Can filter by the number days from today using the past_days
query parameter.
GET http://localhost:8000/analysis/hourly/SB1001?past_days=2
Get uptime statistics for a particular sensor. Can filter by the number days from today using the past_days
query parameter. NOTE: Use a small past_days
number for a fast request. 2 to 4 weeks should be enough.
GET http://localhost:8000/devices/uptime/LOCAL_TESTING_DEVICE?past_weeks=2
.
Response format
{
"uptime_based_on_audio_uploads": {
"upload_gaps": []
"uptime": 336.0,
"previous_downtime": "From 2023-10-19 03:22:01.655109+00:00 to 2023-10-19 04:58:27.070456+00:00"
}
...
}
-
upload_gaps
: Gaps of more than 1.5 hours where there were no uploads from the sensor. -
uptime
: Number of hours that the sensor has been consistently sending uploads (tex and audio files). Consistent means there was no 24 hours gap between uploads. Ifnull
, then the sensor is down. -
previous_downtime
: the last time there was a downtime. (Shows the dates)
You can import this postman collection into postman which sets up the different requests for the above endpoints.