-
-
Notifications
You must be signed in to change notification settings - Fork 32
API
The REST API only applies to reports of type "Internal Database".
- create an application password for the api connection in user->setting->security
- use the POST method
- V1.0
- V2.0
- V3.0
Add one data record to a dataset
Endpoint
/nextcloud/apps/analytics/api/1.0/adddata/{datasetId}
Format
{"dimension1": "x", "dimension2": "x", "dimension3": "333,3"}
Endpoint
/nextcloud/apps/analytics/api/2.0/adddata/{datasetId}
Format
see V3
Endpoint
/nextcloud/apps/analytics/api/2.0/deletedata/{datasetId}
Format
see V3
Add one or many data records. All records need to be provided in a data array []
Endpoint
POST /nextcloud/apps/analytics/api/3.0/data/{datasetId}/add
Format
{
"data":[
{
"dimension1": "x",
"dimension2": "y",
"value": "1,1"
},
{
"Column 1": "x",
"Free Text": "y",
"Percentage": "12"
}
]
}
- parameters can be named by the technical identifiers ('dimension1', 'dimension2', 'value')
- parameters can be named like in the dataset definition (e.g. 'Column 1')
Remove existing data from a dataset. Wildcards are allowed. Both parameters are mandatory.
Endpoint
POST /nextcloud/apps/analytics/api/3.0/data/{datasetId}/delete
Format
{
"delete":[
{
"dimension1": "x",
"dimension2": "y"
},
{
"Column 1": "a*",
"Free Text": "*"
}
]
}
Get all data for a report
Endpoint
GET /nextcloud/apps/analytics/api/3.0/data/{reportId}
List of all datasets
Endpoint
GET /nextcloud/apps/analytics/api/3.0/datasets
List of all reports
Endpoint
GET /nextcloud/apps/analytics/api/3.0/reports
Metadata of a report
Endpoint
GET /nextcloud/apps/analytics/api/3.0/report/{reportId}
Example CURL:
curl -u user:password -d '{"data":[{"dimension1": "x", "dimension2": "x", "dimension3": "333,3"}]}' -X POST -H "Content-Type: application/json" http://***/nextcloud/apps/analytics/api/2.0/adddata/10
curl -u user:password -X GET -H "Content-Type: application/json" https://***/nextcloud/apps/analytics/api/3.0/data/52
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 = {"data":[{'dimension1': sensor, 'dimension2': now, 'value': value}]} r = requests.post(url, json=payload, headers=headers, auth=(user, passw))
- UNKNOWN = 9001
- MISSING_PARAM = 9002
- NOT_FOUND = 9003
- NOT_ALLOWED = 9004