Skip to main content

Python client library for I3X CMIP servers

Project description

i3x-client

Python client library for I3X CMIP servers.

Installation

pip install i3x-client

For development:

pip install -e ".[dev]"

Quick Start

import i3x

# Connect to a CMIP 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 server
  • disconnect() — Disconnect and stop all subscriptions
  • is_connected — Property indicating connection state

Callbacks

  • on_connect(client) — Called after successful connection
  • on_disconnect(client) — Called after disconnection
  • on_value_change(client, change) — Called when a subscribed value changes
  • on_subscribe(client, subscription) — Called after a subscription is created
  • on_error(client, error) — Called on stream/subscription errors

Exploration

  • get_namespaces() — List all namespaces
  • get_object_types(namespace_uri=None) — List object types
  • query_object_types(element_ids) — Query types by ID
  • get_relationship_types(namespace_uri=None) — List relationship types
  • query_relationship_types(element_ids) — Query relationship types by ID
  • get_objects(type_id=None, include_metadata=False) — List object instances
  • get_object(element_id) — Get a single object
  • list_objects(element_ids) — Get multiple objects by ID
  • get_related_objects(element_ids, relationship_type) — Get related objects

Values

  • get_value(element_id, max_depth=1) — Get last known value
  • get_values(element_ids, max_depth=1) — Get multiple last known values
  • get_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 value
  • update_history(element_id, value) — Update historical values

Subscriptions (High-Level)

  • subscribe(element_ids, max_depth=0) — Create subscription + register + start stream
  • unsubscribe(subscription) — Stop stream and delete subscription
  • sync_subscription(subscription) — Poll queued updates

Subscriptions (Low-Level)

  • create_subscription() — Create an empty subscription
  • register_items(subscription_id, element_ids, max_depth=0) — Register items
  • unregister_items(subscription_id, element_ids) — Unregister items
  • get_subscriptions() — List all subscriptions
  • get_subscription(subscription_id) — Get subscription details
  • start_stream(subscription_id) — Start SSE for an existing subscription
  • stop_stream(subscription_id) — Stop SSE without deleting subscription

Models

All models are frozen dataclasses with from_dict() classmethods.

  • Namespaceuri, display_name
  • ObjectTypeelement_id, display_name, namespace_uri, schema
  • RelationshipTypeelement_id, display_name, namespace_uri, reverse_of
  • ObjectInstanceelement_id, display_name, type_id, namespace_uri, parent_id, is_composition
  • VQTvalue, quality, timestamp
  • LastKnownValueelement_id, data (list of VQT), children
  • ValueChangeelement_id, data (list of VQT), children
  • Subscriptionsubscription_id, created, is_streaming, queued_updates, objects

Errors

All errors inherit from i3x.I3XError:

  • ConnectionError — Failed to connect
  • AuthenticationError — Auth rejected (401/403)
  • NotFoundError — Resource not found (404)
  • ServerError — Server error (5xx)
  • TimeoutError — Request timed out
  • SubscriptionError — Subscription operation failed
  • StreamError — 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.1.0.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

i3x_client-0.1.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file i3x_client-0.1.0.tar.gz.

File metadata

  • Download URL: i3x_client-0.1.0.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for i3x_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9751796b5784d9447b9f6108206808caae4d37b52b1efdc7af1afe4d70407a8f
MD5 b05b35661ac6caf143ee6f929bfb005b
BLAKE2b-256 bdd441d7c3bf976ff30a6773ec2f47f5be85fc5022546afbdbf0d27f09c8c715

See more details on using hashes here.

File details

Details for the file i3x_client-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: i3x_client-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for i3x_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01f7f189a022241d680ceab8f6bc74674fd9da1e3b4ab74f0c064532aeb5a444
MD5 95e4f8cbee47c8d1df3660b91693c55b
BLAKE2b-256 97c7e78fdf338f5e383a64a150a39790f9523ca58ec4fb2efe811e58b92e9c48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page