javascriptosisoft

How to get filtered data returned using PI Vision and PI Web Api


I am trying to filter the data returned when using PI Web API. For example, say I have this url structure, https://machinename/piwebapi/tables/tableId/data, which returns the following table data:

{
   "Columns": {
      "Model": "String",
      "4WD": "Boolean",
      "TopSpeed": "Int32"
   },
   "Rows": [
     {
       "Model": "CarModel1",
       "4WD": true,
       "TopSpeed": 100
     },
     {
       "Model": "CarModel2",
       "4WD": false,
       "TopSpeed": 80
     }
  ]
}

I would like to filter this data by 4WD: true.

I've tried reading through the documentation here and using many different queries, but I don't see one that filters based on a value. https://techsupport.osisoft.com/documentation/pi-web-api/help//controllers/table/actions/getdata.html

I've also tried using search queries, which can filter based on values, but I cannot get the url structure to work when table is the AF Object. https://machinename/piwebapi/tables/search?databaseWebId=databaseId

Is it possible to filter a url structure like this, https://machinename/piwebapi/tables/tableId/data, for a specific value?


Solution

  • It looks like filtering table data via the PI Web API is not supported at this time based on a few posts from OSIsoft's developer forum:

    I see as well no way to specify any where conditions when querying AF Table data. To my understanding, the reason of having AF Tables is to supply AF Attributes with values, either fixed or condition based.

    Tables in AF are usually meant to supply AF Attributes with values - does your use case allow you to search for AF Attribute values populated by your AF table?

    If not, you could filter the returned AF table data on the client side via JavaScript. I'd be careful with this approach as you'd want to be mindful of how much data is in that AF table that would be returned to the client for further filtering.

    If your table is a linked table (a table or view hosted by a SQL Server but available in AF), you may be able to use parameters when creating your AF table representation, and then leverage those parameters in your PI Web API calls