Skip to content

Queries

Steve Greatrex edited this page Feb 19, 2015 · 3 revisions

The best way to get data out of EDGE10 is to use a query.

Getting Query Results

Once a query has been defined in EDGE10 the results are accessible through the API.

Note: these samples use API key authentication as described under Authentication.

Configuring a Query

Queries are set up in the Query Builder in EDGE10 Online and define the data you want to retrieve. These can include any one of the following 3 query types:

  1. Session Lists

    A list of sessions for one or more entities along with associated data

  2. Summaries

    Aggregated data over a period of time (e.g. average goals/game, maximum weight, etc.)

  3. Data Item Lists

    The values for a single data item over time for one or more entities

Query Parameters

Once a query has been configured and saved you can get the results through the API by specifying:

  • the query name
  • the entity or entities for whom to run the query
  • the date range over which to run the query

Running the Query

Queries are invoked by making a GET request to the API with the parameters specified in the query string

request({
    method: 'GET',
    url: config.siteUrl + '/api/query?entityType=AllSubjects&dateRangeType=CalendarYear&queryName=' + queryName,
     headers: {
        'X-ApiKey': apiKey
    },
    json: true
});

Query results

The query results are returned in the form of a table, with column, row and cell definitions

var results = {
  "columns": [
    { "header": "A Number" },
    { "header": "A Lookup" }
  ],
  "rows": [
    {
      "cells": [
        {
        "value": 123
        },
        {
          "lookupValues": [
            {
              "id": "ead94c47-c5f9-4e9a-bed8-2502daf500b1",
              "value": "Green",
              "index": 2,
              "score": 2
            }
          ]
        }
      ]
    }
  ]
};

Cell values are stored in either the value property of the cell or in the lookupValues array for a lookup type (whether single- or multi-lookup).

If you have run a session list query for multiple subjects, the results are returned as an array of tables - one table per subject.

Metadata

Depending on the type of the query, each element (the results table itself, each column, row and cell) will contain various items of metadata. These include (but are not limited to):

  • The contact ID (subject or user) to which the data applies
  • The session ID from which the data has been acquired
  • The ID of the attribute definition for the data
  • The ID of the aggregation definition for the data
  • The type of the data (numeric, text, boolean, etc.)
  • Whether or not the data is the result of a calculation
  • The traffic-light value of the data
  • etc.

These properties are accessible through the metadata property on each item which contains string-value pairs.

Samples

Clone this wiki locally