A professional library for PI Web API integration
Project description
piwebapiconnect
A professional Python library for PI Web API integration.
Installation
pip install piwebapiconnect
Usage
Using .env file
Create a .env file in your project root with the following variables:
PI_WEB_API_URL=https://your-pi-server/piwebapi
PI_WEB_API_USERNAME=domain\user
PI_WEB_API_PASSWORD=your-password
PI_SERVER_NAME=PISERVER01
PI_WEB_API_VERIFY_SSL=True # Optional, defaults to True
from piwebapiconnect import get_service
service = get_service()
Functions Provided
All service functions are asynchronous.
get_current_value(tag_name: str): Fetch the current value for a given PI tag.get_recorded_values(tag_name: str, start_time: str, end_time: str): Fetch historical (recorded) values for a time range.write_value(tag_name: str, value: Any, timestamp: Any = None): Write a value for a PI tag.search_tags(query: str): Search for PI tags based on a query pattern.get_asset_servers(): List available PI AF System (Asset Server) names.get_organizations(asset_server: str): List AF Databases (Organizations) on a specific Asset Server.test_connection(): Verify the connection status to the PI Web API.close(): Close the underlying HTTP client.
Passing credentials directly
from piwebapiconnect import get_service
import asyncio
service = get_service(
url="https://your-pi-server/piwebapi",
username="domain\\user",
password="your-password",
server_name="PISERVER01",
verify_ssl=False # Optional
)
async def main():
val = await service.get_current_value("YourTagName")
print(val)
if __name__ == "__main__":
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
piwebapiconnect-0.1.3.tar.gz
(4.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file piwebapiconnect-0.1.3.tar.gz.
File metadata
- Download URL: piwebapiconnect-0.1.3.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46b9e9d59d77f58e0b830f988e62ba817db2558679d5d3fe5bbdaa7e1bcc4093
|
|
| MD5 |
48436994a0e1ae76d6cb04135016ea8e
|
|
| BLAKE2b-256 |
d5fe026bec49ccbbfa5e0422133c00af1d7f46c105ad8f8f1e74ad8b163b9222
|
File details
Details for the file piwebapiconnect-0.1.3-py3-none-any.whl.
File metadata
- Download URL: piwebapiconnect-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1fc0d63bb1e50de97c71a4576f3754ec5610f8b623fb51d6a2e450394a78762
|
|
| MD5 |
cf6b106abc7c35961b0670a49e04fb3b
|
|
| BLAKE2b-256 |
4b69fe8841dad1400c5fb2054bb4ae7f0b807e395e2557280ce13e0f1a493db5
|