Code Samples

Selection of code samples that demonstrate the use of the Data Model and Data Query APIs. Copy and edit these code samples to suit your needs.

When using the code samples, remember to replace:

  • {vanity_name} with your tenant name
  • {api_key} with your API key
  • {security_token} with a valid security token

Basic aggregate query

Headcount query

This sample request retrieves 1 month of Headcount data up to January 1, 2021. It does not use any group bys or filters.

POST /v1/data/query/aggregate

Copy

cURL sample request with JSON body

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' \
--data '{   
    "query": {
        "source": {
            "metric": "employeeCount"
        },
        "timeIntervals": {
            "fromDateTime": "2021-01-01"
        }
    }
}'

POST /v1/data/query/sql

Copy
cURL sample request with SQL-like body
curl -X POST --url 'https://{vanity_name}.api.visier.io/v1/data/query/sql' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
--data '{
    "query": "SELECT employeeCount(), Visier_Time, level(Function, \"Function\") FROM Employee WHERE Visier_Time IN periods(date(\"2021-01-01\"), 1, period(1, Month)) AND Permanent IN (\"True\")"
}'

Aggregate query with filters

Headcount query filtered by Permanent employees

This sample request retrieves 1 month of data for Headcount filtered by Permanent employees up to January 1, 2021. The data is grouped by Function.

POST /v1/data/query/aggregate

Copy

cURL sample request with JSON body

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' \
--data '{   
    "query": {
        "source": {
            "metric": "employeeCount"
        },
        "timeIntervals": {
            "fromDateTime": "2021-01-01"
        },
        "filters": [{
            "memberSet": {
                "dimension": {
                    "name": "Permanent",
                    "qualifyingPath": "Employee"
                },
                "values": {
                    "included": [{
                        "path": ["True"]
                    }]
                }
            }
        }],
        "axes": [
            {
                "dimensionLevelSelection": {
                    "dimension": {
                        "name": "Function",
                        "qualifyingPath": "Employee"
                    },
                    "levelIds": [
                        "Function"
                    ]
                }
            }
        ]
    }
}'

POST /v1/data/query/sql

Copy
cURL sample request with SQL-like body
curl -X POST --url 'https://{vanity_name}.api.visier.io/v1/data/query/sql' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
--data '{
    "query": "SELECT employeeCount(), Visier_Time, level(Function, \"Function\") FROM Employee WHERE Visier_Time IN periods(date(\"2021-01-01\"), 1, period(1, Month)) AND Permanent IN (\"True\")"
}'

Aggregate queries with trailing time

Employee Exit Rate query with 2 months trailing time

This sample request retrieves 2 periods of Exit Rate. Each periods has 3 months trailing time up to January 1, 2021. It does not use any group bys or filters.

POST /v1/data/query/aggregate

Copy

cURL sample request with JSON body

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' \
--data '{   
    "query": {
        "source": {
            "metric": "Exit_Model.Rate.Exit"
        },
        "timeIntervals": {
            "fromDateTime": "2021-01-01",
            "intervalCount": 2,
            "trailingPeriodType": "MONTH",
            "trailingPeriodCount": 3
        }
    }
}'

Employee Exit Rate query with 6 months forward trailing time

This sample request retrieves 2 periods of Exit Rate. Each period has 6 months trailing time starting from January 1, 2021. It does not use any group bys or filters.

POST /v1/data/query/aggregate

Copy

cURL sample request with JSON body

cURL sample request with JSON bodycurl -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' \
--data '{   
    "query": {
        "source": {
            "metric": "Exit_Model.Rate.Exit"
        },
        "timeIntervals": {
            "fromDateTime": "2021-01-01",
            "intervalCount": 2,
            "direction": "FORWARD",
            "trailingPeriodType": "MONTH",
            "trailingPeriodCount": 6
        }
    }
}'

Headcount query filtered by Women employees

This sample request retrieves 1 month of data for Headcount filtered by Women employees up to January 1, 2021. It does not use a group by.

POST /v1/data/query/aggregate

Copy

