MonitorPro API

How to connect to the MonitorPro API

The MonitorPro API can be used for the onward reporting of data from MonitorPro. At the moment its function is limited to outbound data and not inserts or updates, to ensuring continuity of auditing and MCERTS accreditation.

Creating an API token

Navigate to the Administration page, then click on the API Token link.

On the resulting page, click the Generate button to generate a new token.

A dialog is displayed containing the generated token. Click on the link on the right-hand side to copy the value to the clipboard.

Accessing API using Generated Token

To access the API, modify the following url.

https://your.domain.com/api/{databaseId}/reporting/{reportName}/{selectionId}

  • Set your hosted location of MP-Web
  • Set the protocol according to your website configuration, HTTP or HTTPS. HTTPS is recommended.
  • Replace {databaseId} with the databaseID of the database you wish to output from. In multiple database implementations you'll need to confirm this from tblDatabase in the MP5WebGateway database.
  • Replace {reportName} with any of the report names in the list below
  • Replace {selectionId} with the selectionID you wish to use to as the basis of your query. To obtain this you will need to look this up in tblSelection using the sSelectionStoreName (the common name known to the user) as the identifier. 
  • As part of the call, the bearer token (used to authenticate) must be passed in the Authorisation header, i.e. Authorization: Bearer <token>

See the example below using POSTMAN.

Accessing API using PowerBI

It's also possible to use PowerBI to access data via the API. 

In PowerBI create a Blank query. Right-click and go to the Advanced Editor. 

Paste the following example into the query and update 'your.domain.com' with the applicable MonitorPro URL. Include the databaseID then one of the 'reportname' with one of the reports listed below. Then finally the selectionID. The token then needs to be included. 

let
    // Define the API URL
    apiUrl = "https://your.domain.com/api/{databaseId}/reporting/{reportName}/{selectionId}",

    // Define the Authorization header with the Bearer token
    headers = [
        #"Authorization" = "Bearer {Your Token}"
    ],

    // Call the API with the URL and headers 
    response = Web.Contents(apiUrl, [
        Headers = headers
    ]),

    // Parse the JSON response
    jsonResponse = Json.Document(response),

    // Convert the JSON response into a table (assuming it's a list of records)
    dataTable = Table.FromList(jsonResponse, Splitter.SplitByNothing(), null, null, ExtraValues.Error),

    // Expand the records into columns (assuming each record contains fields)
    expandedTable = Table.ExpandRecordColumn(dataTable, "Column1", Record.FieldNames(dataTable{0}[Column1]), Record.FieldNames(dataTable{0}[Column1])),

    // Convert "Sample_Date" to Date type
    transformedTable = Table.TransformColumnTypes(expandedTable, {{"Sample_Date", type datetime}} )
   
in

transformedTable

 

Once finished, click done, and the data will be available for onward visualization. 

Note

Unlike connecting to the database via PowerBI, each query will be defined to a specific MonitorPro Dataset (SelectionID). To pull in differing data, create the process as many times as required for each Dataset.  

Revoke Token

To revoke the generated token, navigate to the Administration -> API Token page used initially, and click on the Revoke Token button.

Available Reports

The following reports are available:

  • report_001_SelectedData
  • report_001_SelectedLocations
  • report_003_SelectedVariables
  • report_003a_SelectedSources
  • report_003b_SelectedSampleTypes
  • report_005_Data_Basic
  • report_005_Data_Basic_AdditionalFields
  • report_005v_Data_Basic_VariableOrder
  • report_005vs_Data_Basic_VariableSamplePointOrder
  • report_005vs_Data_Basic_VariableSamplePointOrderPreordered
  • report_005vsd_Data_Basic_VariableSamplePointOrderDummy
  • report_005x_Data_Deleted
  • report_006_Data_Extended
  • report_006a_Data_Extended_ComplianceGridsOnly
  • report_006a_Data_Extended_ComplianceGridsOnlyBroken
  • report_006avs_Data_Extended_ComplianceGridsOnly_VariableSamplePointOrder
  • report_006b_Data_Extended_AllComplianceTypes
  • report_006b_Data_Extended_CompliancePivot
  • report_006b1_Data_Extended_AllComplianceTypes_ImportanceWarning
  • report_006b2_Data_Extended_AllComplianceTypes_ImportanceInternal
  • report_006b3_Data_Extended_AllComplianceTypes_ImportanceBreach
  • report_006b4_Data_Extended_AllComplianceTypes_ImportanceHighPriorityBreach
  • report_007_Exceedences
  • report_007a_Exceedences_ComplianceGridOnly
  • report_007b_Exceedences_AllComplianceTypes
  • report_008_Data_Basic_By_Group
  • report_008_Data_Basic_by_Grp
  • report_008x_Data_Basic_By_Group_Extended
  • report_009_Data_Basic_By_Suite
  • report_010_Aggregates
  • report_010_DataImportedYesterday_Detail
  • report_010_DataImportedYesterday_DetailWithThresholds
  • report_010a_Aggregates_ComplianceGridsOnly
  • report_010b_Aggregates_AllComplianceTypes
  • report_011_Extended_Incl_Suites
  • report_011a_Extended_Incl_Suites_ComplianceGridsOnly
  • report_011b_Extended_Incl_Suites_AllComplianceTypes
  • report_012_Exceedences_Raw_Data
  • report_012a_Exceedences_Raw_Data_ComplianceGridsOnly
  • report_012b_Exceedences_Raw_Data_AllComplianceTypes
  • report_013_Data_Basic_Monitoring_Performance_Report
  • report_DailyPreviousFiveDaySum
  • report_DMR
  • report_MonthlyMaxAnnualRollingAverage