Aster Futures Skill
Futures request on Aster using authenticated API endpoints. Authentication uses EIP-712 ECDSA signing with API wallet (main wallet + signer wallet). Return the result in JSON format.
Data Fetching Guidelines (CRITICAL)
NEVER truncate JSON responses with head -c, head -n, or similar — truncated JSON is corrupted and will produce wrong results.
Mandatory Rules
- 1. Always specify
symbol parameter when querying a specific trading pair. Many endpoints return ALL symbols when symbol is omitted, producing responses of 100KB+. - Always use
limit parameter to constrain result size. Use the smallest limit that satisfies the request (e.g., limit=5 instead of default 500). - Use
jq to extract fields — never parse raw mega-JSON visually. Pipe through jq to select only needed data.
Progressive Data Exploration Strategy
When the user asks a broad question (e.g., "what futures are available?"), use a layered approach:
- 1. Step 1 — Get lightweight summary first:
CODEBLOCK0
- 2. Step 2 — Confirm scope with user before fetching detailed data for many symbols.
- 3. Step 3 — Fetch details for specific symbols only:
CODEBLOCK1
Endpoints That Return Dangerously Large Data (without symbol filter)
| Endpoint | Without INLINECODE8 | With INLINECODE9 |
|---|
| INLINECODE10 | ALL symbols + filters (100KB+) | N/A — use jq to filter |
| INLINECODE12 |
ALL symbols (50KB+) | Single object (~500B) |
|
/fapi/v3/ticker/price | ALL symbols (10KB+) | Single object (~80B) |
|
/fapi/v3/ticker/bookTicker | ALL symbols (20KB+) | Single object (~150B) |
|
/fapi/v3/premiumIndex | ALL symbols (30KB+) | Single object (~300B) |
|
/fapi/v3/depth | N/A (symbol required) | Varies by
limit: use
limit=5 for overview |
|
/fapi/v3/klines | N/A (symbol required) | Default 500 candles — always set
limit |
|
/fapi/v3/trades | N/A (symbol required) | Default 500 trades — always set
limit |
Example: Safe vs Unsafe
CODEBLOCK2
Quick Reference
| Endpoint | Description | Required | Optional | Authentication |
|---|
| INLINECODE23 (GET) | Test connectivity | None | None | No |
| INLINECODE24 (GET) |
Check server time | None | None | No |
|
/fapi/v3/exchangeInfo (GET) | Exchange information | None | None | No |
|
/fapi/v3/depth (GET) | Order book | symbol | limit | No |
|
/fapi/v3/trades (GET) | Recent trades list | symbol | limit | No |
|
/fapi/v3/historicalTrades (GET) | Old trades lookup | symbol | limit, fromId | Yes |
|
/fapi/v3/aggTrades (GET) | Compressed/Aggregate trades list | symbol | fromId, startTime, endTime, limit | No |
|
/fapi/v3/klines (GET) | Kline/Candlestick data | symbol, interval | startTime, endTime, limit | No |
|
/fapi/v3/indexPriceKlines (GET) | Index price kline data | pair, interval | startTime, endTime, limit | No |
|
/fapi/v3/markPriceKlines (GET) | Mark price kline data | symbol, interval | startTime, endTime, limit | No |
|
/fapi/v3/premiumIndex (GET) | Mark price and funding rate | None | symbol | No |
|
/fapi/v3/fundingRate (GET) | Funding rate history | None | symbol, startTime, endTime, limit | No |
|
/fapi/v3/ticker/24hr (GET) | 24hr ticker price change statistics | None | symbol | No |
|
/fapi/v3/ticker/price (GET) | Symbol price ticker | None | symbol | No |
|
/fapi/v3/ticker/bookTicker (GET) | Symbol order book ticker | None | symbol | No |
|
/fapi/v3/order (POST) | New order | symbol, side, type, timestamp | positionSide, timeInForce, quantity, reduceOnly, price, newClientOrderId, stopPrice, closePosition, activationPrice, callbackRate, workingType, priceProtect, newOrderRespType, recvWindow | Yes |
|
/fapi/v3/batchOrders (POST) | Place multiple orders | batchOrders, timestamp | recvWindow | Yes |
|
/fapi/v3/order (GET) | Query order | symbol, timestamp | orderId, origClientOrderId, recvWindow | Yes |
|
/fapi/v3/order (DELETE) | Cancel order | symbol, timestamp | orderId, origClientOrderId, recvWindow | Yes |
|
/fapi/v3/allOpenOrders (DELETE) | Cancel all open orders | symbol, timestamp | recvWindow | Yes |
|
/fapi/v3/batchOrders (DELETE) | Cancel multiple orders | symbol, timestamp | orderIdList, origClientOrderIdList, recvWindow | Yes |
|
/fapi/v3/countdownCancelAll (POST) | Auto-cancel all open orders (countdown) | symbol, countdownTime, timestamp | recvWindow | Yes |
|
/fapi/v3/openOrder (GET) | Query current open order | symbol, timestamp | orderId, origClientOrderId, recvWindow | Yes |
|
/fapi/v3/openOrders (GET) | Current all open orders | timestamp | symbol, recvWindow | Yes |
|
/fapi/v3/allOrders (GET) | All orders | symbol, timestamp | orderId, startTime, endTime, limit, recvWindow | Yes |
|
/fapi/v3/balance (GET) | Futures account balance | timestamp | recvWindow | Yes |
|
/fapi/v3/account (GET) | Account information | timestamp | recvWindow | Yes |
|
/fapi/v3/leverage (POST) | Change initial leverage | symbol, leverage, timestamp | recvWindow | Yes |
|
/fapi/v3/marginType (POST) | Change margin type | symbol, marginType, timestamp | recvWindow | Yes |
|
/fapi/v3/positionMargin (POST) | Modify isolated position margin | symbol, amount, type, timestamp | positionSide, recvWindow | Yes |
|
/fapi/v3/positionMargin/history (GET) | Position margin change history | symbol, timestamp | type, startTime, endTime, limit, recvWindow | Yes |
|
/fapi/v3/positionRisk (GET) | Position information | timestamp | symbol, recvWindow | Yes |
|
/fapi/v3/positionSide/dual (POST) | Change position mode | dualSidePosition, timestamp | recvWindow | Yes |
|
/fapi/v3/positionSide/dual (GET) | Get current position mode | timestamp | recvWindow | Yes |
|
/fapi/v3/multiAssetsMargin (POST) | Change multi-assets mode | multiAssetsMargin, timestamp | recvWindow | Yes |
|
/fapi/v3/multiAssetsMargin (GET) | Get current multi-assets mode | timestamp | recvWindow | Yes |
|
/fapi/v3/asset/wallet/transfer (POST) | Transfer between futures and spot | amount, asset, clientTranId, kindType, timestamp | None | Yes |
|
/fapi/v3/userTrades (GET) | Account trade list | symbol, timestamp | startTime, endTime, fromId, limit, recvWindow | Yes |
|
/fapi/v3/income (GET) | Get income history | timestamp | symbol, incomeType, startTime, endTime, limit, recvWindow | Yes |
|
/fapi/v3/leverageBracket (GET) | Notional and leverage brackets | timestamp | symbol, recvWindow | Yes |
|
/fapi/v3/adlQuantile (GET) | Position ADL quantile estimation | timestamp | symbol, recvWindow | Yes |
|
/fapi/v3/forceOrders (GET) | User's force orders | timestamp | symbol, autoCloseType, startTime, endTime, limit, recvWindow | Yes |
|
/fapi/v3/commissionRate (GET) | User commission rate | symbol, timestamp | recvWindow | Yes |
|
/fapi/v3/listenKey (POST) | Start user data stream | None | None | Yes |
|
/fapi/v3/listenKey (PUT) | Keepalive user data stream | None | None | Yes |
|
/fapi/v3/listenKey (DELETE) | Close user data stream | None | None | Yes |
|
GET /bapi/futures/v1/public/future/aster/deposit/assets | Get all deposit assets | chainIds, accountType | networks | No |
|
GET /bapi/futures/v1/public/future/aster/withdraw/assets | Get all withdraw assets | chainIds, accountType | networks | No |
|
GET /bapi/futures/v1/public/future/aster/estimate-withdraw-fee | Estimate withdraw fee | chainId, network, currency, accountType | None | No |
|
POST /fapi/aster/user-withdraw | Withdraw by API (EVM Futures) | chainId, asset, amount, fee, receiver, nonce, userSignature, timestamp, signature | recvWindow | Yes |
|
POST /fapi/aster/user-solana-withdraw | Withdraw by API (Solana Futures) | chainId, asset, amount, fee, receiver, timestamp, signature | recvWindow | Yes |
Parameters
Common Parameters
- * symbol: Trading pair symbol (e.g., BTCUSDT)
- pair: Trading pair for index price endpoints (e.g., BTCUSDT)
- side: Order side BUY or SELL
- type: Order type (LIMIT, MARKET, STOP, STOPMARKET, TAKEPROFIT, TAKEPROFITMARKET, TRAILINGSTOPMARKET)
- positionSide: Position side; default BOTH for One-way Mode; LONG/SHORT for Hedge Mode
- timeInForce: Time in force (GTC, IOC, FOK, GTX)
- quantity: Order quantity (e.g., 0.1)
- price: Order price (e.g., 50000)
- stopPrice: Stop price for STOP/STOPMARKET/TAKEPROFIT/TAKEPROFITMARKET orders
- closePosition: Close-All flag; "true" or "false"; cannot be used with quantity
- activationPrice: Activation price for TRAILINGSTOPMARKET orders
- callbackRate: Callback rate for TRAILINGSTOPMARKET; range 0.1-5
- workingType: Stop price trigger type; "MARKPRICE" or "CONTRACTPRICE"
- priceProtect: Price protection flag; "TRUE" or "FALSE"
- reduceOnly: Reduce-only flag; default "false"
- newClientOrderId: Unique client order ID
- newOrderRespType: Response type; "ACK" or "RESULT"
- orderId: Order ID (e.g., 22542179)
- origClientOrderId: Original client order ID
- orderIdList: List of order IDs to cancel (max 10)
- origClientOrderIdList: List of client order IDs to cancel (max 10)
- batchOrders: List of order objects (max 5)
- countdownTime: Countdown time in milliseconds; set to 0 to cancel countdown
- leverage: Leverage value; range 1-125
- marginType: Margin type; ISOLATED or CROSSED
- amount: Margin amount for position margin modification
- dualSidePosition: Position mode; "true" = Hedge Mode; "false" = One-way Mode
- multiAssetsMargin: Multi-assets mode; "true" = Multi-Assets Mode; "false" = Single-Asset Mode
- asset: Asset name (e.g., USDT)
- clientTranId: Client transfer ID (unique within 7 days)
- kindType: Transfer direction; FUTURESPOT or SPOTFUTURE
- incomeType: Income type filter (TRANSFER, WELCOMEBONUS, REALIZEDPNL, FUNDINGFEE, COMMISSION, INSURANCECLEAR, MARKETMERCHANTRETURN_REWARD)
- autoCloseType: Force order type; LIQUIDATION or ADL
- fromId: ID to get trades from INCLUSIVE (e.g., 1)
- startTime: Timestamp in ms to filter from INCLUSIVE (e.g., 1735693200000)
- endTime: Timestamp in ms to filter until INCLUSIVE (e.g., 1735693200000)
- limit: Result limit; varies per endpoint (e.g., 500)
- interval: Kline interval (e.g., 1h)
- recvWindow: Request validity window; cannot be greater than 60000 (e.g., 5000)
- timestamp: Request timestamp in milliseconds (e.g., 1735693200000)
- chainIds: Chain ID(s), comma-separated (for deposit/withdraw asset queries)
- chainId: Chain ID (for withdraw operations)
- networks: Network type (EVM, SOLANA), comma-separated
- network: Network type (EVM, SOL)
- currency: Currency name (e.g., ASTER)
- accountType: Account type (spot, perp)
- fee: Withdraw fee in token units
- receiver: Receipt address for withdrawals
- nonce: Unique number for signing (microsecond timestamp for API auth; milliseconds x 1000 for EIP712 withdraw)
- userSignature: EIP712 signature for EVM withdrawals
- signature: ECDSA API signature
Enums
- * side: BUY | SELL
- positionSide: BOTH | LONG | SHORT
- type (order): LIMIT | MARKET | STOP | STOPMARKET | TAKEPROFIT | TAKEPROFITMARKET | TRAILINGSTOPMARKET
- timeInForce: GTC | IOC | FOK | GTX
- workingType: MARKPRICE | CONTRACTPRICE
- marginType: ISOLATED | CROSSED
- newOrderRespType: ACK | RESULT
- interval: 1m | 3m | 5m | 15m | 30m | 1h | 2h | 4h | 6h | 8h | 12h | 1d | 3d | 1w | 1M
- orderStatus: NEW | PARTIALLYFILLED | FILLED | CANCELED | REJECTED | EXPIRED
- contractStatus: PENDINGTRADING | TRADING | PRESETTLE | SETTLING | CLOSE
- incomeType: TRANSFER | WELCOMEBONUS | REALIZEDPNL | FUNDINGFEE | COMMISSION | INSURANCECLEAR | MARKETMERCHANTRETURNREWARD
- autoCloseType: LIQUIDATION | ADL
- kindType: FUTURESPOT | SPOTFUTURE
- positionMarginType: 1 (add margin) | 2 (reduce margin)
Authentication
For endpoints that require authentication, you will need to provide Aster API credentials.
Required credentials:
- * Main Wallet Address (user): Your Aster main wallet address
- API Wallet Address (signer): Your API wallet address (obtained via Pro API registration at asterdex.com)
- API Wallet Private Key: Your API wallet private key (for ECDSA signing)
Base URLs:
- * Mainnet REST: https://fapi.asterdex.com
- Mainnet WebSocket: wss://fstream.asterdex.com
- Deposit/Withdraw Portal: https://www.asterdex.com
See references/authentication.md for implementation details.
Security
Share Credentials
Users can provide Aster API credentials by sending a file where the content is in the following format:
CODEBLOCK3
Line 1: Main wallet address (user)
Line 2: API wallet address (signer)
Line 3: API wallet private key
Never Display Full Secrets
When showing credentials to users:
- - Main Wallet: Show first 6 + last 4 characters: INLINECODE75
- API Wallet: Show first 6 + last 4 characters: INLINECODE76
- Private Key: Always mask, show only last 5: INLINECODE77
Example response when asked for credentials:
Account: main
Main Wallet: 0x1234...abcd
API Wallet: 0x5678...efgh
Private Key: *...f1a2b
Environment: Mainnet
Listing Accounts
When listing accounts, show names and environment only -- never keys:
Aster Accounts:
- * main (Mainnet)
- trading-01 (Mainnet)
- arb-bot (Mainnet)
Transactions in Mainnet
When performing transactions in mainnet, always confirm with the user before proceeding by asking them to write "CONFIRM" to proceed.
Aster Accounts
main
- - Main Wallet: yourmainwalletaddress
- API Wallet: yourapiwalletaddress
- Private Key: yourapiwalletprivatekey
- Description: Primary trading account
TOOLS.md Structure
CODEBLOCK4
Agent Behavior
- 1. Credentials requested: Mask private keys (show last 5 chars only), mask wallet addresses (show first 6 + last 4)
- Listing accounts: Show names and environment, never keys
- Account selection: Ask if ambiguous, default to main
- When doing a transaction in mainnet, confirm with user before by asking to write "CONFIRM" to proceed
- New credentials: Prompt for name, main wallet, API wallet, private key
Adding New Accounts
When user provides new credentials:
- * Ask for account name
- Ask for main wallet address (user)
- Ask for API wallet address (signer)
- Ask for API wallet private key
- Store in
TOOLS.md with masked display confirmation
Signing Requests
All authenticated endpoints require EIP-712 ECDSA signature:
- 1. Collect all API parameters as key-value pairs (all values as strings)
- Sort parameters by ASCII key order
- Combine sorted parameters with
user (main wallet address), signer (API wallet address), and nonce (microsecond timestamp) using Web3 ABI encoding - Generate Keccak256 hash of the ABI-encoded data
- Sign the hash with the API wallet's private key via ECDSA
- Include
user, signer, nonce, and signature in the request - Timestamp must be current milliseconds; request valid within recvWindow (default 5000ms)
See references/authentication.md for implementation details.
Aster 期货技能
使用经过身份验证的 API 端点对 Aster 进行期货请求。身份验证使用 EIP-712 ECDSA 签名,涉及 API 钱包(主钱包 + 签名钱包)。以 JSON 格式返回结果。
数据获取指南(关键)
切勿使用 head -c、head -n 或类似命令截断 JSON 响应——截断后的 JSON 已损坏,会产生错误结果。
强制性规则
- 1. 查询特定交易对时,始终指定 symbol 参数。许多端点在省略 symbol 时会返回所有交易对,产生 100KB+ 的响应。
- 始终使用 limit 参数 限制结果大小。使用满足请求的最小限制(例如,使用 limit=5 而不是默认的 500)。
- 使用 jq 提取字段——切勿目视解析原始的巨型 JSON。通过管道传递给 jq 仅选择所需数据。
渐进式数据探索策略
当用户提出宽泛的问题(例如,有哪些期货可用?)时,使用分层方法:
- 1. 第 1 步——首先获取轻量级摘要:
bash
# 仅获取交易对列表,而非完整的 exchangeInfo
curl -s https://fapi.asterdex.com/fapi/v3/exchangeInfo | jq [.symbols[].symbol]
- 2. 第 2 步——在获取多个交易对的详细数据之前,先与用户确认范围。
- 3. 第 3 步——仅获取特定交易对的详细信息:
bash
# 获取一个交易对的价格,而非所有
curl -s https://fapi.asterdex.com/fapi/v3/ticker/price?symbol=BTCUSDT
返回危险大数据量的端点(无 symbol 过滤器)
| 端点 | 无 symbol | 有 symbol |
|---|
| /fapi/v3/exchangeInfo | 所有交易对 + 过滤器(100KB+) | 不适用——使用 jq 过滤 |
| /fapi/v3/ticker/24hr |
所有交易对(50KB+) | 单个对象(~500B) |
| /fapi/v3/ticker/price | 所有交易对(10KB+) | 单个对象(~80B) |
| /fapi/v3/ticker/bookTicker | 所有交易对(20KB+) | 单个对象(~150B) |
| /fapi/v3/premiumIndex | 所有交易对(30KB+) | 单个对象(~300B) |
| /fapi/v3/depth | 不适用(需要 symbol) | 因 limit 而异:使用 limit=5 获取概览 |
| /fapi/v3/klines | 不适用(需要 symbol) | 默认 500 根 K 线——始终设置 limit |
| /fapi/v3/trades | 不适用(需要 symbol) | 默认 500 笔交易——始终设置 limit |
示例:安全与不安全
bash
错误——返回所有交易对,然后截断 = 损坏的 JSON
curl -s .../fapi/v3/ticker/price | head -c 5000
正确——返回单个交易对,完整的 JSON
curl -s .../fapi/v3/ticker/price?symbol=BTCUSDT
错误——默认 500 根 K 线
curl -s .../fapi/v3/klines?symbol=BTCUSDT&interval=1h
正确——仅 5 根 K 线
curl -s .../fapi/v3/klines?symbol=BTCUSDT&interval=1h&limit=5
正确——从 exchangeInfo 中仅提取交易对名称
curl -s .../fapi/v3/exchangeInfo | jq [.symbols[] | {symbol, status}]
快速参考
| 端点 | 描述 | 必需参数 | 可选参数 | 身份验证 |
|---|
| /fapi/v3/ping (GET) | 测试连接 | 无 | 无 | 否 |
| /fapi/v3/time (GET) |
检查服务器时间 | 无 | 无 | 否 |
| /fapi/v3/exchangeInfo (GET) | 交易所信息 | 无 | 无 | 否 |
| /fapi/v3/depth (GET) | 订单簿 | symbol | limit | 否 |
| /fapi/v3/trades (GET) | 近期交易列表 | symbol | limit | 否 |
| /fapi/v3/historicalTrades (GET) | 历史交易查询 | symbol | limit, fromId | 是 |
| /fapi/v3/aggTrades (GET) | 压缩/聚合交易列表 | symbol | fromId, startTime, endTime, limit | 否 |
| /fapi/v3/klines (GET) | K线/蜡烛图数据 | symbol, interval | startTime, endTime, limit | 否 |
| /fapi/v3/indexPriceKlines (GET) | 指数价格K线数据 | pair, interval | startTime, endTime, limit | 否 |
| /fapi/v3/markPriceKlines (GET) | 标记价格K线数据 | symbol, interval | startTime, endTime, limit | 否 |
| /fapi/v3/premiumIndex (GET) | 标记价格和资金费率 | 无 | symbol | 否 |
| /fapi/v3/fundingRate (GET) | 资金费率历史 | 无 | symbol, startTime, endTime, limit | 否 |
| /fapi/v3/ticker/24hr (GET) | 24小时价格变动统计 | 无 | symbol | 否 |
| /fapi/v3/ticker/price (GET) | 交易对价格 | 无 | symbol | 否 |
| /fapi/v3/ticker/bookTicker (GET) | 交易对订单簿价格 | 无 | symbol | 否 |
| /fapi/v3/order (POST) | 新订单 | symbol, side, type, timestamp | positionSide, timeInForce, quantity, reduceOnly, price, newClientOrderId, stopPrice, closePosition, activationPrice, callbackRate, workingType, priceProtect, newOrderRespType, recvWindow | 是 |
| /fapi/v3/batchOrders (POST) | 批量下单 | batchOrders, timestamp | recvWindow | 是 |
| /fapi/v3/order (GET) | 查询订单 | symbol, timestamp | orderId, origClientOrderId, recvWindow | 是 |
| /fapi/v3/order (DELETE) | 取消订单 | symbol, timestamp | orderId, origClientOrderId, recvWindow | 是 |
| /fapi/v3/allOpenOrders (DELETE) | 取消所有未成交订单 | symbol, timestamp | recvWindow | 是 |
| /fapi/v3/batchOrders (DELETE) | 批量取消订单 | symbol, timestamp | orderIdList, origClientOrderIdList, recvWindow | 是 |
| /fapi/v3/countdownCancelAll (POST) | 自动取消所有未成交订单(倒计时) | symbol, countdownTime, timestamp | recvWindow | 是 |
| /fapi/v3/openOrder (GET) | 查询当前未成交订单 | symbol, timestamp | orderId, origClientOrderId, recvWindow | 是 |
| /fapi/v3/openOrders (GET) | 当前所有未成交订单 | timestamp | symbol, recvWindow | 是 |
| /fapi/v3/allOrders (GET) | 所有订单 | symbol, timestamp | orderId, startTime, endTime, limit, recvWindow | 是 |
| /fapi/v3/balance (GET) | 期货账户余额 | timestamp | recvWindow | 是 |
| /fapi/v3/account (GET) | 账户信息 | timestamp | recvWindow | 是 |
| /fapi/v3/leverage (POST) | 更改初始杠杆 | symbol, leverage, timestamp | recvWindow | 是 |
| /fapi/v3/marginType (POST) | 更改保证金模式 | symbol, marginType, timestamp | recvWindow | 是 |
| /fapi/v3/positionMargin (POST) | 修改逐仓仓位保证金 | symbol, amount, type, timestamp | positionSide, recvWindow | 是 |
| /fapi/v3/positionMargin/history (GET) | 仓位保证金变更历史 | symbol, timestamp | type, startTime, endTime,