Key Metrics (API)
The url for DocumentsAPI Production is the following one : https://documents.zelros.com
The url for DocumentsAPI Staging is the following one : https://d2i-staging.zelros.com
Route
GET | /api/analytics | Return the KPIs according to the given parameters |
Parameters
To access our API, you will need an authentication token:
import requests
url = "https://documents.zelros.com/auth/realms/documents/protocol/openid-connect/token"
payload = 'client_id=<YOUR_CLIENT_ID>&client_secret=<YOUR_CLIENT_SECRET>&grant_type=client_credentials'
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
which returns the following json response:
{
"access_token": "TOKEN",
"refresh_token": "REFRESH_TOKEN",
"token_type": "bearer",
...
}
The obtained token, access_token
, has to be placed into the authorization tag, like this :
Authorization: Bearer <TOKEN>
.
You can also refresh your token to extend its lifetime, by sending the previous request with an extra refresh_token
parameter, with your REFRESH_TOKEN
value, and updating the grant_type
value to refresh_token
.
API Call
Request parameters:
-
kpi
: type of KPI desired -
start_date
: start date of the period studied -
end_date
: end date of the period studied -
granularity
: the KPI provided should be provided on a daily,weekly… basis
Optional parameters:
-
call_type
:rad
,lad
orrlad
(both). Default:rlad
Example
import requests (1)
import json
token = '<YOUR_TOKEN>'
params = {
'kpi': 'numberOfPage',
'start_date': '2021-01-01',
'end_date':'2021-01-31',
'granularity': 'day',
'call_type':'rlad',
}
resp = requests.get(
'https://documents.zelros.com/api/analytics',
params=params,
headers={'Authorization': f'Bearer {token}'}
) (2)
body = json.loads(resp.content.decode('utf8'))
print(body)
1 | Library import |
2 | Launch request |
Example of answer from the Key Metrics API
The kpi used in this example is numberOfDocType. For other kpi, visit the documentation below.
{'numberOfDocType':
{'request':
{'params':
{'client_id': <YOUR_CLIENT_ID>,
'kpi': 'numberOfDocType',
'start_date': '2022-01-01T00:00:00.000Z',
'end_date': '2022-03-29T00:00:00.000Z',
'granularity': 'day',
'call_type': 'rlad'}},
'data': [{'value': 0, 'date': '2022-01-01T00:00:00.000Z'}, ...]}}
Parameters details
kpi
Type of KPI | kpi value |
Obtained KPI | Usage |
---|---|---|---|
Request KPIs |
|
Number of API calls sent to Zelros |
RAD, LAD, RLAD |
|
Number of Documents found by Zelros within the files sent |
RLAD |
|
|
Number of Files sent to Zelros |
RLAD |
|
|
Number of Pages sent to Zelros |
RLAD |
|
|
Number of Documents found by Zelros within the files sent |
RAD, LAD, RLAD |
|
|
Number of Documents found by Zelros within the files sent |
RAD, LAD, RLAD |
|
|
Repart |
RAD, LAD, RLAD |
|
|
Repartition (%) of Documents found by Zelros within the files sent |
RAD, LAD, RLAD |
Type of KPI | kpi value |
Obtained KPI | Usage |
---|---|---|---|
Response KPIs |
|
Proportion of "Unrecognized field" within the documents sent |
LAD, RLAD |
|
Proportion of "Unrecognized field" within the documents sent (Aggregated) |
LAD, RLAD |
|
|
Proportion of documents with a technical error |
RAD,LAD, RLAD |
|
|
Proportion of documents with a technical error (Aggregated) |
RAD,LAD, RLAD |
|
|
Average time to analyze the docs (per Document type) |
RAD,LAD, RLAD |