Code Examples

Complete integration examples for popular AI platforms and development environments

🤖 OpenClaw
🧠 Claude Functions
💬 ChatGPT Actions
📦 TypeScript SDK
🌐 Raw API

OpenClaw Integration

🤖 Native OpenClaw Support

DITO API is designed specifically for OpenClaw agents with natural language command interface and comprehensive function definitions.

Function Definition
Add DITO function to your OpenClaw agent
JSON
{
  "name": "dito_command",
  "description": "Execute DITO talent management commands. Use natural language to interact with souls, talents, arena events, and ember economy.",
  "parameters": {
    "type": "object",
    "properties": {
      "action": {
        "type": "string",
        "enum": [
          "get_soul", "list_talents", "start_talent_journey",
          "get_arena_events", "join_arena", "get_ember_balance",
          "transfer_ember", "2fa_status", "help"
        ],
        "description": "The action to perform"
      },
      "talent_label": {
        "type": "string",
        "description": "Name of the talent (for talent-related actions)"
      },
      "recipient_id": {
        "type": "string", 
        "description": "Soul ID for ember transfers"
      },
      "amount": {
        "type": "string",
        "description": "Amount for ember transfers"
      }
    },
    "required": ["action"]
  }
}
Agent Implementation
Python function for OpenClaw agents
Python
import requests
import os

def dito_command(action: str, **kwargs) -> dict:
    """Execute DITO talent management commands"""
    
    api_key = os.getenv('DITO_API_KEY')
    base_url = os.getenv('DITO_BASE_URL', 'https://api.dito.guru')
    
    headers = {
        'Authorization': f'Bearer {api_key}',
        'Content-Type': 'application/json'
    }
    
    payload = {'action': action, **kwargs}
    
    try:
        response = requests.post(
            f'{base_url}/command',
            json=payload,
            headers=headers,
            timeout=10
        )
        
        if response.status_code == 200:
            return response.json()
        else:
            return {
                'success': False,
                'error': f'HTTP {response.status_code}: {response.text}'
            }
    
    except Exception as e:
        return {
            'success': False,
            'error': f'Request failed: {str(e)}'
        }

Integration Steps

1

Get API Key

Obtain your DITO API key from the developer portal

export DITO_API_KEY="your-api-key"
export DITO_BASE_URL="https://api.dito.guru"
2

Add Function Definition

Register the DITO function in your OpenClaw agent configuration

3

Test Integration

Try natural language commands like "check my soul status" or "list my talents"

Claude Functions Integration

🧠 Claude Function Calling

DITO integrates seamlessly with Claude's function calling capabilities for natural talent management conversations.

Function Schema
Claude function definition for DITO API
JSON
{
  "name": "manage_dito_talents",
  "description": "Manage talents, souls, and arena participation in the DITO ecosystem. Use this for checking talent progress, starting journeys, arena events, and ember transactions.",
  "input_schema": {
    "type": "object",
    "properties": {
      "action": {
        "type": "string",
        "enum": [
          "get_soul", "list_talents", "start_talent_journey", 
          "get_arena_events", "join_arena", "get_ember_balance"
        ],
        "description": "The specific action to perform"
      },
      "parameters": {
        "type": "object",
        "description": "Action-specific parameters",
        "additionalProperties": true
      }
    },
    "required": ["action"]
  }
}
Implementation
Python function for Claude integration
Python
import anthropic
import requests

def manage_dito_talents(action: str, parameters: dict = None) -> str:
    """Manage talents and souls in DITO ecosystem"""
    
    api_key = os.getenv('DITO_API_KEY')
    base_url = "https://api.dito.guru"
    
    payload = {"action": action}
    if parameters:
        payload.update(parameters)
    
    response = requests.post(
        f"{base_url}/command",
        json=payload,
        headers={'Authorization': f'Bearer {api_key}'}
    )
    
    if response.status_code == 200:
        data = response.json()
        if data.get('success'):
            return f"✅ {data.get('message', 'Success')}\n\nData: {data.get('data', {})}"
        else:
            return f"❌ {data.get('message', 'Error occurred')}"
    else:
        return f"❌ HTTP {response.status_code}: {response.text}"

# Usage with Claude
client = anthropic.Anthropic()

message = client.messages.create(
    model="claude-3-sonnet-20240229",
    max_tokens=1000,
    tools=[{
        "name": "manage_dito_talents",
        "description": "Manage talents, souls, and arena participation in the DITO ecosystem",
        "input_schema": {
            "type": "object",
            "properties": {
                "action": {"type": "string"},
                "parameters": {"type": "object"}
            },
            "required": ["action"]
        }
    }],
    messages=[{
        "role": "user",
        "content": "Check my soul status and list my current talents"
    }]
)

ChatGPT Actions Integration

💬 Custom GPT Actions

Create a custom GPT with DITO actions for seamless talent management through ChatGPT interface.

