How to Create PI Analysis Templates from a Web Interface Using PI Web API
Discover how to create new OSIsoft PI Analyses and manage configurations programmatically via a web interface using PI Web API, including limitations around templating expressions.
Roshan Soni
Creating PI Analysis Templates Through a Web Interface Using PI Web API
Traditionally, configuring new analyses in OSIsoft PI Asset Framework (AF) required access to the PI System Explorer desktop client. However, for organizations aiming to empower end users or automate analysis creation, a web interface is much more convenient. Many engineers and integrators have asked: Is it possible to build a web interface that allows users to define new PI Analyses (including logic, mapped outputs, and linked attributes) without using PI System Explorer? The good news is: Yes, this is now possible with advancements in the PI Web API.
Leveraging PI Web API for Analysis Creation
Starting with PI Web API 2016 SP1, OSIsoft introduced new endpoints that allow programmatic management of analyses, including the ability to create analysis rules and link their outputs to AF attributes. This essentially bridges the gap for building custom web applications or automated scripts to facilitate analysis creation, editing, and deployment.
Example Workflow
Suppose you want users to create their own algorithms—say, "if value > parameter AND value2 < parameter2 for X seconds, trigger a flag." With PI Web API, your web application can present a form to the user to define logic, select attributes, and specify parameters. When submitted, the application can invoke the PI Web API endpoint, such as /analysisrules, to create analyses based on the user's input.
A typical payload might look like this:
{
"ConfigString": "a := TagVal('sinusoid'); b := Pow(a, 2); c := a + b;",
"PlugInName": "PerformanceEquation",
"VariableMapping": "b||Attribute1;c||Attribute2"
}
This example creates an analysis with three calculations, mapping two results to specific AF attributes.
Key Capabilities
- Create and configure new analyses via HTTP requests
- Define complex calculation logic using Performance Equation syntax
- Map analysis outputs to AF attributes
- Integrate into custom web interfaces or automated workflows
Important Considerations and Limitations
While PI Web API opens the door to building a web-based PI Analytics platform, there are some limitations you should be aware of:
- Analysis Templating: It's currently not straightforward to create true analysis templates programmatically. Analysis expressions are tightly coupled with AF element attributes, making templates (as managed in PI System Explorer) complex to automate via the API.
- Documentation: As cited in community threads, the online documentation for PI Web API analyses might lag behind the latest features, so downloading the full technical guide from OSIsoft Tech Support is advisable.
- Complex Dependencies: Analyses can involve dependencies on other analyses, references, and attribute configurations. Proper error handling and careful design are essential for automation.
Getting Started
- Upgrade to PI Web API 2016 SP1 or later to access these features.
- Download the latest documentation from OSIsoft Tech Support for endpoints, payloads, and usage examples.
- Prototype your web interface—start simple (e.g., basic equation input and attribute mapping) and expand functionality as you gain experience.
- Test thoroughly in a development environment before rolling out in production.
Conclusion
With PI Web API’s advanced endpoints, system integrators and application developers can now enable users to create, manage, and deploy analyses via custom web interfaces. While there are still some challenges—especially around templating and dependency management—the path to bespoke PI Analytics tooling is now wide open.
References:
Tags
About Roshan Soni
Expert in PI System implementation, industrial automation, and data management. Passionate about helping organizations maximize the value of their process data through innovative solutions and best practices.
No comments yet
Be the first to share your thoughts on this article.
Related Articles
Enhancing PI ProcessBook Trends with Banding and Zones: User Needs, Workarounds, and the Road Ahead
A look at the user demand for trend banding/zoning in OSIsoft PI ProcessBook, current VBA workarounds, UI challenges, and how future PI Vision releases aim to address these visualization needs.
Roshan Soni
Migrating PIAdvCalcFilVal Uptime Calculations from PI DataLink to PI OLEDB
Learn how to translate PI DataLink's PIAdvCalcFilVal advanced calculations—like counting uptime based on conditions—into efficient PI OLEDB SQL queries. Explore three practical approaches using PIAVG, PIINTERP, and PICOunt tables, and get tips for validation and accuracy.
Roshan Soni
Understanding PI Web API WebID Encoding: Can You Generate WebIDs Client-Side?
Curious about how PI Web API generates WebIDs and whether you can encode them client-side using GUIDs or paths? This article explores the encoding mechanisms, current documentation, and best practices for handling WebIDs in your applications.
Roshan Soni