V-Spark Online Help

Using the /appstats API with Python

The same Python example that was provided for calling the /stats API, Using the /stats API with Python, can also be used to call the /appstats API. This generic Python application can be used to call any V‑Spark API. While you will probably want to develop more specialized Python applications to use specific V‑Spark APIs directly, the sample code shows the basic mechanisms that make it easy to interact with the /appstats API from Python.

The sample application linked previously enables you to specify both the API that you want to call and the parameters that you want to provide as arguments to the Python code. In this case, the parameters are the daterange that you want to retrieve statistics for and other refinements on matching output, based on the application that is specified as the previous argument.

The following is an example of executing this application:

statistics-get-info.py HOSTTOKEN \
    /appstats/DocTestCo/DocTestCo-DocTesting/Clone%20Test%2001 \
    daterange=20170901-20171015      

This call to the example function would retrieve statistics about activity for the application Clone Test 01 that is associated with folders within the company and organization DocTestCo/DocTestCo-DocTesting, for the date range 20170901-20171011.

Sample output from this call would look like the following:

[
    {
        "105": {
            "Communication Skills": {
                "coverage": "0.5250",
                "duration": "0:05:25",
                "hitmiss": "1.0000",
                "ncalls": 2,
                "silence": "0:02:19"
            },
            "Communication Skills.Ask for Call Reason": {
                "coverage": "1.0000",
                "duration": "0:05:25",
                "hitmiss": "1.0000",
                "ncalls": 2,
                "silence": "0:02:19"
            },
            "Communication Skills.Client Informed": {
                "coverage": "1.0000",
                "duration": "0:05:25",
                "hitmiss": "1.0000",
                "ncalls": 2,
                "silence": "0:02:19"
            },
            "Communication Skills.Client Informed.Agent Actions": {
                "coverage": "1.0000",
                "duration": "0:05:25",
                "hitmiss": "1.0000",
                "ncalls": 2,
                "silence": "0:02:19"
            }, ...
        },
        "agents": 1,
        "date": "20171002"
    },...
]

To see how to call the /appstats API, retrieve the output from a call to the API, and write the JSON output to a file, see the sample Python code that is provided in Using the /stats API with Python. The core functionality of the primary steps in this sample application are explained after the sample code is presented.