OpenAPI Schema
GPT Actions configuration
YAML
openapi: 3.0.0
info:
  title: DITO Talent Management API
  version: 1.0.0
  description: Manage talents, souls, and arena events in DITO ecosystem

servers:
  - url: https://api.dito.guru

paths:
  /command:
    post:
      operationId: executeCommand
      summary: Execute DITO command
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                action:
                  type: string
                  enum: [get_soul, list_talents, start_talent_journey]
                  description: Action to perform
                talent_label:
                  type: string
                  description: Talent name (for talent actions)
              required: [action]
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                  message:
                    type: string

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

security:
  - bearerAuth: []
Custom GPT Instructions
System prompt for DITO talent coach
Text
You are DITO Coach, an AI assistant for talent discovery and development in the DITO ecosystem.

Your capabilities include:
- Checking soul status and talent progress
- Starting new talent journeys
- Managing arena event participation  
- Handling ember transactions
- Providing talent development guidance

Always use a supportive, encouraging tone. Help users discover and develop their unique talents through the DITO platform.

When users ask about their progress, use the get_soul action to check their current state. For talent-related questions, use list_talents to see available options.

Remember the DITO motto: "Don't Ignore The One You Are" - help users embrace their authentic talents and capabilities.

TypeScript SDK Examples

📦 Type-Safe Development

Complete TypeScript SDK with full type safety, authentication handling, and error management.

Quick Start
Basic setup and usage
TypeScript
import { DitoClient } from '@dito/sdk';

// Initialize client
const dito = new DitoClient({
  apiKey: process.env.DITO_API_KEY!,
  baseURL: 'https://api.dito.guru'
});

// Basic usage examples
async function main() {
  try {
    // Get soul information
    const soul = await dito.souls.getSoul();
    console.log(`Welcome ${soul.seeker_name}!`);
    console.log(`Stage: ${soul.current_level}`);
    console.log(`Ember: ${soul.ember_points}`);

    // List available talents
    const talents = await dito.talents.listTalents();
    console.log(`Available talents: ${talents.length}`);
    
    // Check ember balance
    const balance = await dito.ember.getBalance();
    console.log(`Balance: ${balance.balance} EMBER`);
    
  } catch (error) {
    console.error('Error:', error);
  }
}

main();
React Integration
Using DITO SDK in React applications
TypeScript React
import React, { useState, useEffect } from 'react';
import { DitoClient, Soul } from '@dito/sdk';

const dito = new DitoClient({
  apiKey: process.env.REACT_APP_DITO_API_KEY!
});

export function SoulDashboard() {
  const [soul, setSoul] = useState(null);
  const [loading, setLoading] = useState(true);
  const [error, setError] = useState(null);

  useEffect(() => {
    async function loadSoul() {
      try {
        const soulData = await dito.souls.getSoul();
        setSoul(soulData);
      } catch (err) {
        setError(err instanceof Error ? err.message : 'Unknown error');
      } finally {
        setLoading(false);
      }
    }
    
    loadSoul();
  }, []);

  if (loading) return 
Loading...
; if (error) return
Error: {error}
; if (!soul) return
No soul found
; return (

Welcome, {soul.seeker_name}!

Stage: {soul.current_level}
Ember: {soul.ember_points}
Talents: {soul.total_talents}
); }

Raw API Examples

🌐 Direct HTTP Integration

Use cURL or any HTTP client to interact directly with the DITO API for maximum flexibility.

Authentication
Basic API authentication setup
bash
# Set your API key
export DITO_API_KEY="your-api-key"

# Basic health check
curl -X GET https://api.dito.guru/health

# Authenticated request
curl -X POST https://api.dito.guru/command \
  -H "Authorization: Bearer $DITO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action": "get_soul"}'
Common Operations
Frequently used API calls
bash
# Get soul information
curl -X POST https://api.dito.guru/command \
  -H "Authorization: Bearer $DITO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action": "get_soul"}'

# List talents
curl -X POST https://api.dito.guru/command \
  -H "Authorization: Bearer $DITO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action": "list_talents"}'

# Start talent journey
curl -X POST https://api.dito.guru/command \
  -H "Authorization: Bearer $DITO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "start_talent_journey",
    "talent_label": "Programming",
    "description": "Learning web development",
    "evidence": "GitHub: https://github.com/user/repo"
  }'

# Check ember balance
curl -X POST https://api.dito.guru/command \
  -H "Authorization: Bearer $DITO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action": "get_ember_balance"}'
Error Handling
Handling API errors and responses
bash
# Check HTTP status and handle errors
response=$(curl -s -w "\n%{http_code}" -X POST \
  https://api.dito.guru/command \
  -H "Authorization: Bearer $DITO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action": "get_soul"}')

body=$(echo "$response" | head -n -1)
status=$(echo "$response" | tail -n 1)

if [ "$status" -eq 200 ]; then
  echo "Success: $body"
else
  echo "Error $status: $body"
fi

# Parse JSON response
echo "$body" | jq '.success, .message, .data'