Data Query API Overview

Learn more about the Data Query API.

Overview

The Data Query API allows you to retrieve data from Visier in aggregate or list form:

  • Aggregate: This aggregates data for a single object in Visier, usually across time. For example, you can perform a single aggregation to retrieve your organization's headcount over the last 12 months grouped by Location and filtered by Organization.
  • List: This returns a list of values for objects at a specific time. The values are not aggregated. For example, you can perform a list query to retrieve the names of the female employees in your organization at a specific time.

Tip:  

If you use Visier to visualize your data, the above actions have a direct correlation to the interface you see in the solution experience, including the Explore room and the Detailed View visual. The following examples illustrate this relationship.

API comparison to Explore and Detailed View

The below image shows a Breakdown of Headcount by Job Pay Level, filtered to Female employees for July 2020 to September 2020.

You can retrieve the data shown in the above image using the Data Query API aggregate action. The components in the image correspond to API as follows. For more information, see "Data Query" in API Reference.

  1. Metric picker: The metric that you're retrieving data for. In this example, the parameters are:

    Copy
    "source": {
            "metric": "employeeCount"
    }
  2. Group By picker: The selection concepts or dimensions that you want to group the data by. In this example, the parameters are:

    Copy
    "axes": [
          {
            "dimensionMemberSelection": {
              "dimension": {
                "name": "Pay_Level",
                "qualifyingPath": "Employee"
              },
              "members": [
                { "path": ["Low"] },
                { "path": ["High"] }
             ]
          }
       }
    ]
  3. Time picker: The time during which the data is valid. In this example, the parameters are:

    Copy
    "timeIntervals": {
          "fromDateTime": "2020-10-01",
          "intervalPeriodType": "MONTH",
          "intervalCount": 3
    }

    Note: If defining timeInterval in a list query or timeIntervals in an aggregate or snapshot query, the direction value impacts the meaning of the defined time value (fromDateTime and fromInstant).

    • When the direction is BACKWARD, the specified time value is excluded.
      • Events that occur on the specified date are excluded.
      • If the data is subject-based, data that ends on the specified date is included because the ending event is excluded.
    • When the direction is FORWARD, the specified time value is included.

    The default direction is BACKWARD. This means the platform queries backwards from the specified time. You can define direction: FORWARD to query forwards from the specified time.

    For aggregate query results, Visier returns the technical member name for time; for example, 2019-06-01T00:00:00.000Z - [0]. You can request "options": { "memberDisplayMode": "DISPLAY" } for aggregate queries to return time members with a display name matching the caller's locale; for example, May 31, 2019.

  4. Filter picker: The values to include or exclude from the data. In this example, the parameters are:

    Copy
    "filters": [
          {
            "selectionConcept": {
              "name": "isFemale",
              "qualifyingPath": "Employee"
          }
       }
    ]
  5. Group: The groups that the data members belong to, as defined by the group by. In this example, the parameters are:

    Copy
    "axes": [
          {
            "dimensionMemberSelection": {
              "dimension": {
                "name": "Pay_Level",
                "qualifyingPath": "Employee"
              },
              "members": [
                { "path": ["Low"] },
                { "path": ["High"] }
             ]
          }
       }
    ]
  6. Value: The aggregated value for the query returned by the response.

The next image shows the Detailed View information for the Headcount of female employees for September 2020.

You can retrieve the data shown in the above image using the Data Query API list action. The components in the image correspond to the API as follows:

  1. Detailed View: The underlying set of subject members or event occurrences that make up a given population. For more information, see "Query a list of details" in API Reference. In this example, the request URL is: POST https://jupiter.api.visier.io/v1/data/query/list.
  2. Subject: The subject associated with the metric. In this example, the parameters are:

    Copy
    "source": {
            "metric": "employeeCount"
    }
  3. Time picker: The time during which the data is valid. In this example, the parameters are:

    Copy
    "timeIntervals": {
          "fromDateTime": "2020-10-01",
          "intervalPeriodType": "MONTH",
          "intervalCount": 1
    }

    Note: If defining timeInterval in a list query or timeIntervals in an aggregate or snapshot query, the direction value impacts the meaning of the defined time value (fromDateTime and fromInstant).

    • When the direction is BACKWARD, the specified time value is excluded.
      • Events that occur on the specified date are excluded.
      • If the data is subject-based, data that ends on the specified date is included because the ending event is excluded.
    • When the direction is FORWARD, the specified time value is included.

    The default direction is BACKWARD. This means the platform queries backwards from the specified time. You can define direction: FORWARD to query forwards from the specified time.

    For aggregate query results, Visier returns the technical member name for time; for example, 2019-06-01T00:00:00.000Z - [0]. You can request "options": { "memberDisplayMode": "DISPLAY" } for aggregate queries to return time members with a display name matching the caller's locale; for example, May 31, 2019.

  4. Filter: The values to include or exclude from the data. In this example, the parameters are:

    Copy
    "filters": [
          {
            "selectionConcept": {
              "name": "isFemale",
              "qualifyingPath": "Employee"
          }
       }
    ]
  5. Value: The list of values returned by the response.

