How to use PI Web API to search AF Tree?
We are required to use PI Web API to search the AF Tree, like searching by a template name.
May I know is there any sample to do so?
Thanks
How to use PI Web API to search AF Tree?
We are required to use PI Web API to search the AF Tree, like searching by a template name.
May I know is there any sample to do so?
Thanks
It sounds like you are new to the PI Web API, so I am going to point you to some resources to help you in addition to answering your question.
You can download the user guide and the programmer's reference guide from here. The user's guide mostly contains information on how to install and configure the PI Web API program rather than use the RESTful API itself. The Programmers Reference guide discusses how to use the RESTful API, but it is written for programmers who are familiar with RESTful APIs, so it is a bit difficult to understand if you are not a programmer.
One other thing, the Programmer's Reference Guide is a collection of html pages instead of a Word document or PDF. The section of the Programmer's Reference guide most pertinent to your question can be found in [directory where you unzipped the Programmer's Reference Guide]/help/topics/pi-web-api-indexed-search_-getting-started.html.
Based on the information in the Programmer's Reference Guide I have constructed an example query for you, https://[web server name]/piwebapi/search/query?q=afelementtemplate:*[template name]* . You should replace the red text with the name of your web server or template name as appropriate for your system. The query will return all of the templates of all of your known AF Servers that match the expression *[template name]*.
Hi Raymond,
I also found the "Programming in PI Web API" videos to be very helpful in learning how to use PI Web API.
They can be found here:
Programming in PI Web API Discussion Forum
You might find the videos titled "Navigating PI Web API Through the Browser" or "Making HTTP GET Requests" to be helpful to search through the AF tree.
Thanks for all of your reply.
May I know if using your suggested method to search template or category, will it search through the whole AF tree very slowly?
Is there any performance issue?
Performance on your machine is going to be dependent on how large your AF tree is and what your network architecture is like. On my test system the template search was very quick. But my test system is minuscule.
If you run into performance issues, then you can limit the scope of the search to a single AF database by using the scope parameter like so:
[web server name]/piwebapi/search/query?q=afelementtemplate:*[template name]*&scope=af:\\[af server name]\[database name]