Skip to main content
Explanation

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 Server

PIconnect 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 Server

PIconnect 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

CriteriaPI Web API + requestsPIconnect
Underlying protocolHTTPS / REST / JSONAF SDK via pythonnet (.NET interop)
Client platformAny OS (Linux, macOS, Windows, containers)Windows only
Prerequisitespip install requests + network accessAF SDK installer + .NET runtime + pip install PIconnect pythonnet
Python version supportAny Python 3.xLimited by pythonnet compatibility (typically 3.8-3.11)
pandas integrationManual (parse JSON to DataFrame)Built-in (returns pandas Series/DataFrame directly)
Cloud / container supportFull support (Alpine, Debian, any base image)Not practical (requires Windows + AF SDK in container)
Write supportFull (POST/PUT/DELETE to any endpoint)Limited (basic write operations)
Batch / bulk operationsBatch endpoint for multiple operations in one requestSequential (one call per point, though AF SDK can batch internally)
AF hierarchy accessREST endpoints for elements, attributes, databasesBuilt-in with natural Python object model
AuthenticationBasic, Kerberos, NTLM, BearerWindows Integrated (automatic, uses logged-in user)
Maintenance statusAVEVA maintains PI Web API as a productCommunity-maintained. Updates have slowed since 2023.
Error messagesHTTP status codes + JSON error bodies.NET exceptions wrapped by pythonnet (can be cryptic)
DebuggingStandard HTTP tools (Postman, curl, browser)Requires .NET debugging knowledge for deep issues

Deployment requirements comparison

RequirementPI Web API + requestsPIconnect
Operating systemAnyWindows 10/11, Windows Server 2016+
RuntimePython 3.xPython 3.8-3.11 + .NET Framework 4.8 or .NET 6+
SDK installationNoneAF SDK (~200 MB installer, requires admin rights)
Network ports443 (HTTPS)5450, 5457, 5459 (PI proprietary)
Server requirementPI Web API server must be deployedNo additional server (connects directly to DA/AF)
pip installrequests pandasPIconnect pythonnet
Docker supportAny 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)

piconnect_example.pypython
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)

piwebapi_example.pypython
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

write_comparison.pypython
# --- 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

bulk_comparison.pypython
# --- 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.

OperationPI Web APIPIconnectNotes
Single point current value5-20 ms2-10 msPIconnect has less overhead per call.
100 points current values50-150 ms (batch)200-1000 ms (sequential)PI Web API batch wins for multi-point reads.
10K recorded values0.5-2 s0.2-1 sPIconnect faster due to binary protocol.
100K recorded values2-8 s1-3 sJSON 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 requests and 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

LimitationImpact
pythonnet version conflictspythonnet has a history of breaking changes between versions. Upgrading Python or pythonnet can break PIconnect.
AF SDK version couplingPIconnect loads the AF SDK version installed on the machine. Upgrading PI System can break existing PIconnect scripts.
Slower maintenance cadencePIconnect is maintained by a single developer in their spare time. Bug fixes and new features depend on volunteer availability.
No async supportPIconnect 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 supportPIconnect 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 containerPI Web API (PIconnect is not an option)
Are on Windows with AF SDK, doing interactive analysisPIconnect (faster to get started)
Need to write valuesPI Web API
Are building a cloud pipelinePI Web API
Want quick Jupyter exploration on a PI serverPIconnect
Are building a production servicePI Web API (portability and maintainability)
Need to read 100+ points efficientlyPI Web API (batch endpoint)
Do not have PI Web API deployedPIconnect (until PI Web API is deployed)
Are starting a new project in 2026PI Web API (future-proof, platform-independent)

Next steps