Find available objects to use in an API request

To use a specific object in an API request, you must know the unique identifier of the object. For example:

  • To query the pay levels of your employees, you must know the Pay Level dimension's ID.
  • To commit a project, you must know the project ID.
  • To check an extraction job's status, you must know the dispatching job ID.

Use APIs to retrieve unique identifiers for available objects. For example, retrieve all dimensions to find the ID of Pay Level.

Example: I want to retrieve Customer Support and Dev Operations employees by pay level

Let's say you want to query the Headcount metric filtered by Function employees and grouped by Pay Level. This query involves several objects:

  • Metric: Headcount
  • Analytic object: Employee
  • Dimensions: Function, Pay Level
  • Dimension members: Function: Customer Support, Dev Operations and Pay Level: Pay Level.

To make an API request, you need the unique IDs of the metric, analytic object, and dimensions, and the paths of the dimension members.

Find metrics

First, you need to know the unique ID of Headcount. Headcount is a metric, so you'll retrieve all metrics.

Copy
Find available metrics
curl -X GET --url 'https://{vanity_name}.api.visier.io/v1/data/model/metrics' \
-H 'apikey:{api_key}'
-H 'Cookie:VisierASIDToken={security_token}'

The response returns all the metrics in your tenant. As shown in the sample response, the id for Headcount is employeeCount.

Find analytic objects and dimensions

In this example, the IDs are the same as the display names. That is, the unique IDs are Employee, Function, and Pay_Level. However, sometimes IDs are less obvious. If you don't know the IDs, call these endpoints:

  • Retrieve analytic objects: GET /v1/data/model/analytic-objects. This returns the subjects, events, and overlays in your tenant, such as Employee.
  • Retrieve dimensions:  GET /v1/data/model/analytic-objects/Employee/dimensions. This returns the Employee dimensions in your tenant, such as Function and Pay Level.

The responses are similar to the metrics response above. In the response body, find the id field.

Find dimension members

Next, find the dimension members to filter and group by in the API request. Because there are two dimensions, you have to make two requests.

Copy
Find Function dimension members
curl -X GET --url 'https://{vanity_name}.api.visier.io/v1/data/model/analytic-objects/Employee/dimensions/Function/members' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}'

The path to Function dimension members are identified in the path field, as shown in the following response.

Because you want to group by all pay levels, not specific pay levels, you can retrieve the dimension information of Pay Level to retrieve the overall level that contains all pay levels.

Copy
Find Pay Level dimension information
curl -X GET --url 'https://{vanity_name}.api.visier.io/v1/data/model/analytic-objects/Employee/dimensions/Pay_Level' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}'

The response returns the levels Level 0 and Job Pay Level. In this example, Job Pay Level is the level to query.

Write the Data Query API request

Finally, put it all together. To craft the Data Query API request, use the IDs, members, and levels to specify the exact conditions of your query.

Copy
Query Headcount filtered by Dev Operations and Customer Support and grouped by Pay Level
curl -X POST --url 'https://{vanity_name}.api.visier.io/v1/data/query/aggregate' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
-d '{   
    "query": {
        "source": {
            "metric": "employeeCount"
        },
        "timeIntervals": {
            "intervalCount": 3,
            "dynamicDateFrom": "SOURCE"
        },
        "filters": [{
            "memberSet": {
                "dimension": {
                    "name": "Function",
                    "qualifyingPath": "Employee"
                },
                "values": {
                    "included": [{
                        "path": ["Dev Operations"]
                    },{
                        "path": ["Customer Support"]
                    }]
                }
            }
        }],
        "axes": [
            {
                "dimensionLevelSelection": {
                    "dimension": {
                        "name": "Pay_Level",
                        "qualifyingPath": "Employee"
                    },
                    "levelIds": [
                        "Pay_Level"
                    ]
                }
            }
        ]
    }
}'

The response returns the Headcount values for each Pay Level.