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.2.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.2-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: iii_sdk-0.8.2.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.2.tar.gz
Algorithm Hash digest
SHA256 630d4ce9e21feec4a322caa4b3af3142dac2f2affaa1cbba0e847fbdd372fa0f
MD5 b662295c3aa8930fdea1f675c113bef0
BLAKE2b-256 b0b62acd982f8d72f30acd5c197890e0777ce3412be3acac1b240baf7063a339

See more details on using hashes here.

File details

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

File metadata

  • Download URL: iii_sdk-0.8.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 86b1c797cfcad87301f93393213c1741ad47edd2a0f1617e6ef9717e472e99a1
MD5 1f44f860dfd7cbe076b35a813dfac388
BLAKE2b-256 cfc92e04149e177418400303892f236576d6e70acc212423d2e692dd2defea44

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