> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/iii-hq/sdk/llms.txt
> Use this file to discover all available pages before exploring further.

# III SDK

> Multi-language SDK for building distributed applications with the III Engine

## Welcome to III SDK

The III SDK provides a unified interface for building distributed applications with function registration, invocation, and trigger management. It enables seamless communication between services through a WebSocket-based engine.

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/quickstart">
    Get started in minutes with our quick start guide
  </Card>

  <Card title="Installation" icon="download" href="/installation">
    Detailed installation instructions for all languages
  </Card>
</CardGroup>

## Supported Languages

The III SDK is available in three languages, each designed to work seamlessly with the III Engine:

<CardGroup cols={3}>
  <Card title="Node.js" icon="node-js" color="#339933">
    TypeScript/JavaScript SDK with full async support and OpenTelemetry integration
  </Card>

  <Card title="Python" icon="python" color="#3776AB">
    Async Python SDK with function registration and context-aware logging
  </Card>

  <Card title="Rust" icon="rust" color="#CE412B">
    High-performance async Rust SDK with automatic reconnection
  </Card>
</CardGroup>

## Key Features

<CardGroup cols={2}>
  <Card title="Function Registration" icon="function">
    Register callable functions that can be invoked by other services in your distributed system
  </Card>

  <Card title="Function Invocation" icon="bolt">
    Call functions synchronously or asynchronously (fire-and-forget) across your service mesh
  </Card>

  <Card title="Trigger Management" icon="webhook">
    Create and manage triggers for API endpoints, events, schedules, and custom trigger types
  </Card>

  <Card title="Custom Trigger Types" icon="puzzle-piece">
    Define your own trigger types with custom logic to extend the platform
  </Card>

  <Card title="Context-Aware Logging" icon="message-lines">
    Built-in logging with execution context tracking across all function calls
  </Card>

  <Card title="OpenTelemetry Integration" icon="chart-line">
    Full observability with traces, metrics, and logs (Node.js SDK with optional Python/Rust support)
  </Card>

  <Card title="Automatic Reconnection" icon="arrows-rotate">
    Resilient WebSocket connections with automatic reconnection handling
  </Card>

  <Card title="State Management" icon="database">
    Built-in state and stream management for atomic updates and distributed data
  </Card>
</CardGroup>

## How It Works

The III SDK communicates with the III Engine via WebSocket connections. The engine acts as a central orchestrator for:

* **Function Registry and Routing** - Maintains a registry of all available functions and routes invocations to the appropriate service
* **Trigger Management** - Manages trigger registration, configuration, and execution across your system
* **Inter-Service Communication** - Enables seamless communication between different services in your architecture
* **Telemetry and Observability** - Collects and exports traces, metrics, and logs for full system visibility

<Note>
  The III Engine must be running and accessible via WebSocket (default: `ws://localhost:49134`) for the SDK to function.
</Note>

## Quick Example

Here's a simple example showing how to register a function and create an HTTP trigger:

<CodeGroup>
  ```javascript Node.js theme={null}
  import { III } from 'iii-sdk'

  const iii = new III('ws://localhost:49134')

  iii.registerFunction({ id: 'myFunction' }, (req) => {
    return { status_code: 200, body: { message: 'Hello, world!' } }
  })

  iii.registerTrigger({
    type: 'http',
    function_id: 'myFunction',
    config: { api_path: '/hello', http_method: 'POST' },
  })

  const result = await iii.call('myFunction', { param: 'value' })
  ```

  ```python Python theme={null}
  from iii import III

  iii = III("ws://localhost:49134")

  async def my_function(data):
      return {"result": "success"}

  iii.register_function("my.function", my_function)

  await iii.connect()

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

  result = await iii.call("my.function", {"param": "value"})
  ```

  ```rust Rust theme={null}
  use iii_sdk::III;
  use serde_json::json;

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let iii = III::new("ws://127.0.0.1:49134");
      iii.connect().await?;

      iii.register_function("my.function", |input| async move {
          Ok(json!({ "message": "Hello, world!", "input": input }))
      });

      let result: serde_json::Value = iii
          .call("my.function", json!({ "param": "value" }))
          .await?;

      println!("result: {result}");
      Ok(())
  }
  ```
</CodeGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Get Started" icon="play" href="/quickstart">
    Follow our quickstart guide to build your first III application
  </Card>

  <Card title="Installation Guide" icon="wrench" href="/installation">
    Detailed setup instructions and prerequisites for each language
  </Card>

  <Card title="API Reference" icon="book" href="/api/types/function-info">
    Explore the complete API documentation for all SDKs
  </Card>

  <Card title="Examples" icon="code" href="https://github.com/iii-hq/sdk">
    Browse complete example applications in the GitHub repository
  </Card>
</CardGroup>

## License

The III SDK is licensed under the Apache License 2.0. See the [LICENSE](https://github.com/iii-hq/sdk/blob/main/LICENSE) file for details.
