Analytics

Query Runs

The query runs object is a representation of all historical runs of a given SQL query. You can use this resource to retrive a list of all runs for a query.

Query Run object

Properties

id

required

string

token

required

string

raw_source

string

statement_annotation

string

state

required

string

created_at

required

string

completed_at

required

string

data_source_id

required

string

data_source_token

required

string

limit

required

string

query_token

required

string

query_name

required

string

query_created_at

required

string

dbt_metric_id

required

string

dbt_metric_token

string

parameters

required

string

rendered_source

string

max_result_bytes

required

string

help_url

string

error_code

string

error_type

string

error_message

string

_links

required

object

All resource responses contain a set of links that describe other related resources or actions that you can take on this resource. A link is comprised of two main pieces: its name (which describes its relationship to this resource) and its href (the URL of the related action or resource). All resources have at least a _self link which is the URL that will return a representation of this resource.

  • executed_by
  • query
  • query_web
  • report_run
  • report_run_web
  • result
  • result_web
  • self
  • view
{
  "id": 1312,
  "token": "f23owhgklkj",
  "state": "ipsum in laboris cillum sed",
  "created_at": "YYYY-MM-DDTHH:MM:SS.msZ",
  "completed_at": "YYYY-MM-DDTHH:MM:SS.msZ",
  "data_source_id": 42,
  "limit": "ad labore do voluptate est",
  "query_token": "fng3b2fjp",
  "parameters": "sed",
  "raw_source": "occaecat elit",
  "statement_annotation": "est sunt",
  "rendered_source": "magna ullamco Duis in culpa",
  "_links": {
    "self": {
      "href": "dolore non ea",
      "templated": false
    },
    "query": {
      "href": "Lorem velit",
      "templated": false
    },
    "result": {
      "href": "dolore deserunt",
      "templated": false
    },
    "result_web": {
      "href": "aute nostrud qui anim Ut",
      "templated": false
    },
    "query_web": {
      "href": "eu veni",
      "templated": false
    },
    "report_run": {
      "href": "culpa ea proident Ut",
      "templated": false
    },
    "report_run_web": {
      "href": "officia ipsum in nisi",
      "templated": false
    },
    "executed_by": {
      "href": "voluptate consequat cupidatat dolore in",
      "templated": false
    }
  },
  "_embedded": {}
}

Get a query run

URL Params

account

required
string Account (Workspace or User) username

report

required
string Report token

run

required
string ReportRun token

query_run

required
string Query Run token
Responses

200

Query Runresponse

401

Unauthorized

404

ReportRun not found

GET /{account}/reports/{report}/runs/{run}/query_runs/{query_run}

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://app.mode.com/api/{account}/reports/{report}/runs/{run}/query_runs/{query_run}'
require 'http'

username = 'your_api_key'
password = 'your_api_secret'

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .get('https://app.mode.com/api/{account}/reports/{report}/runs/{run}/query_runs/{query_run}')
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://app.mode.com/api/{account}/reports/{report}/runs/{run}/query_runs/{query_run}', headers=headers)

response_body = urlopen(request).read()
print(response_body)
var request = require('request');

request({
  method: 'GET',
  url: 'https://app.mode.com/api/{account}/reports/{report}/runs/{run}/query_runs/{query_run}',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  }}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});

List query runs

To return a list of all the query runs for a given Report, send a GET request to the runs resource.

URL Params

account

required
string Account (Workspace or User) username

report

required
string Report token

run

required
string ReportRun token
Responses

200

QueryRun collection response

401

Unauthorized

404

ReportRun not found

GET /{account}/reports/{report}/runs/{run}/query_runs

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://app.mode.com/api/{account}/reports/{report}/runs/{run}/query_runs'
require 'http'

username = 'your_api_key'
password = 'your_api_secret'

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .get('https://app.mode.com/api/{account}/reports/{report}/runs/{run}/query_runs')
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://app.mode.com/api/{account}/reports/{report}/runs/{run}/query_runs', headers=headers)

response_body = urlopen(request).read()
print(response_body)
var request = require('request');

request({
  method: 'GET',
  url: 'https://app.mode.com/api/{account}/reports/{report}/runs/{run}/query_runs',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  }}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});