V-Spark Online Help

Using the /stats API with cURL

This section discusses how to use the /stats API to retrieve high-level folder statistics information from a specified V‑Spark installation.

If you are unfamiliar with the cURL command, see Using cURL for REST API Testing for a short introduction and an explanation of how cURL examples are displayed. See Tips for Debugging and Managing cURL Calls for suggestions about how to debug and manage cURL calls.

An example of a cURL command to retrieve daily stats information from September 25, 2017 (20170925) from the company "DocTestCo", organization "DocTestCo-DocTesting", folder "Test01" on the host example.company.com is the following:

curl -s 'http://example.company.com/stats/DocTestCo/DocTestCo-DocTesting/Test01 \
    ?token=01234567890123456789012345678901&daterange=20170925'

To produce this output in a more human-legible format, and write that output to the file stats.json, you could execute a command like the following:

curl -s 'http://example.company.com/stats/DocTestCo/DocTestCo-DocTesting/Test01 \
    ?token=012345678901234567890123456789012&daterange=20170605' | \
        python -m json.tool > stats.json      

Tip

The json.tool module that is provided by Python sorts keys in JSON output alphabetically. If you want to reformat JSON output to make it more legible without reorganizing key values, consider using the Python command jsonlint. This command includes JSON reformatting along with JSON validation and other capabilities, and is provided as part of the python-demjson-2.2.2-1.el7.noarch package on CentOS 7 systems.

Example output from the previous command would look something like the following:

[
    {
        "date": "20170925",
        "calls": 5,
        "avgduration": "0:09:52",
        "avgsilence": "0:04:12",
        "avgwords": 1256.6,
        "agent": {
            "avgcalls": "1.7",
            "talk": {
                "avg": "0:02:57",
                "min": {
                    "id": "004",
                    "duration": "0:00:32"
                },
                "max": {
                    "id": "002",
                    "duration": "0:09:24"
                }
            },
            "emotion": {
                "positive": 3,
                "worsening": 0,
                "negative": 2,
                "improving": 0
            }
        },
        "client": {
            "talk": {
                "avg": "0:02:43"
            },
            "emotion": {
                "positive": 1,
                "worsening": 0,
                "negative": 3,
                "improving": 1
            }
        }
    }
]