Skip to main content

Retrieve data store data tutorial

In this tutorial, you will use the Varicent Incentives REST APIs to retrieve results from a specific data store in your model.

Prerequisites

  • You have created data stores. For more information on creating data stores, see Data stores.

  • You have run a full model calculation to make sure the results in the model are up-to-date.

  • You have obtained your Varicent API Key as outlined in REST API authentication and headers.

Overview

In this tutorial, we'll be using the following REST API calls to retrieve data:

Get data store list

This call gets the ID of the data store that contains the data that you want to retrieve.

Get data store data

This call gets the data from a data store.

Retrieving the data store ID

First, use the Varicent Incentives REST API call to retrieve a list of all the data stores.

  1. Make the following request:

    GET /api/v1/datastores

    For example,

    curl -X GET -H "Authorization: Bearer API_KEY" 
    -H "Model: YOUR_CLIENT_MODEL” 
    -H "Content-Type: application/json" 
    https://YOUR_ICM10_API_SERVER_ADDRESS/api/v1/datastores

    You can use the following parameters to filter the return response:

    Parameter

    Description

    filter

    The supported field is name (the data store name).

    The supported operations are:

    • Equal matching `name=admin`. This is strict and case-sensitive.

    • Starts with `name^admi`, or ends with `name$min`. This is case-insensitive.

    • Equal matching within a list, such as `userType=Admin\\,Web`. This is case-insensitive.

    • Interval matching, such as `date=[2015-09-22\\,2015-09-25]`, supports the mathematics notation for inclusive/exclusive bounds, `[a\\,b]`, `(a\\,b)`, or a mix `(a\\,b]`. Intervals also support open-ended bounds, `(a\\,]`.

    • Not equal matching `name<>admin`. This is strict and case-sensitive.

    • Is contained in `name⊇dmi`. This is case insensitive.

    • NULL checks, such as `name=NULL` or `name<>NULL`. Only equal and not equal operators are supported.

    You can use multiple filters on one attribute. The filter query also supports the use of an operator. Complete filter definitions, as described above, are expected on both sides of the operator. The column filtered must be the same on both sides of the operator. Supported operators are: AND `&&`, OR `||`.

    To define a filter on multiple attributes, separate each filter statement with `;`.

    The following is an example using the filter parameter:

    GET /api/v1/datastores?filter=name=
    All Payouts Prior to Adjs
  2. In the response body, find the data store containing the data that you want to retrieve, and note the ID.

    {
        "parentBlockId": 127,
        "id": 17,
        "name": "DataStore CRM Opps Top 10 by AE",
        "isFavorite": false
    },
    {
        "parentBlockId": 112,
        "id": 19,
        "name": "Adjustments to Commissions by Component",
        "isFavorite": false
    },
    {
        "parentBlockId": 112,
        "id": 20,
        "name": "All Payouts Prior to Adjs",
        "isFavorite": false
    },

Retrieving data store data

Next, use the ID obtained from the Get data store data call to retrieve the calculation data from Varicent Incentives.

  1. Make the following request:

    GET /api/v1/datastores/{datastoreid}/data

    For example,

    curl -X GET -H "Authorization: Bearer API_KEY" 
    -H "Model: YOUR_CLIENT_MODEL” 
    -H "Content-Type: application/json" 
    https://YOUR_ICM10_API_SERVER_ADDRESS/api/v1/datastores/20/data

    You can use the following parameters to filter the return response:

    Parameter

    Description

    offset

    Use this parameter with the limit parameter to return a group of records. By default, the offset is set to zero (0).

    For example,

    GET /api/v1/datastores/{datastoreid}/data

    will return the first group of 50 rows starting with the first row, and

    GET /api/v1/datastores/{datastoreid}/data?offset=1

    will return the next group of 50 rows.

    limit

    Use this parameter with the offset parameter to only return a group of records. By default, 50 rows are returned.

    For example,

    GET /api/v1/datastores/{datastoreid}/data?offset=0&limit=100

    will return the first 100 records and

    GET /api/v1/datastores/{datastoreid}/data?offset=1&limit=100

    will return the next 100 records.

    filter

    Supported fields are any columns in the data store.

    The supported operations are:

    • Equal matching `name=admin`. This is strict and case-sensitive.

    • Starts with `name^admi`, or ends with `name$min`. This is case-insensitive.

    • Equal matching within a list, such as `userType=Admin\\,Web`. This is case-insensitive.

    • Interval matching, such as `date=[2015-09-22\\,2015-09-25]`, supports the mathematics notation for inclusive/exclusive bounds, `[a\\,b]`, `(a\\,b)`, or a mix `(a\\,b]`. Intervals also support open-ended bounds, `(a\\,]`.

    • Not equal matching `name<>admin`. This is strict and case-sensitive.

    • Is contained in `name⊇dmi`. This is case insensitive.

    • NULL checks, such as `name=NULL` or `name<>NULL`. Only equal and not equal operators are supported.

    You can use multiple filters on one attribute. The filter query also supports the use of an operator. Complete filter definitions, as described above, are expected on both sides of the operator. The column filtered must be the same on both sides of the operator. Supported operators are: AND `&&`, OR `||`.

    To define a filter on multiple attributes, separate each filter statement with `;`.

    The following is an example using the filter parameter:

    GET /api/v1/datastores/{datastoreid}/data?filter=PayeeID_=AE001

    fields

    This parameter is used to limit the output results to selected columns. Use a comma delimited list of fields that you want to display. For example, fields=PayeeID_.

    Defaults to all available fields.

  2. In the response body, you will see the data store data.

    {
        "columnDefinitions": [
            {
                "name": "PayeeID",
                "type": "String",
                "isKey": true,
                "nullable": false
            },
            {
                "name": "AttributeID",
                "type": "String",
                "isKey": true,
                "nullable": false
            },
            {
                "name": "CompPlanID",
                "type": "String",
                "isKey": true,
                "nullable": false
            },
            {
                "name": "Periods",
                "type": "String",
                "isKey": true,
                "nullable": false
            },
            {
                "name": "Value",
                "type": "Decimal",
                "isKey": false,
                "nullable": false
            },
            {
                "name": "Description",
                "type": "String",
                "isKey": false,
                "nullable": false
            }
        ],
        "data": [
            [
                "AE001",
                "KPI PERIODIC PAYOUT [ACTUALS]",
                "AE",
                "2017-01 JAN",
                2214.597,
                "KPI - Strategic Product"
            ],
            [
                "AE001",
                "KPI PERIODIC PAYOUT [ACTUALS]",
                "AE",
                "2017-02 FEB",
                2286.102,
                "KPI - Strategic Product"
            ],