Initial backup 2026-02-17
This commit is contained in:
43
skills/api-setup/SKILL.md
Normal file
43
skills/api-setup/SKILL.md
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
name: api-setup
|
||||
description: Set up API integration with configuration and helper scripts
|
||||
metadata:
|
||||
{
|
||||
"openclaw": { "requires": { "bins": ["curl", "jq"] } },
|
||||
}
|
||||
---
|
||||
|
||||
# API Setup Skill
|
||||
|
||||
This skill helps you set up a new API integration with our standard configuration.
|
||||
|
||||
## Steps
|
||||
|
||||
1. Run `setup.sh <api-name>` to create the integration directory
|
||||
2. Copy `templates/config.template.json` to your integration directory
|
||||
3. Update the config with your API credentials
|
||||
4. Test the connection
|
||||
|
||||
## Configuration
|
||||
|
||||
The config template includes:
|
||||
- `api_key`: Your API key (get from the provider's dashboard)
|
||||
- `endpoint`: API endpoint URL
|
||||
- `timeout`: Request timeout in seconds (default: 30)
|
||||
|
||||
## Verification
|
||||
|
||||
After setup, verify:
|
||||
- [ ] Config file is valid JSON
|
||||
- [ ] API key is set and not a placeholder
|
||||
- [ ] Test connection succeeds
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Create new API integration
|
||||
setup.sh my-api
|
||||
|
||||
# Test connection
|
||||
test-api.sh my-api
|
||||
```
|
||||
63
skills/api-setup/scripts/setup.sh
Normal file
63
skills/api-setup/scripts/setup.sh
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
# API Setup Script
|
||||
# Creates a new API integration directory with templates
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $0 <api-name>"
|
||||
echo "Example: $0 stripe"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
API_NAME="$1"
|
||||
WORKSPACE_DIR="/home/openclaw/.openclaw/workspace"
|
||||
API_DIR="$WORKSPACE_DIR/apis/$API_NAME"
|
||||
|
||||
# Create directory
|
||||
mkdir -p "$API_DIR"
|
||||
|
||||
# Create config template
|
||||
cat > "$API_DIR/config.json" << 'EOF'
|
||||
{
|
||||
"api_key": "YOUR_API_KEY_HERE",
|
||||
"endpoint": "https://api.example.com/v1",
|
||||
"timeout": 30,
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
# Create test script
|
||||
cat > "$API_DIR/test.sh" << EOF
|
||||
#!/bin/bash
|
||||
# Test API connection
|
||||
|
||||
CONFIG_FILE="\$(dirname "\$0")/config.json"
|
||||
|
||||
# Check config exists
|
||||
if [ ! -f "\$CONFIG_FILE" ]; then
|
||||
echo "Error: config.json not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract values (requires jq)
|
||||
API_KEY=\$(jq -r '.api_key' "\$CONFIG_FILE")
|
||||
ENDPOINT=\$(jq -r '.endpoint' "\$CONFIG_FILE")
|
||||
|
||||
if [ "\$API_KEY" = "YOUR_API_KEY_HERE" ]; then
|
||||
echo "Error: Please set your API key in config.json"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Testing \$ENDPOINT..."
|
||||
curl -s -H "Authorization: Bearer \$API_KEY" "\$ENDPOINT" || echo "Connection test complete"
|
||||
EOF
|
||||
|
||||
chmod +x "$API_DIR/test.sh"
|
||||
|
||||
echo "✅ Created API integration: $API_NAME"
|
||||
echo "📁 Location: $API_DIR"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo "1. Edit $API_DIR/config.json with your credentials"
|
||||
echo "2. Run $API_DIR/test.sh to verify connection"
|
||||
8
skills/api-setup/templates/config.template.json
Normal file
8
skills/api-setup/templates/config.template.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"api_key": "YOUR_API_KEY_HERE",
|
||||
"endpoint": "https://api.example.com/v1",
|
||||
"timeout": 30,
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user