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.0.tar.gz (139.7 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.0-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: iii_sdk-0.8.0.tar.gz
  • Upload date:
  • Size: 139.7 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.0.tar.gz
Algorithm Hash digest
SHA256 75b27163b2b80afc03f6ef1182a25639882f28ddf32fb1f3cf3928e069f6c895
MD5 dc78cd3b9f62eee7c1c28555eb989b18
BLAKE2b-256 7ddb92fc8bedda0ced85d45545c66ce881cb448c8fb1ecb769834a62d3ce351e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: iii_sdk-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 32.1 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a87f55a899e98c0484d680b349bcd098b99eda97815476668a4e0e684c800cc
MD5 831642e60c20fe1627610a5a2bd42151
BLAKE2b-256 aca544cf34098803f27171f53f2e81aa8c495d5225d3a104d3c32435dafa98bc

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