Report Data API
This article provides sample API calls to manipulate Reports.
PREREQUISITES:
- Set up API access
- Verify that you have API access
- Obtain a token via a get token call since all API calls require a token
Access Report data for JavaScript charting
Get Report Information
You can obtain all the information about a specific Metric (such as measurement inteval, report type, name, description, category, whether it is a change report, etc.)
- Item: report
- Method: GET
- ID: Specify the ID of a Report you wish to get information about. Report ID can be determined in the web browser URL of the Report Editor. For example:
https://demo.metricinsights.com/editor/report/edit/element/2
- Run request
Set time range ('from_measurement_time' and 'to_measurement_time' values)
- Item: report
- Method: PUT
- ID: Specify the ID of a Report you wish to modify. Report ID can be determined in the web browser URL of the Report Editor. For example:
https://demo.metricinsights.com/editor/report/edit/element/154
- Actions: Select an action you wish to perform. NOTE: Specific time range is defined for "Delete data" and "Update live Report"
- call: This field is going to be automatically populated based on the action you have chosen at the field above
- Specify the time range by defining the following parameters:
- from_measurement_time - (measurement time should be in one of the following formats: yyyy-mm-dd or yyyy-mm-dd 00:00:00) - date from which measurements will be updated
- to_measurement_time- (measurement time should be in one of the following formats: yyyy-mm-dd or yyyy-mm-dd 00:00:00) - date to which measurements will be updated
- Run request
Change ':measurement_time' value
To learn more about the :measurement_time bind variable, follow this link.
- Item: report
- Method: PUT
- ID: Specify the ID of a Report you wish to modify. Report ID can be determined in the web browser URL of the Report Editor. For example:
https://demo.metricinsights.com/editor/report/edit/element/2
- custom_effective_date: (Value or id of a period. Sample correlation :Last week = 1, Yesterday = 2, Today =7) - sets ':measurement_time' value
- Run request
Delete measurements for a certain Time Range
- Item: report
- Method: PUT
- ID: Specify the ID of a Report you wish to modify. Report ID can be determined in the web browser URL of the Report Editor. For example:
https://demo.metricinsights.com/editor/report/edit/element/154
- Actions: "Delete data"
- call: This field is automatically populated based on the action you have chosen at the field above
- Specify the time range by defining the following parameters:
- from_measurement_time - (measurement time should be in one of the following formats: yyyy-mm-dd or yyyy-mm-dd 00:00:00) - date from which measurements will be updated
- to_measurement_time- (measurement time should be in one of the following formats: yyyy-mm-dd or yyyy-mm-dd 00:00:00) - date to which measurements will be updated
- Run request
Get Report's Historical Instance IDs
API:
https://yourinstance.metricinsights.com/api/report_instance?element=<element_id>&dimension_value=<dimension_value_id>
Parameters:
- element (numeric value) - element ID
- dimension_value (numeric value) - Dimension Value ID (for dimensioned elements only)
Example:
Undimensioned Report - https://yourinstance.metricinsights.com/api/report_instance?element=81
Dimensioned Report - https://yourinstance.metricinsights.com/api/report_instance?element=81&dimension_value=6
Header:
Accept:application/json
Token:UClCUUKxUlkdbhE1cHLz3kyjbIZYVh9eB34A5Q21Y3FPqKGSJs
Request example :
{
"call": "generate",
"from_measurement_time": "2016-04-24",
"to_measurement_time": "2016-04-25"
}
Response (without dimension value specified):
{
"report_instances": [
{
"id": "915",
"element": "81",
"dimension_value": "5",
"measurement_time": "2014-01-01 00:00:00"
},
{
"id": "918",
"element": "81",
"dimension_value": "8",
"measurement_time": "2014-01-01 00:00:00"
},
]
}
Response (without dimension value specified):
{
"report_instances": [
{
"id": "916",
"element": "81",
"dimension_value": "6",
"measurement_time": "2014-01-01 00:00:00"
},
{
"id": "804",
"element": "81",
"dimension_value": "6",
"measurement_time": "2014-02-01 00:00:00"
},
]
}
Set historical instances to be backfilled
- Item: report
- Method: PUT
- ID: Specify the ID of a Report you wish to modify. Report ID can be determined in the web browser URL of the Report Editor. For example:
https://demo.metricinsights.com/editor/report/edit/element/2
- keep_history: (yes, no) - When this option is set to 'yes', the Snapshot reporting is enabled (an instance for every data collection run is saved)
- can_historical_instances_be_backfilled: (yes, no) - Define whether historical instances of a snapshot report be backfilled when data is recollected. Backfilling is performed within the ':measurement_time' parameter time range
- Run request