Table Of Contents

Accessing InsightCM Data Services Using HTTP API

    Last Modified: August 30, 2021

    Access your InsightCM data services in your preferred programming language using the HTTP API.

    Before you begin, generate an API key. NI recommends enabling Secure Sockets Layer (SSL) or Transport Layer Security (TLS) before proceeding to ensure that the key is encrypted as it is passed over the network.
    1. Use the following web service API to connect to InsightCM programmatically and acquire data. All endpoints return a JSON string.

    Path Method Description
    /IcmApi.svc/assets GET Get all the equipment asset nodes and their parents.
    /IcmApi.svc/asset-subtree/{assetId} GET Get all the descendants of an asset node.
    /IcmApi.svc/assets/version GET Get the asset collection version.


    GET Get data events for an asset.


    GET Get trend points.
    /IcmApi.svc/data-event/{dataEventId} GET Get data sets.
    /IcmApi.svc/data-event-archived/{assetNodeId}?ts={ts} GET Get archived data sets.
    /IcmApi.svc/active-trend-alarms?skip=0&take=100 GET Get active alarms.
    1. Provide the API key as an HTTP Authorization header in your code. Refer to the examples below for how this can be done in C# and Python.
    2. Confirm that you can successfully call InsightCM data services by passing the URL of your InsightCM Server and the API key in the Command Line Interface (CLI) or in the interface for your application.

    C# and Python Examples

    Providing the API Key in C#
    var client = new HttpClient();
    client.BaseAddress = new Uri(address);
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Api-Key", key);
    var response = await client.GetAsync("IcmApi.svc/assets");
    Providing the API Key in Python
    connection = http.client.HTTPConnection(address)
    headers = {"Authorization": "Api-Key {0}".format(key)}
    startTs = int(( - timedelta(days=1)).timestamp())
    connection.request("GET", "/IcmApi.svc/dataEvents/{0}?startTs={1}".format(asset["Id"], startTs), headers = headers)
    response = connection.getresponse()
    if response.status != 200:
        raise Exception("Request failed with status {0}".format(response.status))

    Recently Viewed Topics