Analytics

Report Runs

Every time a report is run, a full copy of the report with all its components is saved. Each report run is saved as a separate URL and it is possible to see a complete history of all the runs for any given report in Mode.

You can use the runs resource to trigger a new run of a report or retrieve history of all runs for a single report.

Report Run object

Properties

token

required

string

state

required

string

enum: pending enqueued cancelled failed succeeded completed running_notebook

parameters

required

created_at

required

string

updated_at

required

string

completed_at

required

string

purge_started_at

required

string

purge_completed_at

required

string

python_state

required

string

enum: none pending failed submitted succeeded

form_fields

required

array

_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.

  • account
  • clone
  • content
  • embed
  • executed_by
  • pdf_export
  • preview
  • python_cell_runs
  • query_runs
  • report
  • report_schedule
  • self
  • share
  • web_clone
  • web_external_url
{
  "token": "f2lkg3hwjj9",
  "state": "enqueued",
  "parameters": {},
  "created_at": "YYYY-MM-DDTHH:MM:SS.msZ",
  "updated_at": "YYYY-MM-DDTHH:MM:SS.msZ",
  "completed_at": "YYYY-MM-DDTHH:MM:SS.msZ",
  "purge_started_at": "YYYY-MM-DDTHH:MM:SS.msZ",
  "purge_completed_at": "YYYY-MM-DDTHH:MM:SS.msZ",
  "python_state": "none",
  "form_fields": [],
  "_links": {
    "self": {
      "href": "occaecat eiusmod",
      "templated": false
    },
    "preview": {
      "href": "nisi veniam",
      "templated": false
    },
    "account": {
      "href": "in culpa Duis sit Ut",
      "templated": false
    },
    "report_schedule": {
      "href": "aliqua d",
      "templated": false
    },
    "executed_by": {
      "href": "ut",
      "templated": false
    },
    "report": {
      "href": "ad nulla",
      "templated": false
    },
    "clone": {
      "href": "fugiat velit est ex commodo",
      "templated": false
    },
    "query_runs": {
      "href": "minim deserunt",
      "templated": false
    },
    "python_cell_runs": {
      "href": "eu Lorem en",
      "templated": false
    },
    "pdf_export": {
      "href": "tempor",
      "templated": false
    },
    "content": {
      "href": "eiusmod ipsum consectetur magna",
      "templated": false
    },
    "share": {
      "href": "",
      "templated": false
    },
    "embed": {
      "href": "adipisicing ullamco ",
      "templated": false
    },
    "web_clone": {
      "href": "elit",
      "templated": false
    },
    "web_external_url": {
      "href": "anim irure fugiat qui",
      "templated": false
    }
  },
  "_embedded": {}
}

Get a report run

To retrieve a representation of a report run, send a POST request to the runs resource.

URL Params

account

required
string Account (Organization or User) username

report

required
string Report token

run

required
string ReportRun token
Responses

200

ReportRun response

401

Unauthorized

404

ReportRun not found

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

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

username = 'you_api_key'
password = 'you_api_secret'

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

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

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

response_body = urlopen(request).read()
print(response_body)
var request = new XMLHttpRequest();

request.open('GET', 'https://modeanalytics.com/api/{account}/reports/{report}/runs');

request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Accept', 'application/hal+json');

request.onreadystatechange = function () {
  if (this.readyState === 4) {
    console.log('Status:', this.status);
    console.log('Headers:', this.getAllResponseHeaders());
    console.log('Body:', this.responseText);
  }
};

request.send();

List report runs

To get a list of all runs for a given report, send a GET request to the runs resource.

URL Params

account

required
string Account (Organization or User) username

report

required
string Report token
Responses

200

ReportRun collection response

401

Unauthorized

404

Report not found

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

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

username = 'you_api_key'
password = 'you_api_secret'

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

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

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

response_body = urlopen(request).read()
print(response_body)
var request = new XMLHttpRequest();

request.open('GET', 'https://modeanalytics.com/api/{account}/reports/{report}/runs');

request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Accept', 'application/hal+json');

request.onreadystatechange = function () {
  if (this.readyState === 4) {
    console.log('Status:', this.status);
    console.log('Headers:', this.getAllResponseHeaders());
    console.log('Body:', this.responseText);
  }
};

request.send();

Clone a report run

To clone a report run, send a POST request to the reports resource at clone, and specify the report run token.

URL Params

account

required
string Account (Organization or User) username

report

required
string Report token

run

required
string ReportRun token
Responses

200

Report response

400

Bad request

401

Unauthorized

404

ReportRun not found

POST /{account}/reports/{report}/runs/{run}/clone

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

username = 'you_api_key'
password = 'you_api_secret'

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

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

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

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

request({
  method: 'POST',
  url: 'https://modeanalytics.com/api/{account}/reports/{report}/runs/{run}/clone',
  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);
});

Create a report run

To trigger a report run, send a POST request to the runs resource, specifying the report token. This call returns a representation of the resulting report run.

URL Params

account

required
string Account (Organization or User) username

report

required
string Report token
POST Body Params

Object: parameters

parameters

Custom parameter attributes
Responses

200

ReportRun response

400

Bad request

401

Unauthorized

404

Report not found

POST /{account}/reports/{report}/runs

curl --include \
     --request POST \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
     --data-binary "{
  \"parameters\": {
    \"user_id\": 123,
    \"location\": \"San Francisco\"
  }
}" \
'https://modeanalytics.com/api/{account}/reports/{report}/runs'
require 'http'

values = {
  parameters: {
    user_id: 123,
    location: 'San Francisco'
  }
}

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

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .post('https://modeanalytics.com/api/{account}/reports/{report}/runs', json: values)
puts response
from urllib2 import Request, urlopen

values = """
  {
    "parameters": {
      "user_id": 123,
      "location": "San Francisco"
    }
  }
"""

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

response_body = urlopen(request).read()
print(response_body)
var request = new XMLHttpRequest();

request.open('POST', 'https://modeanalytics.com/api/{account}/reports/{report}/runs');

request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Accept', 'application/hal+json');

request.onreadystatechange = function () {
  if (this.readyState === 4) {
    console.log('Status:', this.status);
    console.log('Headers:', this.getAllResponseHeaders());
    console.log('Body:', this.responseText);
  }
};

var body = {
  'parameters': {
    'user_id': 123,
    'location': 'San Francisco'
  }
};

request.send(JSON.stringify(body));