Alura Backend API
Use this skill when integrating with or calling the Alura Trading backend API. The testnet API base URL is https://testnet-api.alura.fun.
Base URL
CODEBLOCK0
- - Swagger docs: INLINECODE0
- All authenticated endpoints require INLINECODE1
Authentication (EVM Wallet)
1. Get challenge
CODEBLOCK1
Returns { address, nonce, message }.
2. Sign & verify
User signs message with MetaMask (personal_sign). Then:
CODEBLOCK2
Returns { ok: true, accessToken, tokenType: "Bearer", expiresIn: 86400, ... }. Use accessToken for subsequent requests.
Trading Sessions
Base path: /trading-sessions. All require Bearer token.
Quick trade – create session
CODEBLOCK3
Required: budget (min 10), profitTarget (max 500), assetIndex (Hyperliquid perp index: 0=BTC, 1=ETH, 2=SOL, etc.).
Advance trade – create session
CODEBLOCK4
Other trading endpoints
| Method | Path | Description |
|---|
| GET | /trading-sessions/active | List active sessions |
| GET |
/trading-sessions/current-trade | Current trade with positions |
| GET | /trading-sessions/:sessionId/logs | Session logs |
| GET | /trading-sessions/trades/:tradeId/logs | Trade logs (paginated) |
| POST | /trading-sessions/positions/:positionId/close | Close a position |
| POST | /trading-sessions/positions/:positionId/close-signature | Get signed close tx for frontend |
| POST | /trading-sessions/trades/:tradeId/close | Close trade (all positions) |
| POST | /trading-sessions/trigger-cron | Manually trigger cron (testing) |
User
Base path: /user. All require Bearer token.
| Method | Path | Description |
|---|
| GET | /user/profile | Current user profile |
| POST |
/user/fills/sync | Sync fills from Hyperliquid |
| POST | /user/withdraw | Withdraw funds |
| POST | /user/close-position | Close position by assetIndex |
| POST | /user/close-all-positions | Close all positions |
| POST | /user/send-usdc | Send USDC |
| GET | /auth/evm/trading-key | Get trading agent key (auth) |
| POST | /user/claim-reward | Claim rewards |
Indicators & Market Data
Base path: /api/indicators. Most are public.
| Method | Path | Description |
|---|
| GET | /api/indicators/health | Service health |
| GET |
/api/indicators/candles/latest | Latest candles |
| GET | /api/indicators/candles/history/:symbol | Historical candles |
| GET | /api/indicators/candles/:symbol/:interval | Candles by symbol/interval |
| GET | /api/indicators/candles/aggregated/symbols | Available symbols |
| GET | /api/indicators/signals/:symbol/:interval | Signals for symbol |
| GET | /api/indicators/signals/all/:interval | All symbols signals |
Leaderboard
Base path: /api/leaderboard.
| Method | Path | Description |
|---|
| GET | /api/leaderboard/stats | Leaderboard stats |
| GET |
/api/leaderboard/rankings | Rankings |
| GET | /api/leaderboard/user/:userId | User ranking |
| GET | /api/leaderboard/analytics | Analytics |
| GET | /api/leaderboard/health | Health |
Referrals
Base path: /referrals.
| Method | Path | Description |
|---|
| GET | /referrals/:userId | User referral info |
| GET |
/referrals/:userId/stats | Referral stats |
| POST | /referrals/:userId/code | Create referral code |
| POST | /referrals/check | Check referral code |
USDC Verification
Base path: /usdc-verification.
| Method | Path | Description |
|---|
| POST | /usdc-verification/verify | Verify USDC deposit |
| GET |
/usdc-verification/my-transactions | My transactions |
| GET | /usdc-verification/total-deposited | Total deposited |
Health
| Method | Path | Description |
|---|
| GET | /health | Basic health |
| GET |
/health/kafka | Kafka health |
Asset Indices (Hyperliquid Perps)
Common perp asset indices:
1 |
| SOL | 2 |
| XRP | 3 |
| DOGE | 4 |
| AVAX | 5 |
Error Handling
- - 401: Missing/invalid Bearer token. Re-auth via
/auth/evm/challenge and /auth/evm/verify. - 400: Validation error. Check
message in response body. - 429: Rate limit. Retry with backoff.
- Common messages:
Duplicate asset index: you already have an active trading session for this asset, Builder fee approval failed: HTTP request failed: status 429.
Alura 后端 API
在与 Alura 交易后端 API 集成或调用时使用此技能。测试网 API 基础 URL 为 https://testnet-api.alura.fun。
基础 URL
https://testnet-api.alura.fun
- - Swagger 文档:https://testnet-api.alura.fun/api/docs
- 所有需要认证的端点均需 Authorization: Bearer
认证(EVM 钱包)
1. 获取挑战
POST /auth/evm/challenge
Content-Type: application/json
{ address: 0x... }
返回 { address, nonce, message }。
2. 签名并验证
用户使用 MetaMask(personal_sign)对 message 进行签名。然后:
POST /auth/evm/verify
Content-Type: application/json
{ address: 0x..., signature: 0x..., referralCode: OPTIONAL }
返回 { ok: true, accessToken, tokenType: Bearer, expiresIn: 86400, ... }。使用 accessToken 进行后续请求。
交易会话
基础路径:/trading-sessions。所有端点均需 Bearer 令牌。
快速交易 – 创建会话
POST /trading-sessions
Authorization: Bearer
Content-Type: application/json
{
budget: 100,
profitTarget: 40,
lossThreshold: 5,
maxPositions: 3,
assetIndex: 0
}
必填项:budget(最小值 10)、profitTarget(最大值 500)、assetIndex(Hyperliquid 永续合约指数:0=BTC、1=ETH、2=SOL 等)。
高级交易 – 创建会话
POST /trading-sessions/advance
Authorization: Bearer
Content-Type: application/json
{
amount: 100,
executionStrategy: Conservative | Aggressive | Degen,
strategyDuration: 1D | 3D | 7D | 30D | 90D | 365D,
assetIndex: 0,
maxWalletBudget: false
}
其他交易端点
| 方法 | 路径 | 描述 |
|---|
| GET | /trading-sessions/active | 列出活跃会话 |
| GET |
/trading-sessions/current-trade | 当前交易及持仓 |
| GET | /trading-sessions/:sessionId/logs | 会话日志 |
| GET | /trading-sessions/trades/:tradeId/logs | 交易日志(分页) |
| POST | /trading-sessions/positions/:positionId/close | 平仓 |
| POST | /trading-sessions/positions/:positionId/close-signature | 获取前端签名后的平仓交易 |
| POST | /trading-sessions/trades/:tradeId/close | 关闭交易(所有持仓) |
| POST | /trading-sessions/trigger-cron | 手动触发定时任务(测试用) |
用户
基础路径:/user。所有端点均需 Bearer 令牌。
| 方法 | 路径 | 描述 |
|---|
| GET | /user/profile | 当前用户资料 |
| POST |
/user/fills/sync | 从 Hyperliquid 同步成交记录 |
| POST | /user/withdraw | 提取资金 |
| POST | /user/close-position | 按资产指数平仓 |
| POST | /user/close-all-positions | 平掉所有持仓 |
| POST | /user/send-usdc | 发送 USDC |
| GET | /auth/evm/trading-key | 获取交易代理密钥(认证) |
| POST | /user/claim-reward | 领取奖励 |
指标与市场数据
基础路径:/api/indicators。大部分为公开接口。
| 方法 | 路径 | 描述 |
|---|
| GET | /api/indicators/health | 服务健康状态 |
| GET |
/api/indicators/candles/latest | 最新 K 线数据 |
| GET | /api/indicators/candles/history/:symbol | 历史 K 线数据 |
| GET | /api/indicators/candles/:symbol/:interval | 按交易对/时间间隔获取 K 线 |
| GET | /api/indicators/candles/aggregated/symbols | 可用交易对 |
| GET | /api/indicators/signals/:symbol/:interval | 交易对信号 |
| GET | /api/indicators/signals/all/:interval | 所有交易对信号 |
排行榜
基础路径:/api/leaderboard。
| 方法 | 路径 | 描述 |
|---|
| GET | /api/leaderboard/stats | 排行榜统计 |
| GET |
/api/leaderboard/rankings | 排名 |
| GET | /api/leaderboard/user/:userId | 用户排名 |
| GET | /api/leaderboard/analytics | 分析数据 |
| GET | /api/leaderboard/health | 健康状态 |
推荐
基础路径:/referrals。
| 方法 | 路径 | 描述 |
|---|
| GET | /referrals/:userId | 用户推荐信息 |
| GET |
/referrals/:userId/stats | 推荐统计 |
| POST | /referrals/:userId/code | 创建推荐码 |
| POST | /referrals/check | 检查推荐码 |
USDC 验证
基础路径:/usdc-verification。
| 方法 | 路径 | 描述 |
|---|
| POST | /usdc-verification/verify | 验证 USDC 存款 |
| GET |
/usdc-verification/my-transactions | 我的交易记录 |
| GET | /usdc-verification/total-deposited | 总存款金额 |
健康状态
| 方法 | 路径 | 描述 |
|---|
| GET | /health | 基础健康检查 |
| GET |
/health/kafka | Kafka 健康检查 |
资产指数(Hyperliquid 永续合约)
常见永续合约资产指数:
1 |
| SOL | 2 |
| XRP | 3 |
| DOGE | 4 |
| AVAX | 5 |
错误处理
- - 401:缺少或无效的 Bearer 令牌。通过 /auth/evm/challenge 和 /auth/evm/verify 重新认证。
- 400:验证错误。检查响应体中的 message 字段。
- 429:请求频率限制。使用退避策略重试。
- 常见消息:Duplicate asset index: you already have an active trading session for this asset、Builder fee approval failed: HTTP request failed: status 429。