Data Model API Code Samples
Selection of code samples that demonstrate the use of the Data Model API. 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
These code samples may not include all available parameters and request body fields for each endpoint. For the endpoint's full request schema, see "Data Model" in API Reference.
Note: Each data model is unique to each Visier tenant, depending on purchased applications and any custom objects. The objects in the response are retrieved from the tenant specified by the tenant name in the request.
Retrieve a list of metrics
This sample request retrieves information about all the metrics in your Visier solution.
curl -X GET --url 'https://{vanity_name}.api.visier.io/v1/data/model/metrics' \
-H 'apikey:{api_key}'
-H 'Cookie:VisierASIDToken={security_token}'
{
"metrics": [
{
"id": "employeeCount",
"displayName": "Headcount",
"description": "The number of employees in the organization.",
"dataStartDate": "1522627200000",
"dataEndDate": "1604102400000",
"analyticObject": "Employee",
"parameters": []
},
{
"id": "employeeTenureAverage",
"displayName": "Tenure",
"description": "The time in years that employees have worked for the organization.",
"dataStartDate": "1522627200000",
"dataEndDate": "1604102400000",
"analyticObject": "Employee",
"parameters": []
}
]
}
Retrieve all currencies
This sample request retrieves information about all currencies in your Visier solution.
cURL sample request: Retrieve a list of all currencies
curl -X GET --url 'https://{vanity_name}.api.visier.io/v1/data/model/currencies' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}'
{
"currencyCode": "USD",
"displayName": "US Dollar",
"symbol": "$",
"shortSymbol": "$"
}
Retrieve a currency
This sample request retrieves information for the USD currency.
cURL sample request: Retrieve a specific currency
curl -X GET --url 'https://{vanity_name}.api.visier.io/v1/data/model/currencies/USD' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}'
{
"currencyCode": "USD",
"displayName": "US Dollar",
"symbol": "$",
"shortSymbol": "$"
}
Retrieve all exchange rates for a currency
This sample request retrieves all the available exchange rates for USD currency for a specific time period.
cURL sample request: Retrieve all exchange rates for a currency
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}'
{
"currencyRates": [
{
"fromCurrencyCode": "CAD",
"toCurrencyCode": "USD",
"rate": 0.84,
"startTime": "1677628800000",
"endTime": "1680546444000"
},
{
"fromCurrencyCode": "CAD",
"toCurrencyCode": "BRL",
"rate": 2.4,
"startTime": "1677628800000",
"endTime": "1680546444000"
},
{
"fromCurrencyCode": "CAD",
"toCurrencyCode": "AUD",
"rate": 1.04,
"startTime": "1677628800000",
"endTime": "1680546444000"
}
]
}
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.
cURL sample request: Retrieve exchange rates from one currency to another currency
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}'
Update properties
This sample request updates the display name, short display name, and description of a property in a project. To publish the update to production immediately, omit the projectId parameter.
curl -X PATCH --url 'https://{vanity_name}.api.visier.io/v1/data/model/properties' \
-H 'Content-Type: application/json' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-d '{
"propertiesByTenant": [
{
"projectId": "da808a8e-76e1-4094-a288-5e2755388bbd",
"properties": [
{
"id": "Employee.Birth_Date",
"displayName": "New Birth Date",
"shortDisplayName": "Birthday",
"description": "Day employee was born"
}
]
}
]
}'
The response returns the successful or unsuccessful property updates.
{
"successes": [
{
"id": "Employee.Birth_Date",
"displayName": "New Birth Date",
"tenantCode": "WFF_j1r"
}
],
"failures": []
}
Update dimensions
This sample request updates the display name, short display name, and description of a dimension in a project. To publish the update to production immediately, omit the projectId parameter.
curl -X PATCH --url 'https://{vanity_name}.api.visier.io/v1/data/model/dimensions' \
-H 'Content-Type: application/json' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-d '{
"dimensionsByTenant": [
{
"projectId": "da808a8e-76e1-4094-a288-5e2755388bbd",
"dimensions": [
{
"id": "Employee.Vaccination_Status",
"displayName": "COVID-19 Vaccine Status",
"shortDisplayName": "COVID Vacc",
"description": "Employee has received one or more dose of COVID-19 vaccine"
}
]
}
]
}'
The response returns the successful or unsuccessful dimension updates.
{
"successes": [
{
"id": "Employee.Vaccination_Status",
"displayName": "COVID-19 Vaccine Status",
"tenantCode": "WFF_j1r"
}
],
"failures": []
}