-
-
Notifications
You must be signed in to change notification settings - Fork 36
API
Analytics features a REST API to update data from external applications.
This only applies to reports of type "Internal Database"
- create an application password for the api connection in user->setting->security
- use the endpoint .../nextcloud/apps/analytics/api/1.0/adddata/{datasetId}
- use the POST method
- provide the parameters
Add one data record to a dataset
endpoint:
/nextcloud/apps/analytics/api/1.0/adddata/{datasetId}
data format:
{"dimension1": "x", "dimension2": "x", "dimension3": "333,3"}
Add one or many data records. All records need to be surrounded in [] - this is different to V1.0
endpoint:
/nextcloud/apps/analytics/api/2.0/adddata/{datasetId}
data format:
[{"..": "x", "..": "y", "..": "1,1"},{...}]- parameters have to be named like set up in the dataset definition with there display names (e.g. 'Column 1', 'Average Value")
Remove existing data from a dataset
endpoint:
- ...
data format:
- ...
Example CURL:
curl -u user:password -d '{"dimension1": "x", "dimension2": "x", "dimension3": "333,3"}' -X POST -H "Content-Type: application/json" http://***/nextcloud/apps/analytics/api/1.0/adddata/10
Example python:
user = 'user' passw = 'password' headers = {'Content-Type': 'application/json'} url = 'http://xxx/nextcloud/apps/analytics/api/1.0/adddata/' + '20' now = datetime.now().strftime('%Y-%m-%d %H:%M:%S') payload = {'dimension1': sensor, 'dimension2': now, 'dimension3': value} r = requests.post(url, json=payload, headers=headers, auth=(user, passw))
- UNKNOWN = 9001
- MISSING_PARAM = 9002
- NOT_FOUND = 9003
- NOT_ALLOWED = 9004