Python client library for i3X servers
Project description
i3x-client
Python client library for i3X servers.
Installation
pip install i3x-client
For development:
pip install -e ".[dev]"
Quick Start
import i3x
# Connect to an i3X server
client = i3x.Client("http://localhost:8080")
client.connect()
# Explore the data model
namespaces = client.get_namespaces()
object_types = client.get_object_types()
objects = client.get_objects(type_id="some-type")
# Read values
value = client.get_value("element-id-1")
print(value.data[0].value, value.data[0].quality)
# Read historical values
history = client.get_history("element-id-1", start_time="2026-01-01T00:00:00Z")
# Write values
client.update_value("element-id-1", {"temperature": 72.5})
# Disconnect
client.disconnect()
Context Manager
with i3x.Client("http://localhost:8080") as client:
namespaces = client.get_namespaces()
Subscriptions
client = i3x.Client("http://localhost:8080")
client.on_value_change = lambda client, change: print(f"{change.element_id}: {change.data}")
client.connect()
# Subscribe to value changes (creates subscription + registers + starts SSE stream)
sub = client.subscribe(["element-id-1", "element-id-2"])
# ... on_value_change fires automatically when values change ...
# Unsubscribe when done
client.unsubscribe(sub)
client.disconnect()
Authentication
client = i3x.Client("http://localhost:8080", auth=("api-key", "secret"))
API Reference
Client Methods
Connection
connect()— Connect to the serverdisconnect()— Disconnect and stop all subscriptionsis_connected— Property indicating connection state
Callbacks
on_connect(client)— Called after successful connectionon_disconnect(client)— Called after disconnectionon_value_change(client, change)— Called when a subscribed value changeson_subscribe(client, subscription)— Called after a subscription is createdon_error(client, error)— Called on stream/subscription errors
Exploration
get_namespaces()— List all namespacesget_object_types(namespace_uri=None)— List object typesquery_object_types(element_ids)— Query types by IDget_relationship_types(namespace_uri=None)— List relationship typesquery_relationship_types(element_ids)— Query relationship types by IDget_objects(type_id=None, include_metadata=False)— List object instancesget_object(element_id)— Get a single objectlist_objects(element_ids)— Get multiple objects by IDget_related_objects(element_ids, relationship_type)— Get related objects
Values
get_value(element_id, max_depth=1)— Get last known valueget_values(element_ids, max_depth=1)— Get multiple last known valuesget_history(element_id, start_time=None, end_time=None, max_depth=1)— Get historical values
Updates
update_value(element_id, value)— Update an element's valueupdate_history(element_id, value)— Update historical values
Subscriptions (High-Level)
subscribe(element_ids, max_depth=0)— Create subscription + register + start streamunsubscribe(subscription)— Stop stream and delete subscriptionsync_subscription(subscription)— Poll queued updates
Subscriptions (Low-Level)
create_subscription()— Create an empty subscriptionregister_items(subscription_id, element_ids, max_depth=0)— Register itemsunregister_items(subscription_id, element_ids)— Unregister itemsget_subscriptions()— List all subscriptionsget_subscription(subscription_id)— Get subscription detailsstart_stream(subscription_id)— Start SSE for an existing subscriptionstop_stream(subscription_id)— Stop SSE without deleting subscription
Models
All models are frozen dataclasses with from_dict() classmethods.
Namespace—uri,display_nameObjectType—element_id,display_name,namespace_uri,schemaRelationshipType—element_id,display_name,namespace_uri,reverse_ofObjectInstance—element_id,display_name,type_id,namespace_uri,parent_id,is_compositionVQT—value,quality,timestampLastKnownValue—element_id,data(list of VQT),childrenValueChange—element_id,data(list of VQT),childrenSubscription—subscription_id,created,is_streaming,queued_updates,objects
Errors
All errors inherit from i3x.I3XError:
ConnectionError— Failed to connectAuthenticationError— Auth rejected (401/403)NotFoundError— Resource not found (404)ServerError— Server error (5xx)TimeoutError— Request timed outSubscriptionError— Subscription operation failedStreamError— SSE streaming error
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
i3x_client-0.5.0.tar.gz
(18.1 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 i3x_client-0.5.0.tar.gz.
File metadata
- Download URL: i3x_client-0.5.0.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e40265b85e61b75097d8f1da16aaafbb7e43760b936ea0fd8a07cb5f2720da6
|
|
| MD5 |
673916893f7b746e570a17b12a0168d8
|
|
| BLAKE2b-256 |
08fa84b3f9e72ec08625b73cc59eef0a0f94ec3adf83480bbd6bd4183c00440f
|
File details
Details for the file i3x_client-0.5.0-py3-none-any.whl.
File metadata
- Download URL: i3x_client-0.5.0-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
285c2cd24145c3b87345f5a16c23b53706a9acbeccd8a704c5a9a1d8991cd264
|
|
| MD5 |
480b66de412e4012e80a873e27011630
|
|
| BLAKE2b-256 |
31f9e7d3f96242bce40a78a48ba39e824ee876b7cb21edbe4ceebbfa46c3b6c2
|