cURL sample request with JSON body

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' \
--data '{   
    "query": {
        "source": {
            "metric": "employeeCount"
        },
        "timeIntervals": {
            "fromDateTime": "2021-01-01"
        },
        "filters": [{
            "selectionConcept": {
                "name": "isFemale",
                "qualifyingPath": "Employee"
            }
        }]
    }
}'

POST /v1/data/query/sql

Copy
cURL sample request with SQL-like body
curl -X POST --url 'https://{vanity_name}.api.visier.io/v1/data/query/sql' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
--data '{
    "query": "SELECT employeeCount(), Visier_Time FROM Employee WHERE Visier_Time IN periods(date(\"2021-01-01\"), 1, period(1, Month)) AND isFemale = TRUE"
}'

Headcount query filtered by Direct Manager

This sample request retrieves 1 months of data for Headcount filtered by Direct Manager up to January 1, 2021. It does not use any group bys.

POST /v1/data/query/aggregate

Copy

cURL sample request with JSON body

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' \
--data '{   
    "query": {
        "source": {
            "metric": "employeeCount"
        },
        "timeIntervals": {
            "fromDateTime": "2021-01-01"
        },
        "filters": [{
            "memberSet": {
                "dimension": {
                    "name": "Permanent",
                    "qualifyingPath": "Employee.Direct_Manager"
                },
                "values": {
                    "included": [{
                        "path": ["True"]
                    }]
                }
            }
        }]
    }
}'

POST /v1/data/query/sql

Copy
cURL sample request with SQL-like body
curl -X POST --url 'https://{vanity_name}.api.visier.io/v1/data/query/sql' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
--data '{
    "query": "SELECT employeeCount(), Visier_Time FROM Employee WHERE Visier_Time IN periods(date(\"2021-01-01\"), 1, period(1, Month)) AND Direct_Manager.Permanent IN (\"True\")"
}'

Aggregate query for multiple periods

Headcount query for 4 time periods

This sample request retrieves 4 quarters of data for Headcount up to January 1, 2021. It does not use any group bys or filters.

POST /v1/data/query/aggregate

Copy

