REST Queries for Retrieving Data Samples

This topic provides REST queries that you can use to retrieve data samples. You can limit the number of samples, retrieve them in a specific order or for a specific duration, and so on.

Table 1. Limit the Number of Data Samples
Parameter Value
Method POST
URI http://<Public IP address of the REST Query service>:8989/v1/datapoints?query=
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
"start": <start time>,  
"end": <end time>,
"tags": [
    {
      "name": "<tag name>",
      "limit": <number>   
    }
 ]
}
Example
{
  "start": 1639973114000,
  "end": 1641182964000,
  "tags": [
    {
      "name": "GF260PF2E_Simulation.Simulation00004",
      "limit": 5000
   }
 ]
}
Table 2. Specify the Order of Data Samples
Parameter Value
Method POST
URI http://<Public IP address of the REST Query service>:8989/v1/datapoints?query=
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
  "start": <start time>,
  "end": <end time>,
  "tags": [
    {
      "name": "<tag name>",
      "order": "<order>"   } //valid values: asc, desc
 ]
}
Example
{
  "start": 1639973114000,
  "end": 1641182964000,
  "tags": [
    {
      "name": "GF260PF2E_Simulation.Simulation00004",
      "order": "desc"
   }
 ]
}
Table 3. Get All Tags
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Table 4. Get Data Samples After a Timestamp
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": <start time>,
    "direction": "forward",
        "tags": [{
        "name": "<tag name>",
        "limit": <number of data samples>
    }]
}
Example
{
    "start": 1641182964000,
    "direction": "forward",
        "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00002",
            "limit": 3
    }]
}
Table 5. Get Data Samples up to a Timestamp
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": <start time>,
    "direction": "backward",
        "tags": [{
        "name": "<tag name>",
            "limit": <number of data samples>
    }]
}
Example
{
    "start": 1641182964000,
    "direction": "backward",
        "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00002",
            "limit": 3
    }]
}
Table 6. Get Interpolated Data for a Specific Duration
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{  
   "start":<start time>,
   "end":<end time>,
   "tags":[  
      {  
         "name":"<tag name>",
         "aggregations":[  
            {  
               "type":"interpolate",
               "interval": "<duration>" 
                //examples: 1h, 1d, 1mm, 1y           
            }
         ]
      }
   ]
}
Example
{  
   "start":1641177806000,
   "end":1641185006000,
   "tags":[  
      {  
         "name":"GF260PF2E_Simulation.Simulation00004",
         "aggregations":[  
            {  
               "type":"interpolate",
               "interval": "1h"
            }
         ]
      }
   ]
}
Output:
{
    "tags": [
        {
            "name": "GF260PF2E_Simulation.Simulation00004",
            "results": [
                {
                    "groups": [
                        {
                            "name": "type",
                            "type": "number"
                        }
                    ],
                    "values": [
                        [
                            1641181406000,
                            0,
                            0
                        ],
                        [
                            1641185006000,
                            129227.5781,
                            3
                        ]
                    ],
                    "attributes": {}
                }
            ],
            "stats": {
                "rawCount": 3269
            }
        }
    ]
}
Table 7. Retrieve Interpolated Data for a Specified Data Samples
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{  
   "start":<start time>,
   "end":<end time>,
   "tags":[  
      {  
         "name":"<tag name>",
         "aggregations":[  
            {  
               "type":"interpolate",
                "sampling": {
                    "datapoints": <number>
            }
            }
         ]
      }
   ]
}
Example
{  
   "start":1640931121000,
   "end":1640935148000,
   "tags":[  
      {  
         "name":"GF260PF2E_Simulation.Simulation00002",
         "aggregations":[  
            {  
               "type":"interpolate",
                "sampling": {
                    "datapoints": 100
            }
            }
         ]
      }
   ]
}
Table 8. Retrieve the Latest Value
Parameter Value
Method POST
URI http://<Public IP address of the REST Query service>:8989/v1/datapoints/latest
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "tags": [
        {
            "name": "<tag name>"
        }
    ]
}
Example
{
    "tags": [
        {
            "name": "GF260PF2E_Simulation.Simulation00004"
        }
    ]
}
Table 9. Retrieve the Latest Value by Applying a Condition
Parameter Value
Method POST
URI http://<Public IP address of the REST Query service>:8989/v1/datapoints/latest
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "tags": [{
        "name": "<tag name>",
        "filters": {
            "measurements": {
                "condition": "<condition>", 
                //valid values: lt,gt,eq,le,ge,ne 
                 "values": [
                    "<number>"
                ]
            },
            "qualities": {
                "values": [
                    "<number>" 
                    //Enter 0 for bad and 3 for good quality
                ]
            }
        }
    }]
}
Example
{
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "filters": {
            "measurements": {
                "condition": "ge",
                 "values": [
                    "1000"
                ]
            },
            "qualities": {
                "values": [
                    "3"
                ]
            }
        }
    }]
}