Skip to main content

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 (Cypher)
query = "MATCH (t:Twin) RETURN t"
for twin in client.query_twins(query):
    print(twin)

# Query with parameters (Cypher + `$name` placeholders, forwarded to the
# server's `parameters` field; only Cypher supports query parameters)
params = {"model": "dtmi:com:example:Room;1", "minTemp": 20}
query = "MATCH (t:Twin) WHERE t.`$metadata`.`$model` = $model AND temperature > $minTemp RETURN t"
for twin in client.query_twins(query, query_parameters=params):
    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 "konnektr-graph[azure]"

Or install azure-identity directly if you prefer:

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.

Metadata

Release files for konnektr-graph 0.3.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for konnektr-graph 0.3.8
File Size Uploaded
konnektr_graph-0.3.8.tar.gz 34.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for konnektr-graph 0.3.8
File Interpreter ABI Platform
konnektr_graph-0.3.8-py3-none-any.whl Python 3 none any Details

Total release size: 67.5 kB

Release files / konnektr_graph-0.3.8.tar.gz

Download URL konnektr_graph-0.3.8.tar.gz
Size 34.8 kB
Tags Source
SHA-256 checksum
How to use checksums
137ac2af3df6cbc523a44d7cfbaa6fbd976bfa11a1630fc9c1a324e277dd6ca7
BLAKE2b-256 checksum
How to use checksums
5f1b6fe7ac30935d95b7d6c8cf8089aadf030e12032313f3878e1d5bd9284175
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / konnektr_graph-0.3.8-py3-none-any.whl

Download URL konnektr_graph-0.3.8-py3-none-any.whl
Size 32.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc953adf53304e2eb4917a40b36e9358f3321a9bb3056f2dbabc115eae306c04
BLAKE2b-256 checksum
How to use checksums
fc936d5cce1933c17502d10c29a139c268298eac0846b8c692f7d98bb845ecbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.9

2 release files

This release

0.3.8 This release

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.2

2 release files

0.3.0

2 release files

0.2.14

2 release files

0.2.13

2 release files

0.2.12

2 release files

0.2.9

2 release files

0.2.7

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page