cURL sample request with JSON body

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' \
--data '{   
    "query": {
        "source": {
            "metric": "employeeCount"
        },
        "timeIntervals": {
            "fromDateTime": "2021-01-01",
            "intervalPeriodType": "QUARTER",
            "intervalCount": 4
        }
    }
}`

POST /v1/data/query/sql

Copy
cURL sample request with SQL-like body
curl -X POST --url 'https://{vanity_name}.api.visier.io/v1/data/query/sql' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
--data '{
    "query": "SELECT employeeCount(), Visier_Time FROM Employee WHERE Visier_Time IN periods(date(\"2021-01-01\"), 4, period(1, Quarter))"
}'

Aggregate query with groupings

Headcount query grouped by Job Function and Pay Level

This sample request retrieves 1 months of data for Headcount grouped by Job Function and Pay Level up to January 1, 2021.

POST /v1/data/query/aggregate

Copy

cURL sample request with JSON body

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' \
--data '{   
    "query": {
        "source": {
            "metric": "employeeCount"
        },
        "timeIntervals": {
            "fromDateTime": "2021-01-01"
        },
        "axes": [{
            "dimensionLevelSelection": {
                "dimension": {
                    "name": "Function",
                    "qualifyingPath": "Employee"
                },
                "levelIds": [
                    "Function"
                ]
            }
        }, {
            "dimensionLevelSelection": {
                "dimension": {
                    "name": "Pay_Level",
                    "qualifyingPath": "Employee"
                },
                "levelIds": [
                    "Pay_Level"
                ]
            }
        }]
    }
}'

POST /v1/data/query/sql

Copy
cURL sample request with SQL-like body
curl -X POST --url 'https://{vanity_name}.api.visier.io/v1/data/query/sql' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
--data '{
    "query": "SELECT employeeCount(), Visier_Time, level(Function, \"Function\"), level(Pay_Level, \"Pay_Level\") FROM Employee WHERE Visier_Time IN periods(date(\"2021-01-01\"), 1, period(1, Month))"
}'

Aggregate query with parameters

Days Worked Over Maximum Consecutive Limit query with the Maximum Consecutive Working Days Limit parameter set to 1

This sample request retrieves 4 intervals each containing 3 months of data for Days Worked Over Maximum Consecutive Limit up to January 1, 2021 with the Maximum Consecutive Working Days Limit parameter set to 1. Some metrics use parameters (dynamic values) in their formulas that allow you to change how the metric is calculated. In this example, you can change the parameter to set the maximum number of consecutive days an employee is able to work. Working streaks that exceed this limit during the period will be included in the calculation. It does not use any group bys or filters.

POST /v1/data/query/aggregate

Copy

JSON sample request body

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' \
--data '{   
    "query": {
        "source": {
            "metric": "daysWorkedOverMaxConsecutiveLimit"
        },
        "parameterValues": [{
            "numericValue": {
                "parameterId": "daysWorkedOverMaxConsecutiveLimit.Max_Consecutive_Working_Days_Limit_Parameter",
                "value": 1
            }
        }],
        "timeIntervals": {
            "fromDateTime": "2021-01-01",
            "intervalPeriodCount": 3,
            "intervalCount": 4
        }
    }
}'

POST /v1/data/query/sql

Copy
cURL sample request with SQL-like body
curl -X POST --url 'https://{vanity_name}.api.visier.io/v1/data/query/sql' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
--data '{
    "query": "SELECT daysWorkedOverMaxConsecutiveLimit(Max_Consecutive_Working_Days_Limit_Parameter = 1), Visier_Time FROM Employee WHERE Visier_Time IN periods(date(\"2021-01-01\"), 4, period(3, Month))"
}'

Basic list query

List query for Employee first name, last name, and organization

This sample request retrieves 1 month of Employee data for the employees' first names, last names, and organizations. It does not use any group bys or filters.

POST /v1/data/query/list

Copy

cURL sample request with JSON body

curl -X POST --url 'https://{vanity_name}.api.visier.io/v1/data/query/list' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
--data '{   
    "source": {
        "analyticObject": "Employee"
    },
    "columns": [{
        "columnName": "First Name",
        "columnDefinition": {
            "property": {
                "name": "Employee.First_Name",
                "qualifyingPath": "Employee"
            }
        }
    }, {
        "columnName": "Last Name",
        "columnDefinition": {
            "property": {
                "name": "Employee.Last_Name",
                "qualifyingPath": "Employee"
            }
        }
    }, {
        "columnName": "Organization",
        "columnDefinition": {
            "dimension": {
                "name": "Organization_Hierarchy",
                "qualifyingPath": "Employee"
            }
        }
    }],
    "timeInterval": {
        "fromDateTime": "2021-01-01"
    }
}'

POST /v1/data/query/sql

Copy
cURL sample request with SQL-like body
curl -X POST --url 'https://{vanity_name}.api.visier.io/v1/data/query/sql' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
--data '
{
    "query": "SELECT Employee.First_Name, Employee.Last_Name, Organization_Hierarchy FROM Employee WHERE Visier_Time BETWEEN date(\"2020-12-01\") AND date(\"2021-01-01\")"
}`

List query with filters

List query for Employee first name, last name, and organization filtered by Woman

This sample request retrieves 1 month of women employees' first names, last names, and organizations. It does not use any group bys.

POST /v1/data/query/list

Copy

cURL sample request with JSON body

curl -X POST --url 'https://{vanity_name}.api.visier.io/v1/data/query/list' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
--data '{   
    "source": {
        "analyticObject": "Employee"
    },
    "filters": [{
        "selectionConcept": {
            "name": "isFemale",
            "qualifyingPath": "Employee"
        }
    }],
    "columns": [{
        "columnName": "First Name",
        "columnDefinition": {
            "property": {
                "name": "Employee.First_Name",
                "qualifyingPath": "Employee"
            }
        }
    }, {
        "columnName": "Last Name",
        "columnDefinition": {
            "property": {
                "name": "Employee.Last_Name",
                "qualifyingPath": "Employee"
            }
        }
    }, {
        "columnName": "Organization",
        "columnDefinition": {
            "dimension": {
                "name": "Organization_Hierarchy",
                "qualifyingPath": "Employee"
            }
        }
    }],
    "timeInterval": {
        "fromDateTime": "2021-01-01"
    }
}'

