Skip to main content

Installation

Install the iii SDK via npm:
Or with yarn:

Quick Start

Here’s a simple example that creates a function and exposes it via HTTP:
Your function is now live at http://localhost:3111/add.

Connection

Initialize the SDK

Connect to the iii engine using the WebSocket URL:
The SDK automatically connects to the engine and maintains the connection.

Environment Variables

You can configure the connection URL using environment variables:

Registering Functions

Basic Function Registration

Register a function that can be invoked by the engine:

Function with Description

Provide metadata about your function:

Async Operations

All function handlers support async/await:

Error Handling

Handle errors gracefully in your functions:

Registering Triggers

Triggers determine when and how functions are invoked. iii supports multiple trigger types.
Expose functions as HTTP endpoints:
Configuration options:
  • api_path: The URL path (e.g., ‘add’ → /add)
  • http_method: HTTP method (GET, POST, PUT, DELETE, PATCH)
Dynamic routes:

Invoking Functions

You can invoke functions directly from your code:

Fire-and-Forget Invocations

Invoke a function without waiting for the result:

Complete Example

Here’s a full example demonstrating multiple features:

API Reference

init(url: string)

Initialize the SDK and connect to the iii engine. Parameters:
  • url: WebSocket URL of the iii engine (default: ws://localhost:49134)
Returns: SDK instance

registerFunction(request, handler)

Register a function with the engine. Parameters:
  • request.id: Unique function identifier
  • request.description: Optional description
  • handler: Async function that receives input and returns output

registerTrigger(trigger)

Register a trigger for a function. Parameters:
  • trigger.type: Trigger type (http, queue, cron, stream)
  • trigger.function_id: ID of the function to invoke
  • trigger.config: Trigger-specific configuration

invoke(functionId, input, options?)

Invoke a function programmatically. Parameters:
  • functionId: ID of the function to invoke
  • input: Input data for the function
  • options.fireAndForget: Don’t wait for result (optional)
Returns: Promise resolving to function result

Best Practices

Use namespaced IDs like user.create, email.send, data.transform to organize your functions.
Always handle errors in your functions and return meaningful error messages.
Each function should do one thing well. Use function invocations to compose complex workflows.
The SDK supports TypeScript for better type checking and IDE support.

Next Steps

Python SDK

Learn about the Python SDK

Rust SDK

Learn about the Rust SDK

HTTP Module

Deep dive into HTTP triggers

Queue Module

Learn about queue-based triggers