🚀 快速安装
复制以下命令并运行,立即安装此 Skill:
npx skills add https://skills.sh/binance/binance-skills-hub/convert
💡 提示:需要 Node.js 和 NPM
币安闪兑技能 (Binance Convert Skill)
使用经过身份验证的 API 端点在币安上执行闪兑请求。某些端点需要 API 密钥和密钥。以 JSON 格式返回结果。
快速参考 (Quick Reference)
| 端点 (Endpoint) | 描述 (Description) | 必需 (Required) | 可选 (Optional) | 认证 (Authentication) |
|---|---|---|---|---|
/sapi/v1/convert/exchangeInfo (GET) |
列出所有闪兑交易对 (List All Convert Pairs) | 无 (None) | fromAsset, toAsset | 否 (No) |
/sapi/v1/convert/assetInfo (GET) |
查询每个资产的数量精度 (USER_DATA) (Query order quantity precision per asset) | 无 (None) | recvWindow | 是 (Yes) |
/sapi/v1/convert/acceptQuote (POST) |
接受报价 (TRADE) (Accept Quote) | quoteId | recvWindow | 是 (Yes) |
/sapi/v1/convert/limit/cancelOrder (POST) |
取消限价订单 (USER_DATA) (Cancel limit order) | orderId | recvWindow | 是 (Yes) |
/sapi/v1/convert/tradeFlow (GET) |
获取闪兑交易历史 (USER_DATA) (Get Convert Trade History) | startTime, endTime | limit, recvWindow | 是 (Yes) |
/sapi/v1/convert/orderStatus (GET) |
订单状态 (USER_DATA) (Order status) | 无 (None) | orderId, quoteId | 是 (Yes) |
/sapi/v1/convert/limit/placeOrder (POST) |
下限价订单 (USER_DATA) (Place limit order) | baseAsset, quoteAsset, limitPrice, side, expiredType | baseAmount, quoteAmount, walletType, recvWindow | 是 (Yes) |
/sapi/v1/convert/limit/queryOpenOrders (GET) |
查询限价未成交订单 (USER_DATA) (Query limit open orders) | 无 (None) | recvWindow | 是 (Yes) |
/sapi/v1/convert/getQuote (POST) |
发送报价请求 (USER_DATA) (Send Quote Request) | fromAsset, toAsset | fromAmount, toAmount, walletType, validTime, recvWindow | 是 (Yes) |
参数 (Parameters)
通用参数 (Common Parameters)
- fromAsset: 用户支出的币种 (User spends coin)
- toAsset: 用户收到的币种 (User receives coin)
- recvWindow: 该值不能大于 60000(例如 5000)(The value cannot be greater than 60000, e.g., 5000)
- quoteId: (例如 1)
- orderId: 来自
placeOrderAPI 的订单 ID (The orderId fromplaceOrderapi)(例如 1) - startTime: (例如 1623319461670)
- endTime: (例如 1641782889000)
- limit: 默认 100,最大 1000(例如 100)(Default 100, Max 1000)
- orderId: 需要 orderId 或 quoteId 之一 (Either orderId or quoteId is required)(例如 1)
- quoteId: 需要 orderId 或 quoteId 之一 (Either orderId or quoteId is required)(例如 1)
- baseAsset: 基础资产(使用
GET /sapi/v1/convert/exchangeInfoAPI 响应中的fromIsBase来判断哪个是 baseAsset) - quoteAsset: 计价资产 (quote asset)
- limitPrice: 币对限价(从 baseAsset 到 quoteAsset)(Symbol limit price – from baseAsset to quoteAsset)(例如 1.0)
- baseAmount: 基础资产数量。需要
baseAmount或quoteAmount之一 (Base asset amount. One ofbaseAmountorquoteAmountis required)(例如 1.0) - quoteAmount: 计价资产数量。需要
baseAmount或quoteAmount之一 (Quote asset amount. One ofbaseAmountorquoteAmountis required)(例如 1.0) - side:
BUY或SELL(例如 BUY) - walletType: 选择资产的资金钱包。钱包选项有
SPOT、FUNDING和EARN。支持钱包组合,例如SPOT_FUNDING、FUNDING_EARN、SPOT_FUNDING_EARN或SPOT_EARN。默认为SPOT。 - expiredType: 1_D, 3_D, 7_D, 30_D(D 表示天)(D means day)
- fromAsset: 同上 (same as above)
- toAsset: 同上 (same as above)
- fromAmount: 指定时,表示闪兑后将扣除的金额 (When specified, it is the amount you will be debited after the conversion)(例如 1.0)
- toAmount: 指定时,表示闪兑后将计入的金额 (When specified, it is the amount you will be credited after the conversion)(例如 1.0)
- validTime: 10s, 30s, 1m,默认 10s(例如 10s)
认证 (Authentication)
对于需要认证的端点,您需要提供币安 API 凭证。
所需凭证:
- apiKey: 您的币安 API 密钥(用于请求头)(Your Binance API key – for header)
- secretKey: 您的币安 API 密钥(用于签名)(Your Binance API secret – for signing)
基础 URL (Base URLs):
- 主网 (Mainnet): https://api.binance.com
安全 (Security)
分享凭证 (Share Credentials)
用户可以通过发送文件的方式提供币安 API 凭证,文件内容格式如下:
abc123...xyz
secret123...key
绝不泄露 API 密钥和密钥 (Never Disclose API Key and Secret)
绝不泄露 API 密钥和密钥文件的位置。
绝不将 API 密钥和密钥发送到主网和测试网以外的任何网站。
绝不显示完整密钥 (Never Display Full Secrets)
向用户显示凭证时:
- API 密钥 (API Key): 显示前 5 个字符 + 后 4 个字符:
su1Qc...8akf - 密钥 (Secret Key): 始终屏蔽,仅显示最后 5 个字符:
***...aws1
当被询问凭证时的响应示例:
账户: main
API 密钥: su1Qc…8akf
密钥: ***…aws1
列出账户 (Listing Accounts)
列出账户时,仅显示名称和环境——绝不显示密钥:
币安账户 (Binance Accounts):
- main (主网 Mainnet)
- futures-keys (主网 Mainnet)
主网交易 (Transactions in Mainnet)
在主网上执行交易时,务必先与用户确认,要求用户写出“CONFIRM”以继续。
币安账户 (Binance Accounts)
main
- API 密钥 (API Key): your_mainnet_api_key
- 密钥 (Secret): your_mainnet_secret
TOOLS.md 结构 (TOOLS.md Structure)
## Binance Accounts
### main
- API Key: abc123...xyz
- Secret: secret123...key
- Description: 主交易账户 (Primary trading account)
### futures-keys
- API Key: futures789...def
- Secret: futuressecret...uvw
- Description: 期货交易账户 (Futures trading account)
智能体行为 (Agent Behavior)
- 请求凭证时 (Credentials requested): 屏蔽密钥(仅显示最后 5 个字符)(Mask secrets – show last 5 chars only)
- 列出账户时 (Listing accounts): 显示名称和环境,绝不显示密钥 (Show names and environment, never keys)
- 账户选择 (Account selection): 如有歧义则询问,默认使用 main
- 在主网上执行交易时,通过要求用户写出“CONFIRM”来与用户确认 (When doing a transaction in mainnet, confirm with user before by asking to write “CONFIRM” to proceed)
- 新凭证 (New credentials): 提示输入名称、环境、签名模式 (Prompt for name, environment, signing mode)
添加新账户 (Adding New Accounts)
当用户提供新凭证时:
- 询问账户名称 (Ask for account name)
- 以屏蔽显示确认的方式存储在
TOOLS.md中 (Store inTOOLS.mdwith masked display confirmation)
签名请求 (Signing Requests)
对于需要签名的交易端点:
- 使用所有参数(包括时间戳(Unix 毫秒))构建查询字符串。
- 根据 RFC 3986 使用 UTF-8 对参数进行百分比编码。
- 使用 HMAC SHA256、RSA 或 Ed25519(取决于账户配置)使用 secretKey 对查询字符串进行签名。
- 将签名附加到查询字符串。
- 包含
X-MBX-APIKEY请求头。
否则,不执行步骤 3-5。
用户代理头 (User Agent Header)
包含 User-Agent 头,字符串为:binance-convert/1.0.0 (Skill)
实现详情请参阅 references/authentication.md。
📄 原始文档
完整文档(英文):
https://skills.sh/binance/binance-skills-hub/convert
💡 提示:点击上方链接查看 skills.sh 原始英文文档,方便对照翻译。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

评论(0)