Here’s a minimal example of using the III SDK across all three languages:
Node.js
Python
Rust
import { init } from 'iii-sdk'// Initialize the SDKconst iii = init('ws://localhost:49134')// Register a functioniii.registerFunction( { id: 'greeting' }, async (data: { name: string }) => { return { message: `Hello, ${data.name}!` } })// Call the functionconst result = await iii.call('greeting', { name: 'World' })console.log(result.message) // "Hello, World!"
from iii import III# Initialize the SDKiii = III("ws://localhost:49134")# Register a functionasync def greeting(data): return {"message": f"Hello, {data['name']}!"}iii.register_function("greeting", greeting)# Connect and call the functionawait iii.connect()result = await iii.call("greeting", {"name": "World"})print(result["message"]) # "Hello, World!"
use iii_sdk::III;use serde_json::json;#[tokio::main]async fn main() -> Result<(), Box<dyn std::error::Error>> { // Initialize the SDK let iii = III::new("ws://127.0.0.1:49134"); iii.connect().await?; // Register a function iii.register_function("greeting", |input| async move { let name = input["name"].as_str().unwrap_or("World"); Ok(json!({ "message": format!("Hello, {}!", name) })) }); // Call the function let result = iii.call("greeting", json!({ "name": "World" })).await?; println!("{}", result["message"]); // "Hello, World!" Ok(())}