-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Data from the Database
All data in the database can be retrieved from the API as JSON. In fact, all the visualizations are driven by the very same APIs (especially for aggregate information).
The pattern for retrieving data is very simple.
To get all records, the URL is formed as /data-sub/api/<data_type>/?format=json&limit=N where N can be
- 0 to get all records (no limit)
- N (>0) to get N records
The limit is by default 50.
To get a single record, the URL is formed as /data-sub/api/<data_type>/<id>/?format=json
Note that the slumber equivalents are
-
api.<data_type>.get(limit=N), or api.<data_type>.get(id=X)
Some examples below feature a <datetime> placeholder. The format is:
-
YYYY-MM-DDfor just date precision, e.g.2014-09-16 -
YYYY-MM-DDTHH:MM:SSfor date and time precision, e.g.2014-09-16T21:01:55
Note the lte and gte parts of the filter string, which are less-than-equal and greater-than-equal. You can use one or both to filter on.
We have added the ability to sort by date for some datatypes. Sorting can be achieved by using:
-
&order_by=<field>for ascending on<field> -
&order_by=-<field>for descending on<field>
The datatypes below specify which parameters can be sorted on.
The available data types are:
-
loginsession (Login sessions).
- Get all (
/data-sub/api/loginsession/?format=json). - Get a single record (
/data-sub/api/loginsession/1/?format=json) - You can also filter through a number of parameters:
-
name - add
&employee__name=Simon Waltonfor example -
employee_id - add
&employee__employee_id=SW001for example -
start_time - add
&start_time__lte=<datetime>/&start_time__gte=<datetime> -
end_time - add
&end_time__lte=<datetime>/&end_time__gte=<datetime>
-
name - add
- Sort on start_time and/or end_time
- Get all (
-
employee (Employees).
- Get all (
/data-sub/api/employee/?format=json) - Get a single record (
/data-sub/api/employee/1/?format=json) - You can also filter through a number of parameters:
-
name - add
&name=Simon Waltonfor example -
employee_id - add
&employee_id=SW001for example -
currentEmploymentStatus - add
&employee__currentEmploymentStatus=R. Options include:- 'U' - Uncontracted Personnel
- 'P' - Probation period
- 'E' - Employed
- 'L' - On leave
- 'R' - Resigning
- 'C' - Contract Terminated
- 'RE' - Retiring
- 'RT' - Retiring
-
name - add
- Get all (
-
communications (Email/Web Communications).
- Get all (
/data-sub/api/communications/?format=json) | - Get a single record (
/data-sub/api/communications/1/?format=json) - You can also filter through a number of parameters:
-
communicationType - add
&communicationType=Efor email&communicationType=Wfor web records -
employee_id - e.g.
&employee__employee_id=SW001 -
source - add
&source=insider@gmail.com -
destination - add
&destination=j.dory@yahoo.com -
time - add
&time__lte=<datetime>/&time__gte=<datetime>
-
communicationType - add
- Sort on time
- Get all (
-
devices (Device Insertions).
- Get all (
/data-sub/api/device/?format=json). - Get a single record (
/data-sub/api/device/1/?format=json) - You can also filter through a number of parameters:
-
employee_id - add
&employee__employee_id=SW001for example -
deviceType - add
&deviceType=USBfor example -
interaction_time - add
&interaction_time__lte=<datetime>/&interaction_time__gte=<datetime>
-
employee_id - add
- Sort on interaction_time
- Get all (
-
contract (Employee Contracts).
- Get all (
/data-sub/api/contract/?format=json) - Get a single record (
/data-sub/api/contract/1/?format=json) - You can also filter through a number of parameters based on the employee, for example:
-
employee_id - add
&employee__employee_id=SW001 -
name - add
&employee__name=SW001 -
currentEmploymentStatus - add
&employee__currentEmploymentStatus=R. Options include:- 'U' - Uncontracted Personnel
- 'P' - Probation period
- 'E' - Employed
- 'L' - On leave
- 'R' - Resigning
- 'C' - Contract Terminated
- 'RE' - Retiring
- 'RT' - Retiring
-
employee_id - add
- Get all (
-
department (Departments).
- Get all (
/data-sub/api/department/?format=json) - Get a single record (
/data-sub/api/department/1/?format=json)
- Get all (
-
employeecontact (Employee Contact Information).
- Get all (
/data-sub/api/employeecontact/?format=json) - Get a single record (
/data-sub/api/employeecontact/1/?format=json) - You can also filter through a number of parameters based on the employee, for example:
-
employee_id - add
&employee__employee_id=SW001 -
name - add
&employee__name=SW001
-
employee_id - add
- Get all (
-
criminal (Criminal Records).
- Get all (
/data-sub/api/employeecontact/?format=json) - Get a single record (
/data-sub/api/employeecontact/1/?format=json) - You can also filter through a number of parameters based on the employee, for example:
-
employee_id - add
&employee__employee_id=SW001 -
name - add
&employee__name=SW001
-
employee_id - add
- Get all (
-
oceanprofile (Departments).
- Get all (
/data-sub/api/oceanprofile/?format=json) - Get a single record (
/data-sub/api/oceanprofile/1/?format=json) - You can also filter through a number of parameters based on the employee, for example:
-
employee_id - add
&employee__employee_id=SW001 -
name - add
&employee__name=SW001
-
employee_id - add
- Get all (
-
darktriad (Departments).
- Get all (
/data-sub/api/darktriad/?format=json) - Get a single record (
/data-sub/api/darktriad/1/?format=json) - You can also filter through a number of parameters based on the employee, for example:
-
employee_id - add
&employee__employee_id=SW001 -
name - add
&employee__name=SW001
-
employee_id - add
- Get all (
-
employeestressprofile (Departments).
- Get all (
/data-sub/api/employeestressprofile/?format=json) - Get a single record (
/data-sub/api/employeestressprofile/1/?format=json) - You can also filter through a number of parameters based on the employee, for example:
-
employee_id - add
&employee__employee_id=SW001 -
name - add
&employee__name=SW001
-
employee_id - add
- Get all (
-
detectionmodelresult (Detection Mode Result).
- Get all (
/data-sub/api/detectionmodelresult/?format=json) - Get a single record (
/data-sub/api/detectionmodelresult/1/?format=json) - You can also filter through a number of parameters, for example:
-
employee_id - add
&employee__employee_id=SW001 -
name - add
&employee__name=SW001 -
status - add
&status=In Queueor'Action Taken', 'In Quarantine', 'Removed' and 'In Queue' -
reporter - add
&reporter=Detection Modelor some analysts name for example -
date - add
&date__lte=<datetime>/&date__gte=<datetime>
-
employee_id - add
- Sort on date
- Get all (