Support

FAQ

    March 10, 2023

    API REST

    We are using the HMAC authentication type for our REST API. Each API CALL should contain CCHMAC-Authorization and CC-HMAC-Date headers. Below is a PHP example of how to generate those headers as well as all the necessary credentials for CC Customer:

     

    API key: CC_Customer_account_name

    API secret: ••••••••••••••••••••••••• /*

    hashing algorithm: sha256

    timesamp format: Y-m-d H:i:s

     

    /* To get the unique API secret The user has to sign NDA. Please contact us to get it.

     

    Example PHP code:

    Sample credentials (not real)

    API key: ABC-Print

    API secret: qyvxgx6582_128so45xq

     

    <?php
    function createHmacAuth($key, $secret, $method, $path, $timestamp) {
        $str = $method . ' ' . $path . $timestamp;
        $hash = hash_hmac('sha256', $str, $secret);
        return $key . ':' . $hash;
    }
    
    $timestamp = gmdate("Y-m-d H:i:s");
    $Auth = createHmacAuth('ABC-Print', 'qyvxgx6582_128so45xq', 'POST', '/rest_api/api.php', $timestamp);
                
    $headers  = array(
        "Content-Type: application/json", 
        "CC-HMAC-Authorization: ".$Auth, 
        "CC-HMAC-Date: ".$timestamp,
    );
    
    
    //
    $ch = curl_init('https://chromachecker.com/rest_api/?action=get_devices');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER,false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        
    $json = curl_exec($ch);
    curl_close($ch);
    
    $response = json_decode($json, true);
    print_r($response);

     

    In response server should return JSON looking like this:

     

    [
       {
          "name":"Sample LFP",
          "type":"Large Format Printer",
          "serial":"SGC145R001",
          "device_id":"32532",
          "location_id":"2618",
          "department_id":"1638",
          "location":"RT NYC",
          "department":"Wallpaper"
       },
       {
          "name":"II JET",
          "type":"Industrial Inkjet",
          "serial":"831-0123",
          "device_id":"33265",
          "location_id":"2569",
          "department_id":"1476",
          "location":"BRL DE",
          "department":"BRL"
       }
    ]

    It will contain a list of all devices, and device_id is necessary for the next API call that will get measurements for specified devices.

     

    Getting measurement data

    API call should contain the same headers as the first one, only the URL has to be changed from: 


    https://chromachecker.com/rest_api/?action=get_devices


    to:

     

    https://chromachecker.com/rest_api/?action=get_measurements&device=3123&start=2018-01-01%2000:00:00&end=2022-06-01%2000:00:00&offset=0

     

    Here are a few variables that should be customized:

    • device: it is device_id from the previous call

    • start and end: specified time period, dates should be in format Y-m-d H:i:s, please remember to change space character to %20. Time in those fields should be converted to UTC (universal time zone)

    • offset allows to get more measurements if the selected time period contains more than the returned limit (there is a limit of 100 measurements per single request), to see the next 100 just put offset =100, then 200, etc.

    The sample response looks like the following:

     

    {
       "total":"11578",
       "start":"2018-01-01 00:00:00",
       "end":"2022-06-01 00:00:00",
       "offset":1,
       "measurements":[
          {
             "filename":"HP Colorbeat 7885384987",
             "device":"IND-50F",
             "device_type":"Digital Press",
             "track":"Standard 29",
             "created":"2022-02-15 00:33:35",
             "created_utc":"2022-02-15 07:33:35",
             "efactor":"3.6",
             "tvi":{
                "mode":"C",
                "C":{
                   "3.14":2.14,
                   "25.10":9.82,
                   "49.80":13.62,
                   "74.90":10.02
                },
                "M":{
                   "3.14":1.09,
                   "25.10":10.2,
                   "49.80":12.42,
                   "74.90":7.21
                },
                "Y":{
                   "3.14":2.11,
                   "25.10":11.14,
                   "49.80":15.5,
                   "74.90":8.89
                },
                "K":{
                   "3.14":1.31,
                   "25.10":11.7,
                   "49.80":14.92,
                   "74.90":8.71
                }
             },
             "density":{
                "C":"1.501",
                "M":"1.476",
                "Y":"1.003",
                "K":"1.747"
             },
             "pass_fail":0,
             "hp_score":"76.00",
             "location":"DF4",
             "department":"DF4 Presses"
          }
       ]
    }

     

     

    Pass_fail is delivered as a number, that has the following meaning:

    0 : normative fail

    1 : normative pass but was within 10% of failure threshold

    2 : normative pass

    3 : informative fail

    4 : informative pass

    5 : missing tolerance set

     

    Total in the first line means how many measurements are in total within the selected time period – this could be used to setup the next request with proper offset to get the next measurements.

     

     

    Contact ChromaChecker Support

    Additional information and Support Form is available for logged users.