-
Notifications
You must be signed in to change notification settings - Fork 6
5. REST APIs
Three views were implemented using DRF - Django-Rest Framework, in order to provide the possible to query the charts data. In particular, the supplied APIs are:
- users_pie_chart_api
- alerts_line_chart_api
- world_map_chart_api
Input: start
and end
datetime captured in the URL: users_pie_chart_api/start=...&end=...
Output: a JSON with user risk as keys and user count as value
Example:
{ "No risk": 32
"Low": 2
"Medium": 86
"High": 4
}
Input: start
and end
datetime captured in the URL: users_pie_chart_api/start=...&end=...
Output: A dictionary containing a list of datetime and a value representing the amount of data for that datetime.
The data is formatted differently based on start and end time duration. There are three types of formats:
- hour
- day
- month
Request using start=2023-06-15T14:00:00Z and end=2023-06-15T16:00:00Z
{
"Timeframe": "hour",
"2023-06-15T14:00:00Z": 23,
"2023-06-15T15:00:00Z": 43,
}
The first value represents the number of alerts triggered between 14:00:00Z and 15:00:00Z. the second represents the number of alerts triggered between 15:00:00Z and 16:00:00Z.
Request using start=2023-06-15T00:00:00Z and end=2023-06-16T23:59:59Z
{
"Timeframe": "day"
"2023-06-15T": 434,
"2023-06-16T": 23
}
Request using start=2023-05-01T00:00:00Z and end=2023-06-31:23:59:59Z
{
"Timeframe": "month"
"2023-06": 4344,
"2023-05": 2332
}
Input: start
and end
datetime captured in the URL: users_pie_chart_api/start=...&end=...
Output: a JSON with the list of all countries (saved in the impossible_travel/dashboard/countries.json
file) and the number of alerts triggered in that place.
Example:
{
"ad": 0,
"ae": 0,
[ ... ]
"sd":43,
"it": 10
}