Skip to content
Rello edited this page Nov 16, 2021 · 22 revisions

The REST API only applies to reports of type "Internal Database".

  1. create an application password for the api connection in user->setting->security
  2. use the POST method


V1.0

add data

Add one data record to a dataset

Endpoint

  • /nextcloud/apps/analytics/api/1.0/adddata/{datasetId}

Format

  • {"dimension1": "x", "dimension2": "x", "dimension3": "333,3"}

V2.0

addData

Endpoint

  • /nextcloud/apps/analytics/api/2.0/adddata/{datasetId}

Format

see V3

removeData

Endpoint

  • /nextcloud/apps/analytics/api/2.0/deletedata/{datasetId}

Format

see V3

V3.0

data add

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')

data delete

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": "*"
        }
    ]
}

data get

Get all data for a report

Endpoint

  • GET /nextcloud/apps/analytics/api/3.0/data/{reportId}

dataset index

List of all datasets

Endpoint

  • GET /nextcloud/apps/analytics/api/3.0/datasets

report index

List of all reports

Endpoint

  • GET /nextcloud/apps/analytics/api/3.0/reports

report detail

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))


Error Codes

  • UNKNOWN = 9001
  • MISSING_PARAM = 9002
  • NOT_FOUND = 9003
  • NOT_ALLOWED = 9004