PI Web API vs PIconnect
PIconnect is a popular open-source Python library for PI System data. This page gives you an honest comparison so you can pick the right tool. Sometimes PIconnect is the better choice.
What is PIconnect?
PIconnect is a community-maintained open-source Python library that wraps AF SDK using Python's pythonnet package. It provides a pandas-friendly interface for reading PI System data with minimal boilerplate code.
Critically, PIconnect does not use PI Web API. It loads AF SDK .NET assemblies directly via .NET interop, which means it inherits all AF SDK requirements: Windows, .NET runtime, and AF SDK installation on the client machine.
Architecture differences
Understanding the architecture is key to understanding the trade-offs. These are fundamentally different approaches to the same problem.
PI Web API architecture
Your Python Code (any OS)
|
| HTTPS / JSON (port 443)
v
PI Web API Server (Windows + IIS)
|
| AF SDK (internal)
v
PI Data Archive + PI AF ServerPIconnect architecture
Your Python Code (Windows only)
|
| pythonnet (.NET interop, in-process)
v
AF SDK assemblies (loaded into Python process)
|
| PI-RPC / AF-RPC (proprietary TCP)
v
PI Data Archive + PI AF ServerPIconnect is NOT a PI Web API wrapper
A common misconception is that PIconnect calls PI Web API under the hood. It does not. PIconnect loads the AF SDK .NET assemblies directly into your Python process using pythonnet. This is why it requires Windows and AF SDK -- it is a completely separate communication path from PI Web API.
Detailed comparison
| Criteria | PI Web API + requests | PIconnect |
|---|---|---|
| Underlying protocol | HTTPS / REST / JSON | AF SDK via pythonnet (.NET interop) |
| Client platform | Any OS (Linux, macOS, Windows, containers) | Windows only |
| Prerequisites | pip install requests + network access | AF SDK installer + .NET runtime + pip install PIconnect pythonnet |
| Python version support | Any Python 3.x | Limited by pythonnet compatibility (typically 3.8-3.11) |
| pandas integration | Manual (parse JSON to DataFrame) | Built-in (returns pandas Series/DataFrame directly) |
| Cloud / container support | Full support (Alpine, Debian, any base image) | Not practical (requires Windows + AF SDK in container) |
| Write support | Full (POST/PUT/DELETE to any endpoint) | Limited (basic write operations) |
| Batch / bulk operations | Batch endpoint for multiple operations in one request | Sequential (one call per point, though AF SDK can batch internally) |
| AF hierarchy access | REST endpoints for elements, attributes, databases | Built-in with natural Python object model |
| Authentication | Basic, Kerberos, NTLM, Bearer | Windows Integrated (automatic, uses logged-in user) |
| Maintenance status | AVEVA maintains PI Web API as a product | Community-maintained. Updates have slowed since 2023. |
| Error messages | HTTP status codes + JSON error bodies | .NET exceptions wrapped by pythonnet (can be cryptic) |
| Debugging | Standard HTTP tools (Postman, curl, browser) | Requires .NET debugging knowledge for deep issues |
Deployment requirements comparison
| Requirement | PI Web API + requests | PIconnect |
|---|---|---|
| Operating system | Any | Windows 10/11, Windows Server 2016+ |
| Runtime | Python 3.x | Python 3.8-3.11 + .NET Framework 4.8 or .NET 6+ |
| SDK installation | None | AF SDK (~200 MB installer, requires admin rights) |
| Network ports | 443 (HTTPS) | 5450, 5457, 5459 (PI proprietary) |
| Server requirement | PI Web API server must be deployed | No additional server (connects directly to DA/AF) |
| pip install | requests pandas | PIconnect pythonnet |
| Docker support | Any base image (python:3.x-slim) | Windows container with AF SDK pre-installed |
PIconnect requires AF SDK on the client
This is the biggest practical difference. If you do not already have AF SDK installed on your machine, you need admin rights to install it, and it is a ~200 MB installer. PI Web API requires nothing on the client side.
Code comparison: same task, both approaches
Read the last 24 hours of recorded values for a PI point into a pandas DataFrame.
Using PIconnect (5 lines)
import PIconnect as PI
# Requires: Windows, AF SDK installed, pythonnet, domain-joined machine
with PI.PIServer() as server:
point = server.search("sinusoid")[0]
data = point.recorded_values("*-1d", "*")
# data is already a pandas Series with timestamps as index
print(data.describe())Using PI Web API with requests (15 lines)
import requests
import pandas as pd
# Works on any OS, no SDK installation needed
session = requests.Session()
session.auth = ("DOMAIN\\user", "password")
session.verify = "/path/to/ca-bundle.pem"
BASE_URL = "https://your-server/piwebapi"
# Look up the point by path (more reliable than search)
resp = session.get(f"{BASE_URL}/points", params={
"path": "\\\\MY-SERVER\\sinusoid",
})
web_id = resp.json()["WebId"]
# Get recorded values
resp = session.get(f"{BASE_URL}/streams/{web_id}/recorded", params={
"startTime": "*-1d",
"endTime": "*",
"selectedFields": "Items.Timestamp;Items.Value;Items.Good",
})
items = resp.json()["Items"]
# Convert to DataFrame
df = pd.DataFrame(items)
df["Timestamp"] = pd.to_datetime(df["Timestamp"])
df = df.set_index("Timestamp").sort_index()
print(df["Value"].describe())Code comparison: writing values
# --- PIconnect: writing is limited ---
# PIconnect's write support is basic and less commonly used.
# Most PIconnect users only read data.
# --- PI Web API: full write support ---
session.post(
f"{BASE_URL}/streams/{web_id}/value",
json={
"Value": 42.0,
"Timestamp": "2026-03-15T10:00:00Z",
},
params={"updateOption": "Replace"},
)
# Write multiple values at once
session.post(
f"{BASE_URL}/streams/{web_id}/recorded",
json=[
{"Value": 70.1, "Timestamp": "2026-03-15T10:00:00Z"},
{"Value": 71.3, "Timestamp": "2026-03-15T10:05:00Z"},
{"Value": 72.0, "Timestamp": "2026-03-15T10:10:00Z"},
],
)Code comparison: batch/bulk reads
# --- PIconnect: read multiple points (sequential) ---
import PIconnect as PI
with PI.PIServer() as server:
for name in ["Temperature", "Pressure", "Flow"]:
point = server.search(name)[0]
data = point.recorded_values("*-1h", "*")
print(f"{name}: {data.mean():.2f}")
# --- PI Web API: read multiple points (one request) ---
# Batch endpoint reads all three in a single HTTP request
batch = {}
for i, wid in enumerate(web_ids):
batch[f"point_{i}"] = {
"Method": "GET",
"Resource": f"{BASE_URL}/streams/{wid}/value"
}
resp = session.post(f"{BASE_URL}/batch", json=batch)
for key, result in resp.json().items():
if result["Status"] == 200:
print(f"{key}: {result['Content']['Value']}")Performance comparison
PIconnect uses AF SDK directly (binary protocol, no HTTP overhead), so it is faster for individual operations. However, PI Web API's batch endpoint can close the gap for multi-point reads.
| Operation | PI Web API | PIconnect | Notes |
|---|---|---|---|
| Single point current value | 5-20 ms | 2-10 ms | PIconnect has less overhead per call. |
| 100 points current values | 50-150 ms (batch) | 200-1000 ms (sequential) | PI Web API batch wins for multi-point reads. |
| 10K recorded values | 0.5-2 s | 0.2-1 s | PIconnect faster due to binary protocol. |
| 100K recorded values | 2-8 s | 1-3 s | JSON serialization is the bottleneck for PI Web API. |
Performance is rarely the deciding factor
For most Python data analysis workflows (Jupyter notebooks, scheduled ETL, dashboards), the performance difference between PI Web API and PIconnect is not significant enough to matter. The deciding factors are usually platform requirements and deployment constraints.
When PIconnect is actually the better choice
We are a PI Web API-focused company, but we are honest: PIconnect is genuinely the better choice in these scenarios.
- Interactive Jupyter analysis on a PI server. If you are sitting on a Windows machine with AF SDK installed and just want to explore data in a notebook, PIconnect gets you from zero to pandas DataFrame in 5 lines of code. The setup overhead of PI Web API (session, auth, JSON parsing) is not worth it for quick exploration.
- Quick one-off scripts on domain-joined Windows machines. PIconnect uses your Windows login automatically. No credentials to manage, no SSL certificates to configure.
- Your code will only ever run on that one Windows machine. If portability is not a requirement and you have AF SDK installed, PIconnect is simpler.
- You need the simplest possible pandas integration. PIconnect returns pandas Series directly from
recorded_values(). With PI Web API, you write 5-10 extra lines to parse JSON into a DataFrame. - PI Web API is not deployed in your organization. Some older PI System environments do not have PI Web API installed. PIconnect connects directly to PI Data Archive without needing a PI Web API server.
When PI Web API is the better choice
- You are on Linux, macOS, or in a container. PIconnect does not work outside Windows. Full stop.
- You do not have AF SDK installed and do not want to. PI Web API requires zero client-side installation. Just
pip install requestsand go. - You need to write values. PI Web API has full write support with updateOption, bufferOption, batch writes, and delete. PIconnect's write support is limited.
- You are building a service or pipeline for production. PI Web API runs anywhere: cloud VMs, Kubernetes, serverless functions, CI/CD pipelines. PIconnect locks you to Windows.
- You need to read many points efficiently. PI Web API's batch endpoint reads 100+ points in a single HTTP request. PIconnect makes one AF SDK call per point.
- You need a stable, maintained API surface. PI Web API is maintained by AVEVA as a product. PIconnect is community-maintained and updates have slowed.
- Your team includes non-Python developers. PI Web API can be called from JavaScript, Java, Go, .NET, curl, Postman, or any HTTP client. PIconnect is Python-only.
- You need Bearer/OpenID Connect authentication. PIconnect only supports Windows Integrated auth.
PIconnect limitations to be aware of
| Limitation | Impact |
|---|---|
| pythonnet version conflicts | pythonnet has a history of breaking changes between versions. Upgrading Python or pythonnet can break PIconnect. |
| AF SDK version coupling | PIconnect loads the AF SDK version installed on the machine. Upgrading PI System can break existing PIconnect scripts. |
| Slower maintenance cadence | PIconnect is maintained by a single developer in their spare time. Bug fixes and new features depend on volunteer availability. |
| No async support | PIconnect calls are synchronous and blocking. For concurrent reads, you need threading (with GIL limitations). |
| Limited error handling | .NET exceptions wrapped by pythonnet can be cryptic and hard to debug without .NET experience. |
| No event frame support | PIconnect focuses on PI point data. Event frames and some AF features are not exposed. |
Decision guide
| If you... | Use |
|---|---|
| Are on Linux, macOS, or in a container | PI Web API (PIconnect is not an option) |
| Are on Windows with AF SDK, doing interactive analysis | PIconnect (faster to get started) |
| Need to write values | PI Web API |
| Are building a cloud pipeline | PI Web API |
| Want quick Jupyter exploration on a PI server | PIconnect |
| Are building a production service | PI Web API (portability and maintainability) |
| Need to read 100+ points efficiently | PI Web API (batch endpoint) |
| Do not have PI Web API deployed | PIconnect (until PI Web API is deployed) |
| Are starting a new project in 2026 | PI Web API (future-proof, platform-independent) |