Tutorial
API Integration: Build powerful applications on top of OpenClaw using its REST API, webhooks, and skill system.
OpenClaw API Overview
OpenClaw exposes several integration points:
- REST API: HTTP endpoints for sending messages and managing sessions
- WebSocket: Real-time message streaming
- Webhooks: Event notifications
- Skills API: Create custom automation logic
Authentication
export OPENCLAW_API_KEY="your-api-key"
curl -H "Authorization: Bearer $OPENCLAW_API_KEY" \
https://api.openclaw.example/v1/messagesSending Messages
POST /v1/messages
{
"text": "What's the weather like?",
"session_id": "user123",
"channel": "whatsapp"
}Building a Custom Integration
// Node.js example
import { OpenClawClient } from '@openclaw/sdk';
const client = new OpenClawClient({
apiKey: process.env.OPENCLAW_API_KEY,
baseURL: 'http://localhost:8080'
});
const response = await client.messages.send({
text: 'Analyze this code for bugs',
context: { code: '...' }
});Skill Development
Create reusable skills that extend OpenClaw's capabilities:
// skills/custom-integration.ts
export async function handleCustomAction(params: CustomParams) {
// Your integration logic here
return { success: true, data: result };
}Best Practices
- Use environment variables for API keys
- Implement proper error handling and retry logic
- Cache responses when appropriate
- Rate limit your API calls
- Log all API interactions for debugging