Konnektr Graph SDK for Python
Project description
Konnektr Graph SDK for Python
A powerful, Python SDK for Konnektr Graph, fully compatible with the Azure Digital Twins API but optimized for the Konnektr ecosystem.
Features
- Azure-Free: No dependencies on Azure libraries.
- Synchronous & Asynchronous: High-performance clients for both threaded and async workflows.
- Modular Auth: Supports OAuth 2.0 Client Credentials, Device Code Flow, and Static Tokens.
- Auto-Pagination: Seamlessly iterate through large query results and resource lists.
- Data Models: Typed dataclasses for Digital Twins, Models, Relationships, and Jobs.
Installation
pip install konnektr-graph
Quick Start
Synchronous Client
from konnektr_graph import KonnektrGraphClient
from konnektr_graph.auth import ClientSecretCredential
# Authenticate
cred = ClientSecretCredential(
domain="auth.konnektr.io",
audience="https://graph.konnektr.io",
client_id="YOUR_CLIENT_ID",
client_secret="YOUR_CLIENT_SECRET"
)
# Initialize Client
client = KonnektrGraphClient("https://your-graph-endpoint.konnektr.io", cred)
# Get a Digital Twin
twin = client.get_digital_twin("my-twin-id")
print(twin)
# Query Twins with auto-pagination
for twin in client.query_twins("SELECT * FROM digitaltwins"):
print(twin)
Asynchronous Client
import asyncio
from konnektr_graph.aio import KonnektrGraphClient
from konnektr_graph.auth import AsyncClientSecretCredential
async def main():
cred = AsyncClientSecretCredential(
domain="auth.konnektr.io",
audience="https://graph.konnektr.io",
client_id="...",
client_secret="..."
)
async with KonnektrGraphClient("https://your-graph-endpoint.konnektr.io", cred) as client:
twin = await client.get_digital_twin("my-twin-id")
print(twin)
asyncio.run(main())
Authentication Options
ClientSecretCredential/AsyncClientSecretCredential: Ideal for server-to-server scenarios.DeviceCodeCredential/AsyncDeviceCodeCredential: Best for interactive CLI tools.StaticTokenCredential: Use when you already have a valid access token.DefaultAzureCredentialAdapter/AsyncDefaultAzureCredentialAdapter: Use Azure Identity credentials through the SDK auth protocol.
Using Azure Identity (DefaultAzureCredential)
If your backend validates Azure AD tokens (e.g., ADT-compatible audience https://digitaltwins.azure.net/),
you can adapt DefaultAzureCredential to this SDK's TokenProvider interface.
Install Azure Identity in your app:
pip install azure-identity
Sync
from azure.identity import DefaultAzureCredential
from konnektr_graph import KonnektrGraphClient
from konnektr_graph.auth import DefaultAzureCredentialAdapter
endpoint = "https://your-graph-endpoint"
azure_cred = DefaultAzureCredential()
cred = DefaultAzureCredentialAdapter(
azure_cred,
scope="https://digitaltwins.azure.net/.default",
)
client = KonnektrGraphClient(endpoint, cred)
twin = client.get_digital_twin("my-twin-id")
print(twin)
Async
import asyncio
from azure.identity.aio import DefaultAzureCredential
from konnektr_graph.aio import KonnektrGraphClient
from konnektr_graph.auth import AsyncDefaultAzureCredentialAdapter
async def main():
endpoint = "https://your-graph-endpoint"
azure_cred = DefaultAzureCredential()
cred = AsyncDefaultAzureCredentialAdapter(
azure_cred,
scope="https://digitaltwins.azure.net/.default",
)
async with KonnektrGraphClient(endpoint, cred) as client:
twin = await client.get_digital_twin("my-twin-id")
print(twin)
await azure_cred.close()
asyncio.run(main())
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
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 konnektr_graph-0.2.13.tar.gz.
File metadata
- Download URL: konnektr_graph-0.2.13.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44767c5cfd36a4409d9073a6ed8a8b249a5f76b918b3598f1376545a72e1edb2
|
|
| MD5 |
4bb6bc2a068c07632876bb707cdf8110
|
|
| BLAKE2b-256 |
c077e1cf03fffd2609e6f5b6a40fe6fa3cd21d2ed7573ff12f0a61ff62ea677d
|
Provenance
The following attestation bundles were made for konnektr_graph-0.2.13.tar.gz:
Publisher:
pypi-publish.yml on konnektr-io/graph-client-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
konnektr_graph-0.2.13.tar.gz -
Subject digest:
44767c5cfd36a4409d9073a6ed8a8b249a5f76b918b3598f1376545a72e1edb2 - Sigstore transparency entry: 1600956282
- Sigstore integration time:
-
Permalink:
konnektr-io/graph-client-sdk-python@e9726e6f7334cdb3a05d168e64ddd867406eb210 -
Branch / Tag:
refs/tags/v0.2.13 - Owner: https://github.com/konnektr-io
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@e9726e6f7334cdb3a05d168e64ddd867406eb210 -
Trigger Event:
push
-
Statement type:
File details
Details for the file konnektr_graph-0.2.13-py3-none-any.whl.
File metadata
- Download URL: konnektr_graph-0.2.13-py3-none-any.whl
- Upload date:
- Size: 31.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f02eb89e98300a0e8b6e552a3193d4b88be8238c4477a05d5bc23d506fdbeab
|
|
| MD5 |
6166f13b7f6919562996b5d51949e13f
|
|
| BLAKE2b-256 |
f1920adb1f2fd1ef90a83f6477b31046beb973d7943879e827a1fb8cc8566141
|
Provenance
The following attestation bundles were made for konnektr_graph-0.2.13-py3-none-any.whl:
Publisher:
pypi-publish.yml on konnektr-io/graph-client-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
konnektr_graph-0.2.13-py3-none-any.whl -
Subject digest:
3f02eb89e98300a0e8b6e552a3193d4b88be8238c4477a05d5bc23d506fdbeab - Sigstore transparency entry: 1600956683
- Sigstore integration time:
-
Permalink:
konnektr-io/graph-client-sdk-python@e9726e6f7334cdb3a05d168e64ddd867406eb210 -
Branch / Tag:
refs/tags/v0.2.13 - Owner: https://github.com/konnektr-io
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@e9726e6f7334cdb3a05d168e64ddd867406eb210 -
Trigger Event:
push
-
Statement type: