API Reference¶
Note
HTTP API functions called from a browser.
-
views.api.
create_monitor
(request) → django.http.response.JsonResponse¶ Create a new monitor.
- API Call:
/create_monitor? name=<unique name assigned to monitor>& detector_name=<name of detector>& detector_model=<existing detector model name>& feed_id=<id of existing feed>& log_objects=<comma-separated list of objects (optional)>& notification_objects=<comma-separated list of objects (optional)>& charting_objects=<comma-separated list of objects (optional)>& charting_time_zone=<pytz time zone to display chart (optional)>& charting_time_horizon=<x-axis time horizon for charting (optional)>
- Parameters
request – The HTML request. See the parameter descriptions below for constraints and defaults for each parameter.
- Returns
-
views.api.
create_stream
(request) → django.http.response.JsonResponse¶ Create a video stream.
- API Call:
/create_stream?cam=<camera URL>& time_zone=<pytz time zone>& description=<user defined>
- Parameters
request – HTTP request that requires ‘cam’, ‘time_zone’ and ‘description’ arguments. The ‘cam’ argument can be any http address to a video stream or a short-hand youtube video hash. The ‘time_zone’ represents the timezone where the video is sourced from. A ‘description’ is a free-form description of the stream. Stream address and time zones will be validated before being saved. If validation fails, an error will be returned.
- Returns
A dictionary of the stream settings that have been set or an error if the stream could not be validated.
-
views.api.
detector_confidence
(request) → django.http.response.JsonResponse¶ Set the confidence that a detector should use when recognizing an object.
- API Call:
/detector_confidence? monitor_name=<monitor name>& value=<confidence value from 0 to 1 to set>
- Parameters
request – HTTP request that expects a ‘monitor_name’ and ‘value’ argument. ‘value’ represents the new confidence. The ‘value’ is expected to be a float value between 0 and 1 (inclusive).
- Returns
The new value after being set or the old value if it was not set.
-
views.api.
detector_sleep_throttle
(request) → django.http.response.JsonResponse¶ Set the number of seconds that a detector should sleep after performing a detection. Increasing this value will lower the number of detections performed per minute and lower the CPU burden.
- API Call:
/detector_sleep_throttle? monitor_name=<monitor name>& value=<throttle value in seconds to set>
- Parameters
request – HTTP request that expects a ‘monitor_name’ and ‘value’ argument. ‘value’ represents the new sleep time to be set.
- Returns
The new value after being set or the old value if it was not set.
-
views.api.
get_active_monitors
(request) → django.http.response.JsonResponse¶ Retrieve the currently active monitors hosted by the application.
- API Call:
/get_active_monitors
- Parameters
request – HTTP request.
- Returns
Dictionary of active monitors where each key is the monitor name and value is a dictionary of k,v pairs of monitor parameters and respective values.
-
views.api.
get_all_log_objects
(request) → django.http.response.JsonResponse¶ Get a distinct list of all objects that have been logged by a monitor.
- API Call:
/get_all_log_objects? monitor_name=<monitor name>
- Parameters
request – HTTP request with a monitor_name argument.
- Returns
A list of distinct objects that have been logged by a monitor.
-
views.api.
get_chart_components
(request)¶ Returns a script that will embed a bokeh chart from a bokeh server
-
views.api.
get_detectors
(request) → django.http.response.JsonResponse¶ Return a dictionary of all available detector_machines-DELETE.
- API Call:
/get_detectors
- Parameters
request – HTML Request. (not used for this function)
- Returns
A JsonResponse dictionary of detector_machines-DELETE. {detector_id: {‘id’:, ‘name’: , ‘model’: }}
-
views.api.
get_log_objects
(request) → django.http.response.JsonResponse¶ Retrieve a list of the objects that a monitor will save to the log.
- API Call:
/get_log_objects? monitor_name=<monitor name>
- Parameters
request – HTTP request that includes a ‘monitor_name’ argument.
- Returns
A list of objects that a named monitor will log.
-
views.api.
get_logdata
(request)¶ Retrieve all logdata for a monitor
- API Call:
/get_logdata? monitor_name=<monitor name>
- Parameters
request – HTTP request.
- Returns
Dictionary with three keys: earliest_log_date, latest_log_date, num_log_records. Dates are in ISO format YYYY-MM-DD.
-
views.api.
get_logdata_bokeh
(request)¶ Retrieve all logdata for a monitor
- API Call:
/get_logdata_bokeh? monitor_name=<monitor name>
- Parameters
request – HTTP request.
- Returns
-
views.api.
get_logdata_info
(request)¶ Retrieve statistical data about the logged data for a monitor (earliest_log_date, latest_log_date, num_log_records)
- API Call:
/get_logdata_info? monitor_name=<monitor name>
- Parameters
request – HTTP request.
- Returns
Dictionary with three keys: earliest_log_date, latest_log_date, num_log_records. Dates are in ISO format YYYY-MM-DD.
-
views.api.
get_logged_data_csv
(request)¶ Return all the data logged for a provided monitor. Without any ‘objects’, ‘start_data’ or ‘end_date’, all items are assumed for the missing parameters.
- API Call:
/get_logged_data? monitor_name=<monitor name>& start_date=<YYYY-MM-DD>& end_date=<YYYY-MM-DD>& objects=<comma separated list of objects to return>
- Parameters
request – request: HTTP request that expects a monitor_name argument.
- Returns
A CSV file of logged entries corresponding the provided monitor and filtering arguments
-
views.api.
get_monitor
(request) → django.http.response.JsonResponse¶ Return that configuration values of a specified monitor.
- API Call:
/get_monitor?name=<monitor name> <optional> &field=<config field>
- Parameters
request – HTTP request that expects a ‘monitor_name’ argument.
- Returns
The full set of configured values for a monitor or a k,v dict pair if a field was supplied.
-
views.api.
get_monitors
(request) → django.http.response.JsonResponse¶ Return a list of all monitors configured in the application. Each list element is a dictionary representing the k,v argument/values for each monitor.
- API Call:
/get_monitors
- Parameters
request – HTTP request.
- Returns
List of dictionaries where each dictionary includes the k,v pairs of the monitor values.
-
views.api.
get_notification_objects
(request) → django.http.response.JsonResponse¶ Get a distinct list of all objects that will trigger notifications for a monitor.
- API Call:
/get_notification_objects? monitor_name=<monitor name>
- Parameters
request – HTTP request with a ‘monitor_name’ argument.
- Returns
A list of distinct objects that will trigger a notification.
-
views.api.
get_streams
(request) → django.http.response.JsonResponse¶ Return a dictionary of all available video streams configured for the application.
- API Call:
/get_streams
- Parameters
request – HTML Request. (not used for this function)
- Returns
A JsonResponse dictionary of video streams. {stream: {‘cam’: , ‘time_zone’: , ‘url’: ,’description’: }}
-
views.api.
get_timezones
(request)¶ Return a list of all the supported timezone values.
- API Call:
/get_timezones
- Returns
List of support timezone values
-
views.api.
get_trained_objects
(request) → django.http.response.JsonResponse¶ Return a list of objects trained by a detector. The detector can be determined by a ‘monitor_name’ or ‘detector_name’.
- API Call:
/get_trained_objects? monitor_name=<monitor name>& detector_name=<detector name>
- Parameters
request – HTTP request the expects either a ‘detector_name’ or ‘monitor_name’ argument.
- Returns
-
views.api.
set_chart_objects
(request) → django.http.response.JsonResponse¶ Set the ‘charting_objects’ of a monitor.
- API Call:
/set_chart_objects? monitor_name=<monitor name>& objects=<comma-separated list of objects to toggle>
- Parameters
request – HTTP request that expects a ‘monitor_name’ and ‘objects’ arguments.
- Returns
The new list of items after being set.
-
views.api.
set_chart_time_horizon
(request) → django.http.response.JsonResponse¶ Set the x-axis (time horizon) of a chart.
- API Call:
/set_chart_time_horizon? monitor_name=<monitor name>& value=<time horizon to set>
- Parameters
request – HTTP request that expects a ‘monitor_name’ and ‘value’ argument. ‘value’ represents the new time horizon to be set. Valid time horizons are: ‘day’, ‘week’, ‘month’, ‘year’, or an integer representing a number of most recent hours to display.
- Returns
The new value after being set or the old value if it was not set.
-
views.api.
set_chart_time_zone
(request) → django.http.response.JsonResponse¶ Set the time zone of a chart.
- API Call:
/set_chart_time_zone? monitor_name=<monitor name>& value=<time zone to set>
- Parameters
request – HTTP request that expects a ‘monitor_name’ and ‘value’ argument. ‘value’ represents the new time zone to be used. Time zones must adhere to the list of valid time zones supported by the pytz module.
- Returns
The new value after being set or the old value if it was not set.
-
views.api.
set_log_interval
(request) → django.http.response.JsonResponse¶ Set the logging interval of a monitor.
- API Call:
/set_log_interval? monitor_name=<monitor name>& value=<log interval value to set>
- Parameters
request – HTTP request that expects a ‘monitor_name’ and ‘value’ argument. ‘value’ represents the new log interval to be set.
- Returns
The new value after being set or the old value if it was not set.
-
views.api.
set_log_objects
(request) → django.http.response.JsonResponse¶ Set the ‘log_objects’ of a monitor.
- API Call:
/set_log_objects? monitor_name=<monitor name>& objects=<comma-separated list of objects to toggle>
- Parameters
request – HTTP request that expects a ‘monitor_name’ and ‘objects’ arguments.
- Returns
The new list of items after being set.
-
views.api.
set_notification_objects
(request) → django.http.response.JsonResponse¶ Set the ‘notification_objects’ of a monitor.
- API Call:
/set_notification_objects? monitor_name=<monitor name>& objects=<comma-separated list of objects to toggle>
- Parameters
request – HTTP request that expects a ‘monitor_name’ and ‘objects’ arguments.
- Returns
The new list of items after being set.
-
views.api.
start_monitor
(request)¶ Start a monitor. Once started, the monitor will begin performing that actions of each enabled service in a loop that can be stopped with stop_monitor().
- API Call:
/start_monitor? monitor_name=<monitor name>
- Parameters
request – HTTP request that expects a monitor_name argument.
- Returns
A message indicating the status of the monitor.
-
views.api.
stop_monitor
(request)¶ Stops an active monitor.
- API Call:
/stop_monitor? monitor_name=<monitor name>
- Parameters
request – HTTP request that expects a monitor_name argument.
- Returns
A message indicating the status of the monitor.
-
views.api.
toggle_chart_objects
(request) → django.http.response.JsonResponse¶ Add or remove objects from the ‘charting_objects’ list in a monitor.
- API Call:
/toggle_chart_objects? monitor_name=<monitor name>& objects=<comma-separated list of objects to toggle>
- Parameters
request – HTTP request that expects a ‘monitor_name’ and ‘objects’ arguments.
- Returns
The new list of objects after being toggled.
-
views.api.
toggle_log_objects
(request) → django.http.response.JsonResponse¶ Add or remove objects from the ‘log_objects’ list in a monitor.
- API Call:
/toggle_log_objects? monitor_name=<monitor name>& objects=<comma-separated list of objects to toggle>
- Parameters
request – HTTP request that expects a ‘monitor_name’ and ‘objects’ arguments.
- Returns
The new list of objects after being toggled.
-
views.api.
toggle_notification_objects
(request) → django.http.response.JsonResponse¶ Add or remove objects from the ‘notification_objects’ list in a monitor.
- API Call:
/toggle_notification_objects? monitor_name=<monitor name>& objects=<comma-separated list of objects to toggle>
- Parameters
request – HTTP request that expects a ‘monitor_name’ and ‘objects’ arguments.
- Returns
The new list of objects after being toggled.
-
views.api.
toggle_service
(request)¶ Toggle a service on or off depending on its current status.
- API Call:
/toggle_service? monitor_name=<monitor name>& service=<name of service to toggle on or off ‘log’|’notification’|’chart’>
- Parameters
request – HTTP request that expects a ‘monitor_name’ and ‘service’ argument. Supported services are ‘log’, ‘notification’ and ‘chart’.
- Returns
The status of the service after toggle is complete.
-
views.api.
update_monitor
(request) → django.http.response.JsonResponse¶ Update parameter values of a monitor.
- API Call:
/update_monitor? detector_name=<name of detector>& detector_model=<existing detector model name>& feed_id=<id of existing feed>& log_objects=<comma-separated list of objects (optional)>& notification_objects=<comma-separated list of objects (optional)>& charting_objects=<comma-separated list of objects (optional)>& charting_time_zone=<pytz time zone to display chart (optional)>& charting_time_horizon=<x-axis time horizon for charting (optional)>
- Parameters
request – HTTP request that expects a ‘monitor_name’ and argument=value parameter settings for each parameter to set.
- Returns
The full list of parameters for the monitor after settings have been applied.