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

Profile
GET 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 or rlad (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

numberOfCall

Number of API calls sent to Zelros

RAD, LAD, RLAD

numberOfDoc

Number of Documents found by Zelros within the files sent

RLAD

numberOfFile

Number of Files sent to Zelros

RLAD

numberOfPage

Number of Pages sent to Zelros

RLAD

numberOfDocType

Number of Documents found by Zelros within the files sent
(per Document type)

RAD, LAD, RLAD

numberOfDocTypeAgg

Number of Documents found by Zelros within the files sent
(per Document type - Aggregated)

RAD, LAD, RLAD

proportionOfDocType

Repart

RAD, LAD, RLAD

proportionOfDocTypeAgg

Repartition (%) of Documents found by Zelros within the files sent
(per Document type - Aggregated)

RAD, LAD, RLAD

Type of KPI kpi value Obtained KPI Usage

Response KPIs

proportionOfErrorField

Proportion of "Unrecognized field" within the documents sent

LAD, RLAD

proportionOfErrorFieldAgg

Proportion of "Unrecognized field" within the documents sent (Aggregated)

LAD, RLAD

proportionOfErrorDoc

Proportion of documents with a technical error

RAD,LAD, RLAD

proportionOfErrorDocAgg

Proportion of documents with a technical error (Aggregated)

RAD,LAD, RLAD

timeToAnalyze

Average time to analyze the docs (per Document type)

RAD,LAD, RLAD

start_date & end_date

Those parameters need to be provided using the "YYYY-MM-DD" format

granularity

granularity Meaning

day

KPIs will be displayed on a daily basis

week

KPIs will be displayed on a weekly basis

month

KPIs will be displayed on a monthly basis

year

KPIs will be displayed on an annual basis