Analytics

Report Filters

Report filters let Mode users limit their view of a given report’s results set, so that charts and visualizations only reflect selected segments of the data.

You can use the filters resource to create or update filters for a report, or to get a list of available filters for a given report.

Report Filter object

Properties

id

required

integer

report_id

required

integer

token

required

string

name

required

string

row_order

required

integer

formula

required

string

data_type

required

string

formula_type

required

string

filter_type

required

string

enum: SINGLE MULTI RANGE

control_type

required

string

enum: LIST DROPDOWN RANGE

variable_type

required

string

enum: CONTINUOUS DISCRETE

options

required

created_at

required

string

updated_at

required

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.

  • report
  • self
  "id": 38242190,
  "report_id": 35790368,
  "token": "f3ngbo2pi31fne",
  "name": "sed cill",
  "row_order": 44464508,
  "formula": "dolore officia nulla ut nostrud",
  "data_type": "labore",
  "formula_type": "elit eiusmod dolor",
  "filter_type": "SINGLE",
  "control_type": "LIST",
  "variable_type": "DISCRETE",
  "options": {},
  "created_at": "YYYY-MM-DDTHH:MM:SS.msZ",
  "updated_at": "YYYY-MM-DDTHH:MM:SS.msZ",
  {
    "_links": {
      "self": {
        "href": "anim",
        "templated": false
      },
      "report": {
        "href": "incididunt occaecat nisi ",
        "templated": false
      }
    },
  "_embedded": {}
}

Get a report filter

To retrieve information about a single filter, send a GET request including the corresponding report and filter tokens to the filters resource.

URL Params

account

required
string Account (Organization or User) username

report

required
string Report token

filter

required
string ReportFilter token
Responses

200

ReportFilter response

400

Bad request

401

Unauthorized

404

ReportFilter not found

GET /{account}/reports/{report}/filters/{filter}

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://modeanalytics.com/api/{account}/reports/{report}/filters/{filter}'
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}/filters/{filter}')
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}/filters/{filter}', headers=headers)

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

request({
  method: 'GET',
  url: 'https://modeanalytics.com/api/{account}/reports/{report}/filters/{filter}',
  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 report filters

To return a list of all report filters available for a given report, send a GET request to the filters resource using the report token.

URL Params

account

required
string Account (Organization or User) username

report

required
string Report token
Responses

200

ReportFilter collection response

400

Bad request

401

Unauthorized

404

Report not found

GET /{account}/reports/{report}/filters

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://modeanalytics.com/api/{account}/reports/{report}/filters'
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}/filters')
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}/filters', headers=headers)

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

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

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();

Create a report filter

A POST request on filters resource creates a new filter on a single report.

URL Params

account

required
string Account (Organization or User) username

report

required
string Report token
POST Body Params

Object: report_filter

name

required
string ReportFilter name

formula

required
string ReportFilter formula

data_type

required
string ReportFilter data type

formula_type

required
string ReportFilter formula type

filter_type

required
ReportFilter type

control_type

required
ReportFilter control type

variable_type

required
ReportFilter variable type

options

required

next_filter_token

string Token of the ReportFilter that should come after this one, if manual ordering is desired
Responses

200

ReportFilter response

400

Bad request

401

Unauthorized

404

Report not found

POST /{account}/reports/{report}/filters

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}/filters'
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}/filters', 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}/filters', 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}/filters');

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));

Update a report filter

A PATCH request on filters can be used to modify an existing filter for a single report with specified attributes.

URL Params

account

required
string Account (Organization or User) username

report

required
string Report token

filter

required
string ReportFilter token
POST Body Params

Object: report_filter

name

required
string ReportFilter name

formula

required
string ReportFilter formula

data_type

required
string ReportFilter data type

formula_type

required
string ReportFilter formula type

filter_type

required
ReportFilter type

control_type

required
ReportFilter control type

variable_type

required
ReportFilter variable type

options

required

next_filter_token

string Token of the ReportFilter that should come after this one, if manual ordering is desired
Responses

200

ReportFilter response

400

Bad request

401

Unauthorized

404

ReportFilter not found

PATCH /{account}/reports/{report}/filters/{filter}

curl --include \
     --request PATCH \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://modeanalytics.com/api/{account}/reports/{report}/filters'
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)
               .patch('https://modeanalytics.com/api/{account}/reports/{report}/filters')
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}/filters', headers=headers)
request.get_method = lambda: 'PATCH'

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

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

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();

Delete a report filter

To remove a given filter from a Report, send a DELETE request to the filters resource.

URL Params

account

required
string Account (Organization or User) username

report

required
string Report token

filter

required
string ReportFilter token
Responses

200

ReportFilter response

400

Bad request

401

Unauthorized

404

ReportFilter not found

DELETE /{account}/reports/{report}/filters/{filter}

curl --include \
     --request DELETE \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://modeanalytics.com/api/{account}/reports/{report}/filters/{filter}'
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)
               .delete('https://modeanalytics.com/api/{account}/reports/{report}/filters/{filter}')
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}/filters/{filter}', headers=headers)
request.get_method = lambda: 'DELETE'

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

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