Skip to main content

III SDK for Python

Project description

iii-sdk

Python SDK for the iii engine.

PyPI Python License

Install

pip install iii-sdk

Hello World

import asyncio
from iii import init

async def main():
    iii = init("ws://localhost:49134")

    async def greet(data):
        return {"message": f"Hello, {data['name']}!"}

    iii.register_function("greet", greet)

    iii.register_trigger(
        type="http",
        function_id="greet",
        config={"api_path": "/greet", "http_method": "POST"}
    )

    result = await iii.trigger("greet", {"name": "world"})
    print(result)

asyncio.run(main())

API

Operation Signature Description
Initialize init(url, options?) Create an SDK instance and auto-connect
Register function iii.register_function(id, handler) Register a function that can be invoked by name
Register trigger iii.register_trigger(type, function_id, config) Bind a trigger (HTTP, cron, queue, etc.) to a function
Invoke (await) await iii.trigger(id, data) Invoke a function and wait for the result
Invoke (fire-and-forget) iii.trigger_void(id, data) Invoke a function without waiting (fire-and-forget)

init() must be called inside an async context. It creates the SDK instance and auto-connects to the engine.

Registering Functions

async def create_order(data):
    return {"status_code": 201, "body": {"id": "123", "item": data["body"]["item"]}}

iii.register_function("orders.create", create_order)

Registering Triggers

iii.register_trigger(
    type="http",
    function_id="orders.create",
    config={"api_path": "/orders", "http_method": "POST"}
)

Invoking Functions

result = await iii.trigger("orders.create", {"body": {"item": "widget"}})

iii.trigger_void("analytics.track", {"event": "page_view"})

Modules

Import What it provides
iii Core SDK (III, types)
iii.stream Stream client for real-time state
iii.telemetry OpenTelemetry integration

Development

Install in development mode

pip install -e .

Type checking

mypy src

Linting

ruff check src

Deprecated

call() and call_void() are deprecated aliases for trigger() and trigger_void(). They still work but will be removed in a future release.

Resources

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

iii_sdk-0.8.3.tar.gz (151.5 kB view details)

Uploaded Source

Built Distribution

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

iii_sdk-0.8.3-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

Details for the file iii_sdk-0.8.3.tar.gz.

File metadata

  • Download URL: iii_sdk-0.8.3.tar.gz
  • Upload date:
  • Size: 151.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for iii_sdk-0.8.3.tar.gz
Algorithm Hash digest
SHA256 cafa5a9b25fe2d7bd538c32c3c6c9d024ff36e35bef32564a9a645036f73ebe5
MD5 7347d9e113ce7bf157f4528b47c7d502
BLAKE2b-256 1202d7eeda6bc13a00f992c208d28117ccca821d9db6fc90c16773b9116c6310

See more details on using hashes here.

File details

Details for the file iii_sdk-0.8.3-py3-none-any.whl.

File metadata

  • Download URL: iii_sdk-0.8.3-py3-none-any.whl
  • Upload date:
  • Size: 31.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for iii_sdk-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 99e92ff28c006e62f161acd324184557fec0c3536ebb4002d085e77b9d6d7414
MD5 ceb857b0a331c4d428a7c785d8e28ac1
BLAKE2b-256 70f48c15ec648a3b179dc4f6b58b327edda6e924655c9040e68674d3656aa7e1

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