Skip to content

Stateless

This guide shows how to submit retail transaction data that needs to be analyzed, and then retrieve the analytics. An overview of all the endpoints with additional options and details can be found on the Endpoints page.

The difference between the stateless and statefull flow is that when using the stateless flow no information is stored and that no subject management is needed. Actions performed through the stateless flow are not reflected in the Navigator dashboard.

1. Authenticate

First you need to authenticate, as explained in Authentication. To get a JWT token you can use the command below:

1
2
3
curl -X POST 'https://navigator.riskquest.com/api/v1/auth/token/' \
  -H 'Content-Type: application/json' \
  -d'{"username":"<username>", "password":"<password>"}'

The response contains the access_token, this can be used to authenticate all other requests.

2. Create a task

The Navigator API uses a task queue to process incoming requests to calculate the analytics. create a new analysis you can upload one or more files (MT940, CSV or JSON) that contains transaction data using the following endpoint:

1
2
3
curl -X POST 'https://navigator.riskquest.com/api/v1/analytics/upload/retail' \
  -H 'Authorization: Bearer <access_token>' \
  -F 'files=@"<file_path>"'

The task_id that is returned can be used to retrieve the progress and eventually the result when the task is finished.

3. Check Progress

After a task is created the Navigator will start process the transaction data and the results are available shortly afterwards. To get the progress (and eventual result):

1
2
curl 'https://navigator.riskquest.com/api/v1/tasks/<task_id>/progress' \
  -H 'Authorization: Bearer <access_token>'

When a task is not yet finished the json is missing the result object. The output would look like:

1
2
3
4
5
6
{
    "progress": {
        "state": "PENDING",
        "percent": 25.3
    }
}

When the task is finished the json is slightly different in that the result object is now also provided. It contains the analytics dictionary as well as the transactions dictionary. The format of the analytics depends on the analytics type that was used during the file upload (retail,corporate). These can be found on the Endpoints page under the 'Schemas' section with the name RetailAnalytics or CorporateAnalytics.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{
    "progress": {
        "state": "SUCCESS",
        "percent": 100.0
    },
    "result": {
      "analytics": {
        ...
        },
      "transactions": {
        ...
        }
    }
}

All the different progress states can be found in the schema TaskProgress. Additionally, below is an overview of the different states that we provide.

Progress state Description
FAILURE The task failed
PENDING Unknown task state or task id
PROGRESS The task is being executed
SUCCESS The task succesfully finished