POST /v1/data/query/sql

Copy
cURL sample request with SQL-like body
curl -X POST --url 'https://{vanity_name}.api.visier.io/v1/data/query/sql' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
--data '{
    "query": "SELECT Employee.First_Name, Employee.Last_Name, Organization_Hierarchy FROM Employee WHERE Visier_Time BETWEEN date(\"2020-12-01\") AND date(\"2021-01-01\") AND isFemale = TRUE"
}'

List query for Employee first name, last name, and organization filtered by HR

This sample request retrieves 1 month of HR employees' first names, last names, and organizations. It does not use any group bys.

POST /v1/data/query/list

Copy

cURL sample request with JSON body

curl -X POST --url 'https://{vanity_name}.api.visier.io/v1/data/query/list' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
--data '{   
    "source": {
        "analyticObject": "Employee"
    },
    "filters": [{
          "formula": "include(Employee.Organization_Hierarchy, list(list(\"HR\")))"
    }],
    "columns": [{
        "columnName": "First Name",
        "columnDefinition": {
            "property": {
                "name": "Employee.First_Name",
                "qualifyingPath": "Employee"
            }
        }
    }, {
        "columnName": "Last Name",
        "columnDefinition": {
            "property": {
                "name": "Employee.Last_Name",
                "qualifyingPath": "Employee"
            }
        }
    }, {
        "columnName": "Organization",
        "columnDefinition": {
            "dimension": {
                "name": "Organization_Hierarchy",
                "qualifyingPath": "Employee"
            }
        }
    }],
    "timeInterval": {
        "fromDateTime": "2021-01-01"
    }
}'

Multi-value property list query

Multi-value property query for employee compensation items

This sample request retrieves 1 month of compensation items, the employee ID of the employee who is being compensated, the compensation type, and the compensation amount. It does not use any group bys or filters.

POST /v1/data/query/list

Copy

cURL sample request with JSON body

curl -X POST --url 'https://{vanity_name}.api.visier.io/v1/data/query/list' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
--data '{   
    "source": {
        "analyticObject": "Employee.Employee_Budgeted_Compensation"
    },
    "columns": [{
        "columnName": "Employee.Employee.EmployeeID",
        "columnDefinition": {
          "property": {
            "name": "Employee.EmployeeID",
            "qualifyingPath": "Employee"
          }
        }
      }, {
        "columnName": "compensationType",
        "columnDefinition": {
          "formula": "Compensation_Type"
        }
      },
      {
        "columnName": "compensationAmount",
        "columnDefinition": {
          "formula": "Employee_Budgeted_Compensation.Compensation_Amount"
        }
      }],
    "timeInterval": {
        "fromDateTime": "2021-01-01"
    }
}'

Currency queries

You can query the Visier model to retrieve information about currencies and exchange rates loaded in Visier.

Query for all currencies

This sample request retrieves information about all currencies in your Visier solution.

GET /v1/data/model/currencies

Copy

cURL sample request

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

Query for a specific currency

This sample request retrieves information for the USD currency.

GET /v1/data/model/currencies/USD

Copy

cURL sample request

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

Query all exchange rates for a currency

This sample request retrieves all the available exchange rates for USD currency for a specific time period.

GET /v1/data/model/currencies/USD/rates

Copy

cURL sample request

curl -X GET --url 'https://{vanity_name}.api.visier.io/v1/data/model/currencies/USD/rates?startTime=1677628800000&endTime=1680546444000' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}'

Retrieve exchange rates from one currency to another currency

This sample request retrieves all the available exchange rates from CAD to USD for a specific time period.

GET /v1/data/model/currencies/USD/rates

Copy

cURL sample request

curl -X GET --url 'https://{vanity_name}.api.visier.io/v1/data/model/currencies/CAD/rates/USD?startTime=1677626600000&endTime=1680546444000' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}'