API 与开发者指南
通过自定义技能、REST API 集成和 Webhook 扩展 ClawBox。构建强大的自动化并连接外部服务。
快速开始
Terminal
# Connect to your ClawBox via SSH
# Default credentials: user "clawbox", password "clawbox"
ssh clawbox@clawbox.local
# Check API status
curl http://clawbox.local:8080/api/status
# Send a message
curl -X POST http://clawbox.local:8080/api/chat \
-H "Content-Type: application/json" \
-d '{"message": "Hello, ClawBox!"}'REST API
ClawBox 提供本地 REST API 用于程序化控制。
GET
/api/status检查您的 ClawBox 当前状态。
示例:
curl http://clawbox.local:8080/api/statusPOST
/api/chat发送消息并接收 AI 回复。
示例:
curl -X POST -H "Content-Type: application/json" -d {"message": "Hello"} http://clawbox.local:8080/api/chatGET
/api/skills列出所有已安装的技能及其状态。
示例:
curl http://clawbox.local:8080/api/skillsPUT
/api/config更新 ClawBox 配置设置。
示例:
curl -X PUT -H "Content-Type: application/json" -d {"voice": true} http://clawbox.local:8080/api/config构建自定义技能
技能是扩展 ClawBox 功能的 Python 模块。它们可以响应触发器、调用 API 并与外部服务集成。
技能结构
my-skill/
├── manifest.json # Skill metadata
├── handler.py # Main skill logic
├── requirements.txt # Python dependencies
└── README.md # Documentationmanifest.json
{
"name": "weather-skill",
"version": "1.0.0",
"description": "Get weather information",
"triggers": ["weather", "forecast", "temperature"],
"author": "Your Name",
"permissions": ["network"]
}handler.py
from openclaw import Skill, Response
class WeatherSkill(Skill):
def handle(self, message: str, context: dict) -> Response:
# Parse location from message
location = self.extract_location(message)
# Fetch weather data
weather = self.get_weather(location)
return Response(
text=f"Weather in {location}: {weather['temp']}°C",
data=weather
)安装技能
Terminal
# Install a skill from GitHub
openclaw skill install github.com/user/weather-skill
# Install from local directory
openclaw skill install ./my-skill
# List installed skills
openclaw skill list
# Remove a skill
openclaw skill remove weather-skillWebhook
当 ClawBox 上发生事件时接收实时通知。
可用事件
🔔
message.received🔔
message.sent🔔
skill.triggered🔔
system.status身份验证
API 请求需要使用 Bearer 令牌进行身份验证。使用 CLI 生成令牌。
# Generate API token
openclaw token generate --name "my-app"
# Use token in requests
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://clawbox.local:8080/api/chat