Base URL: https://your-deployment-url.repl.co
API 前缀: /api
认证方式: JWT Bearer Token
Content-Type: application/json
当前系统启用了 Admin 模式(admin_mode: true),无需认证即可访问受保护的API。
关闭 Admin 模式后,需要在请求头中携带 JWT Token:
Authorization: Bearer <your_jwt_token>
GET /响应示例:
{
"status": "ok",
"service": "Monnaire Trading Agent OS AI Trading System"
}GET /api/health响应示例:
{
"status": "ok",
"time": "2025-11-11T08:52:31Z"
}GET /api/config响应示例:
{
"admin_mode": true,
"beta_mode": false,
"default_coins": ["BTCUSDT", "ETHUSDT", "SOLUSDT", "BNBUSDT"],
"btc_eth_leverage": 5,
"altcoin_leverage": 5
}GET /api/supported-models响应示例:
[
{
"id": "deepseek",
"name": "DeepSeek",
"provider": "deepseek",
"description": "DeepSeek AI 模型"
},
{
"id": "qwen",
"name": "Qwen",
"provider": "qwen",
"description": "通义千问 AI 模型"
}
]GET /api/supported-exchanges响应示例:
[
{
"id": "binance",
"name": "Binance",
"type": "cex",
"description": "币安期货交易所"
},
{
"id": "hyperliquid",
"name": "Hyperliquid",
"type": "dex",
"description": "Hyperliquid DEX"
}
]GET /api/prompt-templates响应示例:
[
{
"name": "default",
"description": "默认系统提示词",
"file_name": "default.txt"
},
{
"name": "adaptive",
"description": "自适应提示词",
"file_name": "adaptive.txt"
}
]GET /api/prompt-templates/:nameURL 参数:
name: 模板名称(如default,adaptive)
响应示例:
{
"name": "default",
"content": "你是一个专业的加密货币AI交易员..."
}GET /api/tradersQuery 参数:
limit: 返回数量(默认50)
响应示例:
[
{
"id": "binance_deepseek_1731312751",
"name": "AI Trader Alpha",
"ai_model": "deepseek",
"exchange": "binance",
"total_pnl": 1250.50,
"win_rate": 68.5,
"total_trades": 145,
"rank": 1
}
]GET /api/competition响应示例:
{
"total_traders": 328,
"total_trades": 12450,
"best_performer": {
"trader_id": "binance_deepseek_1731312751",
"pnl": 1250.50,
"win_rate": 68.5
}
}GET /api/top-traders响应示例:
[
{
"trader_id": "binance_deepseek_1731312751",
"name": "AI Trader Alpha",
"total_pnl": 1250.50,
"win_rate": 68.5
}
]GET /api/equity-history?trader_id=xxxQuery 参数:
trader_id: 交易员ID
响应示例:
[
{
"timestamp": "2025-11-11T08:00:00Z",
"equity": 10250.50,
"pnl": 250.50
}
]POST /api/equity-history-batch请求体:
{
"trader_ids": ["trader1", "trader2", "trader3"]
}响应示例:
{
"trader1": [
{"timestamp": "2025-11-11T08:00:00Z", "equity": 10250.50}
],
"trader2": [
{"timestamp": "2025-11-11T08:00:00Z", "equity": 9850.30}
]
}GET /api/traders/:id/public-configURL 参数:
id: 交易员ID
响应示例:
{
"name": "AI Trader Alpha",
"ai_model": "deepseek",
"exchange": "binance",
"initial_balance": 10000,
"btc_eth_leverage": 5,
"altcoin_leverage": 5
}POST /api/register请求体:
{
"email": "user@example.com",
"beta_code": "YOUR_BETA_CODE"
}响应示例:
{
"message": "验证码已发送至邮箱",
"email": "user@example.com"
}POST /api/login请求体:
{
"email": "user@example.com"
}响应示例:
{
"message": "验证码已发送至邮箱",
"email": "user@example.com"
}POST /api/verify-otp请求体:
{
"email": "user@example.com",
"otp": "123456"
}响应示例:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user_id": "uuid-here"
}POST /api/complete-registration请求体:
{
"email": "user@example.com",
"otp": "123456"
}GET /api/my-traders响应示例:
[
{
"id": "binance_deepseek_1731312751",
"name": "My AI Trader",
"ai_model_id": "deepseek",
"exchange_id": "binance",
"initial_balance": 10000,
"is_running": false,
"btc_eth_leverage": 5,
"altcoin_leverage": 5,
"trading_symbols": "BTCUSDT,ETHUSDT",
"scan_interval_minutes": 3
}
]GET /api/traders/:id/configURL 参数:
id: 交易员ID
响应示例:
{
"id": "binance_deepseek_1731312751",
"name": "My AI Trader",
"ai_model_id": "deepseek",
"exchange_id": "binance",
"initial_balance": 10000,
"btc_eth_leverage": 5,
"altcoin_leverage": 5,
"trading_symbols": "BTCUSDT,ETHUSDT",
"custom_prompt": "",
"override_base_prompt": false,
"system_prompt_template": "default",
"is_cross_margin": true,
"scan_interval_minutes": 3,
"use_coin_pool": false,
"use_oi_top": false
}POST /api/traders请求体:
{
"name": "My AI Trader",
"ai_model_id": "deepseek",
"exchange_id": "binance",
"initial_balance": 10000,
"btc_eth_leverage": 5,
"altcoin_leverage": 5,
"trading_symbols": "BTCUSDT,ETHUSDT,SOLUSDT",
"custom_prompt": "",
"override_base_prompt": false,
"system_prompt_template": "default",
"is_cross_margin": true,
"scan_interval_minutes": 3,
"use_coin_pool": false,
"use_oi_top": false
}响应示例:
{
"trader_id": "binance_deepseek_1731312751",
"trader_name": "My AI Trader",
"ai_model": "deepseek",
"is_running": false
}PUT /api/traders/:idURL 参数:
id: 交易员ID
请求体:
{
"name": "Updated AI Trader",
"ai_model_id": "deepseek",
"exchange_id": "binance",
"initial_balance": 15000,
"btc_eth_leverage": 3,
"altcoin_leverage": 3,
"trading_symbols": "BTCUSDT,ETHUSDT",
"custom_prompt": "更激进的交易策略",
"override_base_prompt": false,
"is_cross_margin": true,
"scan_interval_minutes": 5
}响应示例:
{
"trader_id": "binance_deepseek_1731312751",
"trader_name": "Updated AI Trader",
"ai_model": "deepseek",
"message": "交易员更新成功"
}DELETE /api/traders/:idURL 参数:
id: 交易员ID
响应示例:
{
"message": "交易员已删除"
}POST /api/traders/:id/startURL 参数:
id: 交易员ID
响应示例:
{
"message": "交易员已启动"
}POST /api/traders/:id/stopURL 参数:
id: 交易员ID
响应示例:
{
"message": "交易员已停止"
}PUT /api/traders/:id/promptURL 参数:
id: 交易员ID
请求体:
{
"custom_prompt": "采用更保守的策略,严格止损",
"override_base_prompt": false
}响应示例:
{
"message": "自定义prompt已更新"
}GET /api/models响应示例:
{
"deepseek": {
"id": "deepseek",
"name": "DeepSeek",
"provider": "deepseek",
"enabled": true,
"api_key": "sk-***",
"custom_api_url": "",
"custom_model_name": ""
},
"qwen": {
"id": "qwen",
"name": "Qwen",
"provider": "qwen",
"enabled": false,
"api_key": "",
"custom_api_url": "",
"custom_model_name": ""
}
}PUT /api/models请求体:
{
"models": {
"deepseek": {
"enabled": true,
"api_key": "sk-your-deepseek-api-key",
"custom_api_url": "",
"custom_model_name": ""
},
"qwen": {
"enabled": true,
"api_key": "sk-your-qwen-api-key",
"custom_api_url": "",
"custom_model_name": ""
}
}
}响应示例:
{
"message": "模型配置已更新"
}GET /api/exchanges响应示例:
{
"binance": {
"id": "binance",
"name": "Binance",
"type": "cex",
"enabled": true,
"api_key": "***",
"secret_key": "***",
"testnet": false
},
"hyperliquid": {
"id": "hyperliquid",
"name": "Hyperliquid",
"type": "dex",
"enabled": false,
"wallet_address": ""
}
}PUT /api/exchanges请求体(Binance):
{
"exchanges": {
"binance": {
"enabled": true,
"api_key": "your-binance-api-key",
"secret_key": "your-binance-secret-key",
"testnet": false
}
}
}请求体(Hyperliquid):
{
"exchanges": {
"hyperliquid": {
"enabled": true,
"api_key": "",
"secret_key": "",
"testnet": false,
"hyperliquid_wallet_addr": "0xYourWalletAddress"
}
}
}响应示例:
{
"message": "交易所配置已更新"
}GET /api/user/signal-sources响应示例:
{
"coin_pool_url": "https://api.example.com/coin-pool",
"oi_top_url": "https://api.example.com/oi-top"
}POST /api/user/signal-sources请求体:
{
"coin_pool_url": "https://api.example.com/coin-pool",
"oi_top_url": "https://api.example.com/oi-top"
}响应示例:
{
"message": "信号源配置已保存"
}所有以下接口都需要通过 trader_id query参数指定交易员:
GET /api/status?trader_id=xxx响应示例:
{
"trader_id": "binance_deepseek_1731312751",
"is_running": true,
"uptime_seconds": 3600,
"last_scan_time": "2025-11-11T09:00:00Z"
}GET /api/account?trader_id=xxx响应示例:
{
"balance": 10250.50,
"equity": 10500.30,
"margin_used": 500.00,
"available_margin": 10000.30,
"unrealized_pnl": 249.80
}GET /api/positions?trader_id=xxx响应示例:
[
{
"symbol": "BTCUSDT",
"side": "LONG",
"size": 0.5,
"entry_price": 45000.00,
"current_price": 45500.00,
"unrealized_pnl": 250.00,
"leverage": 5
}
]GET /api/decisions?trader_id=xxxQuery 参数:
trader_id: 交易员IDlimit: 返回数量(默认100)
响应示例:
[
{
"timestamp": "2025-11-11T09:00:00Z",
"symbol": "BTCUSDT",
"action": "OPEN_LONG",
"reason": "技术指标显示上涨趋势...",
"entry_price": 45000.00,
"size": 0.5,
"leverage": 5
}
]GET /api/decisions/latest?trader_id=xxx响应示例:
{
"timestamp": "2025-11-11T09:30:00Z",
"symbol": "ETHUSDT",
"action": "HOLD",
"reason": "市场震荡,暂不操作"
}GET /api/statistics?trader_id=xxx响应示例:
{
"total_trades": 145,
"winning_trades": 99,
"losing_trades": 46,
"win_rate": 68.28,
"total_pnl": 1250.50,
"max_drawdown": 8.5,
"sharpe_ratio": 2.3
}GET /api/performance?trader_id=xxx响应示例:
{
"model_accuracy": 72.5,
"decision_quality_score": 8.5,
"risk_management_score": 9.0,
"learning_progress": [
{"date": "2025-11-01", "score": 7.5},
{"date": "2025-11-10", "score": 8.5}
]
}所有错误响应遵循以下格式:
{
"error": "错误描述信息"
}200 OK: 请求成功201 Created: 资源创建成功400 Bad Request: 请求参数错误401 Unauthorized: 未认证或认证失败403 Forbidden: 无权限访问404 Not Found: 资源不存在500 Internal Server Error: 服务器内部错误
API已启用CORS,允许跨域请求:
Access-Control-Allow-Origin: *Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONSAccess-Control-Allow-Headers: Content-Type, Authorization
// 获取系统配置
const config = await fetch('https://your-deployment.repl.co/api/config')
.then(res => res.json());
// 创建交易员(需要认证)
const trader = await fetch('https://your-deployment.repl.co/api/traders', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer your-jwt-token'
},
body: JSON.stringify({
name: 'My AI Trader',
ai_model_id: 'deepseek',
exchange_id: 'binance',
initial_balance: 10000
})
}).then(res => res.json());import requests
# 获取健康检查
response = requests.get('https://your-deployment.repl.co/api/health')
data = response.json()
# 创建交易员(需要认证)
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer your-jwt-token'
}
payload = {
'name': 'My AI Trader',
'ai_model_id': 'deepseek',
'exchange_id': 'binance',
'initial_balance': 10000
}
response = requests.post(
'https://your-deployment.repl.co/api/traders',
json=payload,
headers=headers
)
trader = response.json()# 健康检查
curl https://your-deployment.repl.co/api/health
# 创建交易员(需要认证)
curl -X POST https://your-deployment.repl.co/api/traders \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-jwt-token" \
-d '{
"name": "My AI Trader",
"ai_model_id": "deepseek",
"exchange_id": "binance",
"initial_balance": 10000
}'