Skip to main content

Overview

TAHO provides a REST API for invoking WebAssembly service components and managing the runtime. The API is available via HTTP(S) and follows standard REST conventions.

Base URL

By default, the API is available at:
http://localhost:9481/api
Configure the port and TLS settings in config.toml:
[http]
port = 9481
tls_enable = false  # Set to true for HTTPS
tls_port = 9443

API Structure

The TAHO API is organized into two main categories:

Services API

Invoke and manage WebAssembly service components:
  • POST /services/{domain}/{service}/invoke/{method} - Invoke a service method
  • POST /services/{domain}/{service}/restart - Restart a service with new config
  • PUT /services/{domain}/{service}/quiesce - Gracefully stop a service

System API

Manage the TAHO runtime:
  • POST /reload - Reload all components from repositories

URL Pattern

Service endpoints follow a consistent pattern:
/api/services/{domain}/{service}/invoke/{method}
  • domain: Component namespace (e.g., example, myapp, ai)
  • service: Service name (e.g., hello, calculator, txt2img)
  • method: Method to invoke (e.g., greet, add, generate)

Request Format

JSON Requests

Most service methods accept JSON request bodies:
curl -X POST http://localhost:9481/api/services/example/hello/invoke/greet \
  -H "Content-Type: application/json" \
  -d '{"name": "World"}'

Binary Requests

For binary data (e.g., image processing):
curl -X POST http://localhost:9481/api/services/ai/txt2img/invoke/generate \
  -H "Content-Type: application/octet-stream" \
  --data-binary @input.png

Response Format

JSON Responses

Structured data returned as JSON:
{
  "result": "Hello, World!"
}

Binary Responses

Raw binary data (e.g., generated images):
curl -X POST http://localhost:9481/api/services/ai/txt2img/invoke/generate \
  -d '{"prompt": "sunset"}' \
  --output image.png

Streaming Responses

For large datasets or real-time output:
curl -X POST http://localhost:9481/api/services/data/processor/invoke/process \
  -d '{"file": "large_dataset.csv"}' \
  -N  # No buffering

Error Handling

Standard HTTP status codes are used:
  • 200 OK: Request succeeded
  • 404 Not Found: Service or method not found
  • 500 Internal Server Error: Service execution error
Error responses include details:
{
  "error": "Service method execution failed",
  "details": "Division by zero",
  "service": "math.calculator",
  "method": "divide"
}

Authentication

Current Version: TAHO does not require authentication. All API endpoints are open.Future versions may add optional authentication mechanisms for production deployments.

Rate Limiting

Current Version: No rate limiting is enforced.Configure timeouts in config.toml to prevent long-running requests:
[http]
request_timeout_seconds = 30

CORS

Cross-Origin Resource Sharing (CORS) is enabled by default for development. Configure CORS settings in config.toml:
[http.cors]
enabled = true
allowed_origins = ["*"]  # Restrict in production
allowed_methods = ["GET", "POST", "PUT", "DELETE"]

Quick Start Examples

Invoke a Service

curl -X POST http://localhost:9481/api/services/example/hello/invoke/greet \
  -H "Content-Type: application/json" \
  -d '{"name": "Developer"}'

Restart a Service

curl -X POST http://localhost:9481/api/services/ai/model/restart \
  -H "Content-Type: application/json" \
  -d '{"model": "llama-3-8b"}'

Reload All Components

curl -X POST http://localhost:9481/api/reload

Configuration

View your merged configuration using the CLI:
# View as TOML
taho config

# View as JSON
taho config --format json
Override settings via environment variables:
# Change API port
export TAHO__HTTP__PORT=8080

# Enable TLS
export TAHO__HTTP__TLS_ENABLE=true
export TAHO__HTTP__TLS_PORT=8443

# Start with new configuration
taho start

Next Steps

Support