# Binance 开发者文档 > Complete documentation for Large Language Models --- ## Document: /introduction URL: /zh-CN/docs/introduction # Binance 开发者文档 欢迎使用 Binance 官方 API 文档。 本门户是面向开发者的核心参考文档,适用于构建与 Binance 集成的应用、服务和交易系统。文档覆盖 Binance 各类产品提供的主要程序化接口,从市场数据访问、账户操作,到高级交易、流式传输以及更低延迟的集成方式。 无论你是在编写简单脚本、生产级后端服务,还是专业交易系统,这些文档都旨在帮助你了解可用接口、选择合适的集成路径,并可靠地完成实现。 --- ## 如何使用本套文档 本套文档主要分为三个部分: - **Documentation** 概念指南、入门内容、环境说明以及运维相关指导。 - **API Reference** 接口定义、请求参数、负载结构以及 API 细节说明。 - **SDKs & Tools** 官方 SDK、Postman Collections、开发者工具以及实现相关资源。 如果你是第一次接触 Binance API,建议先从文档指南开始阅读。如果你已经明确知道所需的产品或接口,也可以直接进入对应的 API Reference。 --- ## 选择你的起点 合适的起点取决于你当前想完成的事情: - **刚开始接触 Binance API** 建议先阅读文档指南、支持的 API 类型、环境说明以及鉴权要求。 - **需要查看接口细节** 可直接进入 API Reference,查看请求参数、负载结构以及接口的具体行为。 - **在寻找 SDK、连接器或测试资源** 可访问 SDKs & Tools,查看官方 SDK、Postman Collections、开发者工具以及实现资源。 - **正在进行特定产品集成** 建议先进入对应的产品线,例如 Spot、Futures、Wallet 或其他支持的产品领域。 --- ## 从这里开始 一个常见的接入路径如下: 1. 了解支持的 API 类型和产品范围 2. 如果你的集成需要鉴权访问,先创建 API Key 3. 了解鉴权、签名以及环境支持情况 4. 在支持的非生产环境中完成验证(如可用) 5. 在确认产品级要求和限制后,再迁移到生产环境 --- ## 你可以用 Binance API 构建什么 通过 Binance API,你可以: - 获取实时和历史市场数据 - 以程序化方式下单、管理订单和撤单 - 监控账户状态、余额和持仓 - 通过基于 WebSocket 的接口接收实时更新 - 构建交易机器人、自动化流程和内部服务 - 将 Binance 数据集成到仪表盘、分析和报表系统中 - 通过专用接口支持更低延迟或机构级工作流 该平台既支持轻量级集成,也支持更高级、对性能更敏感的系统。 --- ## API 类型 Binance 提供多种 API 形式,以支持不同的集成模式: - **REST APIs** 基于 HTTP 的请求/响应式 API,适用于市场数据、交易、账户操作及其他产品工作流。 - **WebSocket APIs** 基于持久连接的请求/响应式 API,适合交互式和有状态的工作流。 - **WebSocket Streams** 面向市场数据和用户事件的实时推送流。 - **FIX APIs** 面向高级和机构交易工作流的会话式 API。 - **SBE(Simple Binary Encoding)** 面向性能敏感场景的二进制编码负载格式。 不同 API 类型在延迟、吞吐、运维复杂度和客户端设计方面各有取舍。具体产品文档会说明何时更适合使用某种接口。 --- ## 鉴权与安全 许多私有接口都需要鉴权。根据接口类型和产品不同,Binance 支持的机制包括: - 基于 HMAC 的请求签名 - 非对称密钥鉴权,包括 RSA 和 Ed25519 - 适用于部分 WebSocket 和 FIX 工作流的会话式鉴权 具体鉴权要求会在对应产品文档中说明。在开发过程中,请尽量使用支持的 Testnet 或 Demo 环境,妥善保护凭证,并在上线前仔细核对签名要求。 --- ## 速率限制与可靠性 Binance API 会实施速率限制和请求权重控制。这些限制会因产品和接口而异,超出限制可能会导致限流或临时限制。 生产环境中的集成应考虑: - 请求权重和接口级限制 - 重试与退避策略 - 连接健康检查与重连处理 - 对 API 错误和服务降级的监控 在大规模部署系统之前,请务必先查阅对应产品的相关文档。 --- ## 环境 Binance 会根据产品和接口提供不同环境,包括: - **Production**:用于真实交易和真实市场数据 - **Testnet**:用于支持的测试流程,无需真实资金 - **Demo environments**:适用于支持的产品和场景,可提供模拟或非生产访问 不同产品对环境的支持并不完全一致。有些产品支持 Testnet,有些支持 Demo 环境,另一些则可能提供不同形式的非生产环境。在实现或上线前,请确认你所使用的具体 API 和产品支持哪些环境。 --- ## Agent 原生 Binance API 从设计上即对 Agent 友好。无论你在构建自动化交易机器人、AI 驱动的助手,还是自动化工作流,以下资源均可使用: - **llms.txt** — 面向 LLM 工具和 Agent 的机器可读文档索引,访问 [`/llms.txt`](/llms.txt) - **Agent REST API** — 针对程序化和 Agent 驱动访问优化的结构化端点 - **MCP Server** — Model Context Protocol 服务器,无缝集成 AI 开发工具 了解更多详情,请查看 [Agent 原生概览](/agent-native/overview)。 --- ## SDK、工具与示例 为帮助你更快完成开发,Binance 提供了以下支持资源: - 支持语言中的官方 SDK - 开发者工具与实用程序 - 用于探索和测试的 Postman Collections - 覆盖常见工作流的示例和样例应用 这些资源可以帮助你更快地从初步探索走向实际可运行的集成。 --- ## 官方与受支持的接口 本门户中记录的接口、端点、流、参数和负载,均可视为面向开发者正式文档化的内容。 不应在生产系统中依赖未文档化的行为或非官方接口。这些内容可能在不另行通知的情况下发生变化,也不属于受支持文档范围。 --- ## 产品级更新 API 变更、新功能和破坏性更新通常会记录在对应产品区域中。在部署或升级集成之前,请先查看你所依赖产品的相关文档。 --- ## 获取帮助 如果你在集成过程中需要帮助: - 先查看相关文档和 API Reference - 查看可用工具、示例和样例应用 - 加入 [Binance Developer Community](https://dev.binance.vision) - 在适当情况下到对应 GitHub 仓库提交 issue - 关注官方 Telegram [Binance API announcements channel](https://t.me/binance_api_announcements),获取服务和 API 相关更新 --- 随着 Binance 产品和 API 的持续演进,本文档也会不断更新。请定期回访,并在进行生产变更前查看相关产品文档。 --- ## Document: SDK 与工具 URL: /zh-CN/docs/sdks-tools/overview # SDK 与工具 官方连接器、开发者工具和示例应用,帮助您高效集成 Binance API。选择语言或工具开始使用,并按照各个包中的快速入门与示例进行集成。 import { Link, Typography, LanguageIcon } from "zudoku/components"; import { Card, CardHeader, CardTitle, CardDescription, CardFooter, } from "zudoku/ui/Card"; import { ChevronRight, KeyRound, Terminal, Github, Bot } from "lucide-react"; export const IconTile = ({ children, label }) => ( {children} ); export const Badge = ({ children }) => ( {children} ); export const REGISTRY_ICONS = { npm: "https://cdn.simpleicons.org/npm", PyPI: "https://cdn.simpleicons.org/pypi", "crates.io": "https://cdn.simpleicons.org/rust", "pkg.go.dev": "https://cdn.simpleicons.org/go", NuGet: "https://cdn.simpleicons.org/nuget", Packagist: "https://cdn.simpleicons.org/packagist", RubyGems: "https://cdn.simpleicons.org/rubygems", Maven: "https://cdn.simpleicons.org/apachemaven", }; export const CardLink = ({ to, title, description, children, github, registry, }) => (
{children}
{title} {description ? ( {description} ) : null}
{(github || registry) && ( {github && ( Git )} {registry && ( {registry.label} )} )}
); --- ## 官方 API 连接器
由 Binance 官方维护的生产级客户端库,覆盖主流编程语言。 每个连接器均包含请求签名工具、类型化模型以及可运行示例。
### REST API、WebSocket API 与 WebSocket Streams
全功能连接器,涵盖 REST 接口、WebSocket API 请求以及实时 WebSocket 数据流。
### FIX
适用于 Binance FIX API 的低延迟连接器,专为高性能报单与成交回报场景设计。
FIX
--- ## 开发者工具
帮助您进行本地开发、签名验证以及自动化常见工作流程的实用工具。 建议结合官方连接器一起使用,以加快测试与集成效率。
--- ## 示例应用
可运行的端到端参考实现,您可以直接运行、修改,并作为项目起点。 适用于学习消息格式与推荐的交互流程。
SBE SBE SBE
--- ## Postman 集合
预构建的 Postman 集合,可快速探索接口并共享可复现请求。 适用于调试、快速上手以及不同环境测试。
Postman
--- ## Document: Agent 原生 URL: /zh-CN/docs/agent-native/overview # Agent 原生 import { Link } from "zudoku/components"; import { Card, CardHeader, CardTitle, CardDescription } from "zudoku/ui/Card"; import { Bot, FileText, ChevronRight, Code2, Lightbulb, Users, } from "lucide-react"; export const IconTile = ({ children, label }) => ( {children} ); export const Badge = ({ children }) => ( {children} ); export const CardLink = ({ to, title, description, children, badge }) => (
{children} {badge && {badge}}
{title} {description} 了解更多
); export const ScenarioCard = ({ icon: Icon, title, description }) => (

{title}

{description}

);

Agent 原生

面向 AI 工具、编程助手和自主 Agent 的轻量级文档接入方式。让 AI 系统能够以编程方式发现并加载 完整的 Binance API 文档。

## 核心组件
选择适合您使用场景的集成方式。
--- ## 快速开始 ### 通过 llms.txt 获取文档 ```bash # 摘要 — 文档标题、描述和链接 curl -s https://developers.binance.com/zh-CN/docs/llms.txt # 完整内容 — 单个文件中的完整文档 curl -s https://developers.binance.com/zh-CN/docs/llms-full.txt ``` --- ## 适用场景
无论您是使用 AI IDE 开发,还是将文档集成到 Agent 流水线中,llms.txt 都能融入多种工作流。
--- ## Document: /agent-native/llms-txt URL: /zh-CN/docs/agent-native/llms-txt # llms.txt [llms.txt](https://llmstxt.org/) 是一项拟议标准,旨在使网站内容对大语言模型更易于访问。与用于网络爬虫的 `robots.txt` 类似,`llms.txt` 告知 AI 工具有哪些文档可用以及如何访问这些文档。 ## 文件 币安 API 文档提供两个 llms.txt 文件: | 文件 | URL | 描述 | | --------------- | ------------------------------------------------------------------------------ | ----------------------------------- | | `llms.txt` | /docs/llms.txt | 摘要 — 文档标题、描述和链接 | | `llms-full.txt` | /docs/llms-full.txt | 完整内容 — 所有文档汇集在一个文件中 | ## 格式 ### llms.txt(摘要) 摘要文件包含所有文档页面的结构化列表,包括标题、描述和 URL: ``` # Binance API Documentation > Comprehensive API documentation for Binance trading platform. ## Spot Trading - [Changelog](/docs/spot-trading/1.changelog): Spot Trading API changelog - [README](/docs/spot-trading/2.readme): Getting started with Spot Trading API ... ## Derivatives Trading - [Change Log](/docs/derivatives/change-log): Derivatives API changelog ... ``` ### llms-full.txt(完整内容) 完整文件包含每个文档页面的完整 Markdown 内容,以标题分隔。这对于将整个文档加载到大语言模型的上下文窗口中非常有用。 ## 使用示例 ### 输入到任意大语言模型 ```bash # 下载并用作上下文 curl -s https://developers.binance.com/zh-CN/docs/llms.txt # 完整文档,用于全面的上下文 curl -s https://developers.binance.com/zh-CN/docs/llms-full.txt ``` ### 与 Claude 配合使用 ``` 请阅读 https://developers.binance.com/zh-CN/docs/llms.txt,并帮助我了解 如何使用币安 API 下合约订单。 ``` ### 在 Python 脚本中使用 ```python import requests # 获取文档索引 response = requests.get("https://developers.binance.com/zh-CN/docs/llms.txt") docs_index = response.text # 将其作为上下文输入到大语言模型 messages = [ {"role": "system", "content": f"Binance API docs:\n{docs_index}"}, {"role": "user", "content": "How do I check my account balance?"} ] ``` ### 与 LangChain 配合使用 ```python from langchain_community.document_loaders import WebBaseLoader loader = WebBaseLoader("https://developers.binance.com/zh-CN/docs/llms-full.txt") docs = loader.load() ``` ## 何时使用 llms.txt 与其他选项 - **llms.txt** — 您希望快速让大语言模型了解所有可用文档,或将完整文档加载到上下文中 - **Agent REST API** — 您需要结构化的 JSON 数据、过滤查询或程序化访问 - **MCP Server** — 您正在使用 Claude Code、Cursor 或其他兼容 MCP 的 IDE --- ## Document: Binance Skills Hub URL: /zh-CN/docs/sdks-tools/tools/skills-hub # Binance Skills Hub Binance Skills Hub 是一个开放的 AI Agent 技能市场,可让任何 LLM 驱动的 Agent 原生访问币安加密能力——代币搜索、链上交易、钱包追踪、聪明钱信号和 DeFi 协议交互。 Skills 与框架无关,可配合 Claude Code、LangChain、CrewAI、OpenClaw 及自定义 Agent 架构使用。 如需查看完整技能目录、安装选项、认证配置及贡献指南,请访问 GitHub 上的 [binance-skills-hub](https://github.com/binance/binance-skills-hub) 仓库。 ## 工作原理 每个 Skill 是一个独立模块,暴露一组 AI Agent 可通过自然语言调用的能力。Skills 遵循 [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) 标准,任何兼容 MCP 的 Agent 无需自定义集成代码即可发现并调用。 Skills 分为两类: - **只读技能** — 查询行情数据、钱包余额、代币信息、热门代币、聪明钱动态、DeFi 协议数据及交易信号 - **读写技能** — 通过 Agentic Wallet 执行链上操作,如代币转账、兑换和限价单 Skills Hub 为开源项目,支持社区扩展——任何人都可按照仓库的贡献指南提交新技能。 ## 支持的环境 - Node.js 22+ - 任何兼容 MCP 的 AI Agent(Claude Code、OpenClaw、自定义客户端) - 通过 LangChain / CrewAI 适配器支持 Python Agent ## 快速开始 从 Hub 安装技能: ```bash npx skills add https://github.com/binance/binance-skills-hub ``` 认证配置、可用技能列表及使用示例请参阅仓库 README。 ## 典型使用场景 - 为任意 AI Agent 添加加密行情与交易能力 - 构建具有自然语言界面的自主交易机器人 - 通过 Agent 监控钱包余额与聪明钱动态 - 将 DeFi 分析集成到研究或报告工作流 - 无需编写 API 集成代码即可快速原型化 Agent 交易策略 --- ## Document: Binance CLI URL: /zh-CN/docs/sdks-tools/tools/binance-cli # Binance CLI Binance CLI 是一个命令行工具,可直接从终端与 Binance API 进行交互。 它提供对多个市场部分 Binance REST API 和 WebSocket 数据流的访问,适用于快速检查、脚本编写及轻量级运维任务。 如需查看源代码、问题反馈及更新说明,请访问 GitHub 上的 [binance-cli](https://github.com/binance/binance-cli) 仓库。 ## 状态 > ⚠️ **维护状态** > > Binance CLI **未处于积极维护状态**,但会**定期更新**。可能不包含最新的接口、产品或功能。 > > 对于长期集成或生产系统,我们建议使用官方 SDK(JavaScript、Python、Go、Java、PHP 或 Rust)。 ## 支持的环境 - Node.js(全局安装) - 类 Unix 环境(Linux、macOS) > 本工具适用于通过终端进行本地或服务端使用。 ## 范围与功能 Binance CLI 支持以下功能: - 多个 Binance 市场的 REST API 交互 - 用于获取实时行情数据的 WebSocket 数据流 - 通过 CLI 命令进行下单和账户查询 - 现货、USDⓈ-M 合约和 COIN-M 合约工作流(部分 API) CLI 专为**手动操作、调试和脚本编写**而设计,不作为基于 SDK 集成方案的替代品。 ## 典型使用场景 - 从终端快速查询行情数据 - 检查交易所元数据和交易对信息 - 在测试期间下单或撤单 - 监听 WebSocket 数据流以进行调试或探索 - 通过 Shell 脚本实现简单自动化 ## 安装 使用 `npm` 全局安装 CLI: ```bash git clone https://github.com/binance/binance-cli.git cd binance-cli npm install -g ``` 验证安装: ```bash binance-cli --help ``` ## 使用概览 CLI 提供大量命令,涵盖行情数据、交易、账户信息和 WebSocket 数据流。 示例: ```bash # 显示帮助信息 binance-cli --help # 获取服务器时间 binance-cli time # 获取订单簿 binance-cli book BNBUSDT # 下一个限价买单 binance-cli buy -s BNBUSDT -t LIMIT -q 0.05 -p 350 -f GTC # 监听 WebSocket 数据流 binance-cli listen bnbusdt@depth bnbusdt@bookTicker ``` 完整的支持命令列表请参阅仓库 README 及 `--help` 输出。 ## 注意事项与最佳实践 - 本 CLI 支持 REST API 和 WebSocket 数据流 - API 和产品覆盖范围有限,可能落后于当前 Binance API - 在提交真实订单前,请务必仔细核查命令 - 实验性操作请使用测试网接口 - 对于生产系统或高级工作流,请使用官方 SDK 而非 CLI --- ## Document: 非对称密钥生成器 URL: /zh-CN/docs/sdks-tools/tools/asymmetric-key-generator # 非对称密钥生成器 非对称密钥生成器是一个用于生成 **Ed25519** 和 **RSA** 非对称密钥对(私钥和公钥)的工具,用于对 Binance API 的请求进行身份验证和签名。 该工具常用于**非对称身份验证**场景,例如 FIX API,或支持 `RSA` 和 `Ed25519` 签名的 REST / WebSocket API。 如需查看源代码、版本发布及更新说明,请访问 GitHub 上的 [asymmetric-key-generator](https://github.com/binance/asymmetric-key-generator) 仓库。 ## 支持的密钥类型 该工具可生成以下密钥类型: - **Ed25519**(PKCS#8) - **RSA-2048** - **RSA-4096** > ⚠️ **重要提示** > > 部分 Binance API(例如 FIX API)**要求使用 Ed25519 密钥**。 `RSA` 密钥仅受明确支持 `RSA` > 身份验证的 API 支持。 ## 支持的环境 - 桌面环境(macOS、Windows、Linux),通过预构建应用程序使用 - Node.js(用于命令行及本地构建) ## 安装方式 您可以通过以下**三种方式**使用该工具,请根据您的工作流选择合适的方式。 ### 方式一:下载预构建应用程序(推荐) 预构建的桌面应用程序可在 [GitHub Releases 页面](https://github.com/binance/asymmetric-key-generator/releases)下载。下载后,请使用提供的校验和验证包的完整性: ```bash sha256sum -c AsymmetricKeyGenerator-.CHECKSUM ``` 验证成功后,输出结果将显示 OK。 ### 方式二:从源码构建 克隆仓库并在本地构建应用程序: ```bash npm install npm run start # 本地运行 npm run dist # 将构建产物输出至 dist 文件夹 ``` ### 方式三:命令行使用 该生成器也可作为命令行工具使用。 安装依赖: ```bash npm install ``` 生成密钥对: ```bash npm run generate -- -k -p -n -o ``` 示例 生成单个 `RSA-2048` 密钥对: ```bash npm run generate -- -k rsa-2048 -o id_rsa.tar.gz ``` 使用密码短语生成两个 `Ed25519` 密钥对: ```bash npm run generate -- -k ed25519 -p mySecretPassphrase -n 2 ``` ## 界面使用说明 桌面应用程序提供简洁的图形界面: 1. 打开应用程序 2. 选择密钥类型(大多数情况下推荐使用 `Ed25519`) 3. 点击 Generate Key Pair(生成密钥对) 4. 安全保存私钥(切勿分享) 5. 保存公钥以备上传或按需分发 ## 典型使用场景 - 为 Binance FIX API 生成 `Ed25519` 密钥 - 为支持非对称身份验证的 REST 或 WebSocket API 生成 `RSA` 密钥 - 安全轮换 API 凭证 - 本地开发和测试已签名的 API 请求 ## 安全最佳实践 - 切勿分享您的私钥 - 将私钥安全存储在磁盘或密钥管理工具中 - 在支持的情况下使用密码短语 - 仅将公钥上传至 Binance - 定期轮换密钥并撤销未使用的凭证 --- ## Document: Postman 集合 URL: /zh-CN/docs/sdks-tools/postman/collections # Postman 集合 Binance 维护一套官方 **Postman 集合与环境配置**,帮助您探索和测试各产品的 Binance **REST API**。 如需查看源代码、集合文件、环境配置及更新说明,请访问 GitHub 上的 [binance-api-postman](https://github.com/binance/binance-api-postman) 仓库。 ## 内容概览 - 适用于 Binance REST 接口的 Postman **集合** - 用于配置基础 URL 和凭证的 Postman **环境**(JSON 格式) > 这些集合专注于 **REST** 使用场景。WebSocket > API 和 WebSocket 数据流通常不在 Postman 集合的覆盖范围内。 ## 快速开始 1. 下载(或克隆)`binance-api-postman` 仓库。 2. 在 Postman 中点击 **Import**,选择仓库的**根目录**。 3. 选择您需要导入的**集合**和**环境**。 4. 在 Postman → **Environments** 中,打开您将使用的环境,在 **Current Value** 列中填入您的 API 凭证。 5. 发送请求前,从环境下拉菜单中选择对应的环境。 ## 身份验证与环境配置 许多接口需要身份验证和请求签名。仓库提供的环境文件支持以下操作: - 通过切换 Postman 环境(例如正式环境与测试网)来切换不同的请求目标 - 将 API Key/Secret 存储在 Postman 环境变量中(请使用 **Current Value**,避免意外导出密钥) ## 安全注意事项 在 Postman 集合中使用真实凭证时,Binance 建议遵循以下安全措施: - 仅使用来自可信来源的集合(本仓库为官方来源) - 使用前请审查环境 JSON 文件的内容 - 避免为 API 密钥开启提币权限 - 测试完成后及时删除 API 密钥 --- ## Document: SBE 示例应用(Rust) URL: /zh-CN/docs/sdks-tools/sample-apps/sbe-rust # SBE 示例应用(Rust) Rust SBE 示例应用是一个参考实现,演示如何在 Rust 环境中**解码使用简单二进制编码(SBE)格式的 Binance API 响应**。 它从 **STDIN** 读取 SBE 编码的数据载荷,并将**人类可读的 YAML 表示**输出至 **STDOUT**,可用于检查、调试和验证 Binance API 返回的 SBE 响应。 如需查看源代码、更新说明及示例,请访问 GitHub 上的 [binance-sbe-rust-sample-app](https://github.com/binance/binance-sbe-rust-sample-app) 仓库。 ## 支持的环境 - Rust(工具链版本定义于 `rust-toolchain.toml`) - Linux - macOS > 本示例应用仅供本地运行和检查使用。 > 它不是一个生产就绪的 SDK。 ## 示例演示内容 本应用专注于**解码 SBE 编码的 API 响应**,而非发送或管理请求本身。 它演示了如何: - 在 Rust 中解码 SBE 响应 - 将二进制 SBE 载荷转换为人类可读的 YAML - 将 REST 或 WebSocket API 的 SBE 响应通过管道传入 Rust 解码器 - 在 Rust 项目中复用已生成的 SBE 解码器模块 ## 典型使用场景 - 检查和验证 SBE 响应 - 调试使用 SBE 的集成方案 - 学习如何在 Rust 中解码 Binance SBE 模式 - 围绕基于 SBE 的 API 构建内部工具 - 验证 SBE 输出的身份验证和请求签名工作流 ## 快速开始 克隆仓库: ```bash git clone https://github.com/binance/binance-sbe-rust-sample-app.git cd binance-sbe-rust-sample-app ``` 构建示例应用: ```bash cargo build ``` 生成的二进制文件位于: ```text ./target/debug/sbe-sample-app ``` ## 使用示例应用 该应用从 STDIN 读取 SBE 编码数据,并将解码后的 YAML 输出至 STDOUT。 ### 示例:解码 SBE REST 响应 ```bash curl -H "Accept: application/sbe" -H "X-MBX-SBE: 3:1" \ "" \ | ./target/debug/sbe-sample-app ``` ### 示例:解码 SBE WebSocket 响应 您可以通过辅助脚本或工具将 WebSocket 原始消息转发后,通过管道传入应用进行解码: ```bash echo '' \ | ./tools/websocket_send.py '' \ | ./target/debug/sbe-sample-app ``` 运行 `websocket_send.py` 需要 Python 环境中安装 websocket-client 包。 ## 身份验证 向需要身份验证的接口请求 SBE 响应时,适用标准的 Binance 身份验证方式。 仓库中的示例演示了以下身份验证方式的用法: - 基于 `HMAC` 的身份验证 - 基于 `RSA` 的身份验证 - 基于 `Ed25519` 的身份验证 示例应用本身不执行请求签名——它仅负责解码 SBE 响应。 ## SBE 解码器 仓库包含使用 [Simple Binary Encoding (SBE)](https://github.com/aeron-io/simple-binary-encoding) 从 Binance SBE 模式文件生成的 Rust 解码器模块。 这些解码器可直接在您自己的 Rust 项目中复用。如有需要,可按照仓库中的说明从最新模式文件重新生成解码器。 ## 注意事项与最佳实践 - 本项目旨在作为参考实现和调试工具使用 - 请始终对照官方 API 文档验证解码后的字段 - 仅在需要二进制传输效率或低延迟时才考虑使用 SBE - 对于通用集成场景,REST 或 WebSocket API 可能更易于使用 - 在测试已认证接口时,请使用测试网环境 --- ## Document: SBE 示例应用(Java) URL: /zh-CN/docs/sdks-tools/sample-apps/sbe-java # SBE 示例应用(Java) Java SBE 示例应用是一个参考实现,演示如何在 JVM 环境中**解码使用简单二进制编码(SBE)格式的 Binance API 响应**。 它从 **STDIN** 读取 SBE 编码的数据载荷,或直接从 API 接口获取数据,并将**人类可读的 YAML 表示**输出至 **STDOUT**。可用于检查、调试和验证 Binance API 返回的 SBE 响应。 如需查看源代码、更新说明及示例,请访问 GitHub 上的 [binance-sbe-java-sample-app](https://github.com/binance/binance-sbe-java-sample-app) 仓库。 ## 支持的环境 - Java 11 或更高版本 - Linux - macOS > 本示例应用仅供本地运行和检查使用。 > 它不是一个生产就绪的 SDK。 ## 示例演示内容 本应用专注于**解码 SBE 编码的 API 响应**,而非发送或管理请求本身。 它演示了如何: - 解码 SBE 编码的 API 响应 - 将二进制 SBE 载荷转换为人类可读的 YAML - 将 REST 或 WebSocket API 的 SBE 响应通过管道传入 Java 解码器 - 在基于 JVM 的项目中复用已生成的 SBE 解码器类 ## 典型使用场景 - 检查和验证 SBE 响应 - 调试使用 SBE 的集成方案 - 学习如何在 Java 中解码 Binance SBE 模式 - 围绕基于 SBE 的 API 构建内部工具 - 验证 SBE 输出的身份验证和请求签名工作流 ## 快速开始 克隆仓库: ```bash git clone https://github.com/binance/binance-sbe-java-sample-app.git cd binance-sbe-java-sample-app ``` 使用 Maven 构建项目: ```bash mvn clean install ``` 生成可运行的 JAR 文件: ```bash ./target/sbe-sample-app-1.0-SNAPSHOT.jar ``` ## 使用示例应用 该应用解码 SBE 载荷并将解码结果写入 STDOUT。 ### 示例:通过 STDIN 解码 SBE REST 响应 ```bash curl -H "Accept: application/sbe" -H "X-MBX-SBE: 3:1" \ "" \ | java -jar ./target/sbe-sample-app-1.0-SNAPSHOT.jar - ``` ### 示例:解码 SBE WebSocket 响应 您可以通过辅助脚本或工具将 WebSocket 原始消息转发后,通过管道传入应用进行解码: ```bash echo '' \ | ./tools/websocket_send.py '' \ | java -jar ./target/sbe-sample-app-1.0-SNAPSHOT.jar - ``` 运行 `websocket_send.py` 需要 Python 环境中安装 websocket-client 包。 ### 示例:在应用内直接获取并解码 示例应用也支持直接获取 SBE 编码响应并进行解码: ```bash java -jar ./target/sbe-sample-app-1.0-SNAPSHOT.jar '' ``` ## 身份验证 向需要身份验证的接口请求 SBE 响应时,适用标准的 Binance 身份验证方式。 仓库中的示例演示了以下身份验证方式的用法: - 基于 `HMAC` 的身份验证 - 基于 `RSA` 的身份验证 - 基于 `Ed25519` 的身份验证 示例应用本身不执行请求签名——它仅负责解码 SBE 响应。 ## SBE 解码器 仓库包含使用 [Simple Binary Encoding (SBE)](https://github.com/aeron-io/simple-binary-encoding) 从 Binance SBE 模式文件生成的 Java 解码器类。 这些解码器可直接在您自己的 Java 或基于 JVM 的项目中复用,或针对自定义 SBE 流水线进行适配。如有需要,可按照仓库中的说明从最新模式文件重新生成解码器。 ## 注意事项与最佳实践 - 本项目旨在作为参考实现和调试工具使用 - 请始终对照官方 API 文档验证解码后的字段 - 仅在需要二进制传输效率或低延迟时才考虑使用 SBE - 对于通用集成场景,REST 或 WebSocket API 可能更易于使用 - 在测试已认证接口时,请使用测试网环境 --- ## Document: SBE 示例应用(C++) URL: /zh-CN/docs/sdks-tools/sample-apps/sbe-cpp # SBE 示例应用(C++) C++ SBE 示例应用是一个参考实现,演示如何**解码使用简单二进制编码(SBE)格式的 Binance API 响应**。 它从 **STDIN** 读取 SBE 编码的数据载荷,并将 **JSON 表示**输出至 **STDOUT**,可用于调试、测试和验证 Binance API 返回的 SBE 响应。 如需查看源代码、更新说明及示例,请访问 GitHub 上的 [binance-sbe-cpp-sample-app](https://github.com/binance/binance-sbe-cpp-sample-app) 仓库。 ## 支持的环境 - Linux - macOS - 兼容 C++20 的编译器 > 本示例应用仅供本地运行和检查使用。 > 它不是一个生产就绪的 SDK。 ## 示例演示内容 本应用专注于**解码 SBE 响应**,而非发送请求本身。 它演示了如何: - 解码 SBE 编码的 API 响应 - 将二进制 SBE 载荷转换为人类可读的 JSON - 在请求 SBE 响应时使用不同的身份验证方案 - 在 C++ 项目中复用已生成的 SBE 解码器 ## 典型使用场景 - 检查和验证 SBE 响应 - 调试使用 SBE 的集成方案 - 学习如何在 C++ 中解码 Binance SBE 模式 - 围绕基于 SBE 的 API 构建内部工具 - 验证 SBE 输出的身份验证和签名工作流 ## 快速开始 克隆仓库: ```bash git clone https://github.com/binance/binance-sbe-cpp-sample-app.git cd binance-sbe-cpp-sample-app ``` 编译示例应用: ```bash c++ -std=c++20 -Wextra -Wall -o sbe-sample-app ./main.cpp ``` 生成的二进制文件(`sbe-sample-app`)从 STDIN 读取输入,并将解码后的 JSON 写入 STDOUT。 ## 使用示例应用 该应用通常通过管道将 API 响应传入来使用。 ### 示例:解码 SBE REST 响应 ```bash curl -H "Accept: application/sbe" -H "X-MBX-SBE: 3:1" \ "" \ | ./sbe-sample-app ``` ### 示例:解码 SBE WebSocket 响应 您可以通过辅助脚本或工具将 WebSocket 响应通过管道传入应用,该工具负责发送 WebSocket 请求并转发原始响应: ```bash echo '' \ | ./tools/websocket_send.py '' \ | ./sbe-sample-app ``` 运行 `websocket_send.py` 需要 Python 环境中安装 websocket-client 包。 ## 身份验证 向需要身份验证的接口请求 SBE 响应时,适用标准的 Binance 身份验证方式。 仓库中的示例演示了以下身份验证方式的用法: - 基于 `HMAC` 的身份验证 - 基于 `RSA` 的身份验证 - 基于 `Ed25519` 的身份验证 示例应用本身不执行请求签名——它仅负责解码 SBE 响应。 ## SBE 解码器 仓库包含使用 [Simple Binary Encoding (SBE)](https://github.com/aeron-io/simple-binary-encoding) 从 Binance SBE 模式文件生成的 C++ 解码器类。 这些解码器可直接在您自己的 C++ 项目中复用,或针对自定义 SBE 流水线进行适配。如有需要,可按照仓库中的说明从最新模式文件重新生成解码器。 ## 注意事项与最佳实践 - 本项目旨在作为参考实现和调试工具使用 - 请始终对照官方 API 文档验证解码后的字段 - 仅在需要二进制传输效率或低延迟时才考虑使用 SBE - 对于通用集成场景,REST 或 WebSocket API 可能更易于使用 - 在测试已认证接口时,请使用测试网环境 --- ## Document: Rust URL: /zh-CN/docs/sdks-tools/connectors/rust # Rust Binance API 官方 Rust 连接器,专为使用 Rust 编写的后端应用程序和服务而设计。 该连接器以单一 crate(`binance-sdk`)的形式发布。您可以通过 Cargo features(例如 `spot`)启用所需的 Binance 产品。它支持 REST API、WebSocket API 和 WebSocket 数据流,并提供内置的请求签名、连接管理以及强类型的请求与响应模型。 如需查看源代码、问题反馈及版本说明,请访问 GitHub 上的 [binance-connector-rust](https://github.com/binance/binance-connector-rust) 仓库。 ## 支持的环境 - Rust 1.86 或更高版本(stable 工具链) - 后端 Rust 应用程序及服务 > 本连接器仅适用于服务端使用。 ## 包结构 Rust 连接器以单一 crate 的形式发布,各产品模块通过 feature flags 按需启用。 在 `Cargo.toml` 中启用所需的产品(例如 `spot`、`derivatives_trading_usds_futures`、`wallet` 等),然后在代码中导入对应模块。这种方式将依赖项保持在最低限度,避免引入不需要的 API。 ## 典型使用场景 - 低延迟交易与执行服务 - 高吞吐量行情数据采集 - 管理账户、余额和订单的后端服务 - 通过 WebSocket API 或 WebSocket 数据流获取实时更新的应用程序 ## 主要特性 - 支持 Binance REST API、WebSocket API 和 WebSocket 数据流 - 内置针对需要身份验证接口的请求签名 - WebSocket 连接管理,支持自动重连和会话续期 - 强类型的请求与响应模型 - 同时支持正式环境和测试网环境 - 内存安全且高性能的 Rust API 设计 ## 快速开始 在 `binance-sdk` 下启用所需的产品 feature: ```toml [dependencies] binance-sdk = { version = "", features = ["spot"] } ``` 创建客户端并发送请求: ```rust use anyhow::{Context, Result}; use std::env; use binance_sdk::config::{ConfigurationRestApi, PrivateKey}; use binance_sdk::spot::{SpotRestApi, rest_api::GetAccountParams}; #[tokio::main] async fn main() -> Result<()> { let api_key = env::var("BINANCE_API_KEY").context("BINANCE_API_KEY must be set")?; let private_key = env::var("BINANCE_PRIVATE_KEY").context("BINANCE_PRIVATE_KEY must be set")?; let configuration = ConfigurationRestApi::builder() .api_key(api_key) .private_key(PrivateKey::File(private_key)) .build()?; let spot_client = SpotRestApi::production(configuration); let params = GetAccountParams::default(); let account_info = spot_client .get_account(params) .await .context("get_account request failed")?; Ok(()) } ``` 上述示例使用非对称密钥进行身份验证。同样支持基于 API Secret 的 HMAC 身份验证方式。 如需各产品的 REST、WebSocket API 和 WebSocket 数据流示例,请参阅 crate 文档。 ## 注意事项与最佳实践 - 使用环境变量或密钥管理工具安全存储 API 密钥 - 获取实时数据时,优先使用 WebSocket API 或数据流,而非轮询 REST 接口 - 构建高吞吐量服务时,注意监控频率限制和接口权重 - 开发和验证集成方案时,请使用测试网环境 --- ## Document: Ruby URL: /zh-CN/docs/sdks-tools/connectors/ruby # Ruby Binance API 的 Ruby 连接器为 Ruby 应用程序提供了一个客户端,用于与 Binance REST API 和 WebSocket 数据流的部分功能进行交互。 该连接器被视为**历史遗留版本**,**未处于积极维护状态**。与其他语言的新版 SDK 相比,它仅支持有限的 Binance 产品和接口。 如需查看源代码、问题反馈及版本说明,请访问 GitHub 上的 [binance-connector-ruby](https://github.com/binance/binance-connector-ruby) 仓库。 ## 状态 > ⚠️ **维护状态** > > Ruby 连接器目前**未处于积极维护状态**。它仅支持部分 Binance 产品和 API,可能不包含较新的接口或功能。 > > 如需完整的产品支持和持续更新,我们建议使用以下积极维护中的 SDK:JavaScript、Python、Go、Java、PHP 或 Rust。 ## 支持的环境 - Ruby 2.5 或更高版本 - 后端 Ruby 应用程序及脚本 > 本连接器仅适用于服务端使用。 ## 包结构 Ruby 连接器以单一 Ruby gem 的形式分发。 它遵循简单的客户端设计模式,为所支持的 REST API 和 WebSocket 数据流提供统一的客户端接口。产品覆盖范围有限,具体情况可能因 API 而异。 ## 典型使用场景 - 与 Binance REST API 交互的简单脚本 - 消费 WebSocket 数据流以获取行情数据的应用程序 - 轻量级自动化或报表任务 - 原型开发或现有的基于 Ruby 的系统 ## 主要特性 - 支持部分 Binance REST API - 支持 Binance WebSocket 数据流 - 简单的客户端 API 设计 - API Key 和 Secret 身份验证 - 通过 RubyGems 便捷安装 ## 快速开始 使用 RubyGems 安装连接器: ```bash gem install binance-connector-ruby ``` 或将其添加至 Gemfile: ```ruby gem 'binance-connector-ruby' ``` 然后安装依赖: ```bash bundle install ``` 创建客户端并发送请求: ```ruby require 'binance' client = Binance::Spot.new( key: ENV['BINANCE_API_KEY'], secret: ENV['BINANCE_API_SECRET'] ) puts client.account ``` 如需更多 REST 和 WebSocket 的使用示例,请参阅仓库文档及 examples 文件夹。 ## 注意事项与最佳实践 - 本连接器支持 REST API 和 WebSocket 数据流 - 产品和接口覆盖范围有限,可能未反映最新的 Binance API - 请注意监控频率限制,旧版客户端可能不会提供详细的权重信息 - 如需用于生产环境或完整的 API 覆盖,请使用积极维护中的 SDK --- ## Document: Python URL: /zh-CN/docs/sdks-tools/connectors/python # Python Binance API 官方 Python 连接器,专为运行在 Python 上的后端应用程序而设计。 该连接器采用完全模块化设计:每个 Binance 产品均以独立的 Python 包形式发布(例如 `binance-spot`),您可以按需安装和使用所需的 API。它支持 REST API、WebSocket API 和 WebSocket 数据流,并提供内置的请求签名、连接管理以及强类型的请求/响应模型,带来一致的开发体验。 如需查看源代码、问题反馈及版本说明,请访问 GitHub 上的 [binance-connector-python](https://github.com/binance/binance-connector-python) 仓库。 ## 支持的环境 - Python 3.9 或更高版本 - 后端 Python 应用程序及服务 > 本连接器仅适用于服务端使用。不支持交互式或客户端 Python 环境。 ## 包结构 每个 Binance 产品均以独立的 Python 包形式发布。 常用包包括: - `binance-sdk-spot` - `binance-sdk-derivatives-trading-usds-futures` - `binance-sdk-derivatives-trading-coin-futures` - `binance-sdk-wallet` - _(其他产品遵循相同的结构)_ 这种模块化方式将依赖项保持在最低限度,同时使升级和集成管理更加便捷。 ## 典型使用场景 - 交易与执行服务 - 实时及历史行情数据采集 - 管理账户、余额和订单的后端服务 - 通过 WebSocket API 或 WebSocket 数据流获取低延迟更新的应用程序 ## 主要特性 - 支持 Binance REST API、WebSocket API 和 WebSocket 数据流 - 内置针对需要身份验证接口的请求签名 - WebSocket 连接管理,支持自动重连和会话续期 - 强类型的请求与响应模型 - 同时支持正式环境和测试网环境 - 跨产品一致的 API 设计 ## 快速开始 安装您需要集成的产品对应的包: ```bash pip install binance-sdk-spot ``` 创建客户端并发送请求: ```python from binance_sdk_spot.spot import Spot, ConfigurationRestAPI configuration_rest_api = ConfigurationRestAPI( api_key=os.environ["BINANCE_API_KEY"], private_key=os.environ["BINANCE_PRIVATE_KEY"], ) spot_client = Spot(config_rest_api=configuration_rest_api) account_info = spot_client.rest_api.get_account() ``` 上述示例使用非对称密钥进行身份验证。同样支持基于 API Secret 的 HMAC 身份验证方式。 如需各产品的 REST、WebSocket API 和 WebSocket 数据流示例,请参阅各包的文档。 ## 注意事项与最佳实践 - 使用环境变量或密钥管理工具安全存储 API 密钥 - 获取实时数据时,优先使用 WebSocket API 或数据流,而非轮询 REST 接口 - 构建高吞吐量服务时,注意监控频率限制和接口权重 - 开发和验证集成方案时,请使用测试网环境 --- ## Document: PHP URL: /zh-CN/docs/sdks-tools/connectors/php # PHP Binance API 官方 PHP 连接器,专为使用 PHP 编写的后端应用程序和服务而设计。 该连接器为 Binance REST API 提供符合 PHP 惯例的接口。内置请求签名、配置辅助工具以及强类型的请求与响应模型,助您构建可靠的服务端集成方案。 如需查看源代码、问题反馈及版本说明,请访问 GitHub 上的 [binance-connector-php](https://github.com/binance/binance-connector-php) 仓库。 ## 支持的环境 - PHP 8.4 或更高版本 - 后端 PHP 应用程序及服务 > 本连接器仅适用于服务端使用。 > 不支持基于浏览器或客户端的 PHP 环境。 ## 包结构 PHP 连接器以单一 Composer 包的形式发布。 各产品的 REST API(如 `Spot`、`DerivativesTradingUsdsFutures`、`Wallet` 等)在库中按命名空间进行组织。这种结构使各 API 保持清晰分离,同时允许共享配置、身份验证和传输逻辑。 ## 典型使用场景 - 使用 REST API 的交易与执行服务 - 管理账户、余额和订单的后端服务 - 历史行情数据采集 - 自动化和报表工作流 ## 主要特性 - 支持 Binance REST API - 内置针对需要身份验证接口的请求签名 - 强类型的请求与响应模型 - 同时支持正式环境和测试网环境 - 一致且符合 PHP 惯例的 API 设计 ## 快速开始 使用 Composer 安装连接器: ```bash composer require binance/binance-connector-php ``` 创建客户端并发送请求: ```php apiKey(getenv('BINANCE_API_KEY')) ->privateKey(getenv('BINANCE_PRIVATE_KEY_FILE_PATH')); $spotClient = new SpotRestApi($configurationBuilder->build()); $accountInfo = $spotClient->getAccount(); ``` 上述示例使用非对称密钥进行身份验证。同样支持基于 API Secret 的 HMAC 身份验证方式。 如需更多 REST API 示例,请参阅仓库文档。 ## 注意事项与最佳实践 - 使用环境变量或密钥管理工具安全存储 API 密钥 - 构建高吞吐量服务时,注意监控频率限制和接口权重 - 开发和验证集成方案时,请使用测试网环境 --- ## Document: JavaScript URL: /zh-CN/docs/sdks-tools/connectors/javascript # JavaScript Binance API 官方 JavaScript 连接器,专为运行在 Node.js 上的后端应用程序而设计。 该连接器采用完全模块化设计:每个 Binance 产品均以独立的 `npm` 包形式发布(例如 `@binance/spot`),您可以按需安装和使用所需的 API。它支持 REST API、WebSocket API 和 WebSocket 数据流,并提供内置的请求签名、连接管理以及 TypeScript 类型定义。 如需查看源代码、问题反馈及版本说明,请访问 GitHub 上的 [binance-connector-js](https://github.com/binance/binance-connector-js) 仓库。 ## 支持的环境 - Node.js v22 或更高版本(推荐使用 LTS 版本) - JavaScript 和 TypeScript 后端应用程序 > 本连接器仅适用于服务端使用。 > 目前不支持浏览器环境。 ## 包结构 每个 Binance 产品均以独立的 `npm` 包形式发布,统一归属于 `@binance` 命名空间。 常用包包括: - `@binance/spot` - `@binance/derivatives-trading-usds-futures` - `@binance/derivatives-trading-coin-futures` - `@binance/wallet` - _(其他产品遵循相同的结构)_ 这种模块化方式将依赖项保持在最低限度,同时使升级和集成管理更加便捷。 ## 典型使用场景 - 交易与执行服务 - 实时及历史行情数据采集 - 管理账户、余额和订单的后端服务 - 通过 WebSocket API 或 WebSocket 数据流获取低延迟更新的应用程序 ## 主要特性 - 支持 Binance REST API、WebSocket API 和 WebSocket 数据流 - 内置针对需要身份验证接口的请求签名 - WebSocket 连接管理,支持自动重连和会话续期 - 完整的 TypeScript 类型定义 - 同时支持正式环境和测试网环境 - 跨产品一致的 API 设计 ## 快速开始 安装您需要集成的产品对应的包: ```bash npm install @binance/spot ``` 创建客户端并发送请求: ```ts import { Spot } from "@binance/spot"; const spotClient = new Spot({ apiKey: process.env.BINANCE_API_KEY, privateKey: process.env.BINANCE_PRIVATE_KEY, }); const accountInfo = await spotClient.restAPI.getAccount(); ``` 上述示例使用非对称密钥进行身份验证。同样支持基于 API Secret 的 HMAC 身份验证方式。 如需各产品的 REST、WebSocket API 和 WebSocket 数据流示例,请参阅各包的文档。 ## 注意事项与最佳实践 - 使用环境变量或密钥管理工具安全存储 API 密钥 - 获取实时数据时,优先使用 WebSocket API 或数据流,而非轮询 REST 接口 - 构建高吞吐量服务时,注意监控频率限制和接口权重 - 开发和验证集成方案时,请使用测试网环境 --- ## Document: Java URL: /zh-CN/docs/sdks-tools/connectors/java # Java Binance API 官方 Java 连接器,专为运行在 JVM 上的后端应用程序和服务而设计。 该连接器为 Binance API 提供模块化且符合 Java 惯例的接口,支持 REST API、WebSocket API 和 WebSocket 数据流。内置请求签名、连接管理以及强类型的请求与响应模型,助您构建可靠且易于维护的集成方案。 如需查看源代码、问题反馈及版本说明,请访问 GitHub 上的 [binance-connector-java](https://github.com/binance/binance-connector-java) 仓库。 ## 支持的环境 - Java 11 或更高版本 - 后端 Java 应用程序及基于 JVM 的服务 > 本连接器仅适用于服务端使用。 ## 包结构 Java 连接器以一组针对各产品的独立构件形式发布。 每个 Binance 产品均作为独立依赖项分发(例如 `binance-sdk-spot`),您可以按需引入所需的 API。这种模块化结构将依赖项保持在最低限度,同时使升级和集成管理更加便捷。 ## 典型使用场景 - 交易与执行服务 - 实时及历史行情数据采集 - 管理账户、余额和订单的后端服务 - 通过 WebSocket API 或 WebSocket 数据流获取低延迟更新的应用程序 ## 主要特性 - 支持 Binance REST API、WebSocket API 和 WebSocket 数据流 - 内置针对需要身份验证接口的请求签名 - WebSocket 连接管理,支持自动重连和会话续期 - 强类型的请求与响应模型 - 同时支持正式环境和测试网环境 - 一致且符合 Java 惯例的 API 设计 ## 快速开始 安装您需要集成的产品对应的依赖项: ```xml io.github.binance binance-spot ``` 创建客户端并发送请求: ```java import com.binance.connector.client.common.configuration.ClientConfiguration; import com.binance.connector.client.common.configuration.SignatureConfiguration; import com.binance.connector.client.spot.rest.api.SpotRestApi; import com.binance.connector.client.common.ApiResponse; import com.binance.connector.client.spot.rest.model.GetAccountResponse; public class Main { public static void main(String[] args) throws Exception { SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); signatureConfiguration.setApiKey(System.getenv("BINANCE_API_KEY")); signatureConfiguration.setPrivateKey(System.getenv("BINANCE_PRIVATE_KEY")); ClientConfiguration clientConfiguration = new ClientConfiguration(); clientConfiguration.setSignatureConfiguration(signatureConfiguration); SpotRestApi spotApi = new SpotRestApi(clientConfiguration); ApiResponse accountInfo = spotApi.getAccount(); } } ``` 上述示例使用非对称密钥进行身份验证。同样支持基于 API Secret 的 HMAC 身份验证方式。 如需各产品的 REST、WebSocket API 和 WebSocket 数据流示例,请参阅各包的文档。 ## 注意事项与最佳实践 - 使用环境变量或密钥管理工具安全存储 API 密钥 - 获取实时数据时,优先使用 WebSocket API 或数据流,而非轮询 REST 接口 - 构建高吞吐量服务时,注意监控频率限制和接口权重 - 开发和验证集成方案时,请使用测试网环境 --- ## Document: Go URL: /zh-CN/docs/sdks-tools/connectors/go # Go Binance API 官方 Go 连接器,专为使用 Go 编写的后端应用程序和服务而设计。 该连接器为 Binance API 提供模块化且符合 Go 惯例的接口,支持 REST API、WebSocket API 和 WebSocket 数据流。内置请求签名、连接管理以及强类型的请求与响应结构,助您构建可靠且易于维护的集成方案。 如需查看源代码、问题反馈及版本说明,请访问 GitHub 上的 [binance-connector-go](https://github.com/binance/binance-connector-go) 仓库。 ## 支持的环境 - Go 1.24 或更高版本 - 后端 Go 应用程序及服务 > 本连接器仅适用于服务端使用。不支持基于浏览器或 WebAssembly 的环境。 ## 包结构 Go 连接器以单一模块的形式发布,对外提供不同 Binance 产品的客户端接口。 各产品的功能按专属包进行组织,例如 `spot`、`derivativestradingusdsfutures`、`wallet` 等。这种结构使各 API 保持清晰分离,同时允许您在多个客户端之间共享配置、身份验证和传输逻辑。 ## 典型使用场景 - 交易与执行服务 - 实时及历史行情数据采集 - 管理账户、余额和订单的后端服务 - 通过 WebSocket API 或 WebSocket 数据流获取低延迟更新的应用程序 ## 主要特性 - 支持 Binance REST API、WebSocket API 和 WebSocket 数据流 - 内置针对需要身份验证接口的请求签名 - WebSocket 连接管理,支持自动重连和会话续期 - 强类型的请求与响应结构 - 同时支持正式环境和测试网环境 - 符合 Go 惯例的 API 设计 ## 快速开始 安装您需要集成的产品对应的包: ```bash go get github.com/binance/binance-connector-go/clients/spot ``` 创建客户端并发送请求: ```go package main import ( "context" "os" spotClient "github.com/binance/binance-connector-go/clients/spot" "github.com/binance/binance-connector-go/common/common" ) func main() { config := common.NewConfigurationRestAPI( common.WithApiKey(os.Getenv("BINANCE_API_KEY")), common.WithPrivateKey(os.Getenv("BINANCE_PRIVATE_KEY")), ) client := spotClient.NewBinanceSpotClient( spotClient.WithRestAPI(config), ) accountInfo, err := client .RestApi .AccountAPI .GetAccount(context.Background()) .Execute() } ``` 上述示例使用非对称密钥进行身份验证。同样支持基于 API Secret 的 HMAC 身份验证方式。 如需各产品的 REST、WebSocket API 和 WebSocket 数据流示例,请参阅仓库文档。 ## 注意事项与最佳实践 - 使用环境变量或密钥管理工具安全存储 API 密钥 - 获取实时数据时,优先使用 WebSocket API 或数据流,而非轮询 REST 接口 - 构建高吞吐量服务时,注意监控频率限制和接口权重 - 开发和验证集成方案时,请使用测试网环境 --- ## Document: FIX (Python) URL: /zh-CN/docs/sdks-tools/connectors/fix-python # FIX (Python) Python FIX 连接器使用 FIX 协议提供对 Binance 金融信息交换(FIX)API 的访问。 本连接器适用于**高级和机构级使用场景**,这些场景需要低延迟的订单报送、成交执行以及基于会话的交易工作流。它提供 Binance 现货 FIX 消息类型和会话流程,支持通过 FIX 消息进行下单、撤单以及跟踪订单状态。 如需查看源代码、问题反馈及版本说明,请访问 GitHub 上的 [binance-fix-connector-python](https://github.com/binance/binance-fix-connector-python) 仓库。 ## 支持的环境 - Python 3.9 或更高版本 - 后端服务及交易系统 > 本连接器仅适用于服务端使用,且需要维持持久的 FIX 会话。 ## 范围与功能 Python FIX 连接器支持以下功能: - Binance 现货 FIX 订单报送 - 下单与撤单 - 成交回报及订单状态更新 - 基于会话的 FIX 通信 本连接器**不**替代 REST 或 WebSocket API,专为特定交易工作流设计。 ## 身份验证 > ⚠️ **重要提示** > > Binance FIX API **仅支持 Ed25519 密钥**。其他身份验证方式(如 HMAC 或 RSA)不受支持。 在使用 FIX 连接器之前,请确保: - 已生成 `Ed25519` 密钥对 - API 密钥已开启 FIX 权限 - 使用正确的 FIX 端点(正式环境或测试网) 请参阅以下指南: - [如何生成 Ed25519 密钥对(主网)](https://www.binance.com/en/support/faq/how-to-generate-an-ed25519-key-pair-to-send-api-requests-on-binance-6b9a63f1e3384cf48a2eedb82767a69a) - [Binance 现货 FIX API 文档](/products/spot/fix-api) ## 安装 使用 `pip` 安装连接器: ```bash pip install binance-fix-connector ``` > 该包在 PyPI 上以 `binance-fix-connector` 发布,源代码维护于上方链接的 GitHub 仓库中。 ## 快速开始 所有 FIX 消息均通过 `create_order_entry_session` 辅助函数创建和管理,该函数用于建立 FIX 会话并提供消息创建与发送的工具方法。 以下示例演示如何建立 FIX 订单报送会话并提交一个简单的限价订单。 ```python import time from binance_fix_connector.fix_connector import create_order_entry_session from binance_fix_connector.utils import get_private_key API_KEY = "" PRIVATE_KEY = get_private_key("/path/to/private.key") FIX_OE_URL = "tcp+tls://fix-oe.testnet.binance.vision:9000" client = create_order_entry_session( api_key=API_KEY, private_key=PRIVATE_KEY, endpoint=FIX_OE_URL, ) # 等待登录确认 client.retrieve_messages_until(message_type="A") # 创建并发送新订单报文(D) msg = client.create_fix_message_with_basic_header("D") msg.append_pair(11, str(time.time_ns())) # ClOrdID 客户订单编号 msg.append_pair(55, "BNBUSDT") # Symbol 交易对 msg.append_pair(54, 1) # Side 方向(买入) msg.append_pair(38, 1) # OrderQty 订单数量 msg.append_pair(40, 2) # OrdType 订单类型(限价) msg.append_pair(44, 730) # Price 价格 msg.append_pair(59, 1) # TimeInForce 有效方式(GTC) client.send_message(msg) # 接收成交回报 responses = client.retrieve_messages_until(message_type="8") ``` 更多示例请参阅仓库文档。 ## 典型使用场景 - 低延迟订单报送与成交执行 - 机构级或专业交易系统 - 需要会话控制的 FIX 集成 - REST 或 WebSocket API 无法满足需求的高级交易基础设施 ## 注意事项与最佳实践 - FIX API 需要持久的 TCP/TLS 连接 - 务必处理好会话生命周期事件(登录、心跳、登出) - 开发和验证阶段请使用测试网端点 - 建议实现重连/退避逻辑并监控会话健康状态 - 本连接器适用于有 FIX 经验的用户 - 通用集成场景建议优先使用 REST 或 WebSocket API --- ## Document: .NET URL: /zh-CN/docs/sdks-tools/connectors/dotnet # .NET Binance API 的 .NET 连接器为 .NET 应用程序提供了一个客户端,用于与 Binance REST API、WebSocket API 和 WebSocket 数据流的部分功能进行交互。 该连接器被视为**历史遗留版本**,**未处于积极维护状态**。与其他语言的新版 SDK 相比,它仅支持有限的 Binance 产品和接口。 如需查看源代码、问题反馈及版本说明,请访问 GitHub 上的 [binance-connector-dotnet](https://github.com/binance/binance-connector-dotnet) 仓库。 ## 状态 > ⚠️ **维护状态** > > .NET 连接器目前**未处于积极维护状态**。它仅支持部分 Binance 产品和 API,可能不包含较新的接口或功能。 > > 如需完整的产品支持和持续更新,我们建议使用以下积极维护中的 SDK:JavaScript、Python、Go、Java、PHP 或 Rust。 ## 支持的环境 - .NET 6.0 或更高版本 - 后端 .NET 应用程序及服务 > 本连接器仅适用于服务端使用。 ## 包结构 .NET 连接器以一个或多个 `NuGet` 包的形式分发。 它为所支持的 REST API、WebSocket 数据流和 WebSocket API 提供客户端接口。产品覆盖范围有限,具体情况可能因 API 而异。 ## 典型使用场景 - 与 Binance REST API 交互的后端服务 - 消费 WebSocket 数据流以获取实时数据的应用程序 - 使用 WebSocket API 进行请求-响应通信的应用程序 - 需要集成 Binance 功能的现有 .NET 系统 ## 主要特性 - 支持部分 Binance 产品和接口 - 基于 HMAC 和 RSA 的请求签名 - 与 .NET 日志生态系统集成 ## 快速开始 使用 NuGet 安装连接器: ```bash dotnet add package Binance.Spot ``` 创建客户端并发送请求: ```csharp using System; using System.Threading.Tasks; using Binance.Spot; class Program { static async Task Main(string[] args) { var market = new Market(); var serverTime = await market.CheckServerTime(); Console.WriteLine(serverTime); } } ``` 如需更多 REST、WebSocket API 和 WebSocket 数据流的使用示例,请参阅仓库文档及 examples 文件夹。 ## 注意事项与最佳实践 - 本连接器支持 REST API、WebSocket API 和 WebSocket 数据流 - 产品和接口覆盖范围有限,可能未反映最新的 Binance API - 请注意监控频率限制,旧版客户端可能不会提供详细的权重信息 - 如需用于生产环境或完整的 API 覆盖,请使用积极维护中的 SDK --- ## Document: Binance Web3 ON-Chain API Specification URL: /zh-CN/docs/products/web3-task-verification/on-chain-verification # Binance Web3 ON-Chain API Specification ## Web3 API description - Binance's Partners need to follow the API specification in this doc in order to integrate with Binance. ## API Specification​ ### EVM Compatible Blockchains #### VerificationProvider ```solidity abstract contract VerificationProvider { // verify is to check if the user is verified in the partner's system function verify(address addr) external view virtual returns (bool pass, string memory message); } ``` You are required to implement the `VerificationProvider` contract in your smart contract. The `verify` function should return `true` if the verification is successful, otherwise `false`. The `message` should contain the reason for the failure. #### Example ```solidity contract Example is VerificationProvider { function verify(address user) external view override returns (bool pass, string memory message) { if (user == address(0)) { return (false, "Invalid address"); } return (true, "Verified"); } } ``` ### Non EVM Compatible Blockchains Currently, We do not support non EVM compatible blockchains. Please refer to [off-chain verfication.](/docs/products/web3-task-verification/apis) --- ## Document: Binance Web3 API Specification URL: /zh-CN/docs/products/web3-task-verification/apis # Binance Web3 API Specification ## Web3 API description - Binance's Partners need to follow the API specification in this doc to provide Binance with a set of endpoints that Binance will call to check if a user has completed specific tasks (like a deposit, swap,etc.). ## General API Information - All endpoints return a common JSON object with "code", "message" and "data", no matter if it's a success or not. - Here "data" is either a customized JSON object or a simple type (int, string...). It may vary from endpoint to endpoint. ```json { "code": "XXXXXX", "message": "success", "data": { "abc": "efg", ... } } ``` - General codes in responses: | code | Description | | --- | --- | | 000000 | success | | 000001 | too many requests | | 000006 | invalid argument | | 000007 | other error | - All time and timestamp related fields are in milliseconds. - HTTP 5XX return codes are used for internal errors. The issue is on the partner's side. Binance will **NOT** treat this as a failure operation; the execution status is UNKNOWN. - For GET endpoints, parameters must be sent as a query string. - Parameters may be sent in any order. - Each request and response should be logged in both Binance and partner's sides for further investigation. - Every partner needs to define a url prefix so that Binance can invoke the partner's endpoint using prefix + endpoint_url. E.g. https://tasks-api.x.build/api/v1/task/completion?walletAddress=xx&task=["deposit"] * **Front all OpenAPI endpoints with a WAF** - Place every public endpoint behind a Web Application Firewall. - Enable core protections (SQLi, XSS, RCE) and basic rate/behavior policies. * **Rate limiting & overload protection** - Enforce global and per-key limits (per IP / user / token), plus per-endpoint limits on critical paths. - When capacity is exceeded, return **HTTP 429 (Too Many Requests)** and include a `Retry-After` header. - Consider circuit breakers and exponential backoff hints for clients. ## API Specification​ ### Task Completion ``` GET /v1/task/completion ``` **Parameters:** | Name | Type | Mandatory | Description | | ------------- | ----------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | walletAddress | String | YES | a user's unified id | | task | String json array | YES | Task ID used to identify the task. Try to use a Task ID that is relevant and descriptive of the task, not a random or arbitrary string. For example, task=["deposit","withdraw"]. If it's not empty, just return corresponding task completion status. Otherwise, return all tasks completion statuses. | **Response Body:** | Name | Type | Mandatory | | ------- | ----------- | --------- | | code | String | YES | | message | String | YES | | data | JSON Object | YES | **Examples:** ```json GET {prefix} + /v1/task/completion?walletAddress=0xabcdefg&task=["deposit", "withdrawal"] Response: { "code": "000000", "message": "success", "data": { "withdrawal": true, // complete "deposit": false, // incomplete } } { "code": "000006", "message": "invalid argument", "data": null } ``` - **Task verification (`verify` API)** - Flow: After a user completes a task and taps **Verify**, Binance backend calls your `verify` API to confirm completion. - **Latency SLO**: **P99 \< 1s**, **hard timeout ≤ 3s** (set a server-side timeout of 3 seconds). - **Observability**: Monitor latency (P50/P95/P99), error ratio, dependency timing; alert on timeouts and anomalies, and investigate immediately. - **Correctness over speed**: Do not return success/failure optimistically if data is inconclusive. - **Response shape**: - If incomplete, return a clear reason to reduce support load (e.g., a missing sub-step). Example: ```json { "completed": false, "reason": "Subtask 'bridge_tx_confirmed' not met (0/1 confirmations)", "evidence": null } ``` - Success example: ```json { "completed": true, "reason": null, "evidence": { "tx_hash": "0xabc...123", "chain_id": 56, "timestamp": 1732178452 } } ``` ## Web3 API Performance - Ensure your API can support >=**50 QPS.** - In special cases, Binance will review your campaign and contact you to increase the API QPS threshold. (E.g. Marketing plan is possible to attract extra traffic to your campaign, or special task design will cause high peak verification queries) - API performance is vital. So please conduct a performance test on the API. - Before developing the API, review the campaign mechanism. Avoid mechanisms requiring all users to verify tasks at the same time. (E.g. a task user can only verify on the last day of a campaign) - When API encounters performance issues, please return an error (error code:000002) to the caller. ## API Maintenance Periods: - Maintain the API till 3 days after the campaign end time. - E.g.: the campaign using your API ends on 1st Jan 2025 00:00(UTC), then the earliest time you can sunset the API is 4th Jan 2025 00:00(UTC) - Before you sunset the API, please ensure no traffic hits your API. If there is still traffic to your API, please contact the Binance team. ## Other Good Practise for API Developing: - Use 95% of the original criteria to verify user’s task status. - E.g. for a task that requires the user to stake more than 10 USDT, the API should return completed (True) if the user takes more than 9.5 USDT. - Avoid API changes before sunsetting the API. - Please update stakeholders if the API has to be updated due to logic change or issue fix. - Monitor the API performances especially the 1st 4 hours after the campaign launch time. * **Observability & slow-query management** - Enable slow-query logs for **DB** and **Redis** (or other caches) and wire up application/APM monitoring (latency percentiles, error codes, dependency timings). - Use distributed tracing (Trace/Span IDs) end-to-end so you can pinpoint bottlenecks quickly. - Define alert thresholds and on-call procedures for timeouts and rising error rates. * **SQL review & caching strategy** - Audit **all** SQL statements: - Ensure predicates use appropriate **indexes**; avoid full scans and implicit casts. - Review execution plans (`EXPLAIN`) and data distribution regularly. - Identify **hot keys** / high-QPS reads; use **Redis** (or similar) with proper TTLs and invalidation/backfill. - Protect against cache **penetration / breakdown / avalanche** (e.g., negative caching, jittered TTLs, bulkhead isolation). - Revisit schema/index health periodically; consider archival, read replicas, or sharding where needed. Provide feedback on this document: --- ## Document: DApp Self-Testing Manual URL: /zh-CN/docs/products/web3-dapp/self-testing # DApp Self-Testing Manual _SDK integration, DApps listing are independent. Well-tested DApps will help to reduce partly campaign workload._ ## Summary For all parties interested in cooperating with Binance Web3 Wallet, this manual contains all relevant information, including [integrating the Binance Web3 Connect SDK](/products/web3-connect/introduction) and **joining the Binance Web3 Wallet Dapp Zone**. **Self-testing** by the project party is essential. The Binance Web3 Wallet team strongly recommends that all projects complete self-testing according to the provided instructions to maximize user experience. Binance reserves the right to reject applications from projects that demonstrate low testing quality. Please read the following information carefully. ## How to test dApp 1. Type your url in the latest Binance Web3 wallet browser. 2. Test all the features in DApps. You could refer to the following test case checklist for guidance. ![browser-entry](/img/web3-dapp/browser-entry.png) ## Frequent Problems ### Error Code : ‘Network not supported for this wallet’ Project website should detect and change to the corresponding chain when users connect. For BEVM, check the `window.ethereum` chainId to change to the correct chain. ### IOS/Android Login Problem Check SDK status and Internet/VPN connection. ### RPC problem When testing on chain actions, projects might find the gas fee abnormally high. In this situation, projects could try the test with Trust Wallet and other Wallets like Metamask. If it only happens in Trust Wallet and Binance Wallet, it would be Binance’s RPC issue. Please contact Jasmine G @P0kEjasmine if this happens. ### Mobile Login Issue Ensure that the Binance App version for both IOS and Android is updated to the **latest version**. ## Test Case Checklist ### SDK | Category | Feature (Web, IOS and Android) | | ---------------- | -------------------------------------------------------------------------------------------------------------------- | | Connect Wallet | Can get wallet address and chainID. | | Send Transaction | The whole transaction process should be successful and can be checked on the chain. | | Sign message | The signature value should be valid | | Logo exposure | E.g.
| ### dApps | Category | Feature (IOS and Android) | | ---------------- | ------------------------------------------------------------------------------------- | | Connect Wallet | Wallet connects successfully and stably. (Without page redirection) | | | Binance Logo Exposure Success (Web & App) | | Send Transaction | All send transaction cases are successful. (e.g. Swap, Approve, etc.) | | | The gas fee is in the normal range. | | User Experience | The font size and icons are displayed appropriately. | | | All the URLs in the dApp can be opened in Binance directly. | | | The project will automatically switch to the user's current chain if it is supported. | | | All cases should be checked in both IOS and Android | --- ## Document: DApp Self-Listing Manual URL: /zh-CN/docs/products/web3-dapp/self-listing # DApp Self-Listing Manual ## Introduction This manual serves to guide any dApp team wishing to have their dApp listed within Binance Web3 Wallet. However, before the dApp can be listed officially, any team is required to go through a self testing process to ensure the dApp and Binance Web3 Wallet SDK integration functions as intended within Binance Web3 Wallet on Binance App. In order for the dApp team to conduct a self test before the dApp is officially released to the general public within Binance Web3 Wallet, the dApp URL will be whitelisted for the dApp team to conduct self testing within the Binance environment. Only dApps passing the quality control process will be shown and released to the general public within Binance Web3 Wallet with the following route: [Web3] - [Discover] - [dApps] [Web3] - [Discover] - [dApps] - dApp Main Page ![DApp](/img/web3-dapp/discover-dapps.jpg) **Please Notice:** 1. All submitted applications are expected to receive review results within **7** business days. 2. Test all the features in DApps. You could refer to the following test case checklist for guidance. 3. Having an 'Approved' status for a DApp application **does not guarantee** display unless the DApp passes Binance's quality control test, which aligns with the standards outlined in the [self-test checklist](/products/web3-dapp/self-testing#test-case-checklist). Therefore, we strongly recommend the dApp team to follow the test guide above and conduct sufficient self tests to facilitate the process of being listed. 4. Any application that fails to comply with the established rules may be rejected. ## How to apply? 1. Log in [Binance developer center](https://developers.binance.com/en/dapps) 2. Read the [rules](/products/web3-dapp/operation-rules) ![how-to-apply](/img/web3-dapp/how-to-apply.jpg) 3. Click [DApp],then click [Get started], and click [Apply] in the subpage. ![apply-DApp](/img/web3-dapp/apply-dapp.jpg) 4. Fill in the [application form](https://developers.binance.com/en/dapps/application-management/apply). ![DApp-application](/img/web3-dapp/dapp-application.jpg) 5. After completing the application form, the status in the Application Management page will change to 'under Review'. ![under-review](/img/web3-dapp/under-review.jpg) 6. Binance will conduct a quality control test following the [self-test checklist](self-testing#test-case-checklist) within 5 business days after application approval. A full self-test is a prerequisite for self-listing. Binance will only list the dApps that complete [Binance Web3 wallet integration](/products/web3-connect/introduction) (including Binance Logo exposure) and pass all items in the [self-test checklist](self-testing#test-case-checklist). --- ## Document: Web3 DApp Platform Operation Rules URL: /zh-CN/docs/products/web3-dapp/operation-rules # Web3 DApp Platform Operation Rules ## 1. Operation Rules ### 1.1 Rules for Registration and Submission 1.1.1 The developer should provide true and valid contact information or entity certification information. It is necessary to ensure that the entity actually providing services through the DApp must be consistent with the entity information. 1.1.2 The DApp submitted by the developer shall be associated with websites, applications, products or services that have complete legal rights or complete authorization. 1.1.3 To ensure the security and stability of the platform that users can access safely, the platform may require that the developer upload appropriate documents or make certain additions or adjustments to the DApp when submitting or operating the DApp. Be sure to provide such assistance based on our requirements or the submission may be rejected. 1.1.4 The services provided by the DApp shall match the category and tags the developer chooses as well as the services that the Web3 DApp provides. ### 1.2 Rules for Basic Information 1.2.1 The name, logo, and brief description of a DAPP constitutes its account's basic information, which shall accurately describe its features and content, help users easily understand it, and be consistent with users' expectations of its features and services. 1.2.2 The basic information of DApp accounts shall not make unauthorized use of trademarks or brand logos to which third parties enjoy the legal rights to, or other content, information or special superscripts/subscripts similar to these trademarks or brand logos. Developers shall not infringe upon third parties' intellectual property rights or other legal rights. --- ## Document: Tron Provider URL: /zh-CN/docs/products/web3-connect/tron-provider # Tron Provider # Tron Provider ## `@tronweb3/tronwallet-adapter-binance` This package provides an adapter to enable TRON DApps to connect to the [Binance Wallet](https://www.binance.com/en/binancewallet). ## Demo ```typescript import { BinanceWalletAdapter } from "@tronweb3/tronwallet-adapter-binance"; const adapter = new BinanceWalletAdapter(); // connect to BinanceWallet await adapter.connect(); // then you can get address console.log(adapter.address); const tronWeb = new TronWeb({ fullHost: "https://api.trongrid.io", }); // create a send TRX transaction const unSignedTransaction = await tronWeb.transactionBuilder.sendTrx(targetAddress, 100, adapter.address); // using adapter to sign the transaction const signedTransaction = await adapter.signTransaction(unSignedTransaction); // broadcast the transaction await tronWeb.trx.sendRawTransaction(signedTransaction); ``` ## Documentation ### API - `Constructor(config: BinanceWalletAdapterConfig)` ```typescript interface BinanceWalletAdapterConfig { /** * Set if open Wallet's website when wallet is not installed. * Default is true. */ openUrlWhenWalletNotFound?: boolean; /** * Timeout in millisecond for checking if TokenPocket wallet is supported. * Default is 2 * 1000ms */ checkTimeout?: number; /** * Set if open TokenPocket app using DeepLink on mobile device. * Default is true. */ openAppWithDeeplink?: boolean; } ``` - `network()` method is supported to get current network information. The type of returned value is `Network` as follows: ```typescript export enum NetworkType { Mainnet = "Mainnet", Shasta = "Shasta", Nile = "Nile", /** * When use custom node */ Unknown = "Unknown", } export type Network = { networkType: NetworkType; chainId: string; fullNode: string; solidityNode: string; eventServer: string; }; ``` ### Caveats - Binance Wallet doesn't implement `multiSign()` and `switchChain()`. - Binance Wallet App does not support any events. For more information about tronwallet adapters, please refer to [`@tronweb3/tronwallet-adapters`](https://github.com/tronweb3/tronwallet-adapter/tree/main/packages/adapters/adapters) --- ## Document: Ton Provider URL: /zh-CN/docs/products/web3-connect/ton-provider # Ton Provider # Ton Provider ## Introduction[](https://developers.devfdg.net/docs/binance-w3w/ton-provider#ton-provider-api) Binance Web3 Wallet's TON API is fully compliant with the [Ton Connect protocol](https://docs.ton.org/develop/dapps/ton-connect/protocol/). By connecting to our TON API Provider, you can use the [TON Connect SDK](https://docs.ton.org/develop/dapps/ton-connect/developers) to integrate with Binance Web3 Wallet. There are 2 ways to integrate with Binance Web3 Wallet: JS Bridge API: for apps opened within the wallet; or when the wallet is a browser extension. HTTP Bridge API: for apps opened outside the wallet The last section, “Interactions”, provides detailed instructions on implementing specific Binance Web3 Wallet interactions. Especially for conducting airdrop campaigns, some interactions are more desirable than others. ## JS Bridge API[](https://developers.devfdg.net/docs/binance-w3w/ton-provider#js-bridge-api) When the dapp is opened in the Binance Web3 Wallet browser, the `window.binancew3w` object will be injected into the global scope. The object contains the `tonconnect` object, which is the bridge object for the TON Connect protocol. ### Provider Detection[](https://developers.devfdg.net/docs/binance-w3w/ton-provider#provider-detection) ```js window.binancew3w.tonconnect; ``` The data structure of the object it points to is as follows: ```js interface TonConnectBridge { deviceInfo: DeviceInfo walletInfo?: WalletInfo protocolVersion: number connect(protocolVersion: number, message: ConnectRequest): Promise restoreConnection(): Promise send(message: AppRequest): Promise listen(callback: (event: WalletEvent) => void): () => void } ``` The version of Ton Connect supported by Binance Web3 Wallet is currently 2. For more information, see [ton-connect bridge api](https://docs.ton.org/develop/dapps/ton-connect/protocol/bridge) and [ton-connect requests and responses](https://docs.ton.org/develop/dapps/ton-connect/protocol/requests-responses) ### Example[](https://developers.devfdg.net/docs/binance-w3w/ton-provider#example) To connect to our wallet to get the wallet address as an identifier and the necessary parameters used to sign the transaction: ```js const result = await window.binancew3w.tonconnect.connect(2, { manifestUrl: "https://example.com/manifest.json", items: [{ name: "ton_addr" }], }); if (result.event === "connect") { console.log(result.payload.items, result.payload.device); } if (result.event === "connect_error") { console.error(result.payload.error.code, result.payload.error.message); } ``` ## HTTP Bridge API[](https://developers.devfdg.net/docs/binance-w3w/ton-provider#http-bridge-api) If the dapp is not opened in the Binance Web3 Wallet browser, the `window.binancew3w` object will not be injected into the global scope. In this case, the dapp can use the [HTTP bridge API](https://github.com/ton-blockchain/ton-connect/blob/main/bridge.md) to interact with the wallet. ### Provider Detection[](https://developers.devfdg.net/docs/binance-w3w/ton-provider#provider-detection-1) Let say dapp with ID A connects to the bridge to listen to incoming requests from wallet with ID B. ```bash request GET https://bridge.tonapi.io/bridge/events?client_id= Accept: text/event-stream ``` Sending message from client A to client B. Bridge returns error if ttl is too high. ```bash request POST https://bridge.tonapi.io/bridge/message?client_id=?to=&ttl=300&topic=sendTransaction body: ``` Dapp need to encrypt the message before sending it to the bridge with id of client B as public key. And client B will decrypt the message with its private key. When the bridge receives a message base64_encoded_message from client A addressed to client B, it generates a message BridgeMessage: ```json { "from": , "message": } ``` Client B send a message to client A. Client A will receive a message from the bridge. Dapp need to decrypt the message with its private key(id of client A). ```json { "from": , "message": } ``` ## Interactions To offer clarity on certain Binance Web3 Wallet interactions which is most appropriate for your dApp. ### Directly Open Binance Web3 Wallet If you want to open Binance Web3 wallet directly without the user selecting a wallet, you can follow the steps below: 1. Add a button with the text `Binance Web3 Connect` 2. Add the following code. > Assume the id of the button above is binance-w3w-connect. ```js import TonConnectUI from "@tonconnect/ui"; // create an instance of TonConnectUI const tonConnectUI = new TonConnectUI({ manifestUrl: "https://ton-connect.github.io/demo-dapp-with-react-ui/tonconnect-manifest.json", buttonRootId: "your-button-root-id", }); // add event listener to the button document.querySelector("#binance-w3w-connect").addEventListener("click", async () => { await tonConnectUI.openSingleWalletModal("binanceWeb3TonWallet"); }); ``` After that, when the user clicks the `Binance Web3 Connect` button, the Binance wallet app will be opened directly. ### Call Specific Page or Action If you want to open a specific page like swap, bridge or earn, you can request from us for a Universal Link with relevant parameters. Use the Universal Link in a button to trigger the page connection. #### Available Page Here are some pages you can open: - **swap** #### Parameters Depending on the action, you may need to include additional parameters: For Swap, - pageName string: swap - fromNetwork string?: ETH or TON or SOL - toNetwork string?: ETH or TON or SOL - fromTokenAddress string?: Token contract address of asset to swap from (If unavailable, skip this parameter) - toTokenAddress string?: Token contract address of asset to swap to (If unavailable, skip this parameter) - tab string?: Specific tab within a page; swap or bridge #### Universal Link Construction Here is how to construct the link: ```bash https://app.binance.com/uni-qr/ww{pageName}?fromNetwork={string}&fromTokenAddress={string}&toNetwork={string}&toTokenAddress={string}&tab={string} ``` #### Implementation To implement these universal links in your application: 1. Construct the appropriate URL based on the desired action and parameters. 2. Use the URL to create a clickable link or button in your app's interface. 3. When the user interacts with the link, it will open the Binance Web3 Wallet app (if installed) or redirect to the Binance app download page. #### Example Code Open swap page for 1 USDT to Ton on Ton chain. ```bash https://app.binance.com/uni-qr/wwswap?fromNetwork=TON&fromTokenAddress=EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs&toNetwork=TON&toTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee ``` ## Conclusion[](https://developers.devfdg.net/docs/binance-w3w/ton-provider#conclusion) The Binance Web3 Wallet browser provides both JS bridge API and HTTP bridge API for dapps to interact with the wallet. Dapps can use the JS bridge API when the dapp is opened in the Binance Web3 Wallet browser, and use the HTTP bridge API when the dapp is not opened in the Binance Web3 Wallet browser. We strongly recommend that dapps use [ton-connect](https://docs.ton.org/develop/dapps/ton-connect/developers) to integrate with Binance Web3 Wallet, as it provides a more secure and reliable way to interact with the wallet. You don't need to care about which bridge API to use, ton-connect will automatically choose the appropriate bridge API based on the environment. Also you don't need to care about the encryption and decryption of messages, ton-connect will handle it for you Refer to Interactions especially when discussing with our BD/PM to decide on a suitable UI/UX for users. --- ## Document: Sui Provider URL: /zh-CN/docs/products/web3-connect/sui-provider # Sui Provider ## Sui Provider API Binance Web3 Wallet comes with built-in support for Wallet Standard on Sui. To get started, simply update the [Sui dApp Kit](https://www.npmjs.com/package/@mysten/dapp-kit) to the latest release. For a demo, check out [Sui dApp Kit](https://sdk.mystenlabs.com/dapp-kit). And if you are using Typescript, check out [Sui TypeScript SDK](https://docs.sui.io/guides/developer/first-app/client-tssdk) --- ## Document: Solana Provider URL: /zh-CN/docs/products/web3-connect/solana-provider # Solana Provider ## Solana Provider API Binance Web3 Wallet comes with built-in support for Wallet Standard on Solana. To get started, simply update the [Solana Wallet Adapter](https://github.com/solana-labs/wallet-adapter) to the latest release. For a demo, check out the [Wallet Adapter Example](https://anza-xyz.github.io/wallet-adapter/example/). --- ## Document: Movement Network URL: /zh-CN/docs/products/web3-connect/movement-network # Movement Network ## Movement Aptos Testnet Binance Web3 Wallet supports Movement Aptos Testnet, the API is the same as [Aptos Provider API](/products/web3-connect/aptos-provider) --- ## Document: Binance Wallet SDK URL: /zh-CN/docs/products/web3-connect/introduction # Binance Wallet SDK ## Introduction Welcome to the Wallet Software Development Kit (SDK) documentation. This SDK is designed to empower third-party Decentralized Applications (dApps) by enabling seamless integration with the Binance Wallet. By leveraging the SDK, developers can enhance their dApp's user experience and provide seamless access to the advanced features of the Binance Wallet. The Binance Wallet is built on the latest multi-party computation (MPC) cryptographic standard, providing unmatched security. With this technique, private keys remain secure and confidential, as each party only has access to its own key fragment. In addition to exceptional security, the Binance Wallet offers a comprehensive suite of advanced features, including biometric authentication, Wallet Connect support, and SoulBound Tokens (SBT). The SDK supports standard functionality such as connecting and signing transactions. It also continuously expands its capabilities, offering unique features like fund transfers from the user's Binance account to a Web3 wallet when using a dApp, with more features to come in the future. ## Features - Secure and easy integration with Binance Wallet. - Support for standard functions such as connecting and signing transactions. - Continuously evolving capabilities, such as offering unique features like fund transfers between the user's Binance account and Web3 wallet. ## Support & Resources If you encounter any issues or have any questions, please reach out to our support team for assistance. Support appeal: Provide feedback on this document: --- ## Document: EVM-Compatible Provider URL: /zh-CN/docs/products/web3-connect/evm-compatible-provider # EVM-Compatible Provider ## Binance Web3 Wallet Provider API The Provider API is a JavaScript API that connects wallets with dApps. The dApps you visit can access your wallet, read on-chain data, sign messages, and send transactions. Below are some common usage examples ```tsx // Wallet connection if (typeof window.binancew3w.ethereum !== "undefined") { try { const accounts = await window.binancew3w.ethereum.request({ method: "eth_requestAccounts", }); console.log("connected:", accounts[0]); } catch (error) { console.error("connection rejected:", error); } } else { alert("Please install wallet!"); } // Send transaction const transactionParameters = { from: accounts[0], // sender address to: "0xRecipientAddress", // recipient address value: "0xDE0B6B3A7640000", gasLimit: "0x5208", // 21000 gas }; try { const txHash = await window.binancew3w.ethereum.request({ method: "eth_sendTransaction", params: [transactionParameters], }); console.log("Transaction hash:", txHash); } catch (error) { console.error("Transaction failed:", error); } // Switch accounts window.binancew3w.ethereum.on("accountsChanged", (accounts) => { if (accounts.length === 0) { console.log("Wallet has been disconnected"); } else { console.log("Current account:", accounts[0]); } }); // Switch chains window.binancew3w.ethereum.on("chainChanged", (chainId) => { console.log("Current chain id:", chainId); }); ``` ## Installation The installation process may vary depending on the technology stack you are using. ## Integration ### Integration with RainbowKit 2.x Add Packages ```shell npm install @binance/w3w-rainbow-connector-v2 @rainbow-me/rainbowkit@2.1.2 wagmi@2.x viem@2.x @tanstack/react-query ``` Usage ```typescript import '@rainbow-me/rainbowkit/styles.css' import { connectorsForWallets, RainbowKitProvider, WalletList } from '@rainbow-me/rainbowkit' import { injectedWallet } from '@rainbow-me/rainbowkit/wallets' import { WagmiProvider, createConfig, http } from 'wagmi' import { bsc, mainnet, sepolia } from 'wagmi/chains' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import binanceWallet from '@binance/w3w-rainbow-connector-v2' const WALLET_CONNECT_PROJECT_ID = 'xxxxxxxxxx' const APP_NAME = 'xxx' const recommendedWalletList: WalletList = [ { groupName: 'Recommended', wallets: [ injectedWallet, binanceWallet, ], }, ] const connectors = connectorsForWallets( recommendedWalletList, { projectId: WALLET_CONNECT_PROJECT_ID, appName: APP_NAME } ) const config = createConfig({ ssr: true, connectors, chains: [mainnet, sepolia, bsc], transports: { [mainnet.id]: http(), [sepolia.id]: http(), [bsc.id]: http(), }, }) const queryClient = new QueryClient() export default function RainbowProvider({ children }) { return ( {children} ) } ``` ### Integration with BlockNative Add Packages ```shell npm install @web3-onboard/core @binance/w3w-blocknative-connector ``` Usage ```typescript import Onboard from "@web3-onboard/core"; import binanceModule from "@binance/w3w-blocknative-connector"; // initialize the module with options const binance = binanceModule({ options: { lng: "en" } }); // can also initialize with no options... // const binance = binanceModule() const onboard = Onboard({ // ... other Onboard options wallets: [ binance, //... other wallets ], }); const connectedWallets = await onboard.connectWallet(); console.log(connectedWallets); ``` ### Integration with wagmi v2 Add Packages ```shell npm install wagmi@2.x viem@2.x @tanstack/react-query @binance/w3w-wagmi-connector-v2 ``` Integrate with your projects ```tsx import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { http, createConfig, WagmiProvider } from "wagmi"; import { injected } from "wagmi/connectors"; import { getWagmiConnectorV2 } from "@binance/w3w-wagmi-connector-v2"; import { bsc, mainnet, sepolia } from "wagmi/chains"; const connector = getWagmiConnectorV2(); const config = createConfig({ chains: [mainnet, sepolia, bsc], connectors: [injected(), connector()], transports: { [mainnet.id]: http(), [sepolia.id]: http(), [bsc.id]: http(), }, }); const queryClient = new QueryClient(); export default function WagmiV2() { return ( ); } ``` Use wagmi v2 API [wagmi v2](https://wagmi.sh/) provides many useful API for you to use, here is a basic example. ```tsx import { Connector, useConnect, useDisconnect, useSignMessage } from "wagmi"; function WalletOption({ connector, onClick }: { connector: Connector; onClick: () => void }) { const [ready, setReady] = React.useState(false); React.useEffect(() => { (async () => { const provider = await connector.getProvider(); setReady(!!provider); })(); }, [connector]); return ( ); } function Home() { const { connectors, connect } = useConnect(); const { disconnect } = useDisconnect(); const { signMessage, data } = useSignMessage(); return (

wagmi v2 connector

{connectors.map((connector) => ( connect({ connector })} /> ))}
); } ``` #### Get connector by id from wagmi If you need to getConnector by id, you can use the following code ```tsx const connector = connectors.find((connector) => { return connector.id === "BinanceW3WSDK" || connector.id === "wallet.binance.com"; }); ``` ### Wagmi injected connector If you like to inject Binance web3 wallet, you can use the following code ```tsx import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { http, createConfig, WagmiProvider } from "wagmi"; // wagmi v2 API import { injected } from "wagmi/connectors"; import { bsc, mainnet, sepolia } from "wagmi/chains"; const config = createConfig({ ssr: true, chains: [mainnet, sepolia, bsc], connectors: [ injected({ target: { // Provide the injected target to avoid window.ethereum provider overwrite conflict id: "wallet.binance.com", name: "Binance Wallet Injected", provider: () => window.binancew3w.ethereum, }, }), ], transports: { [mainnet.id]: http(), [sepolia.id]: http(), [bsc.id]: http(), }, }); const queryClient = new QueryClient(); export default function WagmiV2Injected() { return ( ); } ``` ## Utility ### isInBinance Return `true` if the dApp is in the dApp browser of the Binance Web3 Wallet. ```ts import { isInBinance } from "@binance/w3w-utils"; isInBinance(); // return boolean // Or you can detect without install any packages window.ethereum.isBinance; // boolean ``` ### getDeeplink By this way, you can guide users to open your dapp in Binance dApp browser. ```ts import {getDeeplink} fom '@binance/w3w-utils' getDeeplink(url, defaultChainId) // return {bnc, http} ``` For the response, bnc is the deeplink and http is the universal link. ## Example code Here is the example project which integrating the SDK. ## Troubleshooting ### buffer is not defined While using wagmi or Rainbowkit, if you are using regular React(not SSR), you may encounter the error `buffer is not defined`. You can try to install `buffer` package. ```shell npm install buffer ``` ```tsx // src/index.ts import { Buffer } from "buffer"; window.Buffer = Buffer; ``` ```html // public/index.html ``` ### Non-React project For Non-React project, you can refer this example --- ## Document: Cosmos Provider URL: /zh-CN/docs/products/web3-connect/cosmos-provider # Cosmos Provider ## Cosmos Provider API ### Provider Detection ```javascript // binancew3w.keplr if (window.binancew3w.keplr) { console.log("Cosmos Provider is detected!"); } ``` ## Connecting to Cosmos If Binance Web3 Wallet is locked, you can unlock the wallet by using window.binancew3w.keplr.enable(chainIds). You'll be required to grant the webpage permission to access Keplr if such permission wasn't previously granted. The enable method can receive one or more chain IDs as an array. When passing the chain ID array, you can simultaneously request the permissions of all chains that haven't been authorized. If you cancel the unlocking or are denied permission, an error will show. ```javascript const chainId = "cosmoshub-4"; // Enabling before using the Keplr is recommended. // This method will ask the user whether to allow access if they haven't visited this website. // Also, it will request that the user unlock the wallet if the wallet is locked. await window.binancew3w.keplr.enable(chainId); ``` ## Methods ### signArbitrary This request will sign any information, which is equivalent to the signMessage (any) of the previous chains. Connect the current account. #### Parameters - `chainId` - `string` - `signerAddress` - `string` - `data` - `string` #### Returns `Promise` returns `object` : - `signature` - `string` - `signDoc` - `object` #### Example ```javascript const res = await window.binancew3w.keplr.signArbitrary({ "osmosis-1", "osmo1sxqwesgp7253fdv985csvz95fwc0q53ulldggl", 'test cosmos' } ); ``` ### signAmino This request signs in a fixed format, similar to the signAmino method of OfflineSigner of cosmjs. Parameters are objects, and signDoc is a fixed format. #### Parameters - `chainId` - `string` - `signerAddress` - `string` - `signDoc` - `object` #### Returns `Promise` returns `object` : - `signature` - `string` - `signed` - `boolean` #### Example ```javascript const res = const res = await window.binancew3w.keplr.signAmino( "osmosis-1", "osmo1sxqwesgp7253fdv985csvz95fwc0q53ulldggl", { account_number: "707744", chain_id: "osmosis-1", fee: { gas: "500000", amount: [ { denom: "uosmo", amount: "12500" } ] }, memo: "", msgs: [ { type: "osmosis/gamm/swap-exact-amount-in", value: { routes: [ { pool_id: "795", token_out_denom: "uosmo" }, { pool_id: "1", token_out_denom: "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2" } ], sender: "osmo1sxqwesgp7253fdv985csvz95fwc0q53ulldggl", token_in: { amount: "10000", denom: "ibc/2DA9C149E9AD2BD27FEFA635458FB37093C256C1A940392634A16BEA45262604" }, token_out_min_amount: "553" } } ], sequence: "54" } ); ``` --- ## Document: Bitcoin Provider URL: /zh-CN/docs/products/web3-connect/bitcoin-provider # Bitcoin Provider ## Bitcoin Provider API ### Provider Detection ```javascript // binancew3w.bitcoin if (window.binancew3w.bitcoin) { console.log("Bitcoin Provider is detected!"); } // we also proxy window.unisat, but some of the APIs are different if (window.unisat && window.unisat.isBinance) { console.log("Bitcoin Provider is detected!"); } ``` ## Connecting to Bitcoin Connecting" or "logging in" to Binance Web3 Wallet effectively means "to access the user's Bitcoin account(s)". We recommend that you provide a button to allow the user to connect Binance Web3 Wallet to your dapp. Clicking this button should call the following method: ```javascript binancew3w.bitcoin.requestAccounts(); ``` ## Methods ### requestAccounts ```javascript binancew3w.bitcoin.requestAccounts(); ``` Connect the current account. #### Parameters none #### Returns `Promise` returns `string[]` : Address of current account. #### Example ```javascript try { let accounts = await window.binancew3w.bitcoin.requestAccounts(); console.log('connect success', accounts); } catch (e) { console.log('connect failed'); } > connect success ['tb1qrn7tvhdf6wnh790384ahj56u0xaa0kqgautnnz'] ``` ### getAccounts ```javascript binancew3w.bitcoin.getAccounts(); ``` Get address of current account #### Parameters none #### Returns `Promise` returns `string` : Address of current account. #### Example ```javascript try { let accounts = await window.binancew3w.bitcoin.getAccounts(); console.log('connect success', accounts); } catch (e) { console.log('connect failed'); } > connect success ['tb1qrn7tvhdf6wnh790384ahj56u0xaa0kqgautnnz'] ``` ### getNetwork ```javascript binancew3w.bitcoin.getNetwork(); ``` Get network of current account #### Parameters none #### Returns `Promise` returns `string` : `livenet` `testnet` or `signet` #### Example ```javascript try { let accounts = await window.binancew3w.bitcoin.getNetwork(); console.log('connect network', accounts); } catch (e) { console.log('connect failed', e); } > 'livenet' ``` ### switchNetwork ```javascript binancew3w.bitcoin.switchNetwork(network); ``` Switch network #### Parameters - `network` - `string`: the network. `livenet` `testnet` or `signet` #### Returns none #### Example ```javascript try { let res = await window.binancew3w.bitcoin.switchNetwork("livenet"); console.log(res) } catch (e) { console.error(e) } > true ``` ### getPublicKey ```javascript binancew3w.bitcoin.getPublicKey(); ``` Get publicKey of current account #### Parameters none #### Returns `Promise` returns `string` : publicKey (no tweak for taproot) #### Example ```javascript try { let res = await window.binancew3w.bitcoin.getPublicKey(); console.log(res) } catch (e) { console.log(e); } > 03cbaedc26f03fd3ba02fc936f338e980c9e2172c5e23128877ed46827e935296f ``` ### getBalance ```javascript binancew3w.bitcoin.getBalance(); ``` Get BTC balance #### Parameters none #### Returns - `Promise` returns `Object` : - `confirmed` - `number`: the confirmed satoshis - `unconfirmed` - `number`: the unconfirmed satoshis - `total` - `number`: the total satoshis #### Example ```javascript try { let res = await window.binancew3w.bitcoin.getBalance(); console.log(res) } catch (e) { console.log(e); } > { "confirmed":0, "unconfirmed":100000, "total":100000 } ``` ### signMessage ```javascript binancew3w.signMessage(msg[, type]) ``` sign message #### Parameters - `msg` - `string`: a string to sign - `type` - `string`: (Optional) "ecdsa" | "bip322-simple". default is "ecdsa" #### Returns - `Promise` returns `string`: the signature #### Example ```javascript // sign by ecdsa try { let res = await window.binancew3w.bitcoin.signMessage("abcdefghijk123456789"); console.log(res) } catch (e) { console.log(e); } > G+LrYa7T5dUMDgQduAErw+i6ebK4GqTXYVWIDM+snYk7Yc6LdPitmaqM6j+iJOeID1CsMXOJFpVopvPiHBdulkE= // sign by bip322-simple try { let res = await window.binancew3w.bitcoin.signMessage("abcdefghijk123456789","bip322-simple"); console.log(res) } catch (e) { console.log(e); } > AkcwRAIgeHUcjr0jODaR7GMM8cenWnIj0MYdGmmrpGyMoryNSkgCICzVXWrLIKKp5cFtaCTErY7FGNXTFe6kuEofl4G+Vi5wASECaIeVi8xMtvjATqSSYPDRDjEsQbr0hSUpU7FHJNtVKqw= ``` ### signPsbt ```javascript binancew3w.signPsbt(psbtHex[, options]) ``` Sign PSBT This method will traverse all inputs that match the current address to sign. #### Parameters - `psbtHex` - `string`: the hex string of psbt to sign - `options` - `object`: - `autoFinalized` - `boolean`: whether finalize inputs signed by user's wallet after signing, default is `true` - `toSignInputs` - `array`: - `index` - `number`: which input to sign - `address` - `string`: (at least specify either an address or a publicKey) Which corresponding private key to use for signing - `publicKey` - `string`: (at least specify either an address or a publicKey) Which corresponding private key to use for signing - `sighashTypes` - `number[]`: (optionals) sighashTypes - `disableTweakSigner` - `boolean`: (optionals) When signing and unlocking Taproot addresses, the tweakSigner is used by default for signature generation. Enabling this allows for signing with the original private key. #### Returns - `Promise` returns `string`: the hex string of signed psbt #### Example ```javascript try { let res = await window.binancew3w.bitcoin.signPsbt("70736274ff01007d....", { autoFinalized: false, toSignInputs: [ { index: 0, address: "tb1q8h8....mjxzny", }, { index: 1, publicKey: "tb1q8h8....mjxzny", sighashTypes: [1], }, { index: 2, publicKey: "02062...8779693f", }, ], }); console.log(res); } catch (e) { console.log(e); } binancew3w.bitcoin.signPsbt("xxxxxxxx", { toSignInputs: [{ index: 0, publicKey: "xxxxxx", disableTweakSigner: true }], autoFinalized: false, }); ``` ## Events ### accountsChanged ```javascript binancew3w.bitcoin.on('accountsChanged', handler: (accounts: Array) => void); bitnancew3w.bitcoin.removeListener('accountsChanged', handler: (accounts: Array) => void); ``` The accountsChanged will be emitted whenever the user's exposed account address changes. ### networkChanged ```javascript binancew3w.bitcoin.on('networkChanged', handler: (network: string) => void); binancew3w.bitcoin.removeListener('networkChanged', handler: (network: string) => void); ``` The networkChanged will be emitted whenever the user's network changes. --- ## Document: Avail Provider URL: /zh-CN/docs/products/web3-connect/avail-provider # Avail Provider ## Avail Provider API Binance Web3 Wallet's Avail API is fully compliant with the [polkadot extension](https://polkadot.js.org/docs/extension/). Dapps can use it to integrate with Binance Web3 Wallet. ### Provider Detection We will inject the `window.injectedWeb3` object into the global scope. The object contains the `binancew3w` object, which is the bridge object for the Avail protocol. ```js window.injectedWeb3 = { 'binancew3w': { // semver for the package version: '1.0.0', // this is called to enable the injection, and returns an injected // object containing the accounts, signer and provider interfaces // (or it will reject if not authorized) enable (originName: string): Promise } } ``` You can get the provider object by calling `window.injectedWeb3['binancew3w'].enable('my dapp')`. and then use the `accounts` and `signer` interfaces to interact with the injected account. ```js const provider = await window.injectedWeb3["subwallet-js"].enable("my dapp"); const allAccounts = provider.accounts.get(); const AVAIL_GENESIS_HASH = isTest ? "0xd3d2f3a3495dc597434a99d7d449ebad6616db45e4e4f178f31cc6fa14378b70" : "0xb91746b45e0346cc2f815a520b9c6cb4d5c0902af848db0a80f85932d2e8276a"; if (allAccounts.length > 0) { console.log("Injected accounts:", allAccounts); for (let i = 0; i < allAccounts.length; i++) { if (allAccounts[i].genesisHash === AVAIL_GENESIS_HASH) { console.log("Injected avail account:", allAccounts[i]); } } } ``` You can also use the `@polkadot/extension-dapp` package to detect the provider: ```js const AVAIL_GENESIS_HASH = isTest ? "0xd3d2f3a3495dc597434a99d7d449ebad6616db45e4e4f178f31cc6fa14378b70" : "0xb91746b45e0346cc2f815a520b9c6cb4d5c0902af848db0a80f85932d2e8276a"; const allAccounts = await web3Accounts(); if (allAccounts.length > 0) { console.log("Injected accounts:", allAccounts); for (let i = 0; i < allAccounts.length; i++) { if (allAccounts[i].genesisHash === AVAIL_GENESIS_HASH) { console.log("Injected avail account:", allAccounts[i]); } } } ``` ## Injection information And here is the related interfaces: ```ts interface Injected { // the interface for Accounts, as detailed below readonly accounts: Accounts; // the standard Signer interface for the API, as detailed below readonly signer: Signer; } interface Account = { // ss-58 encoded address readonly address: string; // the genesisHash for this account (empty if applicable to all) readonly genesisHash?: string; // (optional) name for display readonly name?: string; }; // exposes accounts interface Accounts { // retrieves the list of accounts for right now get: () => Promise; // (optional) subscribe to all accounts, updating as they change subscribe?: (cb: (accounts: Account[]) => any) => () => void } // a signer that communicates with the extension via sendMessage interface Signer { /** * @description signs an extrinsic payload from a serialized form */ signPayload?: (payload: SignerPayloadJSON) => Promise; /** * @description signs a raw payload, only the bytes data as supplied */ signRaw?: (raw: SignerPayloadRaw) => Promise; } ``` ## Provide metadata You may need to provide metadata for the wallet, such as the chain name, chain type, color, genesis hash, icon, and meta calls. ```js // the address we use to use for signing, as injected const SENDER = '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE'; // finds an injector for an address const injector = await web3FromAddress(SENDER); injector.metadata.provide({ chain: 'Avail DA Mainnet', chainType: 'substrate', color: '#1B1E26', genesisHash: '0xb91746b45e0346cc2f815a520b9c6cb4d5c0902af848db0a80f85932d2e8276a', icon: 'substrate', metaCalls: ... }) ``` ## signAndSend You can use the `signAndSend` method to sign and send a transaction. ```js import { web3Accounts, web3Enable, web3FromAddress } from '@polkadot/extension-dapp'; // returns an array of all the injected sources // (this needs to be called first, before other requests) const allInjected = await web3Enable('my cool dapp'); // returns an array of { address, meta: { name, source } } // meta.source contains the name of the extension that provides this account const allAccounts = await web3Accounts(); // the address we use to use for signing, as injected const SENDER = '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE'; // finds an injector for an address const injector = await web3FromAddress(SENDER); // sign and send our transaction - notice here that the address of the account // (as retrieved injected) is passed through as the param to the `signAndSend`, // the API then calls the extension to present to the user and get it signed. // Once complete, the api sends the tx + signature via the normal process api.tx.balances .transfer('5C5555yEXUcmEJ5kkcCMvdZjUo7NGJiQJMS7vZXEeoMhj3VQ', 123456) .signAndSend(SENDER, { signer: injector.signer }, (status) => { ... }); ``` --- ## Document: Aptos Provider URL: /zh-CN/docs/products/web3-connect/aptos-provider # Aptos Provider ## Aptos Provider API Binance Web3 Wallet comes with built-in support for AIP-62 - Wallet Standard on Aptos. The interface of provider can be referenced in [AIP-62](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-62.md) To get started, simply update the [Aptos Wallet Adapter](https://github.com/aptos-labs/aptos-wallet-adapter) to the latest release, and follow [the usage](https://github.com/aptos-labs/aptos-wallet-adapter/tree/main/packages/wallet-adapter-reactA). --- ## Document: 支持的 Skills URL: /zh-CN/docs/products/wallet-skills/supported-skills # 支持的 Skills Binance Wallet Skills 已在 [binance-skills-hub](https://github.com/binance/binance-skills-hub/tree/main/skills/binance-web3) 发布,包括 7 个只读 **Wallet Skills** 和用于链上交易的 **Agentic Wallet Skill**。 ## 总览 ### 已发布 Wallet Skills | Skill | 类别 | 状态 | 需要钱包连接 | | ------------------------------------- | ---- | ------- | ------------ | | **query-token-info** | Read | ✅ Live | 否 | | **query-token-audit** | Read | ✅ Live | 否 | | **query-address-info** | Read | ✅ Live | 否 | | **crypto-market-rank** | Read | ✅ Live | 否 | | **meme-rush** | Read | ✅ Live | 否 | | **trading-signal** | Read | ✅ Live | 否 | | **binance-tokenized-securities-info** | Read | ✅ Live | 否 | ### Agentic Wallet Skills | Skill | 类别 | 状态 | 需要钱包连接 | | -------------------------- | ------------ | ------- | ------------ | | **binance-agentic-wallet** | Read + Write | ✅ Live | 是(写操作) | --- ## 已发布 Wallet Skills ### query-token-info 代币全面信息查询,从发现到深度分析一站解决。 **支持操作** | 操作 | 说明 | | ---------- | ----------------------------------------------------- | | 代币搜索 | 按名称、Symbol 或合约地址搜索,返回价格、市值、流动性 | | 元数据查询 | 描述、创建者、审计状态、社交链接等静态信息 | | 实时行情 | 多时间维度价格变化(5m/1h/4h/24h)、买卖量、持币分析 | | K 线数据 | OHLCV K 线,支持 1s 到 1 月多种时间粒度 | **支持链:** BSC、Base、Solana ``` BNB 现在多少钱? 查一下这个代币的持币分布 给我 SOL 过去 4 小时的 K 线数据 ``` --- ### query-token-audit 交易前安全审计,帮助识别风险合约和恶意代币。 **支持操作** | 操作 | 说明 | | -------- | ------------------------------------------- | | 风险评分 | 输出 LOW / MEDIUM / HIGH 风险等级(1–5 分) | | 蜜罐检测 | 识别能买不能卖的欺诈合约 | | 税率分析 | 返回买入/卖出税率,超过 10% 标记为高危 | | 合约验证 | 检查源码是否已公开验证 | **支持链:** Ethereum、BSC、Base、Solana > ⚠️ 审计结果仅供参考,LOW 风险不等于安全背书,请自行做好研究。 ``` 帮我审计一下这个合约地址是否安全 这个代币有没有蜜罐风险? ``` --- ### query-address-info 查询指定钱包地址在链上持有的全部代币及估值。 **支持操作** | 操作 | 说明 | | -------- | ------------------------------------ | | 持仓查询 | 返回地址所有代币余额、数量、合约地址 | | 价格数据 | 每个代币当前 USD 价格及 24h 涨跌幅 | | 分页支持 | 通过 offset 参数翻页查看大量持仓 | **支持链:** BSC、Base、Solana ``` 查一下这个地址持有哪些代币 0xABC... 在 BSC 上有什么仓位? ``` --- ### crypto-market-rank 多维度加密货币市场排行榜,覆盖热度、资金流向、Meme 排名与交易者收益。 **支持操作** | 操作 | 说明 | | -------------- | ------------------------------------------------------------ | | 社交热度榜 | 按社区讨论量排名,含情绪分析(正/负/中性) | | 综合排行榜 | 支持趋势币、搜索热榜、Binance Alpha 精选、代币化股票等多类型 | | 智能钱包流入榜 | 聪明钱净买入最多的代币 TOP 榜 | | Meme 币榜 | Pulse 发射台前 100 Meme 代币,按爆发潜力评分 | | 交易者 PnL 榜 | 地址级别 7d/30d/90d 已实现盈亏排行 | **支持链:** BSC、Base、Solana ``` 最近哪些代币社交热度最高? 聪明钱最近在买什么? 给我看 Binance Alpha 精选代币榜单 ``` --- ### meme-rush Meme 代币实时追踪 + AI 热门话题发现,适合快节奏 Meme 交易场景。包含两大核心功能: **Meme Rush — 发射台代币生命周期追踪** | 操作 | 说明 | | ---------- | -------------------------------------------------- | | 新发代币 | 追踪处于 Bonding Curve 阶段的新上线代币 | | 即将迁移 | 监控 Bonding Curve 接近完成、即将迁移到 DEX 的代币 | | 已迁移代币 | 刚完成迁移的代币列表,捕捉早期流动性机会 | **Topic Rush — AI 热门话题发现** | 操作 | 说明 | | -------- | --------------------------------------- | | 最新话题 | 发现最新的市场热门话题及关联代币 | | 上升话题 | 正在崛起的话题(历史最高流入 $1k–$20k) | 每个话题返回:话题名称、AI 摘要、净流入金额(总计/1h)、关联代币列表(含市值、流动性、净流入、持币人数等)。 **支持链:** Solana(Pump.fun、Raydium 等)、BSC(Four.meme、Flap 等) ``` Solana 上最新上线的 Meme 有哪些? 有哪些 Meme 快要迁移到 DEX 了? 现在什么话题最火? 有哪些正在崛起的热门话题? ``` --- ### trading-signal 监控链上聪明钱交易行为,输出结构化买卖信号供参考。 **支持操作** | 操作 | 说明 | | -------- | ------------------------------------------------------------ | | 信号获取 | 聪明钱地址在 Solana / BSC 上的买卖信号 | | 价格比对 | 信号触发价 vs 当前价,判断是否已错过入场时机 | | 信号质量 | 返回历史最大涨幅(maxGain)和聪明钱退出比例(exitRate) | | 代币标签 | 标注社交事件、发射平台(Pumpfun 等)、敏感事件(巨鲸买卖等) | | 信号状态 | 区分 active / timeout / completed,聚焦仍有效信号 | **支持链:** Solana、BSC ``` 最近有哪些聪明钱买入信号? BNB Chain 上有没有新的链上信号? 这个信号自触发后最高涨了多少? ``` --- ### binance-tokenized-securities-info 查询 Ondo Finance 代币化美股在链上的实时数据与状态。 **支持操作** | 操作 | 说明 | | ------------ | ---------------------------------------------------------------- | | 资产列表 | 所有支持的代币化股票及合约地址 | | 公司信息 | CEO、行业、概念标签、证明报告链接 | | 市场状态 | Ondo 市场是否开放/暂停,下次开收盘时间 | | 企业行动 | 每只代币的停牌状态(分拆、派息、并购等) | | 实时链上行情 | 代币价格、24h 涨跌、持有人数、流通量、市值,及 PE/股息率等基本面 | | K 线数据 | OHLC 数据,支持 1 分钟到 1 天多种粒度 | **支持链:** Ethereum、BSC > 注意:每个代币代表 `multiplier` 股而非 1 股,价格换算需除以 sharesMultiplier。 ``` 当前 Ondo 市场开放了吗? 查一下 AAPL 代币化股票的当前价格 有哪些代币化股票因企业行动停牌了? ``` --- ## Agentic Wallet Skill `binance-agentic-wallet` 提供钱包管理、代币转账、市价兑换和限价单功能。 → 详见 [Agentic Wallet 文档](/products/agentic-wallet/welcome) --- ## 相关页面 - [Binance Wallet Skills 概览](/products/wallet-skills/overview) --- ## Document: Binance Wallet Skills URL: /zh-CN/docs/products/wallet-skills/overview # Binance Wallet Skills Binance Wallet Skills 是面向开发者的可组合 AI 模块,将 Binance Web3 的链上能力以 AI 可调用的形式暴露,供任意 LLM Agent 或应用集成。 ## 什么是 Skills 传统 API 需要开发者手动解析意图、调用接口、处理错误。Skills 把这些封装为 AI 可直接理解的模块: - 用**自然语言意图**触发,不需要写 API 调用 - 每个 Skill 是一个独立能力模块,可单独集成,也可组合使用 - 兼容 Claude、ChatGPT、Copilot 及主流 AI Agent 环境 ## 已发布的 Wallet Skills(binance-web3) 当前在 [binance-skills-hub](https://github.com/binance/binance-skills-hub/tree/main/skills/binance-web3) 发布了 8 个 Skills: | Skill | 类别 | 核心能力 | | ------------------------------------- | ------------ | ----------------------------------------------------------- | | **binance-agentic-wallet** | Read + Write | 钱包管理、代币转账、市价兑换、限价单(BSC/ETH/Base/Solana) | | **query-token-info** | Read | 代币搜索、元数据、实时行情、K 线数据 | | **query-token-audit** | Read | 代币安全审计:风险评分、蜜罐检测、合约验证 | | **query-address-info** | Read | 钱包地址持仓查询,含价格与余额 | | **crypto-market-rank** | Read | 市场排行:热度、智能钱包流入、Meme 币、交易者 PnL | | **meme-rush** | Read | Meme 代币追踪(新发/即将迁移/已迁移)+ AI 叙事主题 | | **trading-signal** | Read | 链上聪明钱交易信号,含信号状态与历史最大涨幅 | | **binance-tokenized-securities-info** | Read | 代币化证券(Ondo Finance)行情、状态与链上数据 | → [查看完整 Skills 列表](/products/wallet-skills/supported-skills) --- ## Document: /products/w3w-prediction/change-log URL: /zh-CN/docs/products/w3w-prediction/change-log # 更新日志 ## 2026-06-16 - 文档增强(不涉及接口行为变更): - `POST /sapi/v1/w3w/wallet/prediction/trade/batch-cancel`:删除不再使用的 `cancelInfoList[i].vendor` 字段(服务端自动填 `predict_fun`)。新增"已知问题"段,说明主流 HTTP 库(Python `requests`、Java `URI`、Go `net/url`、Node `url`)会自动 percent-encode `[`/`]`,但服务端按原始字节验签,导致 `-1022 Signature for this request is not valid`;附 Python / Java / Go 的临时绕过方案。 - `POST /sapi/v1/w3w/wallet/prediction/transfer/inbound`:显式说明该接口需要 SAS 授权(未开启 SAS 时返回 `-31003`)。 - `POST /sapi/v1/w3w/wallet/prediction/trade/get-quote`:补充 MARKET 单的最小金额说明(`amountIn` ≥ 约 1.5 USDT,随市场深度浮动;`LIMIT` 单不受此约束)。 - `GET /sapi/v1/w3w/wallet/prediction/transfer/status`:修正返回示例的终态值为 `COMPLETED`(而非 `SUCCESS`)。补充完整状态枚举:`COMPLETED`、`FAILED`、`PROCESSING`、`PENDING`。 ## 2026-05-25 - 预测市场交易 API 首次发布。 --- ## Document: /products/wallet/quick-start URL: /zh-CN/docs/products/wallet/quick-start # 快速开始 ## API Key 权限设置 - 新创建的API的默认权限是 `只读`。 - 如果需要通过API提款, 需要在UI修改权限, 选中 `允许提现`。 ## 账户 ### 现货账户 新注册的币安账号都会有一个现货(`SPOT`)账号。 ### 杠杆账户 为了开设杠杆(`MARGIN`)账户, 可以参考[Binance杠杆交易账户设置指南](https://www.binance.vision/zh/tutorials/binance-margin-trading-guide) ## API 代码库 ### Connectors 以下有一些轻量级的代码库,使不同语言的用户能够直接调用现货的 Binance 公共 API: - Python [https://github.com/binance/binance-connector-python](https://github.com/binance/binance-connector-python) - JavaScript [https://github.com/binance/binance-connector-js](https://github.com/binance/binance-connector-js) - Ruby [https://github.com/binance/binance-connector-ruby](https://github.com/binance/binance-connector-ruby) - DotNET C# [https://github.com/binance/binance-connector-dotnet](https://github.com/binance/binance-connector-dotnet) - Java [https://github.com/binance/binance-connector-java](https://github.com/binance/binance-connector-java) - Rust [https://github.com/binance/binance-spot-connector-rust](https://github.com/binance/binance-spot-connector-rust) - PHP [https://github.com/binance/binance-connector-php](https://github.com/binance/binance-connector-php) - Go [https://github.com/binance/binance-connector-go](https://github.com/binance/binance-connector-go) ### Postman Collections Postman 集合现已推出。推荐给寻求快速和轻松地开始使用 API 的新用户。 [https://github.com/binance/binance-api-postman](https://github.com/binance/binance-api-postman) ### Swagger 以下有提供包含 RESTful API 的 OpenAPI 规范的 YAML 文件,以及可供参考的 Swagger UI 页面。 [https://github.com/binance/binance-api-swagger](https://github.com/binance/binance-api-swagger) --- ## Document: /products/wallet/general-info URL: /zh-CN/docs/products/wallet/general-info # 基本信息 ## API 基本信息 - 接口可能需要用户的 API Key,如何创建API-KEY请参考[这里](https://www.binance.com/cn/support/articles/360002502072) - 本篇列出接口的 base URL 有: - **https://api.binance.com** - **https://api-gcp.binance.com** - **https://api1.binance.com** - **https://api2.binance.com** - **https://api3.binance.com** - **https://api4.binance.com** - 上述列表的最后4个接口 (`api1`-`api4`) 可能会提供更好的性能,但其稳定性略为逊色。因此,请务必使用最适合您现有配置的那款。 - 所有接口的响应都是 JSON 格式。 - 响应中如有数组,数组元素以时间**升序**排列,越早的数据越提前。 - 所有时间、时间戳均为UNIX时间,单位为**毫秒**。 ### HTTP 返回代码 - HTTP `4XX` 错误码用于指示错误的请求内容、行为、格式。问题在于请求者。 - HTTP `403` 错误码表示违反WAF限制(Web应用程序防火墙)。 - HTTP `409` 错误码表示重新下单(cancelReplace)的请求部分成功。(比如取消订单失败,但是下单成功了) - HTTP `429` 错误码表示警告访问频次超限,即将被封IP。 - HTTP `418` 表示收到429后继续访问,于是被封了。 - HTTP `5XX` 错误码用于指示Binance服务侧的问题。 ### 接口错误代码 - 使用接口 `/api/v3`, 以及 `/sapi/v1/margin`时, 每个接口都有可能抛出异常; > API 与 SAPI 的错误代码返回形式如下: ```javascript { "code": -1121, "msg": "Invalid symbol." } ``` - 具体的错误码及其解释在 [错误代码](./error-code). ### 接口的基本信息 - `GET` 方法的接口, 参数必须在 `query string`中发送。 - `POST`, `PUT`, 和 `DELETE` 方法的接口,参数可以在内容形式为`application/x-www-form-urlencoded`的 `query string` 中发送,也可以在 `request body` 中发送。 如果你喜欢,也可以混合这两种方式发送参数。 - 对参数的顺序不做要求。 - 但如果同一个参数名在query string和request body中都有,query string中的会被优先采用。 --- ## 访问限制 ### 访问限制基本信息 - 以下 是`intervalLetter` 作为头部值: - SECOND => S - MINUTE => M - HOUR => H - DAY => D - 在 `/api/v3/exchangeInfo` `rateLimits` 数组中包含与交易的有关RAW_REQUESTS,REQUEST_WEIGHT和ORDERS速率限制相关的对象。这些在 `限制种类 (rateLimitType)` 下的 `枚举定义` 部分中进一步定义。 - 违反任何一个速率限制时(访问频次限制或下单速率限制),将返回429。 ### IP 访问限制 - 每个请求将包含一个`X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,其中包含当前IP所有请求的已使用权重。 - 每一个接口均有一个相应的权重(weight),有的接口根据参数不同可能拥有不同的权重。越消耗资源的接口权重就会越大。 - 收到429时,您有责任停止发送请求,不得滥用API。 - **收到429后仍然继续违反访问限制,会被封禁IP,并收到418错误码** - 频繁违反限制,封禁时间会逐渐延长,**从最短2分钟到最长3天**。 - `Retry-After`的头会与带有418或429的响应发送,并且会给出**以秒为单位**的等待时长(如果是429)以防止禁令,或者如果是418,直到禁令结束。 - **访问限制是基于IP的,而不是API Key** ###下单频率限制 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - 当下单数超过限制时,会收到带有429但不含`Retry-After`头的响应。请检查 `GET api/v3/exchangeInfo` 的下单频率限制 (rateLimitType = ORDERS) 并等待封禁时间结束。 - 被拒绝或不成功的下单并不保证回报中包含以上头内容。 - **下单频率限制是基于每个账户计数的。** - 用户可以通过接口 `GET api/v3/rateLimit/order` 来查询当前的下单量. ### WEB SOCKET 连接限制 - Websocket服务器每秒最多接受5个消息。消息包括: - PING帧 - PONG帧 - JSON格式的消息, 比如订阅, 断开订阅. - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅 **1024** 个Streams。 - 每IP地址、每5分钟最多可以发送300次连接请求。 ### /api/ 与 /sapi/ 接口限频说明 `/api/*`接口和 `/sapi/*`接口采用两套不同的访问限频规则, 两者互相独立。 - `/api/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以 `/api/*`开头的接口按IP限频,**且所有接口共用每分钟6,000限制**。 - 每个请求将包含一个 `X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,包含当前IP所有请求的已使用权重。 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - `/sapi/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以`/sapi/*`开头的接口采用**单接口限频模式**。按IP统计的权重单接口权重总额为每分钟12000;按照UID统计的单接口权重总额是每分钟180000。 - 每个接口会标明是按照IP或者按照UID统计, 以及相应请求一次的权重值。 - 按照IP统计的接口, 请求返回头里面会包含`X-SAPI-USED-IP-WEIGHT-1M=`或`X-SAPI-USED-IP-WEIGHT-1S=`, 包含当前IP所有请求已使用权重。 - 按照UID统计的接口, 请求返回头里面会包含`X-SAPI-USED-UID-WEIGHT-1M=`或`X-SAPI-USED-UID-WEIGHT-1S=`, 包含当前账户所有已用的UID权重。 --- ## 数据来源 - 因为API系统是异步的, 所以返回的数据有延时很正常, 也在预期之中。 - 在每个接口中,都列出了其数据的来源,可以用于理解数据的时效性。 系统一共有3个数据来源,按照更新速度的先后排序。排在前面的数据最新,在后面就有可能存在延迟。 - **撮合引擎** - 表示数据来源于撮合引擎 - **缓存** - 表示数据来源于内部或者外部的缓存 - **数据库** - 表示数据直接来源于数据库 ## 请求鉴权类型 - 每个接口都有一个鉴权类型,指示所需的 API 密钥权限,显示在接口名称旁边(例如,[下新订单 (TRADE)](#place-new-order-trade))。 - 如果未指定,则鉴权类型为 `NONE`。 - 除了为 `NONE` 外,所有具有鉴权类型的接口均视为 `SIGNED` 请求(即包含 `signature`),[listenKey 管理](#user-data-stream-requests) 除外。 - 具有鉴权类型的接口需要提供有效的 API 密钥并验证通过。 - API 密钥可在您的 Binance 账户的 [API 管理](https://www.binance.com/en/support/faq/360002502072) 页面创建。 - **API 密钥和密钥对均为敏感信息,切勿与他人分享。** 如果发现账户有异常活动,请立即撤销所有密钥并联系 Binance 支持。 - API 密钥可配置为仅允许访问某些鉴权接口。 - 例如,您可以拥有具有 `TRADE` 权限的 API 密钥用于交易,同时使用具有 `USER_DATA` 权限的另一个 API 密钥来监控订单状态。 - 默认情况下,API 密钥无法进行 `TRADE`,您需要先在 API 管理中启用交易权限。 | 鉴权类型 | 描述 | | ----------- | ------------------------- | | NONE | 不需要鉴权的接口 | | TRADE | 需要有效的 API-Key 和签名 | | MARGIN | 需要有效的 API-Key 和签名 | | USER_DATA | 需要有效的 API-Key 和签名 | | USER_STREAM | 需要有效的 API-Key | | MARKET_DATA | 需要有效的 API-Key | ### 需要签名的接口 - 调用`SIGNED` 接口时,除了接口本身所需的参数外,还需要在 `query string` 或 `request body` 中传递 `signature`, 即签名参数。 #### 签名是否是大小写敏感的 - **HMAC:** 使用 HMAC 生成的签名**不区分大小写**。这意味着无论字母大小写如何,签名字符串都可以被验证。 - **RSA:** 使用 RSA 生成的签名是**大小写敏感的**。 - **Ed25519:** 使用 Ed25519 生成的签名也是**大小写敏感的**。 请参阅[已签名请求示例 (HMAC)](#hmac-keys)、[已签名请求示例 (RSA)](#rsa-keys) 和[已签名请求示例 (Ed25519)](#ed25519-keys),了解如何根据您使用的 API 密钥类型计算签名。 ### 时间同步安全 - `SIGNED` 请求还需要一个 `timestamp` 参数,该参数应为当前时间戳,单位为毫秒或微秒。(参见 [通用 API 信息](#general-api-information)) - 另一个可选参数 `recvWindow`,用以指定请求的有效期,只能以毫秒为单位。 - `recvWindow` 扩展为三位小数(例如 6000.346),以便可以指定微秒。 - 如果未发送 `recvWindow`,则 **默认值为 5000 毫秒**。 - `recvWindow` 的最大值为 60000 毫秒。 - 请求处理逻辑如下: ```javascript serverTime = getCurrentTime() if (timestamp < (serverTime + 1 second) && (serverTime - timestamp) <= recvWindow) { // 开始处理请求 serverTime = getCurrentTime() if (serverTime - timestamp) <= recvWindow { // 将请求转发到撮合引擎 } else { // 拒绝请求 } // 结束处理请求 } else { // 拒绝请求 } ``` **关于交易时效性** 互联网状况并不100%可靠,不可完全依赖,因此你的程序本地到币安服务器的时延会有抖动. 这是我们设置`recvWindow`的目的所在,如果你从事高频交易,对交易时效性有较高的要求,可以灵活设置`recvWindow`以达到你的要求。 **不推荐使用5秒以上的recvWindow。最大值不能超过60秒!** ### POST /api/v3/order 的签名示例 #### HMAC Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 以下示例分步演示如何使用 `echo`、`openssl` 和 `curl` 从 Linux 命令行发送有效的签名 payload。其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 API 密钥和密钥示例: | Key | Value | | ----------- | ---------------------------------------------------------------- | | `apiKey` | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A | | `secretKey` | NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j | **警告:请勿与任何人分享您的 API 密钥和秘钥。** 此处提供的示例密钥仅用于示范说明目的。 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | LTCBTC | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` **第二步: 计算签名。** 1. 使用 API 密钥中的 `secretKey` 作为 HMAC-SHA-256 算法的签名密钥。 2. 对步骤 1 中构建的签名 payload 进行签名。 3. 将 HMAC-SHA-256 的输出编码为十六进制字符串。 请注意,`secretKey` 和 payload 是**大小写敏感的**,而生成的签名值是不区分大小写的。 **示例命令** 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71 ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n "symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3 ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71" ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3" ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash apiKey="vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" secretKey="NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" payload="symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" # 对请求进行签名 signature=$(echo -n "$payload" | openssl dgst -sha256 -hmac "$secretKey") signature=${signature#*= } # Keep only the part after the "= " # 发送请求 curl -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?$payload&signature=$signature" ``` #### RSA Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 要获取 API 密钥,您需要将 RSA 公钥上传到您的帐户中,系统将为您提供相应的 API 密钥。 仅支持 `PKCS#8` 密钥。 在以下示例中,其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 这些示例假设私钥存储在文件 `./test-prv-key.pem` 中。 | Key | Value | | -------- | ---------------------------------------------------------------- | | `apiKey` | CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ | 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | BTCUSDT | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` **第二步: 计算签名。** 1. 使用 RSASSA-PKCS1-v1_5 算法和 SHA-256 哈希函数对步骤 1 中构建的签名 payload 进行签名。 2. 将输出结果编码为 base64 格式。 请注意,payload 和生成的`签名值`是**大小写敏感的**。 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n 'symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' HZ8HOjiJ1s/igS9JA+n7+7Ti/ihtkRF5BIWcPIEluJP6tlbFM/Bf44LfZka/iemtahZAZzcO9TnI5uaXh3++lrqtNonCwp6/245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH+XxaCmR0WcvlKjNQnp12/eKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang/1WOq+Jaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT/fNnMRxFc7u+j3qI//5yuGuu14KR0MuQKKCSpViieD+fIti46sxPTsjSemoUKp0oXA== ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n 'symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' qJtv66wyp/1mZE+mIFAAMUoTe8xkmLN7/eAZjuC9x1ocxovItHLl/sNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M+JNIMz5UFxfeA53rXjFlvsyH1Sig+OuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C/QMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt/GuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng== ``` 3. 对 base64 格式的字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符): ```console HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D' ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D' ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash function rawurlencode { local string="${1}" local strlen=${#string} local encoded="" local pos c o for (( pos=0 ; pos 错误JSON格式: ```javascript { "code":-1121, "msg":"Invalid symbol." } ``` 错误由两部分组成:错误代码和消息。 代码是通用的,但是消息可能会有所不同。 ## 10xx -常规服务器或网络问题 ### -1000 UNKNOWN - 处理请求时发生未知错误。 - 处理请求时发生未知错误。[%s] ### -1001 DISCONNECTED - 内部错误; 无法处理您的请求。 请再试一次. ### -1002 UNAUTHORIZED - 您无权执行此请求。 ### -1003 TOO_MANY_REQUESTS - 排队的请求过多。 - 请求权重过多; 当前限制是 %s 每 %s 的请求权重。 请使用 Websocket Streams 进行实时更新,以避免轮询API。 - 请求权重过多; IP被禁止,直到%s。 请使用 Websocket Streams 进行实时更新,以免被禁。 ### -1004 SERVER_BUSY - 服务器正忙,请稍候再试。 ### -1006 UNEXPECTED_RESP - 从消息总线收到意外的响应。 执行状态未知。 ### -1007 TIMEOUT - 等待后端服务器响应超时。 发送状态未知; 执行状态未知。 ### -1008 SERVER_BUSY - 现货交易服务器当前因其他请求而过载。 请在几分钟后重试。 ### -1014 UNKNOWN_ORDER_COMPOSITION - 不支持的订单组合。 ### -1015 TOO_MANY_ORDERS - 新订单太多。 - 新订单太多; 当前限制为每%s %s个订单。 ### -1016 SERVICE_SHUTTING_DOWN - 该服务不可用。 ### -1020 UNSUPPORTED_OPERATION - 不支持此操作。 ### -1021 INVALID_TIMESTAMP - 此请求的时间戳在recvWindow之外。 - 此请求的时间戳比服务器时间提前1000毫秒。 ### -1022 INVALID_SIGNATURE - 此请求的签名无效。 ### -1099 Not found, authenticated, or authorized - 替换错误代码-1999 ## 11xx - 2xxx Request issues ### -1100 ILLEGAL_CHARS - 在参数中发现非法字符。 - 在参数中发现非法字符。`%s` - 在参数`%s`中发现非法字符; 合法范围是`%s`。 ### -1101 TOO_MANY_PARAMETERS - 为此端点发送的参数太多。 - 参数太多; 预期为`%s`并收到了`%s`。 - 检测到的参数值重复。 ### -1102 MANDATORY_PARAM_EMPTY_OR_MALFORMED - 未发送强制性参数,该参数为空/空或格式错误。 - 强制参数`%s`未发送,为空/空或格式错误。 - 必须发送参数`%s`或`%s`,但两者均为空! ### -1103 UNKNOWN_PARAM - 发送了未知参数。 ### -1104 UNREAD_PARAMETERS - 并非所有发送的参数都被读取。 - 并非所有发送的参数都被读取; 读取了`%s`参数,但被发送了`%s`。 ### -1105 PARAM_EMPTY - 参数为空。 - 参数`%s`为空。 ### -1106 PARAM_NOT_REQUIRED - 不需要时已发送参数。 - 不需要时发送参数`%s`。 ### -1111 BAD_PRECISION - 精度超过为此资产定义的最大值。 ### -1112 NO_DEPTH - 交易对没有挂单。 ### -1114 TIF_NOT_REQUIRED - 不需要时发送了TimeInForce参数。 ### -1115 INVALID_TIF - 无效 timeInForce. ### -1116 INVALID_ORDER_TYPE - 无效订单类型。 ### -1117 INVALID_SIDE - 无效买卖方向。 ### -1118 EMPTY_NEW_CL_ORD_ID - 新的客户订单ID为空。 ### -1119 EMPTY_ORG_CL_ORD_ID - 客户自定义的订单ID为空。 ### -1120 BAD_INTERVAL - 无效时间间隔。 ### -1121 BAD_SYMBOL - 无效的交易对。 ### -1125 INVALID_LISTEN_KEY - 该listenKey不存在。 ### -1127 MORE_THAN_XX_HOURS - 查询间隔太大。 - 从开始时间到结束时间之间超过%s小时。 ### -1128 OPTIONAL_PARAMS_BAD_COMBO - 可选参数组合无效。 ### -1130 INVALID_PARAMETER - 发送的参数为无效数据。 - 发送参数`%s`的数据无效。 ### -1131 BAD_RECV_WINDOW - `recvWindow` 必须小于 60000 ### -1134 BAD_STRATEGY_TYPE - `strategyType` 必须小于 1000000 #### -1145 INVALID_CANCEL_RESTRICTIONS - `cancelRestrictions` 必须是 `ONLY_NEW` 或者 `ONLY_PARTIALLY_FILLED`。 #### -1151 重复的交易对 - Symbol is present multiple times in the list. ### -2010 NEW_ORDER_REJECTED - 新订单被拒绝 ### -2011 CANCEL_REJECTED - 取消订单被拒绝 ### -2013 NO_SUCH_ORDER - 订单不存在。 ### -2014 BAD_API_KEY_FMT - API-key 格式无效。 ### -2015 REJECTED_MBX_KEY - 无效的API密钥,IP或操作权限。 ### -2016 NO_TRADING_WINDOW - 找不到该交易对的交易窗口。 尝试改为24小时自动报价。 #### -2026 ORDER_ARCHIVED - 订单已被存档因为此订单被取消或过期,无交易数量而最后的更新已超过 90 天前。 ## 3xxx-5xxx SAPI 具体问题 ### -3000 INNER_FAILURE - 内部服务器错误。 ### -3001 NEED_ENABLE_2FA - 请先启用2FA。 ### -3002 ASSET_DEFICIENCY - 此资产不存在。 ### -3003 NO_OPENED_MARGIN_ACCOUNT - 杠杆账户不存在。 ### -3004 TRADE_NOT_ALLOWED - 禁止交易。 ### -3005 TRANSFER_OUT_NOT_ALLOWED - 不允许转账。 ### -3006 EXCEED_MAX_BORROWABLE - 您的已借金额已超过最高可借金额。 ### -3007 HAS_PENDING_TRANSACTION - 您有待处理的交易,请稍后再试。 ### -3008 BORROW_NOT_ALLOWED - 不允许借款。 ### -3009 ASSET_NOT_MORTGAGEABLE - 此资产目前不允许转入杠杆账户。 ### -3010 REPAY_NOT_ALLOWED - 不允许还款。 ### -3011 BAD_DATE_RANGE - 您输入的日期无效。 ### -3012 ASSET_ADMIN_BAN_BORROW - 此资产禁止借款。 ### -3013 LT_MIN_BORROWABLE - 借入金额少于最低借入金额。 ### -3014 ACCOUNT_BAN_BORROW - 此帐户禁止借款。 ### -3015 REPAY_EXCEED_LIABILITY - 还款额超过借款额。 ### -3016 LT_MIN_REPAY - 还款额少于最低还款额。 ### -3017 ASSET_ADMIN_BAN_MORTGAGE - 此资产目前不允许转入保证金账户。 ### -3018 ACCOUNT_BAN_MORTGAGE - 此帐户已禁止转入。 ### -3019 ACCOUNT_BAN_ROLLOUT - 此帐户禁止转出。 ### -3020 EXCEED_MAX_ROLLOUT - 转出金额超过上限。 ### -3021 PAIR_ADMIN_BAN_TRADE - 杠杆账户无法交易此交易对。 ### -3022 ACCOUNT_BAN_TRADE - 账号被禁止交易。 ### -3023 WARNING_MARGIN_LEVEL - 无法在当前杠杆倍数下转出资金或者下单 ### -3024 FEW_LIABILITY_LEFT - 付款之后未付款的债务太小 ### -3025 INVALID_EFFECTIVE_TIME - 输入时间有误。 ### -3026 VALIDATION_FAILED - 输入参数有误。 ### -3027 NOT_VALID_MARGIN_ASSET - 无效的杠杆资产。 ### -3028 NOT_VALID_MARGIN_PAIR - 无效的杠杆交易对。 ### -3029 TRANSFER_FAILED - 转账失败。 ### -3036 ACCOUNT_BAN_REPAY - 此账号无法还款。 ### -3037 PNL_CLEARING - `PNL`正在清帐,请稍等。 ### -3038 LISTEN_KEY_NOT_FOUND - 找不到`Listen key` ### -3041 BALANCE_NOT_CLEARED - 余额不足 ### -3042 PRICE_INDEX_NOT_FOUND - 该杠杆交易对无可用价格指数。 ### -3043 TRANSFER_IN_NOT_ALLOWED - 不允许转入。 ### -3044 SYSTEM_BUSY - 系统繁忙。 ### -3045 SYSTEM - 系统目前没有足够可借的资产。 ### -3999 NOT_WHITELIST_USER - 此功能只面向邀请的用户。 ### -4001 CAPITAL_INVALID - 非法操作 ### -4002 CAPITAL_IG - 非法获取 ### -4003 CAPITAL_IEV - 非法邮箱验证 ### -4004 CAPITAL_UA - 未登录或者认证。 ### -4005 CAPAITAL_TOO_MANY_REQUEST - 请求太频繁。 ### -4006 CAPITAL_ONLY_SUPPORT_PRIMARY_ACCOUNT - 只支持主账号。 ### -4007 CAPITAL_ADDRESS_VERIFICATION_NOT_PASS - 地址的没有通过校验。 ### -4008 CAPITAL_ADDRESS_TAG_VERIFICATION_NOT_PASS - 地址的标记信息(`tag`)没有通过校验。 ### -4010 CAPITAL_WHITELIST_EMAIL_CONFIRM - 确认电子邮件已经列入白名单。 ### -4011 CAPITAL_WHITELIST_EMAIL_EXPIRED - 列入白名单的电子邮件无效。 ### -4012 CAPITAL_WHITELIST_CLOSE - 白名单未打开。 ### -4013 CAPITAL_WITHDRAW_2FA_VERIFY - 2FA未打开。 ### -4014 CAPITAL_WITHDRAW_LOGIN_DELAY - 在登录后的2分钟之内不允许提款。 ### -4015 CAPITAL_WITHDRAW_RESTRICTED_MINUTE - 暂停提款 ### -4016 CAPITAL_WITHDRAW_RESTRICTED_PASSWORD - 在密码修改后的24小时之内不允许提款。 ### -4017 CAPITAL_WITHDRAW_RESTRICTED_UNBIND_2FA - 在2FA发行后的24小时之内不允许提款。 ### -4018 CAPITAL_WITHDRAW_ASSET_NOT_EXIST - 此资产不存在。 ### -4019 CAPITAL_WITHDRAW_ASSET_PROHIBIT - 此资产不允许提款。 ### -4021 CAPITAL_WITHDRAW_AMOUNT_MULTIPLE - 资产的提款数量必须是%s的%s倍。 ### -4022 CAPITAL_WITHDRAW_MIN_AMOUNT - 不须少于最低的提款数量%s。 ### -4023 CAPITAL_WITHDRAW_MAX_AMOUNT - 在24小时之内,不须超过最高的提款数量。 ### -4024 CAPITAL_WITHDRAW_USER_NO_ASSET - 当前用户没有此资产。 ### -4025 CAPITAL_WITHDRAW_USER_ASSET_LESS_THAN_ZERO - 持有资产的数量小于零。 ### -4026 CAPITAL_WITHDRAW_USER_ASSET_NOT_ENOUGH - 此资产余额不足。 ### -4027 CAPITAL_WITHDRAW_GET_TRAN_ID_FAILURE - 无法获取tranId。 ### -4028 CAPITAL_WITHDRAW_MORE_THAN_FEE - 提款金额必须多于佣金额。 ### -4029 CAPITAL_WITHDRAW_NOT_EXIST - 此提款记录不存在。 ### -4030 CAPITAL_WITHDRAW_CONFIRM_SUCCESS - 提款资产成功。 ### -4031 CAPITAL_WITHDRAW_CANCEL_FAILURE - 取消提款失败。 ### -4032 CAPITAL_WITHDRAW_CHECKSUM_VERIFY_FAILURE - 验证提款失败。 ### -4033 CAPITAL_WITHDRAW_ILLEGAL_ADDRESS - 提款地址不合法。 ### -4034 CAPITAL_WITHDRAW_ADDRESS_CHEAT - 当前地址有异常。 ### -4035 CAPITAL_WITHDRAW_NOT_WHITE_ADDRESS - 此地址不在白名单上。请加入然后重试。 ### -4036 CAPITAL_WITHDRAW_NEW_ADDRESS - 新地址在{0}小时后才可以提款。 ### -4037 CAPITAL_WITHDRAW_RESEND_EMAIL_FAIL - 重新发送邮件失败。 ### -4038 CAPITAL_WITHDRAW_RESEND_EMAIL_TIME_OUT - 请5分钟后重试。 ### -4039 CAPITAL_USER_EMPTY - 用户不存在。 ### -4041 CAPITAL_MINUTE_TOO_SMALL - 请一分钟后重试。 ### -4042 CAPITAL_CHARGE_NOT_RESET - 资产无法重新获取存款地址。 ### -4043 CAPITAL_ADDRESS_TOO_MUCH - 在24小时之内充值超过100多个地址。 ### -4044 CAPITAL_BLACKLIST_COUNTRY_GET_ADDRESS - 此国家在黑名单上。 ### -4045 CAPITAL_GET_ASSET_ERROR - 获得资产失败。 ### -4046 CAPITAL_AGREEMENT_NOT_CONFIRMED - 协议未确认。 ### -4047 CAPITAL_DATE_INTERVAL_LIMIT - 时间间隔必须在0-90天之内 ### -4060 CAPITAL_WITHDRAW_USER_ASSET_LOCK_DEPOSIT - 体现仍在区块确认中,暂时锁定部分资产 ### -4106 TAG_NOT_SUPPORTED_FOR_NETWORK - 该网络不支持 memo/tag。请移除 `addressTag` 字段后重试。 ### -5001 ASSET_DRIBBLET_CONVERT_SWITCH_OFF - 不允许转移到微型资产。 ### -5002 ASSET_ASSET_NOT_ENOUGH - 此余额不足。 ### -5003 ASSET_USER_HAVE_NO_ASSET - 此资产不存在。 ### -5004 USER_OUT_OF_TRANSFER_FLOAT - 剩余余额已超过0.001BTC,请重新选择。 - %s的剩余余额已超过0.001BTC,请重新选择。 ### -5005 USER_ASSET_AMOUNT_IS_TOO_LOW - BTC的剩余余额太低,请重新选择。 - %s的剩余余额太低,请重新选择。 ### -5006 USER_CAN_NOT_REQUEST_IN_24_HOURS - 24小时内只能转账一次。 ### -5007 AMOUNT_OVER_ZERO - 数量必须大于零。 ### -5008 ASSET_WITHDRAW_WITHDRAWING_NOT_ENOUGH - 可退回资产的金额不足。 ### -5009 PRODUCT_NOT_EXIST - 产品不存在。 ### -5010 TRANSFER_FAIL - 资产转移失败。 ### -5011 FUTURE_ACCT_NOT_EXIST - 合约帐户不存在。 ### -5012 TRANSFER_PENDING - 资产转移正在进行中。 ### -5021 PARENT_SUB_HAVE_NO_RELATION - 当前的子账户和母账户没有从属关系。 ### -5012 FUTURE_ACCT_OR_SUBRELATION_NOT_EXIST - 合约帐户或子账户关系不存在。 ## 6XXX - 币安宝相关 ### -6001 DAILY_PRODUCT_NOT_EXIST - 理财产品不存在. ### -6003 DAILY_PRODUCT_NOT_ACCESSIBLE - 产品不存在或者没有权限。 ### -6004 DAILY_PRODUCT_NOT_PURCHASABLE - 产品无法购买。 ### -6005 DAILY_LOWER_THAN_MIN_PURCHASE_LIMIT - 低于可以购买的最小限额。 ### -6006 DAILY_REDEEM_AMOUNT_ERROR - 赎回额度有误。 ### -6007 DAILY_REDEEM_TIME_ERROR - 不在赎回的时间内。 ### -6008 DAILY_PRODUCT_NOT_REDEEMABLE - 产品暂时无法赎回。 ### -6009 REQUEST_FREQUENCY_TOO_HIGH - 发送请求太频繁。 ### -6011 EXCEEDED_USER_PURCHASE_LIMIT - 超购每个月用户可以申购的最大次数。 ### -6012 BALANCE_NOT_ENOUGH - 余额不足。 ### -6013 PURCHASING_FAILED - 申购失败。 ### -6014 UPDATE_FAILED - 超过可以申购的最大上限。 ### -6015 EMPTY_REQUEST_BODY - 请求的`body`为空。 ### -6016 PARAMS_ERR - 请求的参数有误。 ### -6017 NOT_IN_WHITELIST - 不在白名单里面。 ### -6018 ASSET_NOT_ENOUGH - 资产不足。 ### -6019 PENDING - 需要进一步确认。 ### -6020 PROJECT_NOT_EXISTS - 此项目不存在。 ## 70xx - 期货 ### -7001 FUTURES_BAD_DATE_RANGE - 此日期范围不支持。 ### -7002 FUTURES_BAD_TYPE - 此数据请求类型不支持。 ## 20xxx - 合约/现货策略交易 ### -20121 Invalid symbol - 无效交易对。 ### -20124 Invalid algo id or it has been completed - 无效的策略订单ID或者它已经被执行。 ### -20130 Invalid data sent for a parameter - 无效数据。 ### -20132 The client algo id is duplicated - 用户自定义策略订单ID重复。 ### -20194 Duration is too short to execute all required quantity - Duration 时间太短不足以执行用户选择的订单数量。 ### -20195 The total size is too small - 下单数量太小。 ### -20196 The total size is too large - 下单数量太大。 ### -20198 Reach the max open orders allowed - 达到了最大挂单上限。 ### -20204 The notional of USD is less or more than the limit - 订单小于最小USD名义价值 ## 过滤器故障 | 报错信息 | 描述 | | ------------------------------------------ | ---------------------------------------------------------------------------------- | | "Filter failure: PRICE_FILTER" | "价格"过高,过低和/或不遵循交易对的最小价格规则。 | | "Filter failure: PERCENT_PRICE" | "价格"比最近Y分钟的平均加权价格高X%或X%太低。 | | "Filter failure: PERCENT_PRICE_BY_SIDE" | `price` 在当前方向上(`BUY`或者`SELL`)比`lastPrice`价格超过X%或者低于Y%。 | | "Filter failure: LOT_SIZE" | "数量"太高,太低和/或不遵循该交易对的步长规则。 | | "Filter failure: MIN_NOTIONAL" | 价格\*数量太低,无法成为该交易对的有效订单。 | | "Filter failure: ICEBERG_PARTS" | `ICEBERG` 订单会分成太多部分; icebergQty太小。 | | "Filter failure: MARKET_LOT_SIZE" | "MARKET"订单的"数量"过高,过低和/或未遵循交易对的步长规则。 | | "Filter failure: MAX_POSITION" | 达到账户的最大仓位限制。这包括了账户的余额总额,以及所有处于open的买单的数量总和。 | | "Filter failure: MAX_NUM_ORDERS" | 客户在交易对上有太多挂单。 | | "Filter failure: MAX_ALGO_ORDERS" | 账户有太多未平仓止损和/或在交易对上执行获利指令。 | | "Filter failure: MAX_NUM_ICEBERG_ORDERS" | 客户在交易对上有太多 iceberg 挂单。 | | "Filter failure: TRAILING_DELTA" | `trailingDelta` 值不在限定的范围内. | | "Filter failure: EXCHANGE_MAX_NUM_ORDERS" | 帐户上的交易所有太多挂单。 | | "Filter failure: EXCHANGE_MAX_ALGO_ORDERS" | 帐户有太多止损挂单和/或在交易所收取获利指令。 | ## 10xxx - 质押借币 ### -10001 SYSTEM_MAINTENANCE - 系统维护中,请稍后再试 ### -10002 INVALID_INPUT - 无效的输入参数 ### -10005 NO_RECORDS - 暂无记录 ### -10007 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10008 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10009 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10010 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10011 INSUFFICIENT_ASSET - 现货资产不足 ### -10012 INVALID_AMOUNT - 无效的还款金额 ### -10013 INSUFFICIENT_AMOUNT - 抵押资产不足 ### -10015 DEDUCTION_FAILED - 抵押资产扣款失败 ### -10016 LOAN_FAILED - 放贷失败 ### -10017 REPAY_EXCEED_DEBT - 还款金额超过负债金额 ### -10018 INVALID_AMOUNT - 无效的还款金额 ### -10019 CONFIG_NOT_EXIST - 配置不存在 ### -10020 UID_NOT_EXIST - 用户ID不存在 ### -10021 ORDER_NOT_EXIST - 订单不存在 ### -10022 INVALID_AMOUNT - 无效的调整金额 ### -10023 ADJUST_LTV_FAILED - 调整质押率失败 ### -10024 ADJUST_LTV_NOT_SUPPORTED - 暂不支持调整质押率 ### -10025 REPAY_FAILED - 还款失败 ### -10026 INVALID_PARAMETER - 无效的参数 ### -10028 INVALID_PARAMETER - 无效的参数 ### -10029 AMOUNT_TOO_SMALL - 借贷金额过小 ### -10030 AMOUNT_TOO_LARGE - 借贷金额过大 ### -10031 QUOTA_REACHED - 已达到个人借贷限额 ### -10032 REPAY_NOT_AVAILABLE - 暂不支持换款 ### -10034 REPAY_NOT_AVAILABLE - 抵押物还款暂时不支持,请尝试用借贷币还款。 ### -10039 AMOUNT_TOO_SMALL - 还款金额过小 ### -10040 AMOUNT_TOO_LARGE - 还款金额过大 ### -10041 INSUFFICIENT_AMOUNT - 由于借贷需求过多,系统剩余可借{0}额度不足。请调整借贷金额或明天再试。 ### -10042 ASSET_NOT_SUPPORTED - 暂不支持%s币种 ### -10043 ASSET_NOT_SUPPORTED - 暂不支持{0} 借贷 ### -10044 QUOTA_REACHED - 抵押物数量已达到限额,请调整抵押金额或使用其他抵押资产。 ### -10045 COLLTERAL_REPAY_NOT_SUPPORTED - 该借贷币种暂不支持抵押物还款,请稍后再试。 ### -10046 EXCEED_MAX_ADJUSTMENT - 调整抵押物超过最大限额,请重试。 ### -10047 REGION_NOT_SUPPORTED - 受当地法规管制,您所在地区暂不支持该币种。 ## 13xxx - 杠杆代币 ### -13000 BLVT_FORBID_REDEEM - 当前该杠杆代币关闭赎回 ### -13001 BLVT_EXCEED_DAILY_LIMIT - 超过该代币个人24小时赎回金额上限 ### -13002 BLVT_EXCEED_TOKEN_DAILY_LIMIT - 超过该代币全局24小时赎回金额上限 ### -13003 BLVT_FORBID_PURCHASE - 当前该杠杆代币关闭申购 ### -13004 BLVT_EXCEED_DAILY_PURCHASE_LIMIT - 超过该代币个人24小时申购金额上限 ### -13005 BLVT_EXCEED_TOKEN_DAILY_PURCHASE_LIMIT - 超过该代币全局24小时申购金额上限 ### -13006 BLVT_PURCHASE_LESS_MIN_AMOUNT - 申购金额低于规定下限 ### -13007 BLVT_PURCHASE_AGREEMENT_NOT_SIGN - 没有签署开通交易协议 ## 12xxx - 流动性挖矿 ### -12014 TOO MANY REQUESTS - 2秒内接收的请求数量多于1条 ## 18xxx - 币安码 ### -18002 - The total amount of codes you created has exceeded the 24-hour limit, please try again after UTC 0 - 24小时内制码总金额已超过限额,请UTC0点后再尝试 ### -18003 - Too many codes created in 24 hours, please try again after UTC 0 - 24小时内制码总次数已超过限额,请UTC0点后再尝试 ### -18004 - Too many invalid redeem attempts in 24 hours, please try again after UTC 0 - 24小时内兑现币安码输错次数已超过限额,请UTC0点后再尝试 ### -18005 - Too many invalid verify attempts, please try later - 参考号输错次数过多,请稍后再试 ### -18006 - The amount is too small, please re-enter - 金额过小,请重新输入 ### -18007 - This token is not currently supported, please re-enter - 尚未支持该币种,请重新输入 ## 21xxx - 統一帳戶 ### -21001 USER_IS_NOT_UNIACCOUNT - 尚未开通统一账户。 ### -21002 UNI_ACCOUNT_CANT_TRANSFER_FUTURE - 统一账户禁用margin向futures转账。 ### -21003 NET_ASSET_MUST_LTE_RATIO - margin资产更新失败。 ### -21004 USER_NO_LIABILITY - 用户不存在统一账户穿仓负债 ### -21005 NO_ENOUGH_ASSET - 用户现货钱包BUSD资产不足以偿还统一账户穿仓负债 ### -21006 HAD_IN_PROCESS_REPAY - 用户存在正在偿还的统一账户穿仓负债 ### -21007 IN_FORCE_LIQUIDATION - 强平进行中,用户偿还统一账户穿仓负债失败 ## 订单拒绝错误 以下错误代码表示撮合引擎返回的订单相关错误: - `-1010 ERROR_MSG_RECEIVED` - `-2010 NEW_ORDER_REJECTED` - `-2011 CANCEL_REJECTED` 结合以下消息将指示特定的错误: | 错误信息 | 描述 | | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | "Unknown order sent." | 找不到订单(通过"orderId","clientOrderId","origClientOrderId") | | "Duplicate order sent." | `clientOrderId`已经被使用 | | "Market is closed." | 该交易对不在交易范围 | | "Account has insufficient balance for requested action." | 没有足够的资金来完成行动 | | "Market orders are not supported for this symbol." | 交易对上未启用"MARKET" | | "Iceberg orders are not supported for this symbol." | 交易对上未启用`icebergQty` | | "Stop loss orders are not supported for this symbol." | 交易对上未启用 `STOP_LOSS` | | "Stop loss limit orders are not supported for this symbol." | 交易对上未启`STOP_LOSS_LIMIT` | | "Take profit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT` | | "Take profit limit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT_LIMIT` | | "Price \* QTY is zero or less." | `price` \* `quantity`太小 | | "IcebergQty exceeds QTY." | `icebergQty` 必须少于订单数量 | | "This action is disabled on this account." | 联系客户支持; 该账户已禁用了某些操作。 | | "This account may not place or cancel orders." | 联系客户支持: 该账户已被禁用了交易操作。 | | "Unsupported order combination" | 不允许组合`orderType`, `timeInForce`, `stopPrice`, 和/或 `icebergQty` 。 | | "Order would trigger immediately." | 与最后交易价格相比,订单的止损价无效。 | | "Cancel order is invalid. Check origClientOrderId and orderId." | 未发送`origClientOrderId` 或`orderId` 。 | | "Order would immediately match and take." | `LIMIT_MAKER` 订单类型将立即匹配并进行交易,而不是纯粹的生成订单。 | | "The relationship of the prices for the orders is not correct." | `OCO`订单中设置的价格不符合报价规则:

The rules are:

`SELL Orders`: Limit Price > Last Price > Stop Price

`BUY Orders`: Limit Price < Last Price < Stop Price | | "OCO orders are not supported for this symbol" | `OCO`订单不支持该交易对 | | "Quote order qty market orders are not support for this symbol." | 这个交易对,市价单不支持参数`quoteOrderQty` | | "Trailing stop orders are not supported for this symbol." | 此symbol不支持 `trailingDelta` | | | "Order cancel-replace is not supported for this symbol." | 此symbol不支持 `POST /api/v3/order/cancelReplace` 或者 `order.cancelReplace` (WebSocket API) | | | "This symbol is not permitted for this account." | 账户和交易对的权限不一致 (比如 `SPOT`, `MARGIN` 等)。| | | "This symbol is restricted for this account." | 账户没有权限在此交易对交易 (比如账户只拥有 `ISOLATED_MARGIN`权限,则无法下`SPOT` 订单)。 | | | "Order was not canceled due to cancel restrictions." | `cancelRestrictions` 设置为 `ONLY_NEW` 但订单状态不是 `NEW`

`cancelRestrictions` 设置为 `ONLY_PARTIALLY_FILLED` 但订单状态不是 `PARTIALLY_FILLED`。 | | ## 关于 POST /api/v3/order/cancelReplace 的错误 ### -2021 Order cancel-replace partially failed 收到该错误码代表撤单**或者**下单失败。 ### -2022 Order cancel-replace failed. 收到该错误码代表撤单**和**下单都失败。 --- ## Document: /products/wallet/change-log URL: /zh-CN/docs/products/wallet/change-log # 更新日志 ## 2026-06-01 - 在旅行规则问卷中新增澳大利亚本地站: - `提币问卷内容` - 新增 `澳大利亚` 章节。 - `充值问卷内容` - 新增 `澳大利亚` 章节。 - 新增接口以支持问卷: - `GET /sapi/v1/localentity/country/list` - 查询活跃国家列表。 - `GET /sapi/v1/localentity/region/list` - 查询指定国家下的活跃地区/城市列表。 --- ## 2026-05-22 - 以下接口新增 `accountType` 参数: - `POST /sapi/v1/asset/dust-convert/convert` - `POST /sapi/v1/asset/dust-convert/query-convertible-assets` --- ## 2026-04-28 - 在[错误代码表](error-code_zh-CN.md)中新增错误代码 `-4106 TAG_NOT_SUPPORTED_FOR_NETWORK`。 - 更新 `POST /sapi/v1/capital/withdraw/apply` 文档,说明不支持 memo/tag 的网络中 `addressTag` 的使用规则。 --- ## 2026-02-27 - 在 `GET /sapi/v1/localentity/vasp` 的响应中新增了字段 `identifier`。 - 更新了旅行规则(Travel Rule)存取款问卷: - 输入参数 `vasp` 现在应使用 `GET /sapi/v1/localentity/vasp` 响应中的 `identifier` 字段,替代之前预期的 `vaspCode`。 - 在过渡期内,存取款问卷的 `vasp` 字段将同时接受 `vaspCode` 和 `identifier`,该过渡期截至 **2026年5月28日**。 --- ## 2025-12-26 ### 时效性通知 - **以下有关于REST API变更将在 2026-01-15 07:OO UTC 发生:**
调用需要签名的接口时,请在计算签名之前对 payload 进行百分比编码(percent-encode)。不符合此顺序的请求将被拒绝,并返回错误代码 [`-1022 签名不正确`](error-code_zh-CN.md#-1022-invalid_signature)。请检查并相应地更新您代码中的签名逻辑部分。 ### REST API - 更新了 REST API 文档中有关于 [签名请求示例](general-info_zh-CN.md#post-apiv3order-的签名示例) 的部分。 --- ## 2025-12-19 - 新增旅行规则 API: - `PUT /sapi/v2/localentity/deposit/provide-info` - V2 版本,使用 `depositId` 参数替代 `tranId`。 --- ## 2025-09-18 - 修改菜单名称 `Onboarded VASP List` 到 `VASP List`. --- ## 2025-09-12 - 新增一个返回字段 `travelRuleStatus` 在 `GET /sapi/v1/capital/deposit/hisrec`. travelRuleStatus: 0: travel rule not required OR info already provided and funds ready to use, 1: travel rule required to provide deposit info. --- ## 2025-09-08 - 新增一个返回字段 `withdrawTag` 在 `GET /sapi/v1/capital/config/getall`接口上. 替换原有的 `sameAddress` 字段. 建议用户使用新的 `withdrawTag` 字段,暂时会保留 `sameAddress` 并且值与 `withdrawTag` 相同. --- ## 2025-08-25 - 添加新的充值历史记录V2 API。 - 更新地址验证列表 API 的描述。 - 更新以下页面的权重描述: - /travel-rule/withdraw-history - /travel-rule/withdraw-history-v2 - /travel-rule/questionnaire-requirements - /travel-rule/onboarded-vasp-list --- ## 2025-08-05 - 更新 `POST /sapi/v1/capital/withdraw/apply` 接口关于旅行规则的脚注说明。 --- ## 2025-07-11 - 添加附录: - 姓名限制规则。 - 旅行规则的国家/地区代码。 - 添加用于旅行规则问卷要求的新 API。 - `GET /sapi/v1/localentity/questionnaire-requirements` --- ## 2025-06-25 - 修改Travel Rule API文档: - 修改提币问卷`txnPurpose`选项: - 1: 在日本国内购物 - 2: 遗产、赠予或生活费 - 4: 投资 - 5: 支付第三方VASP的服务费用 - 6: 偿还贷款 - 7: 礼物或捐款 - 删除`txnPurposeOthers` --- ## 2025-06-12 - 开启法国SAPI支持,问卷中增加法国问卷内容。 - 修复文档中文版本的若干问题。 --- ## 2025-06-10 - 详细解释了 withdrawOrderId 在 POST `/sapi/v1/capital/withdraw/apply` 和 GET `/sapi/v1/capital/withdraw/history` 中的使用 --- ## 2025-05-12 - 合规站KZ,IN,问卷更新. --- ## 2025-03-27 - 新增接口`GET sapi/v1/capital/withdraw/quota`,获取用户提现额度 --- ## 2025-02-27 - `GET /sapi/v1/capital/config/getall`接口增加了一个`币种面值`的返回,默认不返回代表为1. --- ## 2025-01-15 - 更新 `GET /sapi/v2/localentity/withdraw/history` 接口 `请求权重` 描述为 UID. - 更新 `GET /sapi/v1/capital/withdraw/apply` 接口 `请求权重` 描述从 600 到 900. --- ## 2025-01-08 - 增加新接口 `GET /sapi/v1/localentity/vasp` 用来获取本地站支持的VASP列表. - 增加新接口 `GET /sapi/v2/localentity/withdraw/history` 改善提币历史查询的效率. - 支持问卷中合并`Binance`的逻辑。 --- ## 2024-11-21 - `GET /sapi/v1/capital/config/getall`接口增加了一个`内部转账最小提现数`的返回. - 以下接口功能将于 2024-11-21 不再提供支持: - `POST /sapi/v1/asset/convert-transfer` BUSD的资产相互转换接口功能下线,为兼容调用,现固定返回:"{\"tranId\":null,\"status\":"F",\"response\":"No longer supported"}" - `GET /sapi/v1/capital/contract/convertible-coins` BUSD资产可相互转换的稳定币查询功能下线,为兼容调用,现固定返回:"{\"convertEnabled\":false,\"coins\":[],\"exchangeRates\":{}}" - `POST /sapi/v1/capital/contract/convertible-coins` BUSD资产可相互转换稳定币编辑功能下线,为兼容调用,后台不再有任何更改 - 将 `GET /sapi/v1/capital/withdraw/history` 接口参数 idList 最大值调整为 45 --- ## 2024-11-08 - 更新 `GET /sapi/v1/account/info`:新增 "European Options account enable status" 與 "Portfolio Margin enable status"。 - 更新 `GET /sapi/v1/account/apiRestrictions`:新增 "FIX API trading permission" 與 "FIX API reading permission"。 --- ## 2024-10-28 - 提现查询历史 API 现在支持 `withdrawOrderId` 作为查询参数。 - 提现申请 API 已更新,增加了处理网络参数为空的逻辑。 --- ## 2024-10-18 - 为每一个主题添加对应的预先加载的VASP列表. --- ## 2024-10-16 - 为Travel Rule API增加预先加载的VASP列表 --- ## 2024-10-09 - 更新Travel Rule问卷内容: - 新增印度的提现/充值问卷: 印度用户现在可以参考问卷内容使用sAPI进行提现/充值 --- ## 2025-06-25 - 修改Travel Rule API文档: - 修改提币问卷`txnPurpose`选项: - 1: 在日本国内购物 - 2: 遗产、赠予或生活费 - 4: 投资 - 5: 支付第三方VASP的服务费用 - 6: 偿还贷款 - 7: 礼物或捐款 - 删除`txnPurposeOthers` --- ## 2024-08-14 - 修改Travel Rule API文档: - 新西兰问卷内容: `isAddressOwner` 的枚举值应为 `1`:是, `2`:不是 - 增加出金/入金API文档对于URL参数的补充描述 --- ## 2024-07-09 - 更新Travel Rule问卷内容: - 新增巴林的提现/充值问卷: 巴林用户现在可以参考问卷内容使用sAPI进行提现/充值 - 更新日本充值问卷: 新增必填项目`声明`,并修改了一些文本错误 --- ## 2024-06-21 - 新增本地站用充值/提币接口以满足旅行规则的合规需求: - `POST /sapi/v1/localentity/withdraw/apply` - `GET /sapi/v1/localentity/withdraw/history` - `PUT /sapi/v1/localentity/deposit/provide-info` - `GET /sapi/v1/localentity/deposit/history` --- ## 2024-06-04 - 钱包接口调整:对于内部转账,TXID前缀已于2024年5月28日被替换为“Off-chain transfer”。"Internal transfer"标记不再出现在TXID字段中,包括历史交易,以下接口受到影响: - `GET /sapi/v1/capital/deposit/hisrec` - `GET /sapi/v1/capital/withdraw/history` - `GET /sapi/v1/capital/deposit/subHisrec` --- ## 2024-05-22 - 更新子账户接口: - `GET /sapi/v1/sub-account/transfer/subUserHistory`: 更新返回字段`fromAccountType`和 `toAccountType`. 合约钱包划转时返回USDT_FUTURE/COIN_FUTURE以区分钱包 - 新增钱包接口: - `GET /sapi/v1/account/info`: 取得 “VIP 等级”, “是否开启杠杆帐户” 及 “是否开启合约帐户” --- ## 2024-04-18 - 新增钱包接口: - `GET /sapi/v1/capital/withdraw/address/list`: 获取提现地址列表 --- ## 2024-04-08 - 更新钱包接口: - `GET /sapi/v1/capital/config/getall`: 删除返回字段 `resetAddressStatus` --- ## 2024-01-15 - 新增钱包接口: - `GET /sapi/v1/spot/delist-schedule`:查询现货币对的下架计划 - 更新钱包接口: - `GET /sapi/v1/asset/dribblet`:增加参数`accountType` - `POST /sapi/v1/asset/dust-btc`:增加参数`accountType` - `POST /sapi/v1/asset/dust`:增加参数`accountType` --- ## 2023-11-21 - 新增钱包接口: - `GET /sapi/v1/capital/deposit/address/list`: 根据网络币种或币种获取充值地址列表 --- ## 2023-11-02 - 钱包接口更新: - `GET /sapi/v1/account/apiRestrictions`: 新增相应字段 `enablePortfolioMarginTrading` --- ## 2023-09-22 - 新增钱包接口: - `GET /sapi/v1/asset/wallet/balance`: 查询用户钱包余额 - `GET /sapi/v1/asset/custody/transfer-history`: 查询用户委托资金历史(适用主账户) --- ## 2023-09-04 - 钱包接口限频调整: - `GET /sapi/v1/capital/withdraw/history`: Weight(UID)调整为 18000,每秒最多请求 10 次。请查看接口描述获得更详细内容 --- ## 2023-05-18 - 新增钱包接口: - `POST /sapi/v1/capital/deposit/credit-apply`:申请充值到过期地址的一键上账 --- ## 2023-05-09 - 更新钱包接口: - `POST /sapi/v1/asset/transfer`:增加枚举类型`MAIN_PORTFOLIO_MARGIN` 和 `PORTFOLIO_MARGIN_MAIN` --- ## 2023-02-02 - 更新钱包接口: - 万能划转`POST /sapi/v1/asset/transfer`支持期权 --- ## 2022-12-26 - 添加钱包接口: - `GET /sapi/v1/capital/contract/convertible-coins`: 查询用户充值/提现时候稳定币与 BUSD 互转的设置 - `POST /sapi/v1/capital/contract/convertible-coins`: 修改哪些稳定币可与 BUSD 互相转换 --- ## 2022-11-18 - 新增钱包接口: - `GET /sapi/v1/asset/ledger-transfer/cloud-mining/queryByPage`: 云算力支付和退款历史分页查询 --- ## 2022-11-02 - 更新钱包接口: - `POST /sapi/v1/capital/withdraw/apply`: 权重改至 Weight(UID) 600。 --- ## 2022-10-28 - 更新钱包接口: - `POST /sapi/v1/asset/convert-transfer`: 增加 `accountType` 参数 - `POST /sapi/v1/asset/convert-transfer/queryByPage`: 改为 `GET` 请求方式,增加 `clientTranId` 参数 --- ## 2022-09-29 - 添加钱包接口: - `POST /sapi/v1/asset/convert-transfer`: 稳定币自动兑换划转 - `POST /sapi/v1/asset/convert-transfer/queryByPage`: 稳定币自动兑换划转查询 --- ## 2022-07-01 - 添加新钱包接口: - `POST /sapi/v3/asset/getUserAsset` 获取用户持仓。 --- ## 2022-2-17 以下更新于**2 月 24, 2022 08:00 AM UTC**生效 - 更新钱包接口: - `GET /sapi/v1/accountSnapshot` 接口查询范围缩短为仅支持查询最近一个月数据,即 startTime 不支持选定最近 1 个月之外的时间。 --- ## 2022-2-09 - 新增钱包接口: - `POST /sapi/v1/asset/dust-btc` 以获取可以转换成 BNB 的小额资产 ## 2021-12-30 - 更新钱包接口: - 由于矿池钱包合并于资金账户钱包,用户万向划转接口 `POST /sapi/v1/asset/transfer`的以下划转类型 MAIN_MINING, MINING_MAIN, MINING_UMFUTURE, MARGIN_MINING,和 MINING_MARGIN 将于 **1 月 05, 2022 08:00 AM UTC** 停止使用 --- ## 2021-11-19 - 更新钱包接口: - 新增响应参数 `info` 于接口 `GET /sapi/v1/capital/withdraw/history` 以显示提币失败原因 --- ## 2021-11-19 - 更新钱包接口: - 新增响应参数 `info` 于接口 `GET /sapi/v1/capital/withdraw/history` 以显示提币失败原因 --- ## 2021-11-18 以下更新于**11 月 25, 2021 08:00 AM UTC**生效 - 更新钱包接口: - `GET /sapi/v1/accountSnapshot` 接口查询范围缩短为仅支持查询最近半年内的数据,即 startTime 不支持选定最近 6 个月之外的时间。若您没有传入 startTime 和 endTime,则默认返回最近 7 天的数据 --- ## 2021-11-17 - 以下接口将于**11 月 17, 2021 13:00 PM UTC**停止使用: - `POST /sapi/v1/account/apiRestrictions/ipRestriction` 以支持用户为 API Key 开启或关闭 IP 白名单 - `POST /sapi/v1/account/apiRestrictions/ipRestriction/ipList` 以支持用户为 API Key 添加 IP 白名单地址列表 - `GET /sapi/v1/account/apiRestrictions/ipRestriction` 以支持用户为 API Key 查询 IP 白名单 - `DELETE /sapi/v1/account/apiRestrictions/ipRestriction/ipList` 以支持用户为 API Key 删除 IP 白名单地址列表 --- ## 2021-11-16 - 新增子母账户接口: - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction` 以支持母账户为子账户 API Key 开启或关闭 IP 白名单 - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList` 以支持母账户为子账户 API Key 添加 IP 白名单地址列表 - `GET /sapi/v1/sub-account/subAccountApi/ipRestriction` 以支持母账户为子账户 API Key 查询 IP 白名单 - `DELETE /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList` 以支持母账户为子账户 API Key 删除 IP 白名单地址列表 --- ## 2021-11-05 - 更新钱包接口: - 新增参数 `walletType`于提币接口`POST /sapi/v1/capital/withdraw/apply`以支持用户选择从`现货钱包`或`资金钱包`进行提币 --- ## 2021-11-04 以下更新于**11 月 11, 2021 08:00 AM UTC**生效 - 更新接口: - `GET /sapi/v1/asset/transfer` 接口查询范围缩短为仅支持查询最近半年内的数据,即 startTime 不支持选定最近 6 个月之外的时间。若您没有传入 startTime 和 endTime,则默认返回最近 7 天的数据 --- ## 2021-10-22 - 钱包接口更新: - 新增划转类型 `MAIN_FUNDING`,`FUNDING_MAIN`,`FUNDING_UMFUTURE`,`UMFUTURE_FUNDING`,`MARGIN_FUNDING`,`FUNDING_MARGIN`,`FUNDING_CMFUTURE`and `CMFUTURE_FUNDING` 于用户万向划转接口 `POST /sapi/v1/asset/transfer` 和 `GET /sapi/v1/asset/transfer` 以支持资金账户和现货账户,杠杆全仓账户,U 本位合约账户,币本位合约账户之间相互划转 - 由于 C2C 账户,币安支付、币安卡等业务合并至资金账户,用户万向划转接口`POST /sapi/v1/asset/transfer` 和 `GET /sapi/v1/asset/transfer` 的以下划转类型`MAIN_C2C`,`C2C_MAIN`,`C2C_UMFUTURE`,`C2C_MINING`,`UMFUTURE_C2C`,`MINING_C2C`,`MARGIN_C2C`,`C2C_MARGIN`,`MAIN_PAY`和`PAY_MAIN` 将于**11 月 04, 2021 08:00 AM UTC** 停止使用 --- ## 2021-09-03 - 更新钱包接口: - 新增响应内容 `sameAddress`,`depositDust` 和 `specialWithdrawTips`于`GET /sapi/v1/capital/config/getall`, `sameAddress` 表示需要输入 memo 的币种,`depositDust` 表示最小可上帐金额,`specialWithdrawTips` 表示提现时的特殊说明 - 新增响应内容 `confirmNo`于`GET /sapi/v1/capital/withdraw/history` 以支持查询提现确认数 --- ## 2021-08-27 - 更新钱包接口: - 新增参数 `withdrawOrderId` 于 `GET /sapi/v1/capital/withdraw/history` 以支持查询指定`withdrawOrderId`的提币历史记录 - 新增响应内容 `unlockConfirm` 于 `GET /sapi/v1/capital/deposit/hisrec` 以支持查询解锁需要的网络确认次数 --- ## 2021-08-20 - 更新钱包接口: - 新增参数`fromSymbol `,`toSymbol `和新增划转类型 `ISOLATEDMARGIN_MARGIN`, `MARGIN_ISOLATEDMARGIN`, `ISOLATEDMARGIN_ISOLATEDMARGIN` 于接口 `POST /sapi/v1/asset/transfer` 和 `GET /sapi/v1/asset/transfer` 以支持杠杆逐仓钱包与杠杆全仓钱包之前相互划转 --- ## 2021-07-16 - 新增钱包接口: - `GET /sapi/v1/account/apiRestrictions` 以查询用户 API Key 权限 --- ## 2021-07-09 - 新增钱包接口: - `POST /sapi/v1/asset/get-funding-asset` 以查询资金账户资产,目前支持查询的业务为:Binance Pay, Binance Card, Binance Gift Card, Stock Token --- ## 2021-06-24 - 钱包接口更新: - `GET /sapi/v1/capital/withdraw/history` 现有的 `limit` 参数增加默认值 1000,最大值 1000 的限制 - `GET /sapi/v1/capital/deposit/hisrec` 现有的 `limit` 参数增加默认值 1000,最大值 1000 的限制 --- ## 2021-05-26 - 更新钱包接口: - 用户万向划转接口 `POST /sapi/v1/asset/transfer` 和`GET /sapi/v1/asset/transfer` 新增划转类型`MAIN_PAY` , `PAY_MAIN` 以支持现货和支付账户之间相互划转 --- ## 2020-12-30 - 新增钱包接口: - `POST /sapi/v1/asset/transfer` 用户万向划转接口,以支持现货,全仓杠杆,合约,C2C,矿池账户间划转。 - `GET /sapi/v1/asset/transfer` 以支持查询用户万向划转历史记录。 --- ## 2020-04-02 - 接口 `GET /sapi/v1/capital/config/getall` 返回内容新增字段: - `minConfirm` 表示资产上账所需的最小确认数 - `unLockConfirm` 表示资产解锁需所需确认数 --- ## 2020-03-13 - 新增可选参数 `transactionFeeFlag` 于以下提币接口: - `POST /sapi/v1/capital/withdraw/apply` - `POST /wapi/v3/withdraw.html` --- ## 2020-01-15 - 接口`POST /wapi/v3/withdraw.html` 新增参数 `withdrawOrderId`: 用户自定义提币 id - 接口`GET /wapi/v3/withdrawHistory.html` 返回内容新增字段 `withdrawOrderId`: 该笔提币的用户自定义 id --- ## 2019-12-25 - 新增请求时间间隔于以下接口 `GET /sapi/v1/capital/withdraw/history`, `GET /wapi/v3/withdrawHistory.html`, `GET /sapi/v1/capital/deposit/hisrec` and `GET /wapi/v3/depositHistory.html`: _ 默认`startTime`为当前时间起 90 天前, 默认`endTime`为当前时间; _ 请注意`startTime` 与 `endTime` 的默认时间戳,保证请求时间间隔不超过 90 天; \* 同时提交`startTime` 与 `endTime`间隔不得超过 90 天. --- ## 2019-12-18 - 新增接口用以获取账户每日资产快照: `GET /sapi/v1/accountSnapshot` --- ## 2019-11-28 - 新增 SAPI 接口用以关闭账户站内划转功能: `POST /sapi/v1/account/disableFastWithdrawSwitch (HMAC SHA256)` - 新增 SAPI 接口用以开启账户站内划转功能: `POST /sapi/v1/account/enableFastWithdrawSwitch (HMAC SHA256)` --- ## 2019-10-29 - 新增钱包提币功能相关的 sapi 接口 - `POST /sapi/v1/capital/withdraw/apply (HMAC SHA256)`: 提币。 - `Get /sapi/v1/capital/withdraw/history (HMAC SHA256)`: 获取提币历史(支持多网络)。 --- ## 2019-10-14 - 新增钱包功能相关的 sapi 接口 - `GET /sapi/v1/capital/config/getall (HMAC SHA256)`: 获取针对用户的所有币种信息。 - `GET /sapi/v1/capital/deposit/hisrec (HMAC SHA256)`: 获取充值历史(支持多网络)。 - `GET /sapi/v1/capital/deposit/address (HMAC SHA256)`: 获取充值地址(支持多网络). --- ## Document: /products/wallet/Introduction URL: /zh-CN/docs/products/wallet/Introduction 钱包API提供了整合币安钱包数据和操作的方式。 --- ## Document: /products/vip-service/change-log URL: /zh-CN/docs/products/vip-service/change-log # 更新日志 ## 2025-09-04 - 上传至文档 --- --- ## Document: /products/vip-caas/quick-start URL: /zh-CN/docs/products/vip-caas/quick-start # 快速开始 ## API Key 权限设置 - 新创建的API的默认权限是 `只读`。 - 如果需要通过API提款, 需要在UI修改权限, 选中 `允许提现`。 ## 账户 ### 现货账户 新注册的币安账号都会有一个现货(`SPOT`)账号。 ### 杠杆账户 为了开设杠杆(`MARGIN`)账户, 可以参考[Binance杠杆交易账户设置指南](https://www.binance.vision/zh/tutorials/binance-margin-trading-guide) ## API 代码库 ### Connectors 以下有一些轻量级的代码库,使不同语言的用户能够直接调用现货的 Binance 公共 API: - Python [https://github.com/binance/binance-connector-python](https://github.com/binance/binance-connector-python) - JavaScript [https://github.com/binance/binance-connector-js](https://github.com/binance/binance-connector-js) - Ruby [https://github.com/binance/binance-connector-ruby](https://github.com/binance/binance-connector-ruby) - DotNET C# [https://github.com/binance/binance-connector-dotnet](https://github.com/binance/binance-connector-dotnet) - Java [https://github.com/binance/binance-connector-java](https://github.com/binance/binance-connector-java) - Rust [https://github.com/binance/binance-spot-connector-rust](https://github.com/binance/binance-spot-connector-rust) - PHP [https://github.com/binance/binance-connector-php](https://github.com/binance/binance-connector-php) - Go [https://github.com/binance/binance-connector-go](https://github.com/binance/binance-connector-go) ### Postman Collections Postman 集合现已推出。推荐给寻求快速和轻松地开始使用 API 的新用户。 [https://github.com/binance/binance-api-postman](https://github.com/binance/binance-api-postman) ### Swagger 以下有提供包含 RESTful API 的 OpenAPI 规范的 YAML 文件,以及可供参考的 Swagger UI 页面。 [https://github.com/binance/binance-api-swagger](https://github.com/binance/binance-api-swagger) --- ## Document: /products/vip-caas/general-info URL: /zh-CN/docs/products/vip-caas/general-info # 基本信息 ## API 基本信息 - 接口可能需要用户的 API Key,如何创建API-KEY请参考[这里](https://www.binance.com/cn/support/articles/360002502072) - 本篇列出接口的 base URL 有: - **https://api.binance.com** - **https://api-gcp.binance.com** - **https://api1.binance.com** - **https://api2.binance.com** - **https://api3.binance.com** - **https://api4.binance.com** - 上述列表的最后4个接口 (`api1`-`api4`) 可能会提供更好的性能,但其稳定性略为逊色。因此,请务必使用最适合您现有配置的那款。 - 所有接口的响应都是 JSON 格式。 - 响应中如有数组,数组元素以时间**升序**排列,越早的数据越提前。 - 所有时间、时间戳均为UNIX时间,单位为**毫秒**。 ### HTTP 返回代码 - HTTP `4XX` 错误码用于指示错误的请求内容、行为、格式。问题在于请求者。 - HTTP `403` 错误码表示违反WAF限制(Web应用程序防火墙)。 - HTTP `409` 错误码表示重新下单(cancelReplace)的请求部分成功。(比如取消订单失败,但是下单成功了) - HTTP `429` 错误码表示警告访问频次超限,即将被封IP。 - HTTP `418` 表示收到429后继续访问,于是被封了。 - HTTP `5XX` 错误码用于指示Binance服务侧的问题。 ### 接口错误代码 - 使用接口 `/api/v3`, 以及 `/sapi/v1/margin`时, 每个接口都有可能抛出异常; > API 与 SAPI 的错误代码返回形式如下: ```javascript { "code": -1121, "msg": "Invalid symbol." } ``` - 具体的错误码及其解释在 [错误代码](./error-code). ### 接口的基本信息 - `GET` 方法的接口, 参数必须在 `query string`中发送。 - `POST`, `PUT`, 和 `DELETE` 方法的接口,参数可以在内容形式为`application/x-www-form-urlencoded`的 `query string` 中发送,也可以在 `request body` 中发送。 如果你喜欢,也可以混合这两种方式发送参数。 - 对参数的顺序不做要求。 - 但如果同一个参数名在query string和request body中都有,query string中的会被优先采用。 --- ## 访问限制 ### 访问限制基本信息 - 以下 是`intervalLetter` 作为头部值: - SECOND => S - MINUTE => M - HOUR => H - DAY => D - 在 `/api/v3/exchangeInfo` `rateLimits` 数组中包含与交易的有关RAW_REQUESTS,REQUEST_WEIGHT和ORDERS速率限制相关的对象。这些在 `限制种类 (rateLimitType)` 下的 `枚举定义` 部分中进一步定义。 - 违反任何一个速率限制时(访问频次限制或下单速率限制),将返回429。 ### IP 访问限制 - 每个请求将包含一个`X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,其中包含当前IP所有请求的已使用权重。 - 每一个接口均有一个相应的权重(weight),有的接口根据参数不同可能拥有不同的权重。越消耗资源的接口权重就会越大。 - 收到429时,您有责任停止发送请求,不得滥用API。 - **收到429后仍然继续违反访问限制,会被封禁IP,并收到418错误码** - 频繁违反限制,封禁时间会逐渐延长,**从最短2分钟到最长3天**。 - `Retry-After`的头会与带有418或429的响应发送,并且会给出**以秒为单位**的等待时长(如果是429)以防止禁令,或者如果是418,直到禁令结束。 - **访问限制是基于IP的,而不是API Key** ###下单频率限制 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - 当下单数超过限制时,会收到带有429但不含`Retry-After`头的响应。请检查 `GET api/v3/exchangeInfo` 的下单频率限制 (rateLimitType = ORDERS) 并等待封禁时间结束。 - 被拒绝或不成功的下单并不保证回报中包含以上头内容。 - **下单频率限制是基于每个账户计数的。** - 用户可以通过接口 `GET api/v3/rateLimit/order` 来查询当前的下单量. ### WEB SOCKET 连接限制 - Websocket服务器每秒最多接受5个消息。消息包括: - PING帧 - PONG帧 - JSON格式的消息, 比如订阅, 断开订阅. - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅 **1024** 个Streams。 - 每IP地址、每5分钟最多可以发送300次连接请求。 ### /api/ 与 /sapi/ 接口限频说明 `/api/*`接口和 `/sapi/*`接口采用两套不同的访问限频规则, 两者互相独立。 - `/api/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以 `/api/*`开头的接口按IP限频,**且所有接口共用每分钟6,000限制**。 - 每个请求将包含一个 `X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,包含当前IP所有请求的已使用权重。 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - `/sapi/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以`/sapi/*`开头的接口采用**单接口限频模式**。按IP统计的权重单接口权重总额为每分钟12000;按照UID统计的单接口权重总额是每分钟180000。 - 每个接口会标明是按照IP或者按照UID统计, 以及相应请求一次的权重值。 - 按照IP统计的接口, 请求返回头里面会包含`X-SAPI-USED-IP-WEIGHT-1M=`或`X-SAPI-USED-IP-WEIGHT-1S=`, 包含当前IP所有请求已使用权重。 - 按照UID统计的接口, 请求返回头里面会包含`X-SAPI-USED-UID-WEIGHT-1M=`或`X-SAPI-USED-UID-WEIGHT-1S=`, 包含当前账户所有已用的UID权重。 --- ## 数据来源 - 因为API系统是异步的, 所以返回的数据有延时很正常, 也在预期之中。 - 在每个接口中,都列出了其数据的来源,可以用于理解数据的时效性。 系统一共有3个数据来源,按照更新速度的先后排序。排在前面的数据最新,在后面就有可能存在延迟。 - **撮合引擎** - 表示数据来源于撮合引擎 - **缓存** - 表示数据来源于内部或者外部的缓存 - **数据库** - 表示数据直接来源于数据库 ## 请求鉴权类型 - 每个接口都有一个鉴权类型,指示所需的 API 密钥权限,显示在接口名称旁边(例如,[下新订单 (TRADE)](#place-new-order-trade))。 - 如果未指定,则鉴权类型为 `NONE`。 - 除了为 `NONE` 外,所有具有鉴权类型的接口均视为 `SIGNED` 请求(即包含 `signature`),[listenKey 管理](#user-data-stream-requests) 除外。 - 具有鉴权类型的接口需要提供有效的 API 密钥并验证通过。 - API 密钥可在您的 Binance 账户的 [API 管理](https://www.binance.com/en/support/faq/360002502072) 页面创建。 - **API 密钥和密钥对均为敏感信息,切勿与他人分享。** 如果发现账户有异常活动,请立即撤销所有密钥并联系 Binance 支持。 - API 密钥可配置为仅允许访问某些鉴权接口。 - 例如,您可以拥有具有 `TRADE` 权限的 API 密钥用于交易,同时使用具有 `USER_DATA` 权限的另一个 API 密钥来监控订单状态。 - 默认情况下,API 密钥无法进行 `TRADE`,您需要先在 API 管理中启用交易权限。 | 鉴权类型 | 描述 | | ----------- | ------------------------- | | NONE | 不需要鉴权的接口 | | TRADE | 需要有效的 API-Key 和签名 | | MARGIN | 需要有效的 API-Key 和签名 | | USER_DATA | 需要有效的 API-Key 和签名 | | USER_STREAM | 需要有效的 API-Key | | MARKET_DATA | 需要有效的 API-Key | ### 需要签名的接口 - 调用`SIGNED` 接口时,除了接口本身所需的参数外,还需要在 `query string` 或 `request body` 中传递 `signature`, 即签名参数。 #### 签名是否是大小写敏感的 - **HMAC:** 使用 HMAC 生成的签名**不区分大小写**。这意味着无论字母大小写如何,签名字符串都可以被验证。 - **RSA:** 使用 RSA 生成的签名是**大小写敏感的**。 - **Ed25519:** 使用 Ed25519 生成的签名也是**大小写敏感的**。 请参阅[已签名请求示例 (HMAC)](#hmac-keys)、[已签名请求示例 (RSA)](#rsa-keys) 和[已签名请求示例 (Ed25519)](#ed25519-keys),了解如何根据您使用的 API 密钥类型计算签名。 ### 时间同步安全 - `SIGNED` 请求还需要一个 `timestamp` 参数,该参数应为当前时间戳,单位为毫秒或微秒。(参见 [通用 API 信息](#general-api-information)) - 另一个可选参数 `recvWindow`,用以指定请求的有效期,只能以毫秒为单位。 - `recvWindow` 扩展为三位小数(例如 6000.346),以便可以指定微秒。 - 如果未发送 `recvWindow`,则 **默认值为 5000 毫秒**。 - `recvWindow` 的最大值为 60000 毫秒。 - 请求处理逻辑如下: ```javascript serverTime = getCurrentTime() if (timestamp < (serverTime + 1 second) && (serverTime - timestamp) <= recvWindow) { // 开始处理请求 serverTime = getCurrentTime() if (serverTime - timestamp) <= recvWindow { // 将请求转发到撮合引擎 } else { // 拒绝请求 } // 结束处理请求 } else { // 拒绝请求 } ``` **关于交易时效性** 互联网状况并不100%可靠,不可完全依赖,因此你的程序本地到币安服务器的时延会有抖动. 这是我们设置`recvWindow`的目的所在,如果你从事高频交易,对交易时效性有较高的要求,可以灵活设置`recvWindow`以达到你的要求。 **不推荐使用5秒以上的recvWindow。最大值不能超过60秒!** ### POST /api/v3/order 的签名示例 #### HMAC Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 以下示例分步演示如何使用 `echo`、`openssl` 和 `curl` 从 Linux 命令行发送有效的签名 payload。其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 API 密钥和密钥示例: | Key | Value | | ----------- | ---------------------------------------------------------------- | | `apiKey` | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A | | `secretKey` | NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j | **警告:请勿与任何人分享您的 API 密钥和秘钥。** 此处提供的示例密钥仅用于示范说明目的。 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | LTCBTC | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` **第二步: 计算签名。** 1. 使用 API 密钥中的 `secretKey` 作为 HMAC-SHA-256 算法的签名密钥。 2. 对步骤 1 中构建的签名 payload 进行签名。 3. 将 HMAC-SHA-256 的输出编码为十六进制字符串。 请注意,`secretKey` 和 payload 是**大小写敏感的**,而生成的签名值是不区分大小写的。 **示例命令** 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71 ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n "symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3 ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71" ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3" ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash apiKey="vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" secretKey="NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" payload="symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" # 对请求进行签名 signature=$(echo -n "$payload" | openssl dgst -sha256 -hmac "$secretKey") signature=${signature#*= } # Keep only the part after the "= " # 发送请求 curl -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?$payload&signature=$signature" ``` #### RSA Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 要获取 API 密钥,您需要将 RSA 公钥上传到您的帐户中,系统将为您提供相应的 API 密钥。 仅支持 `PKCS#8` 密钥。 在以下示例中,其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 这些示例假设私钥存储在文件 `./test-prv-key.pem` 中。 | Key | Value | | -------- | ---------------------------------------------------------------- | | `apiKey` | CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ | 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | BTCUSDT | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` **第二步: 计算签名。** 1. 使用 RSASSA-PKCS1-v1_5 算法和 SHA-256 哈希函数对步骤 1 中构建的签名 payload 进行签名。 2. 将输出结果编码为 base64 格式。 请注意,payload 和生成的`签名值`是**大小写敏感的**。 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n 'symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' HZ8HOjiJ1s/igS9JA+n7+7Ti/ihtkRF5BIWcPIEluJP6tlbFM/Bf44LfZka/iemtahZAZzcO9TnI5uaXh3++lrqtNonCwp6/245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH+XxaCmR0WcvlKjNQnp12/eKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang/1WOq+Jaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT/fNnMRxFc7u+j3qI//5yuGuu14KR0MuQKKCSpViieD+fIti46sxPTsjSemoUKp0oXA== ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n 'symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' qJtv66wyp/1mZE+mIFAAMUoTe8xkmLN7/eAZjuC9x1ocxovItHLl/sNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M+JNIMz5UFxfeA53rXjFlvsyH1Sig+OuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C/QMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt/GuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng== ``` 3. 对 base64 格式的字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符): ```console HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D' ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D' ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash function rawurlencode { local string="${1}" local strlen=${#string} local encoded="" local pos c o for (( pos=0 ; pos API 与 SAPI 的错误代码返回形式如下: ```javascript { "code": -1121, "msg": "Invalid symbol." } ``` - 具体的错误码及其解释在 [错误代码](./error-code). ### 接口的基本信息 - `GET` 方法的接口, 参数必须在 `query string`中发送。 - `POST`, `PUT`, 和 `DELETE` 方法的接口,参数可以在内容形式为`application/x-www-form-urlencoded`的 `query string` 中发送,也可以在 `request body` 中发送。 如果你喜欢,也可以混合这两种方式发送参数。 - 对参数的顺序不做要求。 - 但如果同一个参数名在query string和request body中都有,query string中的会被优先采用。 --- ## 访问限制 ### 访问限制基本信息 - 以下 是`intervalLetter` 作为头部值: - SECOND => S - MINUTE => M - HOUR => H - DAY => D - 在 `/api/v3/exchangeInfo` `rateLimits` 数组中包含与交易的有关RAW_REQUESTS,REQUEST_WEIGHT和ORDERS速率限制相关的对象。这些在 `限制种类 (rateLimitType)` 下的 `枚举定义` 部分中进一步定义。 - 违反任何一个速率限制时(访问频次限制或下单速率限制),将返回429。 ### IP 访问限制 - 每个请求将包含一个`X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,其中包含当前IP所有请求的已使用权重。 - 每一个接口均有一个相应的权重(weight),有的接口根据参数不同可能拥有不同的权重。越消耗资源的接口权重就会越大。 - 收到429时,您有责任停止发送请求,不得滥用API。 - **收到429后仍然继续违反访问限制,会被封禁IP,并收到418错误码** - 频繁违反限制,封禁时间会逐渐延长,**从最短2分钟到最长3天**。 - `Retry-After`的头会与带有418或429的响应发送,并且会给出**以秒为单位**的等待时长(如果是429)以防止禁令,或者如果是418,直到禁令结束。 - **访问限制是基于IP的,而不是API Key** ###下单频率限制 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - 当下单数超过限制时,会收到带有429但不含`Retry-After`头的响应。请检查 `GET api/v3/exchangeInfo` 的下单频率限制 (rateLimitType = ORDERS) 并等待封禁时间结束。 - 被拒绝或不成功的下单并不保证回报中包含以上头内容。 - **下单频率限制是基于每个账户计数的。** - 用户可以通过接口 `GET api/v3/rateLimit/order` 来查询当前的下单量. ### WEB SOCKET 连接限制 - Websocket服务器每秒最多接受5个消息。消息包括: - PING帧 - PONG帧 - JSON格式的消息, 比如订阅, 断开订阅. - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅 **1024** 个Streams。 - 每IP地址、每5分钟最多可以发送300次连接请求。 ### /api/ 与 /sapi/ 接口限频说明 `/api/*`接口和 `/sapi/*`接口采用两套不同的访问限频规则, 两者互相独立。 - `/api/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以 `/api/*`开头的接口按IP限频,**且所有接口共用每分钟6,000限制**。 - 每个请求将包含一个 `X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,包含当前IP所有请求的已使用权重。 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - `/sapi/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以`/sapi/*`开头的接口采用**单接口限频模式**。按IP统计的权重单接口权重总额为每分钟12000;按照UID统计的单接口权重总额是每分钟180000。 - 每个接口会标明是按照IP或者按照UID统计, 以及相应请求一次的权重值。 - 按照IP统计的接口, 请求返回头里面会包含`X-SAPI-USED-IP-WEIGHT-1M=`或`X-SAPI-USED-IP-WEIGHT-1S=`, 包含当前IP所有请求已使用权重。 - 按照UID统计的接口, 请求返回头里面会包含`X-SAPI-USED-UID-WEIGHT-1M=`或`X-SAPI-USED-UID-WEIGHT-1S=`, 包含当前账户所有已用的UID权重。 --- ## 数据来源 - 因为API系统是异步的, 所以返回的数据有延时很正常, 也在预期之中。 - 在每个接口中,都列出了其数据的来源,可以用于理解数据的时效性。 系统一共有3个数据来源,按照更新速度的先后排序。排在前面的数据最新,在后面就有可能存在延迟。 - **撮合引擎** - 表示数据来源于撮合引擎 - **缓存** - 表示数据来源于内部或者外部的缓存 - **数据库** - 表示数据直接来源于数据库 ## 请求鉴权类型 - 每个接口都有一个鉴权类型,指示所需的 API 密钥权限,显示在接口名称旁边(例如,[下新订单 (TRADE)](#place-new-order-trade))。 - 如果未指定,则鉴权类型为 `NONE`。 - 除了为 `NONE` 外,所有具有鉴权类型的接口均视为 `SIGNED` 请求(即包含 `signature`),[listenKey 管理](#user-data-stream-requests) 除外。 - 具有鉴权类型的接口需要提供有效的 API 密钥并验证通过。 - API 密钥可在您的 Binance 账户的 [API 管理](https://www.binance.com/en/support/faq/360002502072) 页面创建。 - **API 密钥和密钥对均为敏感信息,切勿与他人分享。** 如果发现账户有异常活动,请立即撤销所有密钥并联系 Binance 支持。 - API 密钥可配置为仅允许访问某些鉴权接口。 - 例如,您可以拥有具有 `TRADE` 权限的 API 密钥用于交易,同时使用具有 `USER_DATA` 权限的另一个 API 密钥来监控订单状态。 - 默认情况下,API 密钥无法进行 `TRADE`,您需要先在 API 管理中启用交易权限。 | 鉴权类型 | 描述 | | ----------- | ------------------------- | | NONE | 不需要鉴权的接口 | | TRADE | 需要有效的 API-Key 和签名 | | MARGIN | 需要有效的 API-Key 和签名 | | USER_DATA | 需要有效的 API-Key 和签名 | | USER_STREAM | 需要有效的 API-Key | | MARKET_DATA | 需要有效的 API-Key | ### 需要签名的接口 - 调用`SIGNED` 接口时,除了接口本身所需的参数外,还需要在 `query string` 或 `request body` 中传递 `signature`, 即签名参数。 #### 签名是否是大小写敏感的 - **HMAC:** 使用 HMAC 生成的签名**不区分大小写**。这意味着无论字母大小写如何,签名字符串都可以被验证。 - **RSA:** 使用 RSA 生成的签名是**大小写敏感的**。 - **Ed25519:** 使用 Ed25519 生成的签名也是**大小写敏感的**。 请参阅[已签名请求示例 (HMAC)](#hmac-keys)、[已签名请求示例 (RSA)](#rsa-keys) 和[已签名请求示例 (Ed25519)](#ed25519-keys),了解如何根据您使用的 API 密钥类型计算签名。 ### 时间同步安全 - `SIGNED` 请求还需要一个 `timestamp` 参数,该参数应为当前时间戳,单位为毫秒或微秒。(参见 [通用 API 信息](#general-api-information)) - 另一个可选参数 `recvWindow`,用以指定请求的有效期,只能以毫秒为单位。 - `recvWindow` 扩展为三位小数(例如 6000.346),以便可以指定微秒。 - 如果未发送 `recvWindow`,则 **默认值为 5000 毫秒**。 - `recvWindow` 的最大值为 60000 毫秒。 - 请求处理逻辑如下: ```javascript serverTime = getCurrentTime() if (timestamp < (serverTime + 1 second) && (serverTime - timestamp) <= recvWindow) { // 开始处理请求 serverTime = getCurrentTime() if (serverTime - timestamp) <= recvWindow { // 将请求转发到撮合引擎 } else { // 拒绝请求 } // 结束处理请求 } else { // 拒绝请求 } ``` **关于交易时效性** 互联网状况并不100%可靠,不可完全依赖,因此你的程序本地到币安服务器的时延会有抖动. 这是我们设置`recvWindow`的目的所在,如果你从事高频交易,对交易时效性有较高的要求,可以灵活设置`recvWindow`以达到你的要求。 **不推荐使用5秒以上的recvWindow。最大值不能超过60秒!** ### POST /api/v3/order 的签名示例 #### HMAC Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 以下示例分步演示如何使用 `echo`、`openssl` 和 `curl` 从 Linux 命令行发送有效的签名 payload。其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 API 密钥和密钥示例: | Key | Value | | ----------- | ---------------------------------------------------------------- | | `apiKey` | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A | | `secretKey` | NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j | **警告:请勿与任何人分享您的 API 密钥和秘钥。** 此处提供的示例密钥仅用于示范说明目的。 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | LTCBTC | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` **第二步: 计算签名。** 1. 使用 API 密钥中的 `secretKey` 作为 HMAC-SHA-256 算法的签名密钥。 2. 对步骤 1 中构建的签名 payload 进行签名。 3. 将 HMAC-SHA-256 的输出编码为十六进制字符串。 请注意,`secretKey` 和 payload 是**大小写敏感的**,而生成的签名值是不区分大小写的。 **示例命令** 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71 ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n "symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3 ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71" ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3" ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash apiKey="vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" secretKey="NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" payload="symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" # 对请求进行签名 signature=$(echo -n "$payload" | openssl dgst -sha256 -hmac "$secretKey") signature=${signature#*= } # Keep only the part after the "= " # 发送请求 curl -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?$payload&signature=$signature" ``` #### RSA Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 要获取 API 密钥,您需要将 RSA 公钥上传到您的帐户中,系统将为您提供相应的 API 密钥。 仅支持 `PKCS#8` 密钥。 在以下示例中,其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 这些示例假设私钥存储在文件 `./test-prv-key.pem` 中。 | Key | Value | | -------- | ---------------------------------------------------------------- | | `apiKey` | CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ | 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | BTCUSDT | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` **第二步: 计算签名。** 1. 使用 RSASSA-PKCS1-v1_5 算法和 SHA-256 哈希函数对步骤 1 中构建的签名 payload 进行签名。 2. 将输出结果编码为 base64 格式。 请注意,payload 和生成的`签名值`是**大小写敏感的**。 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n 'symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' HZ8HOjiJ1s/igS9JA+n7+7Ti/ihtkRF5BIWcPIEluJP6tlbFM/Bf44LfZka/iemtahZAZzcO9TnI5uaXh3++lrqtNonCwp6/245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH+XxaCmR0WcvlKjNQnp12/eKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang/1WOq+Jaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT/fNnMRxFc7u+j3qI//5yuGuu14KR0MuQKKCSpViieD+fIti46sxPTsjSemoUKp0oXA== ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n 'symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' qJtv66wyp/1mZE+mIFAAMUoTe8xkmLN7/eAZjuC9x1ocxovItHLl/sNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M+JNIMz5UFxfeA53rXjFlvsyH1Sig+OuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C/QMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt/GuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng== ``` 3. 对 base64 格式的字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符): ```console HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D' ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D' ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash function rawurlencode { local string="${1}" local strlen=${#string} local encoded="" local pos c o for (( pos=0 ; pos 错误JSON格式: ```javascript { "code":-1121, "msg":"Invalid symbol." } ``` 错误由两部分组成:错误代码和消息。 代码是通用的,但是消息可能会有所不同。 ## 10xx -常规服务器或网络问题 ### -1000 UNKNOWN - 处理请求时发生未知错误。 - 处理请求时发生未知错误。[%s] ### -1001 DISCONNECTED - 内部错误; 无法处理您的请求。 请再试一次. ### -1002 UNAUTHORIZED - 您无权执行此请求。 ### -1003 TOO_MANY_REQUESTS - 排队的请求过多。 - 请求权重过多; 当前限制是 %s 每 %s 的请求权重。 请使用 Websocket Streams 进行实时更新,以避免轮询API。 - 请求权重过多; IP被禁止,直到%s。 请使用 Websocket Streams 进行实时更新,以免被禁。 ### -1004 SERVER_BUSY - 服务器正忙,请稍候再试。 ### -1006 UNEXPECTED_RESP - 从消息总线收到意外的响应。 执行状态未知。 ### -1007 TIMEOUT - 等待后端服务器响应超时。 发送状态未知; 执行状态未知。 ### -1008 SERVER_BUSY - 现货交易服务器当前因其他请求而过载。 请在几分钟后重试。 ### -1014 UNKNOWN_ORDER_COMPOSITION - 不支持的订单组合。 ### -1015 TOO_MANY_ORDERS - 新订单太多。 - 新订单太多; 当前限制为每%s %s个订单。 ### -1016 SERVICE_SHUTTING_DOWN - 该服务不可用。 ### -1020 UNSUPPORTED_OPERATION - 不支持此操作。 ### -1021 INVALID_TIMESTAMP - 此请求的时间戳在recvWindow之外。 - 此请求的时间戳比服务器时间提前1000毫秒。 ### -1022 INVALID_SIGNATURE - 此请求的签名无效。 ### -1099 Not found, authenticated, or authorized - 替换错误代码-1999 ## 11xx - 2xxx Request issues ### -1100 ILLEGAL_CHARS - 在参数中发现非法字符。 - 在参数中发现非法字符。`%s` - 在参数`%s`中发现非法字符; 合法范围是`%s`。 ### -1101 TOO_MANY_PARAMETERS - 为此端点发送的参数太多。 - 参数太多; 预期为`%s`并收到了`%s`。 - 检测到的参数值重复。 ### -1102 MANDATORY_PARAM_EMPTY_OR_MALFORMED - 未发送强制性参数,该参数为空/空或格式错误。 - 强制参数`%s`未发送,为空/空或格式错误。 - 必须发送参数`%s`或`%s`,但两者均为空! ### -1103 UNKNOWN_PARAM - 发送了未知参数。 ### -1104 UNREAD_PARAMETERS - 并非所有发送的参数都被读取。 - 并非所有发送的参数都被读取; 读取了`%s`参数,但被发送了`%s`。 ### -1105 PARAM_EMPTY - 参数为空。 - 参数`%s`为空。 ### -1106 PARAM_NOT_REQUIRED - 不需要时已发送参数。 - 不需要时发送参数`%s`。 ### -1111 BAD_PRECISION - 精度超过为此资产定义的最大值。 ### -1112 NO_DEPTH - 交易对没有挂单。 ### -1114 TIF_NOT_REQUIRED - 不需要时发送了TimeInForce参数。 ### -1115 INVALID_TIF - 无效 timeInForce. ### -1116 INVALID_ORDER_TYPE - 无效订单类型。 ### -1117 INVALID_SIDE - 无效买卖方向。 ### -1118 EMPTY_NEW_CL_ORD_ID - 新的客户订单ID为空。 ### -1119 EMPTY_ORG_CL_ORD_ID - 客户自定义的订单ID为空。 ### -1120 BAD_INTERVAL - 无效时间间隔。 ### -1121 BAD_SYMBOL - 无效的交易对。 ### -1125 INVALID_LISTEN_KEY - 该listenKey不存在。 ### -1127 MORE_THAN_XX_HOURS - 查询间隔太大。 - 从开始时间到结束时间之间超过%s小时。 ### -1128 OPTIONAL_PARAMS_BAD_COMBO - 可选参数组合无效。 ### -1130 INVALID_PARAMETER - 发送的参数为无效数据。 - 发送参数`%s`的数据无效。 ### -1131 BAD_RECV_WINDOW - `recvWindow` 必须小于 60000 ### -1134 BAD_STRATEGY_TYPE - `strategyType` 必须小于 1000000 #### -1145 INVALID_CANCEL_RESTRICTIONS - `cancelRestrictions` 必须是 `ONLY_NEW` 或者 `ONLY_PARTIALLY_FILLED`。 #### -1151 重复的交易对 - Symbol is present multiple times in the list. ### -2010 NEW_ORDER_REJECTED - 新订单被拒绝 ### -2011 CANCEL_REJECTED - 取消订单被拒绝 ### -2013 NO_SUCH_ORDER - 订单不存在。 ### -2014 BAD_API_KEY_FMT - API-key 格式无效。 ### -2015 REJECTED_MBX_KEY - 无效的API密钥,IP或操作权限。 ### -2016 NO_TRADING_WINDOW - 找不到该交易对的交易窗口。 尝试改为24小时自动报价。 #### -2026 ORDER_ARCHIVED - 订单已被存档因为此订单被取消或过期,无交易数量而最后的更新已超过 90 天前。 ## 3xxx-5xxx SAPI 具体问题 ### -3000 INNER_FAILURE - 内部服务器错误。 ### -3001 NEED_ENABLE_2FA - 请先启用2FA。 ### -3002 ASSET_DEFICIENCY - 此资产不存在。 ### -3003 NO_OPENED_MARGIN_ACCOUNT - 杠杆账户不存在。 ### -3004 TRADE_NOT_ALLOWED - 禁止交易。 ### -3005 TRANSFER_OUT_NOT_ALLOWED - 不允许转账。 ### -3006 EXCEED_MAX_BORROWABLE - 您的已借金额已超过最高可借金额。 ### -3007 HAS_PENDING_TRANSACTION - 您有待处理的交易,请稍后再试。 ### -3008 BORROW_NOT_ALLOWED - 不允许借款。 ### -3009 ASSET_NOT_MORTGAGEABLE - 此资产目前不允许转入杠杆账户。 ### -3010 REPAY_NOT_ALLOWED - 不允许还款。 ### -3011 BAD_DATE_RANGE - 您输入的日期无效。 ### -3012 ASSET_ADMIN_BAN_BORROW - 此资产禁止借款。 ### -3013 LT_MIN_BORROWABLE - 借入金额少于最低借入金额。 ### -3014 ACCOUNT_BAN_BORROW - 此帐户禁止借款。 ### -3015 REPAY_EXCEED_LIABILITY - 还款额超过借款额。 ### -3016 LT_MIN_REPAY - 还款额少于最低还款额。 ### -3017 ASSET_ADMIN_BAN_MORTGAGE - 此资产目前不允许转入保证金账户。 ### -3018 ACCOUNT_BAN_MORTGAGE - 此帐户已禁止转入。 ### -3019 ACCOUNT_BAN_ROLLOUT - 此帐户禁止转出。 ### -3020 EXCEED_MAX_ROLLOUT - 转出金额超过上限。 ### -3021 PAIR_ADMIN_BAN_TRADE - 杠杆账户无法交易此交易对。 ### -3022 ACCOUNT_BAN_TRADE - 账号被禁止交易。 ### -3023 WARNING_MARGIN_LEVEL - 无法在当前杠杆倍数下转出资金或者下单 ### -3024 FEW_LIABILITY_LEFT - 付款之后未付款的债务太小 ### -3025 INVALID_EFFECTIVE_TIME - 输入时间有误。 ### -3026 VALIDATION_FAILED - 输入参数有误。 ### -3027 NOT_VALID_MARGIN_ASSET - 无效的杠杆资产。 ### -3028 NOT_VALID_MARGIN_PAIR - 无效的杠杆交易对。 ### -3029 TRANSFER_FAILED - 转账失败。 ### -3036 ACCOUNT_BAN_REPAY - 此账号无法还款。 ### -3037 PNL_CLEARING - `PNL`正在清帐,请稍等。 ### -3038 LISTEN_KEY_NOT_FOUND - 找不到`Listen key` ### -3041 BALANCE_NOT_CLEARED - 余额不足 ### -3042 PRICE_INDEX_NOT_FOUND - 该杠杆交易对无可用价格指数。 ### -3043 TRANSFER_IN_NOT_ALLOWED - 不允许转入。 ### -3044 SYSTEM_BUSY - 系统繁忙。 ### -3045 SYSTEM - 系统目前没有足够可借的资产。 ### -3999 NOT_WHITELIST_USER - 此功能只面向邀请的用户。 ### -4001 CAPITAL_INVALID - 非法操作 ### -4002 CAPITAL_IG - 非法获取 ### -4003 CAPITAL_IEV - 非法邮箱验证 ### -4004 CAPITAL_UA - 未登录或者认证。 ### -4005 CAPAITAL_TOO_MANY_REQUEST - 请求太频繁。 ### -4006 CAPITAL_ONLY_SUPPORT_PRIMARY_ACCOUNT - 只支持主账号。 ### -4007 CAPITAL_ADDRESS_VERIFICATION_NOT_PASS - 地址的没有通过校验。 ### -4008 CAPITAL_ADDRESS_TAG_VERIFICATION_NOT_PASS - 地址的标记信息(`tag`)没有通过校验。 ### -4010 CAPITAL_WHITELIST_EMAIL_CONFIRM - 确认电子邮件已经列入白名单。 ### -4011 CAPITAL_WHITELIST_EMAIL_EXPIRED - 列入白名单的电子邮件无效。 ### -4012 CAPITAL_WHITELIST_CLOSE - 白名单未打开。 ### -4013 CAPITAL_WITHDRAW_2FA_VERIFY - 2FA未打开。 ### -4014 CAPITAL_WITHDRAW_LOGIN_DELAY - 在登录后的2分钟之内不允许提款。 ### -4015 CAPITAL_WITHDRAW_RESTRICTED_MINUTE - 暂停提款 ### -4016 CAPITAL_WITHDRAW_RESTRICTED_PASSWORD - 在密码修改后的24小时之内不允许提款。 ### -4017 CAPITAL_WITHDRAW_RESTRICTED_UNBIND_2FA - 在2FA发行后的24小时之内不允许提款。 ### -4018 CAPITAL_WITHDRAW_ASSET_NOT_EXIST - 此资产不存在。 ### -4019 CAPITAL_WITHDRAW_ASSET_PROHIBIT - 此资产不允许提款。 ### -4021 CAPITAL_WITHDRAW_AMOUNT_MULTIPLE - 资产的提款数量必须是%s的%s倍。 ### -4022 CAPITAL_WITHDRAW_MIN_AMOUNT - 不须少于最低的提款数量%s。 ### -4023 CAPITAL_WITHDRAW_MAX_AMOUNT - 在24小时之内,不须超过最高的提款数量。 ### -4024 CAPITAL_WITHDRAW_USER_NO_ASSET - 当前用户没有此资产。 ### -4025 CAPITAL_WITHDRAW_USER_ASSET_LESS_THAN_ZERO - 持有资产的数量小于零。 ### -4026 CAPITAL_WITHDRAW_USER_ASSET_NOT_ENOUGH - 此资产余额不足。 ### -4027 CAPITAL_WITHDRAW_GET_TRAN_ID_FAILURE - 无法获取tranId。 ### -4028 CAPITAL_WITHDRAW_MORE_THAN_FEE - 提款金额必须多于佣金额。 ### -4029 CAPITAL_WITHDRAW_NOT_EXIST - 此提款记录不存在。 ### -4030 CAPITAL_WITHDRAW_CONFIRM_SUCCESS - 提款资产成功。 ### -4031 CAPITAL_WITHDRAW_CANCEL_FAILURE - 取消提款失败。 ### -4032 CAPITAL_WITHDRAW_CHECKSUM_VERIFY_FAILURE - 验证提款失败。 ### -4033 CAPITAL_WITHDRAW_ILLEGAL_ADDRESS - 提款地址不合法。 ### -4034 CAPITAL_WITHDRAW_ADDRESS_CHEAT - 当前地址有异常。 ### -4035 CAPITAL_WITHDRAW_NOT_WHITE_ADDRESS - 此地址不在白名单上。请加入然后重试。 ### -4036 CAPITAL_WITHDRAW_NEW_ADDRESS - 新地址在{0}小时后才可以提款。 ### -4037 CAPITAL_WITHDRAW_RESEND_EMAIL_FAIL - 重新发送邮件失败。 ### -4038 CAPITAL_WITHDRAW_RESEND_EMAIL_TIME_OUT - 请5分钟后重试。 ### -4039 CAPITAL_USER_EMPTY - 用户不存在。 ### -4041 CAPITAL_MINUTE_TOO_SMALL - 请一分钟后重试。 ### -4042 CAPITAL_CHARGE_NOT_RESET - 资产无法重新获取存款地址。 ### -4043 CAPITAL_ADDRESS_TOO_MUCH - 在24小时之内充值超过100多个地址。 ### -4044 CAPITAL_BLACKLIST_COUNTRY_GET_ADDRESS - 此国家在黑名单上。 ### -4045 CAPITAL_GET_ASSET_ERROR - 获得资产失败。 ### -4046 CAPITAL_AGREEMENT_NOT_CONFIRMED - 协议未确认。 ### -4047 CAPITAL_DATE_INTERVAL_LIMIT - 时间间隔必须在0-90天之内 ### -4060 CAPITAL_WITHDRAW_USER_ASSET_LOCK_DEPOSIT - 体现仍在区块确认中,暂时锁定部分资产 ### -4106 TAG_NOT_SUPPORTED_FOR_NETWORK - 该网络不支持 memo/tag。请移除 `addressTag` 字段后重试。 ### -5001 ASSET_DRIBBLET_CONVERT_SWITCH_OFF - 不允许转移到微型资产。 ### -5002 ASSET_ASSET_NOT_ENOUGH - 此余额不足。 ### -5003 ASSET_USER_HAVE_NO_ASSET - 此资产不存在。 ### -5004 USER_OUT_OF_TRANSFER_FLOAT - 剩余余额已超过0.001BTC,请重新选择。 - %s的剩余余额已超过0.001BTC,请重新选择。 ### -5005 USER_ASSET_AMOUNT_IS_TOO_LOW - BTC的剩余余额太低,请重新选择。 - %s的剩余余额太低,请重新选择。 ### -5006 USER_CAN_NOT_REQUEST_IN_24_HOURS - 24小时内只能转账一次。 ### -5007 AMOUNT_OVER_ZERO - 数量必须大于零。 ### -5008 ASSET_WITHDRAW_WITHDRAWING_NOT_ENOUGH - 可退回资产的金额不足。 ### -5009 PRODUCT_NOT_EXIST - 产品不存在。 ### -5010 TRANSFER_FAIL - 资产转移失败。 ### -5011 FUTURE_ACCT_NOT_EXIST - 合约帐户不存在。 ### -5012 TRANSFER_PENDING - 资产转移正在进行中。 ### -5021 PARENT_SUB_HAVE_NO_RELATION - 当前的子账户和母账户没有从属关系。 ### -5012 FUTURE_ACCT_OR_SUBRELATION_NOT_EXIST - 合约帐户或子账户关系不存在。 ## 6XXX - 币安宝相关 ### -6001 DAILY_PRODUCT_NOT_EXIST - 理财产品不存在. ### -6003 DAILY_PRODUCT_NOT_ACCESSIBLE - 产品不存在或者没有权限。 ### -6004 DAILY_PRODUCT_NOT_PURCHASABLE - 产品无法购买。 ### -6005 DAILY_LOWER_THAN_MIN_PURCHASE_LIMIT - 低于可以购买的最小限额。 ### -6006 DAILY_REDEEM_AMOUNT_ERROR - 赎回额度有误。 ### -6007 DAILY_REDEEM_TIME_ERROR - 不在赎回的时间内。 ### -6008 DAILY_PRODUCT_NOT_REDEEMABLE - 产品暂时无法赎回。 ### -6009 REQUEST_FREQUENCY_TOO_HIGH - 发送请求太频繁。 ### -6011 EXCEEDED_USER_PURCHASE_LIMIT - 超购每个月用户可以申购的最大次数。 ### -6012 BALANCE_NOT_ENOUGH - 余额不足。 ### -6013 PURCHASING_FAILED - 申购失败。 ### -6014 UPDATE_FAILED - 超过可以申购的最大上限。 ### -6015 EMPTY_REQUEST_BODY - 请求的`body`为空。 ### -6016 PARAMS_ERR - 请求的参数有误。 ### -6017 NOT_IN_WHITELIST - 不在白名单里面。 ### -6018 ASSET_NOT_ENOUGH - 资产不足。 ### -6019 PENDING - 需要进一步确认。 ### -6020 PROJECT_NOT_EXISTS - 此项目不存在。 ## 70xx - 期货 ### -7001 FUTURES_BAD_DATE_RANGE - 此日期范围不支持。 ### -7002 FUTURES_BAD_TYPE - 此数据请求类型不支持。 ## 20xxx - 合约/现货策略交易 ### -20121 Invalid symbol - 无效交易对。 ### -20124 Invalid algo id or it has been completed - 无效的策略订单ID或者它已经被执行。 ### -20130 Invalid data sent for a parameter - 无效数据。 ### -20132 The client algo id is duplicated - 用户自定义策略订单ID重复。 ### -20194 Duration is too short to execute all required quantity - Duration 时间太短不足以执行用户选择的订单数量。 ### -20195 The total size is too small - 下单数量太小。 ### -20196 The total size is too large - 下单数量太大。 ### -20198 Reach the max open orders allowed - 达到了最大挂单上限。 ### -20204 The notional of USD is less or more than the limit - 订单小于最小USD名义价值 ## 过滤器故障 | 报错信息 | 描述 | | ------------------------------------------ | ---------------------------------------------------------------------------------- | | "Filter failure: PRICE_FILTER" | "价格"过高,过低和/或不遵循交易对的最小价格规则。 | | "Filter failure: PERCENT_PRICE" | "价格"比最近Y分钟的平均加权价格高X%或X%太低。 | | "Filter failure: PERCENT_PRICE_BY_SIDE" | `price` 在当前方向上(`BUY`或者`SELL`)比`lastPrice`价格超过X%或者低于Y%。 | | "Filter failure: LOT_SIZE" | "数量"太高,太低和/或不遵循该交易对的步长规则。 | | "Filter failure: MIN_NOTIONAL" | 价格\*数量太低,无法成为该交易对的有效订单。 | | "Filter failure: ICEBERG_PARTS" | `ICEBERG` 订单会分成太多部分; icebergQty太小。 | | "Filter failure: MARKET_LOT_SIZE" | "MARKET"订单的"数量"过高,过低和/或未遵循交易对的步长规则。 | | "Filter failure: MAX_POSITION" | 达到账户的最大仓位限制。这包括了账户的余额总额,以及所有处于open的买单的数量总和。 | | "Filter failure: MAX_NUM_ORDERS" | 客户在交易对上有太多挂单。 | | "Filter failure: MAX_ALGO_ORDERS" | 账户有太多未平仓止损和/或在交易对上执行获利指令。 | | "Filter failure: MAX_NUM_ICEBERG_ORDERS" | 客户在交易对上有太多 iceberg 挂单。 | | "Filter failure: TRAILING_DELTA" | `trailingDelta` 值不在限定的范围内. | | "Filter failure: EXCHANGE_MAX_NUM_ORDERS" | 帐户上的交易所有太多挂单。 | | "Filter failure: EXCHANGE_MAX_ALGO_ORDERS" | 帐户有太多止损挂单和/或在交易所收取获利指令。 | ## 10xxx - 质押借币 ### -10001 SYSTEM_MAINTENANCE - 系统维护中,请稍后再试 ### -10002 INVALID_INPUT - 无效的输入参数 ### -10005 NO_RECORDS - 暂无记录 ### -10007 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10008 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10009 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10010 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10011 INSUFFICIENT_ASSET - 现货资产不足 ### -10012 INVALID_AMOUNT - 无效的还款金额 ### -10013 INSUFFICIENT_AMOUNT - 抵押资产不足 ### -10015 DEDUCTION_FAILED - 抵押资产扣款失败 ### -10016 LOAN_FAILED - 放贷失败 ### -10017 REPAY_EXCEED_DEBT - 还款金额超过负债金额 ### -10018 INVALID_AMOUNT - 无效的还款金额 ### -10019 CONFIG_NOT_EXIST - 配置不存在 ### -10020 UID_NOT_EXIST - 用户ID不存在 ### -10021 ORDER_NOT_EXIST - 订单不存在 ### -10022 INVALID_AMOUNT - 无效的调整金额 ### -10023 ADJUST_LTV_FAILED - 调整质押率失败 ### -10024 ADJUST_LTV_NOT_SUPPORTED - 暂不支持调整质押率 ### -10025 REPAY_FAILED - 还款失败 ### -10026 INVALID_PARAMETER - 无效的参数 ### -10028 INVALID_PARAMETER - 无效的参数 ### -10029 AMOUNT_TOO_SMALL - 借贷金额过小 ### -10030 AMOUNT_TOO_LARGE - 借贷金额过大 ### -10031 QUOTA_REACHED - 已达到个人借贷限额 ### -10032 REPAY_NOT_AVAILABLE - 暂不支持换款 ### -10034 REPAY_NOT_AVAILABLE - 抵押物还款暂时不支持,请尝试用借贷币还款。 ### -10039 AMOUNT_TOO_SMALL - 还款金额过小 ### -10040 AMOUNT_TOO_LARGE - 还款金额过大 ### -10041 INSUFFICIENT_AMOUNT - 由于借贷需求过多,系统剩余可借{0}额度不足。请调整借贷金额或明天再试。 ### -10042 ASSET_NOT_SUPPORTED - 暂不支持%s币种 ### -10043 ASSET_NOT_SUPPORTED - 暂不支持{0} 借贷 ### -10044 QUOTA_REACHED - 抵押物数量已达到限额,请调整抵押金额或使用其他抵押资产。 ### -10045 COLLTERAL_REPAY_NOT_SUPPORTED - 该借贷币种暂不支持抵押物还款,请稍后再试。 ### -10046 EXCEED_MAX_ADJUSTMENT - 调整抵押物超过最大限额,请重试。 ### -10047 REGION_NOT_SUPPORTED - 受当地法规管制,您所在地区暂不支持该币种。 ## 13xxx - 杠杆代币 ### -13000 BLVT_FORBID_REDEEM - 当前该杠杆代币关闭赎回 ### -13001 BLVT_EXCEED_DAILY_LIMIT - 超过该代币个人24小时赎回金额上限 ### -13002 BLVT_EXCEED_TOKEN_DAILY_LIMIT - 超过该代币全局24小时赎回金额上限 ### -13003 BLVT_FORBID_PURCHASE - 当前该杠杆代币关闭申购 ### -13004 BLVT_EXCEED_DAILY_PURCHASE_LIMIT - 超过该代币个人24小时申购金额上限 ### -13005 BLVT_EXCEED_TOKEN_DAILY_PURCHASE_LIMIT - 超过该代币全局24小时申购金额上限 ### -13006 BLVT_PURCHASE_LESS_MIN_AMOUNT - 申购金额低于规定下限 ### -13007 BLVT_PURCHASE_AGREEMENT_NOT_SIGN - 没有签署开通交易协议 ## 12xxx - 流动性挖矿 ### -12014 TOO MANY REQUESTS - 2秒内接收的请求数量多于1条 ## 18xxx - 币安码 ### -18002 - The total amount of codes you created has exceeded the 24-hour limit, please try again after UTC 0 - 24小时内制码总金额已超过限额,请UTC0点后再尝试 ### -18003 - Too many codes created in 24 hours, please try again after UTC 0 - 24小时内制码总次数已超过限额,请UTC0点后再尝试 ### -18004 - Too many invalid redeem attempts in 24 hours, please try again after UTC 0 - 24小时内兑现币安码输错次数已超过限额,请UTC0点后再尝试 ### -18005 - Too many invalid verify attempts, please try later - 参考号输错次数过多,请稍后再试 ### -18006 - The amount is too small, please re-enter - 金额过小,请重新输入 ### -18007 - This token is not currently supported, please re-enter - 尚未支持该币种,请重新输入 ## 21xxx - 統一帳戶 ### -21001 USER_IS_NOT_UNIACCOUNT - 尚未开通统一账户。 ### -21002 UNI_ACCOUNT_CANT_TRANSFER_FUTURE - 统一账户禁用margin向futures转账。 ### -21003 NET_ASSET_MUST_LTE_RATIO - margin资产更新失败。 ### -21004 USER_NO_LIABILITY - 用户不存在统一账户穿仓负债 ### -21005 NO_ENOUGH_ASSET - 用户现货钱包BUSD资产不足以偿还统一账户穿仓负债 ### -21006 HAD_IN_PROCESS_REPAY - 用户存在正在偿还的统一账户穿仓负债 ### -21007 IN_FORCE_LIQUIDATION - 强平进行中,用户偿还统一账户穿仓负债失败 ## 订单拒绝错误 以下错误代码表示撮合引擎返回的订单相关错误: - `-1010 ERROR_MSG_RECEIVED` - `-2010 NEW_ORDER_REJECTED` - `-2011 CANCEL_REJECTED` 结合以下消息将指示特定的错误: | 错误信息 | 描述 | | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | "Unknown order sent." | 找不到订单(通过"orderId","clientOrderId","origClientOrderId") | | "Duplicate order sent." | `clientOrderId`已经被使用 | | "Market is closed." | 该交易对不在交易范围 | | "Account has insufficient balance for requested action." | 没有足够的资金来完成行动 | | "Market orders are not supported for this symbol." | 交易对上未启用"MARKET" | | "Iceberg orders are not supported for this symbol." | 交易对上未启用`icebergQty` | | "Stop loss orders are not supported for this symbol." | 交易对上未启用 `STOP_LOSS` | | "Stop loss limit orders are not supported for this symbol." | 交易对上未启`STOP_LOSS_LIMIT` | | "Take profit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT` | | "Take profit limit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT_LIMIT` | | "Price \* QTY is zero or less." | `price` \* `quantity`太小 | | "IcebergQty exceeds QTY." | `icebergQty` 必须少于订单数量 | | "This action is disabled on this account." | 联系客户支持; 该账户已禁用了某些操作。 | | "This account may not place or cancel orders." | 联系客户支持: 该账户已被禁用了交易操作。 | | "Unsupported order combination" | 不允许组合`orderType`, `timeInForce`, `stopPrice`, 和/或 `icebergQty` 。 | | "Order would trigger immediately." | 与最后交易价格相比,订单的止损价无效。 | | "Cancel order is invalid. Check origClientOrderId and orderId." | 未发送`origClientOrderId` 或`orderId` 。 | | "Order would immediately match and take." | `LIMIT_MAKER` 订单类型将立即匹配并进行交易,而不是纯粹的生成订单。 | | "The relationship of the prices for the orders is not correct." | `OCO`订单中设置的价格不符合报价规则:

The rules are:

`SELL Orders`: Limit Price > Last Price > Stop Price

`BUY Orders`: Limit Price < Last Price < Stop Price | | "OCO orders are not supported for this symbol" | `OCO`订单不支持该交易对 | | "Quote order qty market orders are not support for this symbol." | 这个交易对,市价单不支持参数`quoteOrderQty` | | "Trailing stop orders are not supported for this symbol." | 此symbol不支持 `trailingDelta` | | | "Order cancel-replace is not supported for this symbol." | 此symbol不支持 `POST /api/v3/order/cancelReplace` 或者 `order.cancelReplace` (WebSocket API) | | | "This symbol is not permitted for this account." | 账户和交易对的权限不一致 (比如 `SPOT`, `MARGIN` 等)。| | | "This symbol is restricted for this account." | 账户没有权限在此交易对交易 (比如账户只拥有 `ISOLATED_MARGIN`权限,则无法下`SPOT` 订单)。 | | | "Order was not canceled due to cancel restrictions." | `cancelRestrictions` 设置为 `ONLY_NEW` 但订单状态不是 `NEW`

`cancelRestrictions` 设置为 `ONLY_PARTIALLY_FILLED` 但订单状态不是 `PARTIALLY_FILLED`。 | | ## 关于 POST /api/v3/order/cancelReplace 的错误 ### -2021 Order cancel-replace partially failed 收到该错误码代表撤单**或者**下单失败。 ### -2022 Order cancel-replace failed. 收到该错误码代表撤单**和**下单都失败。 --- ## Document: /products/vip-loan/change-log URL: /zh-CN/docs/products/vip-loan/change-log # 更新日志 ## 2026-06-15 - 新增 VIP 借币接口: - `GET /sapi/v1/loan/vip/fixed/market` - 查询 VIP 借币固定利率市场。 - `POST /sapi/v1/loan/vip/fixed/borrow` - VIP 借币固定利率借款。 --- ## 2025-12-26 ### 时效性通知 - **以下有关于REST API变更将在 2026-01-15 07:OO UTC 发生:**
调用需要签名的接口时,请在计算签名之前对 payload 进行百分比编码(percent-encode)。不符合此顺序的请求将被拒绝,并返回错误代码 [`-1022 签名不正确`](./error-code.md#-1022-invalid_signature)。请检查并相应地更新您代码中的签名逻辑部分。 ### REST API - 更新了 REST API 文档中有关于 [签名请求示例](./general-info.md#post-apiv3order-的签名示例) 的部分。 --- ## 2024-11-27 - 新增 VIP 借币接口: - `GET /sapi/v1/loan/vip/interestRateHistory`: 查询借币利率 - `GET /sapi/v1/loan/vip/accruedInterest`: 查询利息记录 --- ## 2023-10-11 - 新增 VIP 借币: - `GET /sapi/v1/loan/vip/request/interestRate`: 查询借币利率 --- ## 2023-09-22 - VIP 借币接口改动: - `GET /sapi/v1/loan/vip/loanable/data`: 新增返回字段`_flexibleDailyInterestRate`,`_flexibleYearlyInterestRate` - `GET /sapi/v1/loan/vip/ongoing/orders`: 新增返回字段`loanDate`,`loanRate`,`loanTerm`,`expirationTime` --- ## 2023-09-18 - VIP 借币接口改动: - 新增入参`type` - 移除入参`transFrom`,`transTo` --- ## 2023-08-18 - 更新 VIP 借币接口: - `POST /sapi/v1/loan/vip/borrow`: 增加参数`isFlexibleRate`以支持浮动利率借贷 --- ## 2023-07-14 - 新增 VIP 借币接口: - `POST /sapi/v1/loan/vip/renew`: VIP 借币续期 --- ## 2023-04-20 - 更新 VIP 借币接口: - `GET /sapi/v1/loan/vip/ongoing/orders`:增加字段`totalCollateralValueAfterHaircut` 和 `lockedCollateralValue` --- ## 2022-11-29 - 添加 VIP 借币接口: - `GET /sapi/v1/loan/vip/collateral/account`: 查询 VIP 子账户冻结抵押物金额 --- ## 2022-11-14 - 添加 VIP 借币接口: - `GET /sapi/v1/loan/vip/ongoing/orders`:查询 VIP 借币借款中订单 - `POST /sapi/v1/loan/vip/repay`:VIP 借币还款 - `GET /sapi/v1/loan/vip/repay/history`:查询 VIP 借币还款记录历史 --- ## Document: /products/vip-loan/Introduction URL: /zh-CN/docs/products/vip-loan/Introduction 杠杆代币接口接口用于与定投产品交互。更多细节, 请参考[币安杠杆代币](https://www.binance.com/en/vip-loan)页面。 --- ## Document: /products/sub-account/quick-start URL: /zh-CN/docs/products/sub-account/quick-start # 快速开始 ## API Key 权限设置 - 新创建的API的默认权限是 `只读`。 - 如果需要通过API提款, 需要在UI修改权限, 选中 `允许提现`。 ## 账户 ### 现货账户 新注册的币安账号都会有一个现货(`SPOT`)账号。 ### 杠杆账户 为了开设杠杆(`MARGIN`)账户, 可以参考[Binance杠杆交易账户设置指南](https://www.binance.vision/zh/tutorials/binance-margin-trading-guide) ## API 代码库 ### Connectors 以下有一些轻量级的代码库,使不同语言的用户能够直接调用现货的 Binance 公共 API: - Python [https://github.com/binance/binance-connector-python](https://github.com/binance/binance-connector-python) - JavaScript [https://github.com/binance/binance-connector-js](https://github.com/binance/binance-connector-js) - Ruby [https://github.com/binance/binance-connector-ruby](https://github.com/binance/binance-connector-ruby) - DotNET C# [https://github.com/binance/binance-connector-dotnet](https://github.com/binance/binance-connector-dotnet) - Java [https://github.com/binance/binance-connector-java](https://github.com/binance/binance-connector-java) - Rust [https://github.com/binance/binance-spot-connector-rust](https://github.com/binance/binance-spot-connector-rust) - PHP [https://github.com/binance/binance-connector-php](https://github.com/binance/binance-connector-php) - Go [https://github.com/binance/binance-connector-go](https://github.com/binance/binance-connector-go) ### Postman Collections Postman 集合现已推出。推荐给寻求快速和轻松地开始使用 API 的新用户。 [https://github.com/binance/binance-api-postman](https://github.com/binance/binance-api-postman) ### Swagger 以下有提供包含 RESTful API 的 OpenAPI 规范的 YAML 文件,以及可供参考的 Swagger UI 页面。 [https://github.com/binance/binance-api-swagger](https://github.com/binance/binance-api-swagger) --- ## Document: /products/sub-account/general-info URL: /zh-CN/docs/products/sub-account/general-info # 基本信息 ## API 基本信息 - 接口可能需要用户的 API Key,如何创建API-KEY请参考[这里](https://www.binance.com/cn/support/articles/360002502072) - 本篇列出接口的 base URL 有: - **https://api.binance.com** - **https://api-gcp.binance.com** - **https://api1.binance.com** - **https://api2.binance.com** - **https://api3.binance.com** - **https://api4.binance.com** - 上述列表的最后4个接口 (`api1`-`api4`) 可能会提供更好的性能,但其稳定性略为逊色。因此,请务必使用最适合您现有配置的那款。 - 所有接口的响应都是 JSON 格式。 - 响应中如有数组,数组元素以时间**升序**排列,越早的数据越提前。 - 所有时间、时间戳均为UNIX时间,单位为**毫秒**。 ### HTTP 返回代码 - HTTP `4XX` 错误码用于指示错误的请求内容、行为、格式。问题在于请求者。 - HTTP `403` 错误码表示违反WAF限制(Web应用程序防火墙)。 - HTTP `409` 错误码表示重新下单(cancelReplace)的请求部分成功。(比如取消订单失败,但是下单成功了) - HTTP `429` 错误码表示警告访问频次超限,即将被封IP。 - HTTP `418` 表示收到429后继续访问,于是被封了。 - HTTP `5XX` 错误码用于指示Binance服务侧的问题。 ### 接口错误代码 - 使用接口 `/api/v3`, 以及 `/sapi/v1/margin`时, 每个接口都有可能抛出异常; > API 与 SAPI 的错误代码返回形式如下: ```javascript { "code": -1121, "msg": "Invalid symbol." } ``` - 具体的错误码及其解释在 [错误代码](./error-code). ### 接口的基本信息 - `GET` 方法的接口, 参数必须在 `query string`中发送。 - `POST`, `PUT`, 和 `DELETE` 方法的接口,参数可以在内容形式为`application/x-www-form-urlencoded`的 `query string` 中发送,也可以在 `request body` 中发送。 如果你喜欢,也可以混合这两种方式发送参数。 - 对参数的顺序不做要求。 - 但如果同一个参数名在query string和request body中都有,query string中的会被优先采用。 --- ## 访问限制 ### 访问限制基本信息 - 以下 是`intervalLetter` 作为头部值: - SECOND => S - MINUTE => M - HOUR => H - DAY => D - 在 `/api/v3/exchangeInfo` `rateLimits` 数组中包含与交易的有关RAW_REQUESTS,REQUEST_WEIGHT和ORDERS速率限制相关的对象。这些在 `限制种类 (rateLimitType)` 下的 `枚举定义` 部分中进一步定义。 - 违反任何一个速率限制时(访问频次限制或下单速率限制),将返回429。 ### IP 访问限制 - 每个请求将包含一个`X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,其中包含当前IP所有请求的已使用权重。 - 每一个接口均有一个相应的权重(weight),有的接口根据参数不同可能拥有不同的权重。越消耗资源的接口权重就会越大。 - 收到429时,您有责任停止发送请求,不得滥用API。 - **收到429后仍然继续违反访问限制,会被封禁IP,并收到418错误码** - 频繁违反限制,封禁时间会逐渐延长,**从最短2分钟到最长3天**。 - `Retry-After`的头会与带有418或429的响应发送,并且会给出**以秒为单位**的等待时长(如果是429)以防止禁令,或者如果是418,直到禁令结束。 - **访问限制是基于IP的,而不是API Key** ###下单频率限制 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - 当下单数超过限制时,会收到带有429但不含`Retry-After`头的响应。请检查 `GET api/v3/exchangeInfo` 的下单频率限制 (rateLimitType = ORDERS) 并等待封禁时间结束。 - 被拒绝或不成功的下单并不保证回报中包含以上头内容。 - **下单频率限制是基于每个账户计数的。** - 用户可以通过接口 `GET api/v3/rateLimit/order` 来查询当前的下单量. ### WEB SOCKET 连接限制 - Websocket服务器每秒最多接受5个消息。消息包括: - PING帧 - PONG帧 - JSON格式的消息, 比如订阅, 断开订阅. - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅 **1024** 个Streams。 - 每IP地址、每5分钟最多可以发送300次连接请求。 ### /api/ 与 /sapi/ 接口限频说明 `/api/*`接口和 `/sapi/*`接口采用两套不同的访问限频规则, 两者互相独立。 - `/api/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以 `/api/*`开头的接口按IP限频,**且所有接口共用每分钟6,000限制**。 - 每个请求将包含一个 `X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,包含当前IP所有请求的已使用权重。 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - `/sapi/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以`/sapi/*`开头的接口采用**单接口限频模式**。按IP统计的权重单接口权重总额为每分钟12000;按照UID统计的单接口权重总额是每分钟180000。 - 每个接口会标明是按照IP或者按照UID统计, 以及相应请求一次的权重值。 - 按照IP统计的接口, 请求返回头里面会包含`X-SAPI-USED-IP-WEIGHT-1M=`或`X-SAPI-USED-IP-WEIGHT-1S=`, 包含当前IP所有请求已使用权重。 - 按照UID统计的接口, 请求返回头里面会包含`X-SAPI-USED-UID-WEIGHT-1M=`或`X-SAPI-USED-UID-WEIGHT-1S=`, 包含当前账户所有已用的UID权重。 --- ## 数据来源 - 因为API系统是异步的, 所以返回的数据有延时很正常, 也在预期之中。 - 在每个接口中,都列出了其数据的来源,可以用于理解数据的时效性。 系统一共有3个数据来源,按照更新速度的先后排序。排在前面的数据最新,在后面就有可能存在延迟。 - **撮合引擎** - 表示数据来源于撮合引擎 - **缓存** - 表示数据来源于内部或者外部的缓存 - **数据库** - 表示数据直接来源于数据库 ## 请求鉴权类型 - 每个接口都有一个鉴权类型,指示所需的 API 密钥权限,显示在接口名称旁边(例如,[下新订单 (TRADE)](#place-new-order-trade))。 - 如果未指定,则鉴权类型为 `NONE`。 - 除了为 `NONE` 外,所有具有鉴权类型的接口均视为 `SIGNED` 请求(即包含 `signature`),[listenKey 管理](#user-data-stream-requests) 除外。 - 具有鉴权类型的接口需要提供有效的 API 密钥并验证通过。 - API 密钥可在您的 Binance 账户的 [API 管理](https://www.binance.com/en/support/faq/360002502072) 页面创建。 - **API 密钥和密钥对均为敏感信息,切勿与他人分享。** 如果发现账户有异常活动,请立即撤销所有密钥并联系 Binance 支持。 - API 密钥可配置为仅允许访问某些鉴权接口。 - 例如,您可以拥有具有 `TRADE` 权限的 API 密钥用于交易,同时使用具有 `USER_DATA` 权限的另一个 API 密钥来监控订单状态。 - 默认情况下,API 密钥无法进行 `TRADE`,您需要先在 API 管理中启用交易权限。 | 鉴权类型 | 描述 | | ----------- | ------------------------- | | NONE | 不需要鉴权的接口 | | TRADE | 需要有效的 API-Key 和签名 | | MARGIN | 需要有效的 API-Key 和签名 | | USER_DATA | 需要有效的 API-Key 和签名 | | USER_STREAM | 需要有效的 API-Key | | MARKET_DATA | 需要有效的 API-Key | ### 需要签名的接口 - 调用`SIGNED` 接口时,除了接口本身所需的参数外,还需要在 `query string` 或 `request body` 中传递 `signature`, 即签名参数。 #### 签名是否是大小写敏感的 - **HMAC:** 使用 HMAC 生成的签名**不区分大小写**。这意味着无论字母大小写如何,签名字符串都可以被验证。 - **RSA:** 使用 RSA 生成的签名是**大小写敏感的**。 - **Ed25519:** 使用 Ed25519 生成的签名也是**大小写敏感的**。 请参阅[已签名请求示例 (HMAC)](#hmac-keys)、[已签名请求示例 (RSA)](#rsa-keys) 和[已签名请求示例 (Ed25519)](#ed25519-keys),了解如何根据您使用的 API 密钥类型计算签名。 ### 时间同步安全 - `SIGNED` 请求还需要一个 `timestamp` 参数,该参数应为当前时间戳,单位为毫秒或微秒。(参见 [通用 API 信息](#general-api-information)) - 另一个可选参数 `recvWindow`,用以指定请求的有效期,只能以毫秒为单位。 - `recvWindow` 扩展为三位小数(例如 6000.346),以便可以指定微秒。 - 如果未发送 `recvWindow`,则 **默认值为 5000 毫秒**。 - `recvWindow` 的最大值为 60000 毫秒。 - 请求处理逻辑如下: ```javascript serverTime = getCurrentTime() if (timestamp < (serverTime + 1 second) && (serverTime - timestamp) <= recvWindow) { // 开始处理请求 serverTime = getCurrentTime() if (serverTime - timestamp) <= recvWindow { // 将请求转发到撮合引擎 } else { // 拒绝请求 } // 结束处理请求 } else { // 拒绝请求 } ``` **关于交易时效性** 互联网状况并不100%可靠,不可完全依赖,因此你的程序本地到币安服务器的时延会有抖动. 这是我们设置`recvWindow`的目的所在,如果你从事高频交易,对交易时效性有较高的要求,可以灵活设置`recvWindow`以达到你的要求。 **不推荐使用5秒以上的recvWindow。最大值不能超过60秒!** ### POST /api/v3/order 的签名示例 #### HMAC Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 以下示例分步演示如何使用 `echo`、`openssl` 和 `curl` 从 Linux 命令行发送有效的签名 payload。其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 API 密钥和密钥示例: | Key | Value | | ----------- | ---------------------------------------------------------------- | | `apiKey` | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A | | `secretKey` | NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j | **警告:请勿与任何人分享您的 API 密钥和秘钥。** 此处提供的示例密钥仅用于示范说明目的。 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | LTCBTC | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` **第二步: 计算签名。** 1. 使用 API 密钥中的 `secretKey` 作为 HMAC-SHA-256 算法的签名密钥。 2. 对步骤 1 中构建的签名 payload 进行签名。 3. 将 HMAC-SHA-256 的输出编码为十六进制字符串。 请注意,`secretKey` 和 payload 是**大小写敏感的**,而生成的签名值是不区分大小写的。 **示例命令** 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71 ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n "symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3 ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71" ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3" ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash apiKey="vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" secretKey="NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" payload="symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" # 对请求进行签名 signature=$(echo -n "$payload" | openssl dgst -sha256 -hmac "$secretKey") signature=${signature#*= } # Keep only the part after the "= " # 发送请求 curl -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?$payload&signature=$signature" ``` #### RSA Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 要获取 API 密钥,您需要将 RSA 公钥上传到您的帐户中,系统将为您提供相应的 API 密钥。 仅支持 `PKCS#8` 密钥。 在以下示例中,其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 这些示例假设私钥存储在文件 `./test-prv-key.pem` 中。 | Key | Value | | -------- | ---------------------------------------------------------------- | | `apiKey` | CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ | 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | BTCUSDT | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` **第二步: 计算签名。** 1. 使用 RSASSA-PKCS1-v1_5 算法和 SHA-256 哈希函数对步骤 1 中构建的签名 payload 进行签名。 2. 将输出结果编码为 base64 格式。 请注意,payload 和生成的`签名值`是**大小写敏感的**。 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n 'symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' HZ8HOjiJ1s/igS9JA+n7+7Ti/ihtkRF5BIWcPIEluJP6tlbFM/Bf44LfZka/iemtahZAZzcO9TnI5uaXh3++lrqtNonCwp6/245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH+XxaCmR0WcvlKjNQnp12/eKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang/1WOq+Jaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT/fNnMRxFc7u+j3qI//5yuGuu14KR0MuQKKCSpViieD+fIti46sxPTsjSemoUKp0oXA== ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n 'symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' qJtv66wyp/1mZE+mIFAAMUoTe8xkmLN7/eAZjuC9x1ocxovItHLl/sNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M+JNIMz5UFxfeA53rXjFlvsyH1Sig+OuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C/QMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt/GuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng== ``` 3. 对 base64 格式的字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符): ```console HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D' ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D' ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash function rawurlencode { local string="${1}" local strlen=${#string} local encoded="" local pos c o for (( pos=0 ; pos 错误JSON格式: ```javascript { "code":-1121, "msg":"Invalid symbol." } ``` 错误由两部分组成:错误代码和消息。 代码是通用的,但是消息可能会有所不同。 ## 10xx -常规服务器或网络问题 ### -1000 UNKNOWN - 处理请求时发生未知错误。 - 处理请求时发生未知错误。[%s] ### -1001 DISCONNECTED - 内部错误; 无法处理您的请求。 请再试一次. ### -1002 UNAUTHORIZED - 您无权执行此请求。 ### -1003 TOO_MANY_REQUESTS - 排队的请求过多。 - 请求权重过多; 当前限制是 %s 每 %s 的请求权重。 请使用 Websocket Streams 进行实时更新,以避免轮询API。 - 请求权重过多; IP被禁止,直到%s。 请使用 Websocket Streams 进行实时更新,以免被禁。 ### -1004 SERVER_BUSY - 服务器正忙,请稍候再试。 ### -1006 UNEXPECTED_RESP - 从消息总线收到意外的响应。 执行状态未知。 ### -1007 TIMEOUT - 等待后端服务器响应超时。 发送状态未知; 执行状态未知。 ### -1008 SERVER_BUSY - 现货交易服务器当前因其他请求而过载。 请在几分钟后重试。 ### -1014 UNKNOWN_ORDER_COMPOSITION - 不支持的订单组合。 ### -1015 TOO_MANY_ORDERS - 新订单太多。 - 新订单太多; 当前限制为每%s %s个订单。 ### -1016 SERVICE_SHUTTING_DOWN - 该服务不可用。 ### -1020 UNSUPPORTED_OPERATION - 不支持此操作。 ### -1021 INVALID_TIMESTAMP - 此请求的时间戳在recvWindow之外。 - 此请求的时间戳比服务器时间提前1000毫秒。 ### -1022 INVALID_SIGNATURE - 此请求的签名无效。 ### -1099 Not found, authenticated, or authorized - 替换错误代码-1999 ## 11xx - 2xxx Request issues ### -1100 ILLEGAL_CHARS - 在参数中发现非法字符。 - 在参数中发现非法字符。`%s` - 在参数`%s`中发现非法字符; 合法范围是`%s`。 ### -1101 TOO_MANY_PARAMETERS - 为此端点发送的参数太多。 - 参数太多; 预期为`%s`并收到了`%s`。 - 检测到的参数值重复。 ### -1102 MANDATORY_PARAM_EMPTY_OR_MALFORMED - 未发送强制性参数,该参数为空/空或格式错误。 - 强制参数`%s`未发送,为空/空或格式错误。 - 必须发送参数`%s`或`%s`,但两者均为空! ### -1103 UNKNOWN_PARAM - 发送了未知参数。 ### -1104 UNREAD_PARAMETERS - 并非所有发送的参数都被读取。 - 并非所有发送的参数都被读取; 读取了`%s`参数,但被发送了`%s`。 ### -1105 PARAM_EMPTY - 参数为空。 - 参数`%s`为空。 ### -1106 PARAM_NOT_REQUIRED - 不需要时已发送参数。 - 不需要时发送参数`%s`。 ### -1111 BAD_PRECISION - 精度超过为此资产定义的最大值。 ### -1112 NO_DEPTH - 交易对没有挂单。 ### -1114 TIF_NOT_REQUIRED - 不需要时发送了TimeInForce参数。 ### -1115 INVALID_TIF - 无效 timeInForce. ### -1116 INVALID_ORDER_TYPE - 无效订单类型。 ### -1117 INVALID_SIDE - 无效买卖方向。 ### -1118 EMPTY_NEW_CL_ORD_ID - 新的客户订单ID为空。 ### -1119 EMPTY_ORG_CL_ORD_ID - 客户自定义的订单ID为空。 ### -1120 BAD_INTERVAL - 无效时间间隔。 ### -1121 BAD_SYMBOL - 无效的交易对。 ### -1125 INVALID_LISTEN_KEY - 该listenKey不存在。 ### -1127 MORE_THAN_XX_HOURS - 查询间隔太大。 - 从开始时间到结束时间之间超过%s小时。 ### -1128 OPTIONAL_PARAMS_BAD_COMBO - 可选参数组合无效。 ### -1130 INVALID_PARAMETER - 发送的参数为无效数据。 - 发送参数`%s`的数据无效。 ### -1131 BAD_RECV_WINDOW - `recvWindow` 必须小于 60000 ### -1134 BAD_STRATEGY_TYPE - `strategyType` 必须小于 1000000 #### -1145 INVALID_CANCEL_RESTRICTIONS - `cancelRestrictions` 必须是 `ONLY_NEW` 或者 `ONLY_PARTIALLY_FILLED`。 #### -1151 重复的交易对 - Symbol is present multiple times in the list. ### -2010 NEW_ORDER_REJECTED - 新订单被拒绝 ### -2011 CANCEL_REJECTED - 取消订单被拒绝 ### -2013 NO_SUCH_ORDER - 订单不存在。 ### -2014 BAD_API_KEY_FMT - API-key 格式无效。 ### -2015 REJECTED_MBX_KEY - 无效的API密钥,IP或操作权限。 ### -2016 NO_TRADING_WINDOW - 找不到该交易对的交易窗口。 尝试改为24小时自动报价。 #### -2026 ORDER_ARCHIVED - 订单已被存档因为此订单被取消或过期,无交易数量而最后的更新已超过 90 天前。 ## 3xxx-5xxx SAPI 具体问题 ### -3000 INNER_FAILURE - 内部服务器错误。 ### -3001 NEED_ENABLE_2FA - 请先启用2FA。 ### -3002 ASSET_DEFICIENCY - 此资产不存在。 ### -3003 NO_OPENED_MARGIN_ACCOUNT - 杠杆账户不存在。 ### -3004 TRADE_NOT_ALLOWED - 禁止交易。 ### -3005 TRANSFER_OUT_NOT_ALLOWED - 不允许转账。 ### -3006 EXCEED_MAX_BORROWABLE - 您的已借金额已超过最高可借金额。 ### -3007 HAS_PENDING_TRANSACTION - 您有待处理的交易,请稍后再试。 ### -3008 BORROW_NOT_ALLOWED - 不允许借款。 ### -3009 ASSET_NOT_MORTGAGEABLE - 此资产目前不允许转入杠杆账户。 ### -3010 REPAY_NOT_ALLOWED - 不允许还款。 ### -3011 BAD_DATE_RANGE - 您输入的日期无效。 ### -3012 ASSET_ADMIN_BAN_BORROW - 此资产禁止借款。 ### -3013 LT_MIN_BORROWABLE - 借入金额少于最低借入金额。 ### -3014 ACCOUNT_BAN_BORROW - 此帐户禁止借款。 ### -3015 REPAY_EXCEED_LIABILITY - 还款额超过借款额。 ### -3016 LT_MIN_REPAY - 还款额少于最低还款额。 ### -3017 ASSET_ADMIN_BAN_MORTGAGE - 此资产目前不允许转入保证金账户。 ### -3018 ACCOUNT_BAN_MORTGAGE - 此帐户已禁止转入。 ### -3019 ACCOUNT_BAN_ROLLOUT - 此帐户禁止转出。 ### -3020 EXCEED_MAX_ROLLOUT - 转出金额超过上限。 ### -3021 PAIR_ADMIN_BAN_TRADE - 杠杆账户无法交易此交易对。 ### -3022 ACCOUNT_BAN_TRADE - 账号被禁止交易。 ### -3023 WARNING_MARGIN_LEVEL - 无法在当前杠杆倍数下转出资金或者下单 ### -3024 FEW_LIABILITY_LEFT - 付款之后未付款的债务太小 ### -3025 INVALID_EFFECTIVE_TIME - 输入时间有误。 ### -3026 VALIDATION_FAILED - 输入参数有误。 ### -3027 NOT_VALID_MARGIN_ASSET - 无效的杠杆资产。 ### -3028 NOT_VALID_MARGIN_PAIR - 无效的杠杆交易对。 ### -3029 TRANSFER_FAILED - 转账失败。 ### -3036 ACCOUNT_BAN_REPAY - 此账号无法还款。 ### -3037 PNL_CLEARING - `PNL`正在清帐,请稍等。 ### -3038 LISTEN_KEY_NOT_FOUND - 找不到`Listen key` ### -3041 BALANCE_NOT_CLEARED - 余额不足 ### -3042 PRICE_INDEX_NOT_FOUND - 该杠杆交易对无可用价格指数。 ### -3043 TRANSFER_IN_NOT_ALLOWED - 不允许转入。 ### -3044 SYSTEM_BUSY - 系统繁忙。 ### -3045 SYSTEM - 系统目前没有足够可借的资产。 ### -3999 NOT_WHITELIST_USER - 此功能只面向邀请的用户。 ### -4001 CAPITAL_INVALID - 非法操作 ### -4002 CAPITAL_IG - 非法获取 ### -4003 CAPITAL_IEV - 非法邮箱验证 ### -4004 CAPITAL_UA - 未登录或者认证。 ### -4005 CAPAITAL_TOO_MANY_REQUEST - 请求太频繁。 ### -4006 CAPITAL_ONLY_SUPPORT_PRIMARY_ACCOUNT - 只支持主账号。 ### -4007 CAPITAL_ADDRESS_VERIFICATION_NOT_PASS - 地址的没有通过校验。 ### -4008 CAPITAL_ADDRESS_TAG_VERIFICATION_NOT_PASS - 地址的标记信息(`tag`)没有通过校验。 ### -4010 CAPITAL_WHITELIST_EMAIL_CONFIRM - 确认电子邮件已经列入白名单。 ### -4011 CAPITAL_WHITELIST_EMAIL_EXPIRED - 列入白名单的电子邮件无效。 ### -4012 CAPITAL_WHITELIST_CLOSE - 白名单未打开。 ### -4013 CAPITAL_WITHDRAW_2FA_VERIFY - 2FA未打开。 ### -4014 CAPITAL_WITHDRAW_LOGIN_DELAY - 在登录后的2分钟之内不允许提款。 ### -4015 CAPITAL_WITHDRAW_RESTRICTED_MINUTE - 暂停提款 ### -4016 CAPITAL_WITHDRAW_RESTRICTED_PASSWORD - 在密码修改后的24小时之内不允许提款。 ### -4017 CAPITAL_WITHDRAW_RESTRICTED_UNBIND_2FA - 在2FA发行后的24小时之内不允许提款。 ### -4018 CAPITAL_WITHDRAW_ASSET_NOT_EXIST - 此资产不存在。 ### -4019 CAPITAL_WITHDRAW_ASSET_PROHIBIT - 此资产不允许提款。 ### -4021 CAPITAL_WITHDRAW_AMOUNT_MULTIPLE - 资产的提款数量必须是%s的%s倍。 ### -4022 CAPITAL_WITHDRAW_MIN_AMOUNT - 不须少于最低的提款数量%s。 ### -4023 CAPITAL_WITHDRAW_MAX_AMOUNT - 在24小时之内,不须超过最高的提款数量。 ### -4024 CAPITAL_WITHDRAW_USER_NO_ASSET - 当前用户没有此资产。 ### -4025 CAPITAL_WITHDRAW_USER_ASSET_LESS_THAN_ZERO - 持有资产的数量小于零。 ### -4026 CAPITAL_WITHDRAW_USER_ASSET_NOT_ENOUGH - 此资产余额不足。 ### -4027 CAPITAL_WITHDRAW_GET_TRAN_ID_FAILURE - 无法获取tranId。 ### -4028 CAPITAL_WITHDRAW_MORE_THAN_FEE - 提款金额必须多于佣金额。 ### -4029 CAPITAL_WITHDRAW_NOT_EXIST - 此提款记录不存在。 ### -4030 CAPITAL_WITHDRAW_CONFIRM_SUCCESS - 提款资产成功。 ### -4031 CAPITAL_WITHDRAW_CANCEL_FAILURE - 取消提款失败。 ### -4032 CAPITAL_WITHDRAW_CHECKSUM_VERIFY_FAILURE - 验证提款失败。 ### -4033 CAPITAL_WITHDRAW_ILLEGAL_ADDRESS - 提款地址不合法。 ### -4034 CAPITAL_WITHDRAW_ADDRESS_CHEAT - 当前地址有异常。 ### -4035 CAPITAL_WITHDRAW_NOT_WHITE_ADDRESS - 此地址不在白名单上。请加入然后重试。 ### -4036 CAPITAL_WITHDRAW_NEW_ADDRESS - 新地址在{0}小时后才可以提款。 ### -4037 CAPITAL_WITHDRAW_RESEND_EMAIL_FAIL - 重新发送邮件失败。 ### -4038 CAPITAL_WITHDRAW_RESEND_EMAIL_TIME_OUT - 请5分钟后重试。 ### -4039 CAPITAL_USER_EMPTY - 用户不存在。 ### -4041 CAPITAL_MINUTE_TOO_SMALL - 请一分钟后重试。 ### -4042 CAPITAL_CHARGE_NOT_RESET - 资产无法重新获取存款地址。 ### -4043 CAPITAL_ADDRESS_TOO_MUCH - 在24小时之内充值超过100多个地址。 ### -4044 CAPITAL_BLACKLIST_COUNTRY_GET_ADDRESS - 此国家在黑名单上。 ### -4045 CAPITAL_GET_ASSET_ERROR - 获得资产失败。 ### -4046 CAPITAL_AGREEMENT_NOT_CONFIRMED - 协议未确认。 ### -4047 CAPITAL_DATE_INTERVAL_LIMIT - 时间间隔必须在0-90天之内 ### -4060 CAPITAL_WITHDRAW_USER_ASSET_LOCK_DEPOSIT - 体现仍在区块确认中,暂时锁定部分资产 ### -4106 TAG_NOT_SUPPORTED_FOR_NETWORK - 该网络不支持 memo/tag。请移除 `addressTag` 字段后重试。 ### -5001 ASSET_DRIBBLET_CONVERT_SWITCH_OFF - 不允许转移到微型资产。 ### -5002 ASSET_ASSET_NOT_ENOUGH - 此余额不足。 ### -5003 ASSET_USER_HAVE_NO_ASSET - 此资产不存在。 ### -5004 USER_OUT_OF_TRANSFER_FLOAT - 剩余余额已超过0.001BTC,请重新选择。 - %s的剩余余额已超过0.001BTC,请重新选择。 ### -5005 USER_ASSET_AMOUNT_IS_TOO_LOW - BTC的剩余余额太低,请重新选择。 - %s的剩余余额太低,请重新选择。 ### -5006 USER_CAN_NOT_REQUEST_IN_24_HOURS - 24小时内只能转账一次。 ### -5007 AMOUNT_OVER_ZERO - 数量必须大于零。 ### -5008 ASSET_WITHDRAW_WITHDRAWING_NOT_ENOUGH - 可退回资产的金额不足。 ### -5009 PRODUCT_NOT_EXIST - 产品不存在。 ### -5010 TRANSFER_FAIL - 资产转移失败。 ### -5011 FUTURE_ACCT_NOT_EXIST - 合约帐户不存在。 ### -5012 TRANSFER_PENDING - 资产转移正在进行中。 ### -5021 PARENT_SUB_HAVE_NO_RELATION - 当前的子账户和母账户没有从属关系。 ### -5012 FUTURE_ACCT_OR_SUBRELATION_NOT_EXIST - 合约帐户或子账户关系不存在。 ## 6XXX - 币安宝相关 ### -6001 DAILY_PRODUCT_NOT_EXIST - 理财产品不存在. ### -6003 DAILY_PRODUCT_NOT_ACCESSIBLE - 产品不存在或者没有权限。 ### -6004 DAILY_PRODUCT_NOT_PURCHASABLE - 产品无法购买。 ### -6005 DAILY_LOWER_THAN_MIN_PURCHASE_LIMIT - 低于可以购买的最小限额。 ### -6006 DAILY_REDEEM_AMOUNT_ERROR - 赎回额度有误。 ### -6007 DAILY_REDEEM_TIME_ERROR - 不在赎回的时间内。 ### -6008 DAILY_PRODUCT_NOT_REDEEMABLE - 产品暂时无法赎回。 ### -6009 REQUEST_FREQUENCY_TOO_HIGH - 发送请求太频繁。 ### -6011 EXCEEDED_USER_PURCHASE_LIMIT - 超购每个月用户可以申购的最大次数。 ### -6012 BALANCE_NOT_ENOUGH - 余额不足。 ### -6013 PURCHASING_FAILED - 申购失败。 ### -6014 UPDATE_FAILED - 超过可以申购的最大上限。 ### -6015 EMPTY_REQUEST_BODY - 请求的`body`为空。 ### -6016 PARAMS_ERR - 请求的参数有误。 ### -6017 NOT_IN_WHITELIST - 不在白名单里面。 ### -6018 ASSET_NOT_ENOUGH - 资产不足。 ### -6019 PENDING - 需要进一步确认。 ### -6020 PROJECT_NOT_EXISTS - 此项目不存在。 ## 70xx - 期货 ### -7001 FUTURES_BAD_DATE_RANGE - 此日期范围不支持。 ### -7002 FUTURES_BAD_TYPE - 此数据请求类型不支持。 ## 20xxx - 合约/现货策略交易 ### -20121 Invalid symbol - 无效交易对。 ### -20124 Invalid algo id or it has been completed - 无效的策略订单ID或者它已经被执行。 ### -20130 Invalid data sent for a parameter - 无效数据。 ### -20132 The client algo id is duplicated - 用户自定义策略订单ID重复。 ### -20194 Duration is too short to execute all required quantity - Duration 时间太短不足以执行用户选择的订单数量。 ### -20195 The total size is too small - 下单数量太小。 ### -20196 The total size is too large - 下单数量太大。 ### -20198 Reach the max open orders allowed - 达到了最大挂单上限。 ### -20204 The notional of USD is less or more than the limit - 订单小于最小USD名义价值 ## 过滤器故障 | 报错信息 | 描述 | | ------------------------------------------ | ---------------------------------------------------------------------------------- | | "Filter failure: PRICE_FILTER" | "价格"过高,过低和/或不遵循交易对的最小价格规则。 | | "Filter failure: PERCENT_PRICE" | "价格"比最近Y分钟的平均加权价格高X%或X%太低。 | | "Filter failure: PERCENT_PRICE_BY_SIDE" | `price` 在当前方向上(`BUY`或者`SELL`)比`lastPrice`价格超过X%或者低于Y%。 | | "Filter failure: LOT_SIZE" | "数量"太高,太低和/或不遵循该交易对的步长规则。 | | "Filter failure: MIN_NOTIONAL" | 价格\*数量太低,无法成为该交易对的有效订单。 | | "Filter failure: ICEBERG_PARTS" | `ICEBERG` 订单会分成太多部分; icebergQty太小。 | | "Filter failure: MARKET_LOT_SIZE" | "MARKET"订单的"数量"过高,过低和/或未遵循交易对的步长规则。 | | "Filter failure: MAX_POSITION" | 达到账户的最大仓位限制。这包括了账户的余额总额,以及所有处于open的买单的数量总和。 | | "Filter failure: MAX_NUM_ORDERS" | 客户在交易对上有太多挂单。 | | "Filter failure: MAX_ALGO_ORDERS" | 账户有太多未平仓止损和/或在交易对上执行获利指令。 | | "Filter failure: MAX_NUM_ICEBERG_ORDERS" | 客户在交易对上有太多 iceberg 挂单。 | | "Filter failure: TRAILING_DELTA" | `trailingDelta` 值不在限定的范围内. | | "Filter failure: EXCHANGE_MAX_NUM_ORDERS" | 帐户上的交易所有太多挂单。 | | "Filter failure: EXCHANGE_MAX_ALGO_ORDERS" | 帐户有太多止损挂单和/或在交易所收取获利指令。 | ## 10xxx - 质押借币 ### -10001 SYSTEM_MAINTENANCE - 系统维护中,请稍后再试 ### -10002 INVALID_INPUT - 无效的输入参数 ### -10005 NO_RECORDS - 暂无记录 ### -10007 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10008 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10009 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10010 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10011 INSUFFICIENT_ASSET - 现货资产不足 ### -10012 INVALID_AMOUNT - 无效的还款金额 ### -10013 INSUFFICIENT_AMOUNT - 抵押资产不足 ### -10015 DEDUCTION_FAILED - 抵押资产扣款失败 ### -10016 LOAN_FAILED - 放贷失败 ### -10017 REPAY_EXCEED_DEBT - 还款金额超过负债金额 ### -10018 INVALID_AMOUNT - 无效的还款金额 ### -10019 CONFIG_NOT_EXIST - 配置不存在 ### -10020 UID_NOT_EXIST - 用户ID不存在 ### -10021 ORDER_NOT_EXIST - 订单不存在 ### -10022 INVALID_AMOUNT - 无效的调整金额 ### -10023 ADJUST_LTV_FAILED - 调整质押率失败 ### -10024 ADJUST_LTV_NOT_SUPPORTED - 暂不支持调整质押率 ### -10025 REPAY_FAILED - 还款失败 ### -10026 INVALID_PARAMETER - 无效的参数 ### -10028 INVALID_PARAMETER - 无效的参数 ### -10029 AMOUNT_TOO_SMALL - 借贷金额过小 ### -10030 AMOUNT_TOO_LARGE - 借贷金额过大 ### -10031 QUOTA_REACHED - 已达到个人借贷限额 ### -10032 REPAY_NOT_AVAILABLE - 暂不支持换款 ### -10034 REPAY_NOT_AVAILABLE - 抵押物还款暂时不支持,请尝试用借贷币还款。 ### -10039 AMOUNT_TOO_SMALL - 还款金额过小 ### -10040 AMOUNT_TOO_LARGE - 还款金额过大 ### -10041 INSUFFICIENT_AMOUNT - 由于借贷需求过多,系统剩余可借{0}额度不足。请调整借贷金额或明天再试。 ### -10042 ASSET_NOT_SUPPORTED - 暂不支持%s币种 ### -10043 ASSET_NOT_SUPPORTED - 暂不支持{0} 借贷 ### -10044 QUOTA_REACHED - 抵押物数量已达到限额,请调整抵押金额或使用其他抵押资产。 ### -10045 COLLTERAL_REPAY_NOT_SUPPORTED - 该借贷币种暂不支持抵押物还款,请稍后再试。 ### -10046 EXCEED_MAX_ADJUSTMENT - 调整抵押物超过最大限额,请重试。 ### -10047 REGION_NOT_SUPPORTED - 受当地法规管制,您所在地区暂不支持该币种。 ## 13xxx - 杠杆代币 ### -13000 BLVT_FORBID_REDEEM - 当前该杠杆代币关闭赎回 ### -13001 BLVT_EXCEED_DAILY_LIMIT - 超过该代币个人24小时赎回金额上限 ### -13002 BLVT_EXCEED_TOKEN_DAILY_LIMIT - 超过该代币全局24小时赎回金额上限 ### -13003 BLVT_FORBID_PURCHASE - 当前该杠杆代币关闭申购 ### -13004 BLVT_EXCEED_DAILY_PURCHASE_LIMIT - 超过该代币个人24小时申购金额上限 ### -13005 BLVT_EXCEED_TOKEN_DAILY_PURCHASE_LIMIT - 超过该代币全局24小时申购金额上限 ### -13006 BLVT_PURCHASE_LESS_MIN_AMOUNT - 申购金额低于规定下限 ### -13007 BLVT_PURCHASE_AGREEMENT_NOT_SIGN - 没有签署开通交易协议 ## 12xxx - 流动性挖矿 ### -12014 TOO MANY REQUESTS - 2秒内接收的请求数量多于1条 ## 18xxx - 币安码 ### -18002 - The total amount of codes you created has exceeded the 24-hour limit, please try again after UTC 0 - 24小时内制码总金额已超过限额,请UTC0点后再尝试 ### -18003 - Too many codes created in 24 hours, please try again after UTC 0 - 24小时内制码总次数已超过限额,请UTC0点后再尝试 ### -18004 - Too many invalid redeem attempts in 24 hours, please try again after UTC 0 - 24小时内兑现币安码输错次数已超过限额,请UTC0点后再尝试 ### -18005 - Too many invalid verify attempts, please try later - 参考号输错次数过多,请稍后再试 ### -18006 - The amount is too small, please re-enter - 金额过小,请重新输入 ### -18007 - This token is not currently supported, please re-enter - 尚未支持该币种,请重新输入 ## 21xxx - 統一帳戶 ### -21001 USER_IS_NOT_UNIACCOUNT - 尚未开通统一账户。 ### -21002 UNI_ACCOUNT_CANT_TRANSFER_FUTURE - 统一账户禁用margin向futures转账。 ### -21003 NET_ASSET_MUST_LTE_RATIO - margin资产更新失败。 ### -21004 USER_NO_LIABILITY - 用户不存在统一账户穿仓负债 ### -21005 NO_ENOUGH_ASSET - 用户现货钱包BUSD资产不足以偿还统一账户穿仓负债 ### -21006 HAD_IN_PROCESS_REPAY - 用户存在正在偿还的统一账户穿仓负债 ### -21007 IN_FORCE_LIQUIDATION - 强平进行中,用户偿还统一账户穿仓负债失败 ## 订单拒绝错误 以下错误代码表示撮合引擎返回的订单相关错误: - `-1010 ERROR_MSG_RECEIVED` - `-2010 NEW_ORDER_REJECTED` - `-2011 CANCEL_REJECTED` 结合以下消息将指示特定的错误: | 错误信息 | 描述 | | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | "Unknown order sent." | 找不到订单(通过"orderId","clientOrderId","origClientOrderId") | | "Duplicate order sent." | `clientOrderId`已经被使用 | | "Market is closed." | 该交易对不在交易范围 | | "Account has insufficient balance for requested action." | 没有足够的资金来完成行动 | | "Market orders are not supported for this symbol." | 交易对上未启用"MARKET" | | "Iceberg orders are not supported for this symbol." | 交易对上未启用`icebergQty` | | "Stop loss orders are not supported for this symbol." | 交易对上未启用 `STOP_LOSS` | | "Stop loss limit orders are not supported for this symbol." | 交易对上未启`STOP_LOSS_LIMIT` | | "Take profit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT` | | "Take profit limit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT_LIMIT` | | "Price \* QTY is zero or less." | `price` \* `quantity`太小 | | "IcebergQty exceeds QTY." | `icebergQty` 必须少于订单数量 | | "This action is disabled on this account." | 联系客户支持; 该账户已禁用了某些操作。 | | "This account may not place or cancel orders." | 联系客户支持: 该账户已被禁用了交易操作。 | | "Unsupported order combination" | 不允许组合`orderType`, `timeInForce`, `stopPrice`, 和/或 `icebergQty` 。 | | "Order would trigger immediately." | 与最后交易价格相比,订单的止损价无效。 | | "Cancel order is invalid. Check origClientOrderId and orderId." | 未发送`origClientOrderId` 或`orderId` 。 | | "Order would immediately match and take." | `LIMIT_MAKER` 订单类型将立即匹配并进行交易,而不是纯粹的生成订单。 | | "The relationship of the prices for the orders is not correct." | `OCO`订单中设置的价格不符合报价规则:

The rules are:

`SELL Orders`: Limit Price > Last Price > Stop Price

`BUY Orders`: Limit Price < Last Price < Stop Price | | "OCO orders are not supported for this symbol" | `OCO`订单不支持该交易对 | | "Quote order qty market orders are not support for this symbol." | 这个交易对,市价单不支持参数`quoteOrderQty` | | "Trailing stop orders are not supported for this symbol." | 此symbol不支持 `trailingDelta` | | | "Order cancel-replace is not supported for this symbol." | 此symbol不支持 `POST /api/v3/order/cancelReplace` 或者 `order.cancelReplace` (WebSocket API) | | | "This symbol is not permitted for this account." | 账户和交易对的权限不一致 (比如 `SPOT`, `MARGIN` 等)。| | | "This symbol is restricted for this account." | 账户没有权限在此交易对交易 (比如账户只拥有 `ISOLATED_MARGIN`权限,则无法下`SPOT` 订单)。 | | | "Order was not canceled due to cancel restrictions." | `cancelRestrictions` 设置为 `ONLY_NEW` 但订单状态不是 `NEW`

`cancelRestrictions` 设置为 `ONLY_PARTIALLY_FILLED` 但订单状态不是 `PARTIALLY_FILLED`。 | | ## 关于 POST /api/v3/order/cancelReplace 的错误 ### -2021 Order cancel-replace partially failed 收到该错误码代表撤单**或者**下单失败。 ### -2022 Order cancel-replace failed. 收到该错误码代表撤单**和**下单都失败。 --- ## Document: /products/sub-account/change-log URL: /zh-CN/docs/products/sub-account/change-log # 更新日志 ## 2026-06-18 ### 时效性通知 - **更新:** `POST /sapi/v1/sub-account/futures/move-position`(子账户移仓接口)自 2026-06-18 起至 2026-06-30 (UTC) 期间不可用。窗口结束后自动恢复。 --- ## 2026-06-04 - 更新子账户接口: - `GET /sapi/v1/capital/deposit/subHisrec`:新增可选参数 `includeSource`,默认为 `false`,设为 `true` 时响应中将包含 `sourceAddress` 字段。 --- ## 2025-12-26 ### 时效性通知 - **以下有关于REST API变更将在 2026-01-15 07:OO UTC 发生:**
调用需要签名的接口时,请在计算签名之前对 payload 进行百分比编码(percent-encode)。不符合此顺序的请求将被拒绝,并返回错误代码 [`-1022 签名不正确`](./error-code.md#-1022-invalid_signature)。请检查并相应地更新您代码中的签名逻辑部分。 ### REST API - 更新了 REST API 文档中有关于 [签名请求示例](./general-info.md#post-apiv3order-的签名示例) 的部分。 --- ## 2025-09-17 - 更新 GET `/sapi/v1/sub-account/transaction-statistics` 接口 - 支持默认返回母账户的交易信息(不发送email参数) --- ## 2025-06-03 - 移除 POST `/sapi/v1/sub-account/blvt/enable` 与 POST `/sapi/v1/sub-account/margin/enable` 接口。 - 用户可划入首笔资金开启杠杆帐户。 --- ## 2025-04-30 - 更新子母账户划转接口:`POST /sapi/v1/sub-account/universalTransfer `支持`ALPHA` 划转到 `ALPHA` (无论母账户或子账户)。 --- ## 2025-04-08 - 更新子母账户接口请求权重(UID): - `POST /sapi/v1/sub-account/universalTransfer `请求权重(UID)更新為360。 --- ## 2025-03-26 - 新增子母账户移仓接口: - `POST /sapi/v1/sub-account/futures/move-position`: 支持母账户和子账户,子账户和子账户的移仓 - `GET /sapi/v1/sub-account/futures/move-position`: 获取账户移仓历史记录 ## 2024-11-22 - 更新託管子母账户接口: - GET `/sapi/v1/managed-subaccount/marginAsset`: 添加新的入参判定请求的杠杆帐户类型。 - GET `/sapi/v1/managed-subaccount/fetch-future-asset`: 添加新的入参判定请求的期货帐户类型。 --- ## 2024-11-04 - 更新子母账户接口: - `GET /sapi/v1/sub-account/universalTransfer `: 若 startTime 和 endTime 都未传,则只可查询最近7天的记录。查询时间范围最大不得超过7天。 --- ## 2024-10-24 - 更新子母账户接口: - `GET /sapi/v4/sub-account/assets ` 及 `GET /sapi/v3/sub-account/assets`: 新增 2 种资产类型 --- ## 2024-05-21 - 更新子母账户接口: - `GET /sapi/v1/sub-account/transfer/subUserHistory`: 更新返回字段`fromAccountType`和 `toAccountType`. 合约钱包划转时返回USDT_FUTURE/COIN_FUTURE以区分钱包 --- ## 2023-04-20 - 新增子母账户接口: - `GET /sapi/v1/managed-subaccount/deposit/address`:支持获取投资人之托管子账户充值地址 --- ## 2023-03-23 - 更新子母账户接口: - `GET /sapi/v1/managed-subaccount/queryTransLogForInvestor`: 响应出参增加字段`tranId` - `GET /sapi/v1/managed-subaccount/queryTransLogForTradeParent`: 响应出参增加字段`tranId` - 添加子母账户接口: - `GET /sapi/v1/managed-subaccount/info`: 查询托管子账户列表 - `GET /sapi/v1/sub-account/transaction-statistics`: 查询子账户交易量统计列表 --- ## 2023-02-13 - 添加子母账户接口: - `GET /sapi/v4/sub-account/assets`: 查询子账户资产 --- ## 2023-01-13 - 以下接口将于 1 月 13, 2023 6:00 AM UTC 停止使用: - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction` 以支持母账户为子账户 API Key 开启或关闭 IP 白名单 - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList` 以支持母账户为子账户 API Key 添加 IP 白名单地址列表 - 添加子母账户接口: - `GET /sapi/v1/managed-subaccount/fetch-future-asset`: Investor can use this api to query managed sub account futures asset details - `GET /sapi/v1/managed-subaccount/marginAsset`: Investor can use this api to query managed sub account margin asset details --- ## 2023-01-05 - 添加子母账户接口: - `GET /sapi/v1/managed-subaccount/queryTransLogForInvestor`: 投资人可以根据此接口查询其托管子账户划转记录 - `GET /sapi/v1/managed-subaccount/queryTransLogForTradeParent`: 交易团队可以根据此接口查询其托管子账户划转记录 --- ## 2022-11-18 - 新增子母账户接口: - `POST /sapi/v2/sub-account/subAccountApi/ipRestriction`: 为子账户 API Key 更新 IP 白名单 --- ## 2022-09-22 - 更新子母账户接口: - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction`:添加一个新的参数 `thirdParty` - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList`:添加一个新的参数 `thirdPartyName` - `DELETE /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList`:添加一个新的参数 `thirdPartyName` --- ## 2022-09-12 - 更新子母账户接口: \* `GET /sapi/v1/sub-account/subAccountApi/ipRestriction`:以支持母账户为子账户 API Key 查询三方 IP 白名单 --- ## 2022-06-02 - 更新子母账户接口: - `GET /sapi/v1/sub-account/sub/transfer/history`:fromEmail 及 toEmail 可以是母账户 email。 --- ## 2022-3-29 以下更新于**3 月 31, 2022 08:00 AM UTC**生效 - 更新子母账户接口: - `GET /sapi/v1/sub-account/universalTransfer` 接口查询时间窗口缩短为 30 天;若`startTime`和`endTime`没传,则默认返回最近 30 天数据。 --- ## 2022-03-25 - 更新子母账户接口: - 新增接口 `GET /sapi/v1/managed-subaccount/accountSnapshot`以支持投资人母账户查询托管子账户资产快照 --- ## 2022-03-08 - 更新子母账户接口: - 新增划转类型`MARGIN `,`ISOLATED_MARGIN `以及传参`symbol`于子母账户万能划转接口`POST /sapi/v1/sub-account/universalTransfer` 以支持母账户现货账户划转到子账户杠杆全仓账户和杠杆逐仓账户 --- ## 2022-2-18 - 更新子母账户接口: - 新增响应参数 `isManagedSubAccount`和 `isAssetManagementSubAccount` 于接口 `GET /sapi/v1/sub-account/list` 以支持查询子账户是否是托管子账户或资产管理子账户 --- ## 2021-12-24 - 更新子母账户接口: - 新增传参`clientTranId`于子母账户万能划转接口`POST /sapi/v1/sub-account/universalTransfer` 和查询子母账户万能划转历史接口 `GET /sapi/v1/sub-account/universalTransfer` 以支持用户自定义划转 id --- ## 2021-11-16 - 新增子母账户接口: - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction` 以支持母账户为子账户 API Key 开启或关闭 IP 白名单 - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList` 以支持母账户为子账户 API Key 添加 IP 白名单地址列表 - `GET /sapi/v1/sub-account/subAccountApi/ipRestriction` 以支持母账户为子账户 API Key 查询 IP 白名单 - `DELETE /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList` 以支持母账户为子账户 API Key 删除 IP 白名单地址列表 --- ## 2021-07-29 - 子母账户接口更新: - `GET /sapi/v1/sub-account/transfer/subUserHistory` 如果`startTime`和`endTime`均未发送,默认只返回最近 30 天数据 --- ## 2021-06-15 - 新增子母账户接口: - `POST /sapi/v1/managed-subaccount/deposit ` 以支持投资人账户为托管子账户充值资产(仅投资人账户方使用) - `GET /sapi/v1/managed-subaccount/asset` 以支持投资人账户查询托管子账户资产(仅投资人账户方使用) - `POST /sapi/v1/managed-subaccount/withdraw`以支持投资人账户为托管子账户提币资产(仅投资人账户方使用) --- ## 2021-04-08 - 子母账户接口更新: - `GET /sapi/v1/sub-account/futures/accountSummary` 和 `GET /sapi/v2/sub-account/futures/accountSummary` 接口返回字段`asset` 更新为以 USD 计价的资产汇总,即子账户 USDT,BUSD 等保证金总和 --- ## 2021-04-01 - 子母账户接口更新: - `GET /sapi/v1/sub-account/transfer/subUserHistory` 新增返回字段 `fromAccountType` 和 `toAccountType`为用户转出账户类型和转入账户类型 --- ## 2021-03-31 - 子母账户接口更新: - `GET /wapi/v3/sub-account/transfer/history.html` 新增参数 `fromEmail` 和 `toEmail`,原有参数`email` 将默认查询`fromEmail`的记录 --- ## 2021-03-08 - 新增子母账户接口: - `POST /sapi/v1/sub-account/virtualSubAccount` 以支持母账户创建虚拟子账户 - `GET /sapi/v1/sub-account/list` 以支持查询子账户列表 - `POST /sapi/v1/sub-account/blvt/enable` 以支持为子账户开通杠杆代币 --- ## 2020-12-22 - 新增子母账户接口: - `GET /sapi/v1/sub-account/sub/transfer/history` 以支持查询子母账户现货资金划转历史。 --- ## 2020-12-02 - 新增子母账户接口: - `GET /sapi/v2/sub-account/futures/account` 以支持查询子账户 USDT 合约和币本位合约账户详情。 - `GET /sapi/v2/sub-account/futures/accountSummary` 以支持查询子账户 USDT 合约和币本位合约账户汇总。 - `GET /sapi/v2/sub-account/futures/positionRisk` 以支持查询子账户 USDT 合约和币本位合约持仓信息。 --- ## 2020-11-13 - 新增子母账户接口: - `POST /sapi/v1/sub-account/universalTransfer` 以支持子母账户,现货和合约账户之间相互划转。 - `GET /sapi/v1/sub-account/universalTransfer` 以查询划转记录。 --- ## 2020-11-09 - 新增返回字段 `tranId` 于子母账户接口: - `GET /sapi/v1/sub-account/futures/internalTransfer` - `GET /sapi/v1/sub-account/transfer/subUserHistory` --- ## 2020-10-10 - 子母账户接口`POST /sapi/v1/sub-account/futures/transfer`新增划转类型`type` 以支持子账户现货账户和币本位合约账户间相互划转。 --- ## 2020-09-03 - 新增子母账户接口`POST /sapi/v1/sub-account/futures/internalTransfer` 以执行子账户合约资金直接划转。 - 新增子母账户接口`GET /sapi/v1/sub-account/futures/internalTransfer` 以查询子账户合约资金直接划转历史。 --- ## 2020-09-01 - 子母账户接口`GET /sapi/v1/sub-account/spotSummary` 返回内容中新增字段 `masterAccountTotalAsset`以获取 BTC 计价的母账户资产。 --- ## 2020-08-27 - 新增接口 `GET /sapi/v1/sub-account/spotSummary` 以获取 BTC 计价的子账户现货资产汇总。 --- ## 2020-02-05 - 新增子账户相关接口: - `POST /sapi/v1/sub-account/futures/transfer`: 对子账户实施 futures 账户划转 - `POST /sapi/v1/sub-account/margin/transfer`: 对子账户实施 margin 账户划转 - `POST /sapi/v1/sub-account/transfer/subToSub`: 向兄弟子账户划转 - `POST /sapi/v1/sub-account/transfer/subToMaster`: 向母账户划转 - `GET /sapi/v1/sub-account/transfer/subUserHistory`: 子账户获取自身划转历史 --- ## 2019-11-08 - 新增以下 sapi 接口用以管理子账户的杠杆与期货: - `GET /sapi/v1/sub-account/status (HMAC SHA256)` - `POST /sapi/v1/sub-account/margin/enable (HMAC SHA256)` - `GET /sapi/v1/sub-account/margin/account (HMAC SHA256)` - `GET /sapi/v1/sub-account/margin/accountSummary (HMAC SHA256)` - `POST /sapi/v1/sub-account/futures/enable (HMAC SHA256)` - `GET /sapi/v1/sub-account/futures/account (HMAC SHA256)` - `GET /sapi/v1/sub-account/futures/accountSummary (HMAC SHA256)` - `GET /sapi/v1/sub-account/futures/positionRisk (HMAC SHA256)` --- ## 2019-11-04 - 新增管理子账户充值功能相关的 sapi 接口 - `GET /sapi/v1/capital/deposit/subAddress (HMAC SHA256))`: 获取子账户充值地址。 - `GET /sapi/v1/capital/deposit/subHisrec (HMAC SHA256))`: 获取子账户充值记录。 --- ## 2019-11-19 - `GET /sapi/v1/sub-account/margin/account` 返回内容新增: `marginTradeCoeffVo` 其中包括 - `forceLiquidationBar`: 强平风险率; - `marginCallBar`: 补仓风险率; - `normalBar`: 初始风险率 --- ## Document: /products/sub-account/Introduction URL: /zh-CN/docs/products/sub-account/Introduction 子账户接口接口用于与子账户等功能交互。更多细节, 请参考[币安子账户功能FAQ](https://www.binance.com/zh-CN/support/faq/%E5%B8%81%E5%AE%89%E5%AD%90%E8%B4%A6%E6%88%B7%E5%8A%9F%E8%83%BD%E5%8F%8A%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E8%A7%A3%E7%AD%94-360020632811)页面。 --- ## Document: /products/staking/quick-start URL: /zh-CN/docs/products/staking/quick-start # 快速开始 ## API Key 权限设置 - 新创建的API的默认权限是 `只读`。 - 如果需要通过API提款, 需要在UI修改权限, 选中 `允许提现`。 ## 账户 ### 现货账户 新注册的币安账号都会有一个现货(`SPOT`)账号。 ### 杠杆账户 为了开设杠杆(`MARGIN`)账户, 可以参考[Binance杠杆交易账户设置指南](https://www.binance.vision/zh/tutorials/binance-margin-trading-guide) ## API 代码库 ### Connectors 以下有一些轻量级的代码库,使不同语言的用户能够直接调用现货的 Binance 公共 API: - Python [https://github.com/binance/binance-connector-python](https://github.com/binance/binance-connector-python) - JavaScript [https://github.com/binance/binance-connector-js](https://github.com/binance/binance-connector-js) - Ruby [https://github.com/binance/binance-connector-ruby](https://github.com/binance/binance-connector-ruby) - DotNET C# [https://github.com/binance/binance-connector-dotnet](https://github.com/binance/binance-connector-dotnet) - Java [https://github.com/binance/binance-connector-java](https://github.com/binance/binance-connector-java) - Rust [https://github.com/binance/binance-spot-connector-rust](https://github.com/binance/binance-spot-connector-rust) - PHP [https://github.com/binance/binance-connector-php](https://github.com/binance/binance-connector-php) - Go [https://github.com/binance/binance-connector-go](https://github.com/binance/binance-connector-go) ### Postman Collections Postman 集合现已推出。推荐给寻求快速和轻松地开始使用 API 的新用户。 [https://github.com/binance/binance-api-postman](https://github.com/binance/binance-api-postman) ### Swagger 以下有提供包含 RESTful API 的 OpenAPI 规范的 YAML 文件,以及可供参考的 Swagger UI 页面。 [https://github.com/binance/binance-api-swagger](https://github.com/binance/binance-api-swagger) --- ## Document: /products/staking/general-info URL: /zh-CN/docs/products/staking/general-info # 基本信息 ## API 基本信息 - 接口可能需要用户的 API Key,如何创建API-KEY请参考[这里](https://www.binance.com/cn/support/articles/360002502072) - 本篇列出接口的 base URL 有: - **https://api.binance.com** - **https://api-gcp.binance.com** - **https://api1.binance.com** - **https://api2.binance.com** - **https://api3.binance.com** - **https://api4.binance.com** - 上述列表的最后4个接口 (`api1`-`api4`) 可能会提供更好的性能,但其稳定性略为逊色。因此,请务必使用最适合您现有配置的那款。 - 所有接口的响应都是 JSON 格式。 - 响应中如有数组,数组元素以时间**升序**排列,越早的数据越提前。 - 所有时间、时间戳均为UNIX时间,单位为**毫秒**。 ### HTTP 返回代码 - HTTP `4XX` 错误码用于指示错误的请求内容、行为、格式。问题在于请求者。 - HTTP `403` 错误码表示违反WAF限制(Web应用程序防火墙)。 - HTTP `409` 错误码表示重新下单(cancelReplace)的请求部分成功。(比如取消订单失败,但是下单成功了) - HTTP `429` 错误码表示警告访问频次超限,即将被封IP。 - HTTP `418` 表示收到429后继续访问,于是被封了。 - HTTP `5XX` 错误码用于指示Binance服务侧的问题。 ### 接口错误代码 - 使用接口 `/api/v3`, 以及 `/sapi/v1/margin`时, 每个接口都有可能抛出异常; > API 与 SAPI 的错误代码返回形式如下: ```javascript { "code": -1121, "msg": "Invalid symbol." } ``` - 具体的错误码及其解释在 [错误代码](./error-code). ### 接口的基本信息 - `GET` 方法的接口, 参数必须在 `query string`中发送。 - `POST`, `PUT`, 和 `DELETE` 方法的接口,参数可以在内容形式为`application/x-www-form-urlencoded`的 `query string` 中发送,也可以在 `request body` 中发送。 如果你喜欢,也可以混合这两种方式发送参数。 - 对参数的顺序不做要求。 - 但如果同一个参数名在query string和request body中都有,query string中的会被优先采用。 --- ## 访问限制 ### 访问限制基本信息 - 以下 是`intervalLetter` 作为头部值: - SECOND => S - MINUTE => M - HOUR => H - DAY => D - 在 `/api/v3/exchangeInfo` `rateLimits` 数组中包含与交易的有关RAW_REQUESTS,REQUEST_WEIGHT和ORDERS速率限制相关的对象。这些在 `限制种类 (rateLimitType)` 下的 `枚举定义` 部分中进一步定义。 - 违反任何一个速率限制时(访问频次限制或下单速率限制),将返回429。 ### IP 访问限制 - 每个请求将包含一个`X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,其中包含当前IP所有请求的已使用权重。 - 每一个接口均有一个相应的权重(weight),有的接口根据参数不同可能拥有不同的权重。越消耗资源的接口权重就会越大。 - 收到429时,您有责任停止发送请求,不得滥用API。 - **收到429后仍然继续违反访问限制,会被封禁IP,并收到418错误码** - 频繁违反限制,封禁时间会逐渐延长,**从最短2分钟到最长3天**。 - `Retry-After`的头会与带有418或429的响应发送,并且会给出**以秒为单位**的等待时长(如果是429)以防止禁令,或者如果是418,直到禁令结束。 - **访问限制是基于IP的,而不是API Key** ###下单频率限制 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - 当下单数超过限制时,会收到带有429但不含`Retry-After`头的响应。请检查 `GET api/v3/exchangeInfo` 的下单频率限制 (rateLimitType = ORDERS) 并等待封禁时间结束。 - 被拒绝或不成功的下单并不保证回报中包含以上头内容。 - **下单频率限制是基于每个账户计数的。** - 用户可以通过接口 `GET api/v3/rateLimit/order` 来查询当前的下单量. ### WEB SOCKET 连接限制 - Websocket服务器每秒最多接受5个消息。消息包括: - PING帧 - PONG帧 - JSON格式的消息, 比如订阅, 断开订阅. - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅 **1024** 个Streams。 - 每IP地址、每5分钟最多可以发送300次连接请求。 ### /api/ 与 /sapi/ 接口限频说明 `/api/*`接口和 `/sapi/*`接口采用两套不同的访问限频规则, 两者互相独立。 - `/api/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以 `/api/*`开头的接口按IP限频,**且所有接口共用每分钟6,000限制**。 - 每个请求将包含一个 `X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,包含当前IP所有请求的已使用权重。 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - `/sapi/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以`/sapi/*`开头的接口采用**单接口限频模式**。按IP统计的权重单接口权重总额为每分钟12000;按照UID统计的单接口权重总额是每分钟180000。 - 每个接口会标明是按照IP或者按照UID统计, 以及相应请求一次的权重值。 - 按照IP统计的接口, 请求返回头里面会包含`X-SAPI-USED-IP-WEIGHT-1M=`或`X-SAPI-USED-IP-WEIGHT-1S=`, 包含当前IP所有请求已使用权重。 - 按照UID统计的接口, 请求返回头里面会包含`X-SAPI-USED-UID-WEIGHT-1M=`或`X-SAPI-USED-UID-WEIGHT-1S=`, 包含当前账户所有已用的UID权重。 --- ## 数据来源 - 因为API系统是异步的, 所以返回的数据有延时很正常, 也在预期之中。 - 在每个接口中,都列出了其数据的来源,可以用于理解数据的时效性。 系统一共有3个数据来源,按照更新速度的先后排序。排在前面的数据最新,在后面就有可能存在延迟。 - **撮合引擎** - 表示数据来源于撮合引擎 - **缓存** - 表示数据来源于内部或者外部的缓存 - **数据库** - 表示数据直接来源于数据库 ## 请求鉴权类型 - 每个接口都有一个鉴权类型,指示所需的 API 密钥权限,显示在接口名称旁边(例如,[下新订单 (TRADE)](#place-new-order-trade))。 - 如果未指定,则鉴权类型为 `NONE`。 - 除了为 `NONE` 外,所有具有鉴权类型的接口均视为 `SIGNED` 请求(即包含 `signature`),[listenKey 管理](#user-data-stream-requests) 除外。 - 具有鉴权类型的接口需要提供有效的 API 密钥并验证通过。 - API 密钥可在您的 Binance 账户的 [API 管理](https://www.binance.com/en/support/faq/360002502072) 页面创建。 - **API 密钥和密钥对均为敏感信息,切勿与他人分享。** 如果发现账户有异常活动,请立即撤销所有密钥并联系 Binance 支持。 - API 密钥可配置为仅允许访问某些鉴权接口。 - 例如,您可以拥有具有 `TRADE` 权限的 API 密钥用于交易,同时使用具有 `USER_DATA` 权限的另一个 API 密钥来监控订单状态。 - 默认情况下,API 密钥无法进行 `TRADE`,您需要先在 API 管理中启用交易权限。 | 鉴权类型 | 描述 | | ----------- | ------------------------- | | NONE | 不需要鉴权的接口 | | TRADE | 需要有效的 API-Key 和签名 | | MARGIN | 需要有效的 API-Key 和签名 | | USER_DATA | 需要有效的 API-Key 和签名 | | USER_STREAM | 需要有效的 API-Key | | MARKET_DATA | 需要有效的 API-Key | ### 需要签名的接口 - 调用`SIGNED` 接口时,除了接口本身所需的参数外,还需要在 `query string` 或 `request body` 中传递 `signature`, 即签名参数。 #### 签名是否是大小写敏感的 - **HMAC:** 使用 HMAC 生成的签名**不区分大小写**。这意味着无论字母大小写如何,签名字符串都可以被验证。 - **RSA:** 使用 RSA 生成的签名是**大小写敏感的**。 - **Ed25519:** 使用 Ed25519 生成的签名也是**大小写敏感的**。 请参阅[已签名请求示例 (HMAC)](#hmac-keys)、[已签名请求示例 (RSA)](#rsa-keys) 和[已签名请求示例 (Ed25519)](#ed25519-keys),了解如何根据您使用的 API 密钥类型计算签名。 ### 时间同步安全 - `SIGNED` 请求还需要一个 `timestamp` 参数,该参数应为当前时间戳,单位为毫秒或微秒。(参见 [通用 API 信息](#general-api-information)) - 另一个可选参数 `recvWindow`,用以指定请求的有效期,只能以毫秒为单位。 - `recvWindow` 扩展为三位小数(例如 6000.346),以便可以指定微秒。 - 如果未发送 `recvWindow`,则 **默认值为 5000 毫秒**。 - `recvWindow` 的最大值为 60000 毫秒。 - 请求处理逻辑如下: ```javascript serverTime = getCurrentTime() if (timestamp < (serverTime + 1 second) && (serverTime - timestamp) <= recvWindow) { // 开始处理请求 serverTime = getCurrentTime() if (serverTime - timestamp) <= recvWindow { // 将请求转发到撮合引擎 } else { // 拒绝请求 } // 结束处理请求 } else { // 拒绝请求 } ``` **关于交易时效性** 互联网状况并不100%可靠,不可完全依赖,因此你的程序本地到币安服务器的时延会有抖动. 这是我们设置`recvWindow`的目的所在,如果你从事高频交易,对交易时效性有较高的要求,可以灵活设置`recvWindow`以达到你的要求。 **不推荐使用5秒以上的recvWindow。最大值不能超过60秒!** ### POST /api/v3/order 的签名示例 #### HMAC Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 以下示例分步演示如何使用 `echo`、`openssl` 和 `curl` 从 Linux 命令行发送有效的签名 payload。其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 API 密钥和密钥示例: | Key | Value | | ----------- | ---------------------------------------------------------------- | | `apiKey` | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A | | `secretKey` | NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j | **警告:请勿与任何人分享您的 API 密钥和秘钥。** 此处提供的示例密钥仅用于示范说明目的。 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | LTCBTC | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` **第二步: 计算签名。** 1. 使用 API 密钥中的 `secretKey` 作为 HMAC-SHA-256 算法的签名密钥。 2. 对步骤 1 中构建的签名 payload 进行签名。 3. 将 HMAC-SHA-256 的输出编码为十六进制字符串。 请注意,`secretKey` 和 payload 是**大小写敏感的**,而生成的签名值是不区分大小写的。 **示例命令** 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71 ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n "symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3 ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71" ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3" ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash apiKey="vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" secretKey="NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" payload="symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" # 对请求进行签名 signature=$(echo -n "$payload" | openssl dgst -sha256 -hmac "$secretKey") signature=${signature#*= } # Keep only the part after the "= " # 发送请求 curl -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?$payload&signature=$signature" ``` #### RSA Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 要获取 API 密钥,您需要将 RSA 公钥上传到您的帐户中,系统将为您提供相应的 API 密钥。 仅支持 `PKCS#8` 密钥。 在以下示例中,其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 这些示例假设私钥存储在文件 `./test-prv-key.pem` 中。 | Key | Value | | -------- | ---------------------------------------------------------------- | | `apiKey` | CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ | 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | BTCUSDT | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` **第二步: 计算签名。** 1. 使用 RSASSA-PKCS1-v1_5 算法和 SHA-256 哈希函数对步骤 1 中构建的签名 payload 进行签名。 2. 将输出结果编码为 base64 格式。 请注意,payload 和生成的`签名值`是**大小写敏感的**。 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n 'symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' HZ8HOjiJ1s/igS9JA+n7+7Ti/ihtkRF5BIWcPIEluJP6tlbFM/Bf44LfZka/iemtahZAZzcO9TnI5uaXh3++lrqtNonCwp6/245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH+XxaCmR0WcvlKjNQnp12/eKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang/1WOq+Jaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT/fNnMRxFc7u+j3qI//5yuGuu14KR0MuQKKCSpViieD+fIti46sxPTsjSemoUKp0oXA== ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n 'symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' qJtv66wyp/1mZE+mIFAAMUoTe8xkmLN7/eAZjuC9x1ocxovItHLl/sNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M+JNIMz5UFxfeA53rXjFlvsyH1Sig+OuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C/QMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt/GuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng== ``` 3. 对 base64 格式的字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符): ```console HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D' ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D' ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash function rawurlencode { local string="${1}" local strlen=${#string} local encoded="" local pos c o for (( pos=0 ; pos 错误JSON格式: ```javascript { "code":-1121, "msg":"Invalid symbol." } ``` 错误由两部分组成:错误代码和消息。 代码是通用的,但是消息可能会有所不同。 ## 10xx -常规服务器或网络问题 ### -1000 UNKNOWN - 处理请求时发生未知错误。 - 处理请求时发生未知错误。[%s] ### -1001 DISCONNECTED - 内部错误; 无法处理您的请求。 请再试一次. ### -1002 UNAUTHORIZED - 您无权执行此请求。 ### -1003 TOO_MANY_REQUESTS - 排队的请求过多。 - 请求权重过多; 当前限制是 %s 每 %s 的请求权重。 请使用 Websocket Streams 进行实时更新,以避免轮询API。 - 请求权重过多; IP被禁止,直到%s。 请使用 Websocket Streams 进行实时更新,以免被禁。 ### -1004 SERVER_BUSY - 服务器正忙,请稍候再试。 ### -1006 UNEXPECTED_RESP - 从消息总线收到意外的响应。 执行状态未知。 ### -1007 TIMEOUT - 等待后端服务器响应超时。 发送状态未知; 执行状态未知。 ### -1008 SERVER_BUSY - 现货交易服务器当前因其他请求而过载。 请在几分钟后重试。 ### -1014 UNKNOWN_ORDER_COMPOSITION - 不支持的订单组合。 ### -1015 TOO_MANY_ORDERS - 新订单太多。 - 新订单太多; 当前限制为每%s %s个订单。 ### -1016 SERVICE_SHUTTING_DOWN - 该服务不可用。 ### -1020 UNSUPPORTED_OPERATION - 不支持此操作。 ### -1021 INVALID_TIMESTAMP - 此请求的时间戳在recvWindow之外。 - 此请求的时间戳比服务器时间提前1000毫秒。 ### -1022 INVALID_SIGNATURE - 此请求的签名无效。 ### -1099 Not found, authenticated, or authorized - 替换错误代码-1999 ## 11xx - 2xxx Request issues ### -1100 ILLEGAL_CHARS - 在参数中发现非法字符。 - 在参数中发现非法字符。`%s` - 在参数`%s`中发现非法字符; 合法范围是`%s`。 ### -1101 TOO_MANY_PARAMETERS - 为此端点发送的参数太多。 - 参数太多; 预期为`%s`并收到了`%s`。 - 检测到的参数值重复。 ### -1102 MANDATORY_PARAM_EMPTY_OR_MALFORMED - 未发送强制性参数,该参数为空/空或格式错误。 - 强制参数`%s`未发送,为空/空或格式错误。 - 必须发送参数`%s`或`%s`,但两者均为空! ### -1103 UNKNOWN_PARAM - 发送了未知参数。 ### -1104 UNREAD_PARAMETERS - 并非所有发送的参数都被读取。 - 并非所有发送的参数都被读取; 读取了`%s`参数,但被发送了`%s`。 ### -1105 PARAM_EMPTY - 参数为空。 - 参数`%s`为空。 ### -1106 PARAM_NOT_REQUIRED - 不需要时已发送参数。 - 不需要时发送参数`%s`。 ### -1111 BAD_PRECISION - 精度超过为此资产定义的最大值。 ### -1112 NO_DEPTH - 交易对没有挂单。 ### -1114 TIF_NOT_REQUIRED - 不需要时发送了TimeInForce参数。 ### -1115 INVALID_TIF - 无效 timeInForce. ### -1116 INVALID_ORDER_TYPE - 无效订单类型。 ### -1117 INVALID_SIDE - 无效买卖方向。 ### -1118 EMPTY_NEW_CL_ORD_ID - 新的客户订单ID为空。 ### -1119 EMPTY_ORG_CL_ORD_ID - 客户自定义的订单ID为空。 ### -1120 BAD_INTERVAL - 无效时间间隔。 ### -1121 BAD_SYMBOL - 无效的交易对。 ### -1125 INVALID_LISTEN_KEY - 该listenKey不存在。 ### -1127 MORE_THAN_XX_HOURS - 查询间隔太大。 - 从开始时间到结束时间之间超过%s小时。 ### -1128 OPTIONAL_PARAMS_BAD_COMBO - 可选参数组合无效。 ### -1130 INVALID_PARAMETER - 发送的参数为无效数据。 - 发送参数`%s`的数据无效。 ### -1131 BAD_RECV_WINDOW - `recvWindow` 必须小于 60000 ### -1134 BAD_STRATEGY_TYPE - `strategyType` 必须小于 1000000 #### -1145 INVALID_CANCEL_RESTRICTIONS - `cancelRestrictions` 必须是 `ONLY_NEW` 或者 `ONLY_PARTIALLY_FILLED`。 #### -1151 重复的交易对 - Symbol is present multiple times in the list. ### -2010 NEW_ORDER_REJECTED - 新订单被拒绝 ### -2011 CANCEL_REJECTED - 取消订单被拒绝 ### -2013 NO_SUCH_ORDER - 订单不存在。 ### -2014 BAD_API_KEY_FMT - API-key 格式无效。 ### -2015 REJECTED_MBX_KEY - 无效的API密钥,IP或操作权限。 ### -2016 NO_TRADING_WINDOW - 找不到该交易对的交易窗口。 尝试改为24小时自动报价。 #### -2026 ORDER_ARCHIVED - 订单已被存档因为此订单被取消或过期,无交易数量而最后的更新已超过 90 天前。 ## 3xxx-5xxx SAPI 具体问题 ### -3000 INNER_FAILURE - 内部服务器错误。 ### -3001 NEED_ENABLE_2FA - 请先启用2FA。 ### -3002 ASSET_DEFICIENCY - 此资产不存在。 ### -3003 NO_OPENED_MARGIN_ACCOUNT - 杠杆账户不存在。 ### -3004 TRADE_NOT_ALLOWED - 禁止交易。 ### -3005 TRANSFER_OUT_NOT_ALLOWED - 不允许转账。 ### -3006 EXCEED_MAX_BORROWABLE - 您的已借金额已超过最高可借金额。 ### -3007 HAS_PENDING_TRANSACTION - 您有待处理的交易,请稍后再试。 ### -3008 BORROW_NOT_ALLOWED - 不允许借款。 ### -3009 ASSET_NOT_MORTGAGEABLE - 此资产目前不允许转入杠杆账户。 ### -3010 REPAY_NOT_ALLOWED - 不允许还款。 ### -3011 BAD_DATE_RANGE - 您输入的日期无效。 ### -3012 ASSET_ADMIN_BAN_BORROW - 此资产禁止借款。 ### -3013 LT_MIN_BORROWABLE - 借入金额少于最低借入金额。 ### -3014 ACCOUNT_BAN_BORROW - 此帐户禁止借款。 ### -3015 REPAY_EXCEED_LIABILITY - 还款额超过借款额。 ### -3016 LT_MIN_REPAY - 还款额少于最低还款额。 ### -3017 ASSET_ADMIN_BAN_MORTGAGE - 此资产目前不允许转入保证金账户。 ### -3018 ACCOUNT_BAN_MORTGAGE - 此帐户已禁止转入。 ### -3019 ACCOUNT_BAN_ROLLOUT - 此帐户禁止转出。 ### -3020 EXCEED_MAX_ROLLOUT - 转出金额超过上限。 ### -3021 PAIR_ADMIN_BAN_TRADE - 杠杆账户无法交易此交易对。 ### -3022 ACCOUNT_BAN_TRADE - 账号被禁止交易。 ### -3023 WARNING_MARGIN_LEVEL - 无法在当前杠杆倍数下转出资金或者下单 ### -3024 FEW_LIABILITY_LEFT - 付款之后未付款的债务太小 ### -3025 INVALID_EFFECTIVE_TIME - 输入时间有误。 ### -3026 VALIDATION_FAILED - 输入参数有误。 ### -3027 NOT_VALID_MARGIN_ASSET - 无效的杠杆资产。 ### -3028 NOT_VALID_MARGIN_PAIR - 无效的杠杆交易对。 ### -3029 TRANSFER_FAILED - 转账失败。 ### -3036 ACCOUNT_BAN_REPAY - 此账号无法还款。 ### -3037 PNL_CLEARING - `PNL`正在清帐,请稍等。 ### -3038 LISTEN_KEY_NOT_FOUND - 找不到`Listen key` ### -3041 BALANCE_NOT_CLEARED - 余额不足 ### -3042 PRICE_INDEX_NOT_FOUND - 该杠杆交易对无可用价格指数。 ### -3043 TRANSFER_IN_NOT_ALLOWED - 不允许转入。 ### -3044 SYSTEM_BUSY - 系统繁忙。 ### -3045 SYSTEM - 系统目前没有足够可借的资产。 ### -3999 NOT_WHITELIST_USER - 此功能只面向邀请的用户。 ### -4001 CAPITAL_INVALID - 非法操作 ### -4002 CAPITAL_IG - 非法获取 ### -4003 CAPITAL_IEV - 非法邮箱验证 ### -4004 CAPITAL_UA - 未登录或者认证。 ### -4005 CAPAITAL_TOO_MANY_REQUEST - 请求太频繁。 ### -4006 CAPITAL_ONLY_SUPPORT_PRIMARY_ACCOUNT - 只支持主账号。 ### -4007 CAPITAL_ADDRESS_VERIFICATION_NOT_PASS - 地址的没有通过校验。 ### -4008 CAPITAL_ADDRESS_TAG_VERIFICATION_NOT_PASS - 地址的标记信息(`tag`)没有通过校验。 ### -4010 CAPITAL_WHITELIST_EMAIL_CONFIRM - 确认电子邮件已经列入白名单。 ### -4011 CAPITAL_WHITELIST_EMAIL_EXPIRED - 列入白名单的电子邮件无效。 ### -4012 CAPITAL_WHITELIST_CLOSE - 白名单未打开。 ### -4013 CAPITAL_WITHDRAW_2FA_VERIFY - 2FA未打开。 ### -4014 CAPITAL_WITHDRAW_LOGIN_DELAY - 在登录后的2分钟之内不允许提款。 ### -4015 CAPITAL_WITHDRAW_RESTRICTED_MINUTE - 暂停提款 ### -4016 CAPITAL_WITHDRAW_RESTRICTED_PASSWORD - 在密码修改后的24小时之内不允许提款。 ### -4017 CAPITAL_WITHDRAW_RESTRICTED_UNBIND_2FA - 在2FA发行后的24小时之内不允许提款。 ### -4018 CAPITAL_WITHDRAW_ASSET_NOT_EXIST - 此资产不存在。 ### -4019 CAPITAL_WITHDRAW_ASSET_PROHIBIT - 此资产不允许提款。 ### -4021 CAPITAL_WITHDRAW_AMOUNT_MULTIPLE - 资产的提款数量必须是%s的%s倍。 ### -4022 CAPITAL_WITHDRAW_MIN_AMOUNT - 不须少于最低的提款数量%s。 ### -4023 CAPITAL_WITHDRAW_MAX_AMOUNT - 在24小时之内,不须超过最高的提款数量。 ### -4024 CAPITAL_WITHDRAW_USER_NO_ASSET - 当前用户没有此资产。 ### -4025 CAPITAL_WITHDRAW_USER_ASSET_LESS_THAN_ZERO - 持有资产的数量小于零。 ### -4026 CAPITAL_WITHDRAW_USER_ASSET_NOT_ENOUGH - 此资产余额不足。 ### -4027 CAPITAL_WITHDRAW_GET_TRAN_ID_FAILURE - 无法获取tranId。 ### -4028 CAPITAL_WITHDRAW_MORE_THAN_FEE - 提款金额必须多于佣金额。 ### -4029 CAPITAL_WITHDRAW_NOT_EXIST - 此提款记录不存在。 ### -4030 CAPITAL_WITHDRAW_CONFIRM_SUCCESS - 提款资产成功。 ### -4031 CAPITAL_WITHDRAW_CANCEL_FAILURE - 取消提款失败。 ### -4032 CAPITAL_WITHDRAW_CHECKSUM_VERIFY_FAILURE - 验证提款失败。 ### -4033 CAPITAL_WITHDRAW_ILLEGAL_ADDRESS - 提款地址不合法。 ### -4034 CAPITAL_WITHDRAW_ADDRESS_CHEAT - 当前地址有异常。 ### -4035 CAPITAL_WITHDRAW_NOT_WHITE_ADDRESS - 此地址不在白名单上。请加入然后重试。 ### -4036 CAPITAL_WITHDRAW_NEW_ADDRESS - 新地址在{0}小时后才可以提款。 ### -4037 CAPITAL_WITHDRAW_RESEND_EMAIL_FAIL - 重新发送邮件失败。 ### -4038 CAPITAL_WITHDRAW_RESEND_EMAIL_TIME_OUT - 请5分钟后重试。 ### -4039 CAPITAL_USER_EMPTY - 用户不存在。 ### -4041 CAPITAL_MINUTE_TOO_SMALL - 请一分钟后重试。 ### -4042 CAPITAL_CHARGE_NOT_RESET - 资产无法重新获取存款地址。 ### -4043 CAPITAL_ADDRESS_TOO_MUCH - 在24小时之内充值超过100多个地址。 ### -4044 CAPITAL_BLACKLIST_COUNTRY_GET_ADDRESS - 此国家在黑名单上。 ### -4045 CAPITAL_GET_ASSET_ERROR - 获得资产失败。 ### -4046 CAPITAL_AGREEMENT_NOT_CONFIRMED - 协议未确认。 ### -4047 CAPITAL_DATE_INTERVAL_LIMIT - 时间间隔必须在0-90天之内 ### -4060 CAPITAL_WITHDRAW_USER_ASSET_LOCK_DEPOSIT - 体现仍在区块确认中,暂时锁定部分资产 ### -4106 TAG_NOT_SUPPORTED_FOR_NETWORK - 该网络不支持 memo/tag。请移除 `addressTag` 字段后重试。 ### -5001 ASSET_DRIBBLET_CONVERT_SWITCH_OFF - 不允许转移到微型资产。 ### -5002 ASSET_ASSET_NOT_ENOUGH - 此余额不足。 ### -5003 ASSET_USER_HAVE_NO_ASSET - 此资产不存在。 ### -5004 USER_OUT_OF_TRANSFER_FLOAT - 剩余余额已超过0.001BTC,请重新选择。 - %s的剩余余额已超过0.001BTC,请重新选择。 ### -5005 USER_ASSET_AMOUNT_IS_TOO_LOW - BTC的剩余余额太低,请重新选择。 - %s的剩余余额太低,请重新选择。 ### -5006 USER_CAN_NOT_REQUEST_IN_24_HOURS - 24小时内只能转账一次。 ### -5007 AMOUNT_OVER_ZERO - 数量必须大于零。 ### -5008 ASSET_WITHDRAW_WITHDRAWING_NOT_ENOUGH - 可退回资产的金额不足。 ### -5009 PRODUCT_NOT_EXIST - 产品不存在。 ### -5010 TRANSFER_FAIL - 资产转移失败。 ### -5011 FUTURE_ACCT_NOT_EXIST - 合约帐户不存在。 ### -5012 TRANSFER_PENDING - 资产转移正在进行中。 ### -5021 PARENT_SUB_HAVE_NO_RELATION - 当前的子账户和母账户没有从属关系。 ### -5012 FUTURE_ACCT_OR_SUBRELATION_NOT_EXIST - 合约帐户或子账户关系不存在。 ## 6XXX - 币安宝相关 ### -6001 DAILY_PRODUCT_NOT_EXIST - 理财产品不存在. ### -6003 DAILY_PRODUCT_NOT_ACCESSIBLE - 产品不存在或者没有权限。 ### -6004 DAILY_PRODUCT_NOT_PURCHASABLE - 产品无法购买。 ### -6005 DAILY_LOWER_THAN_MIN_PURCHASE_LIMIT - 低于可以购买的最小限额。 ### -6006 DAILY_REDEEM_AMOUNT_ERROR - 赎回额度有误。 ### -6007 DAILY_REDEEM_TIME_ERROR - 不在赎回的时间内。 ### -6008 DAILY_PRODUCT_NOT_REDEEMABLE - 产品暂时无法赎回。 ### -6009 REQUEST_FREQUENCY_TOO_HIGH - 发送请求太频繁。 ### -6011 EXCEEDED_USER_PURCHASE_LIMIT - 超购每个月用户可以申购的最大次数。 ### -6012 BALANCE_NOT_ENOUGH - 余额不足。 ### -6013 PURCHASING_FAILED - 申购失败。 ### -6014 UPDATE_FAILED - 超过可以申购的最大上限。 ### -6015 EMPTY_REQUEST_BODY - 请求的`body`为空。 ### -6016 PARAMS_ERR - 请求的参数有误。 ### -6017 NOT_IN_WHITELIST - 不在白名单里面。 ### -6018 ASSET_NOT_ENOUGH - 资产不足。 ### -6019 PENDING - 需要进一步确认。 ### -6020 PROJECT_NOT_EXISTS - 此项目不存在。 ## 70xx - 期货 ### -7001 FUTURES_BAD_DATE_RANGE - 此日期范围不支持。 ### -7002 FUTURES_BAD_TYPE - 此数据请求类型不支持。 ## 20xxx - 合约/现货策略交易 ### -20121 Invalid symbol - 无效交易对。 ### -20124 Invalid algo id or it has been completed - 无效的策略订单ID或者它已经被执行。 ### -20130 Invalid data sent for a parameter - 无效数据。 ### -20132 The client algo id is duplicated - 用户自定义策略订单ID重复。 ### -20194 Duration is too short to execute all required quantity - Duration 时间太短不足以执行用户选择的订单数量。 ### -20195 The total size is too small - 下单数量太小。 ### -20196 The total size is too large - 下单数量太大。 ### -20198 Reach the max open orders allowed - 达到了最大挂单上限。 ### -20204 The notional of USD is less or more than the limit - 订单小于最小USD名义价值 ## 过滤器故障 | 报错信息 | 描述 | | ------------------------------------------ | ---------------------------------------------------------------------------------- | | "Filter failure: PRICE_FILTER" | "价格"过高,过低和/或不遵循交易对的最小价格规则。 | | "Filter failure: PERCENT_PRICE" | "价格"比最近Y分钟的平均加权价格高X%或X%太低。 | | "Filter failure: PERCENT_PRICE_BY_SIDE" | `price` 在当前方向上(`BUY`或者`SELL`)比`lastPrice`价格超过X%或者低于Y%。 | | "Filter failure: LOT_SIZE" | "数量"太高,太低和/或不遵循该交易对的步长规则。 | | "Filter failure: MIN_NOTIONAL" | 价格\*数量太低,无法成为该交易对的有效订单。 | | "Filter failure: ICEBERG_PARTS" | `ICEBERG` 订单会分成太多部分; icebergQty太小。 | | "Filter failure: MARKET_LOT_SIZE" | "MARKET"订单的"数量"过高,过低和/或未遵循交易对的步长规则。 | | "Filter failure: MAX_POSITION" | 达到账户的最大仓位限制。这包括了账户的余额总额,以及所有处于open的买单的数量总和。 | | "Filter failure: MAX_NUM_ORDERS" | 客户在交易对上有太多挂单。 | | "Filter failure: MAX_ALGO_ORDERS" | 账户有太多未平仓止损和/或在交易对上执行获利指令。 | | "Filter failure: MAX_NUM_ICEBERG_ORDERS" | 客户在交易对上有太多 iceberg 挂单。 | | "Filter failure: TRAILING_DELTA" | `trailingDelta` 值不在限定的范围内. | | "Filter failure: EXCHANGE_MAX_NUM_ORDERS" | 帐户上的交易所有太多挂单。 | | "Filter failure: EXCHANGE_MAX_ALGO_ORDERS" | 帐户有太多止损挂单和/或在交易所收取获利指令。 | ## 10xxx - 质押借币 ### -10001 SYSTEM_MAINTENANCE - 系统维护中,请稍后再试 ### -10002 INVALID_INPUT - 无效的输入参数 ### -10005 NO_RECORDS - 暂无记录 ### -10007 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10008 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10009 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10010 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10011 INSUFFICIENT_ASSET - 现货资产不足 ### -10012 INVALID_AMOUNT - 无效的还款金额 ### -10013 INSUFFICIENT_AMOUNT - 抵押资产不足 ### -10015 DEDUCTION_FAILED - 抵押资产扣款失败 ### -10016 LOAN_FAILED - 放贷失败 ### -10017 REPAY_EXCEED_DEBT - 还款金额超过负债金额 ### -10018 INVALID_AMOUNT - 无效的还款金额 ### -10019 CONFIG_NOT_EXIST - 配置不存在 ### -10020 UID_NOT_EXIST - 用户ID不存在 ### -10021 ORDER_NOT_EXIST - 订单不存在 ### -10022 INVALID_AMOUNT - 无效的调整金额 ### -10023 ADJUST_LTV_FAILED - 调整质押率失败 ### -10024 ADJUST_LTV_NOT_SUPPORTED - 暂不支持调整质押率 ### -10025 REPAY_FAILED - 还款失败 ### -10026 INVALID_PARAMETER - 无效的参数 ### -10028 INVALID_PARAMETER - 无效的参数 ### -10029 AMOUNT_TOO_SMALL - 借贷金额过小 ### -10030 AMOUNT_TOO_LARGE - 借贷金额过大 ### -10031 QUOTA_REACHED - 已达到个人借贷限额 ### -10032 REPAY_NOT_AVAILABLE - 暂不支持换款 ### -10034 REPAY_NOT_AVAILABLE - 抵押物还款暂时不支持,请尝试用借贷币还款。 ### -10039 AMOUNT_TOO_SMALL - 还款金额过小 ### -10040 AMOUNT_TOO_LARGE - 还款金额过大 ### -10041 INSUFFICIENT_AMOUNT - 由于借贷需求过多,系统剩余可借{0}额度不足。请调整借贷金额或明天再试。 ### -10042 ASSET_NOT_SUPPORTED - 暂不支持%s币种 ### -10043 ASSET_NOT_SUPPORTED - 暂不支持{0} 借贷 ### -10044 QUOTA_REACHED - 抵押物数量已达到限额,请调整抵押金额或使用其他抵押资产。 ### -10045 COLLTERAL_REPAY_NOT_SUPPORTED - 该借贷币种暂不支持抵押物还款,请稍后再试。 ### -10046 EXCEED_MAX_ADJUSTMENT - 调整抵押物超过最大限额,请重试。 ### -10047 REGION_NOT_SUPPORTED - 受当地法规管制,您所在地区暂不支持该币种。 ## 13xxx - 杠杆代币 ### -13000 BLVT_FORBID_REDEEM - 当前该杠杆代币关闭赎回 ### -13001 BLVT_EXCEED_DAILY_LIMIT - 超过该代币个人24小时赎回金额上限 ### -13002 BLVT_EXCEED_TOKEN_DAILY_LIMIT - 超过该代币全局24小时赎回金额上限 ### -13003 BLVT_FORBID_PURCHASE - 当前该杠杆代币关闭申购 ### -13004 BLVT_EXCEED_DAILY_PURCHASE_LIMIT - 超过该代币个人24小时申购金额上限 ### -13005 BLVT_EXCEED_TOKEN_DAILY_PURCHASE_LIMIT - 超过该代币全局24小时申购金额上限 ### -13006 BLVT_PURCHASE_LESS_MIN_AMOUNT - 申购金额低于规定下限 ### -13007 BLVT_PURCHASE_AGREEMENT_NOT_SIGN - 没有签署开通交易协议 ## 12xxx - 流动性挖矿 ### -12014 TOO MANY REQUESTS - 2秒内接收的请求数量多于1条 ## 18xxx - 币安码 ### -18002 - The total amount of codes you created has exceeded the 24-hour limit, please try again after UTC 0 - 24小时内制码总金额已超过限额,请UTC0点后再尝试 ### -18003 - Too many codes created in 24 hours, please try again after UTC 0 - 24小时内制码总次数已超过限额,请UTC0点后再尝试 ### -18004 - Too many invalid redeem attempts in 24 hours, please try again after UTC 0 - 24小时内兑现币安码输错次数已超过限额,请UTC0点后再尝试 ### -18005 - Too many invalid verify attempts, please try later - 参考号输错次数过多,请稍后再试 ### -18006 - The amount is too small, please re-enter - 金额过小,请重新输入 ### -18007 - This token is not currently supported, please re-enter - 尚未支持该币种,请重新输入 ## 21xxx - 統一帳戶 ### -21001 USER_IS_NOT_UNIACCOUNT - 尚未开通统一账户。 ### -21002 UNI_ACCOUNT_CANT_TRANSFER_FUTURE - 统一账户禁用margin向futures转账。 ### -21003 NET_ASSET_MUST_LTE_RATIO - margin资产更新失败。 ### -21004 USER_NO_LIABILITY - 用户不存在统一账户穿仓负债 ### -21005 NO_ENOUGH_ASSET - 用户现货钱包BUSD资产不足以偿还统一账户穿仓负债 ### -21006 HAD_IN_PROCESS_REPAY - 用户存在正在偿还的统一账户穿仓负债 ### -21007 IN_FORCE_LIQUIDATION - 强平进行中,用户偿还统一账户穿仓负债失败 ## 订单拒绝错误 以下错误代码表示撮合引擎返回的订单相关错误: - `-1010 ERROR_MSG_RECEIVED` - `-2010 NEW_ORDER_REJECTED` - `-2011 CANCEL_REJECTED` 结合以下消息将指示特定的错误: | 错误信息 | 描述 | | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | "Unknown order sent." | 找不到订单(通过"orderId","clientOrderId","origClientOrderId") | | "Duplicate order sent." | `clientOrderId`已经被使用 | | "Market is closed." | 该交易对不在交易范围 | | "Account has insufficient balance for requested action." | 没有足够的资金来完成行动 | | "Market orders are not supported for this symbol." | 交易对上未启用"MARKET" | | "Iceberg orders are not supported for this symbol." | 交易对上未启用`icebergQty` | | "Stop loss orders are not supported for this symbol." | 交易对上未启用 `STOP_LOSS` | | "Stop loss limit orders are not supported for this symbol." | 交易对上未启`STOP_LOSS_LIMIT` | | "Take profit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT` | | "Take profit limit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT_LIMIT` | | "Price \* QTY is zero or less." | `price` \* `quantity`太小 | | "IcebergQty exceeds QTY." | `icebergQty` 必须少于订单数量 | | "This action is disabled on this account." | 联系客户支持; 该账户已禁用了某些操作。 | | "This account may not place or cancel orders." | 联系客户支持: 该账户已被禁用了交易操作。 | | "Unsupported order combination" | 不允许组合`orderType`, `timeInForce`, `stopPrice`, 和/或 `icebergQty` 。 | | "Order would trigger immediately." | 与最后交易价格相比,订单的止损价无效。 | | "Cancel order is invalid. Check origClientOrderId and orderId." | 未发送`origClientOrderId` 或`orderId` 。 | | "Order would immediately match and take." | `LIMIT_MAKER` 订单类型将立即匹配并进行交易,而不是纯粹的生成订单。 | | "The relationship of the prices for the orders is not correct." | `OCO`订单中设置的价格不符合报价规则:

The rules are:

`SELL Orders`: Limit Price > Last Price > Stop Price

`BUY Orders`: Limit Price < Last Price < Stop Price | | "OCO orders are not supported for this symbol" | `OCO`订单不支持该交易对 | | "Quote order qty market orders are not support for this symbol." | 这个交易对,市价单不支持参数`quoteOrderQty` | | "Trailing stop orders are not supported for this symbol." | 此symbol不支持 `trailingDelta` | | | "Order cancel-replace is not supported for this symbol." | 此symbol不支持 `POST /api/v3/order/cancelReplace` 或者 `order.cancelReplace` (WebSocket API) | | | "This symbol is not permitted for this account." | 账户和交易对的权限不一致 (比如 `SPOT`, `MARGIN` 等)。| | | "This symbol is restricted for this account." | 账户没有权限在此交易对交易 (比如账户只拥有 `ISOLATED_MARGIN`权限,则无法下`SPOT` 订单)。 | | | "Order was not canceled due to cancel restrictions." | `cancelRestrictions` 设置为 `ONLY_NEW` 但订单状态不是 `NEW`

`cancelRestrictions` 设置为 `ONLY_PARTIALLY_FILLED` 但订单状态不是 `PARTIALLY_FILLED`。 | | ## 关于 POST /api/v3/order/cancelReplace 的错误 ### -2021 Order cancel-replace partially failed 收到该错误码代表撤单**或者**下单失败。 ### -2022 Order cancel-replace failed. 收到该错误码代表撤单**和**下单都失败。 --- ## Document: /products/staking/change-log URL: /zh-CN/docs/products/staking/change-log # 更新日志 ## 2025-12-26 ### 时效性通知 - **以下有关于REST API变更将在 2026-01-15 07:OO UTC 发生:**
调用需要签名的接口时,请在计算签名之前对 payload 进行百分比编码(percent-encode)。不符合此顺序的请求将被拒绝,并返回错误代码 [`-1022 签名不正确`](./error-code.md#-1022-invalid_signature)。请检查并相应地更新您代码中的签名逻辑部分。 ### REST API - 更新了 REST API 文档中有关于 [签名请求示例](./general-info.md#post-apiv3order-的签名示例) 的部分。 ## 2025-10-27 - 更新 ETH Staking 的接口: - `GET /sapi/v1/eth-staking/eth/quota` 查询ETH质押的赎回周期和最小数量限制等参数。 ## 2025-09-09 - 新增持币生息相关接口。 ## 2025-07-01 - 新增链上赚币定期相关接口。 ## 2024-12-3 - 新增 SOL Staking 的接口: - `GET /sapi/v1/sol-staking/sol/history/boostRewardsHistory` 查询 SOL质押Boost空投奖励历史记录。 - `GET /sapi/v1/sol-staking/sol/history/unclaimedRewards` 查询 SOL质押未领取的Boost空投奖励。 - `POST /sapi/v1/sol-staking/sol/claim` 领取 Boost空投奖励。 - 更新 SOL Staking 的接口: - `GET /sapi/v1/sol-staking/sol/history/rateHistory` 查询 SOL质押Boost空投奖励年利率。 ## 2024-10-15 - 新增 Staking 接口: - `POST /sapi/v1/sol-staking/sol/stake`: 质押SOL并获得BNSOL。 - `POST /sapi/v1/sol-staking/sol/redeem`: 赎回BNSOL并获得 SOL。 - `GET /sapi/v1/sol-staking/sol/history/stakingHistory`: 查询SOL质押的申购历史记录。 - `GET /sapi/v1/sol-staking/sol/history/redemptionHistory`: 查询SOL质押的赎回历史记录。 - `GET /sapi/v1/sol-staking/sol/history/bnsolRewardsHistory`: 查询SOL质押的奖励历史记录。 - `GET /sapi/v1/sol-staking/sol/history/rateHistory`: 查询SOL质押的汇率历史记录。 - `GET /sapi/v1/sol-staking/account`: 获取BNSOL账户详情。 - `GET /sapi/v1/sol-staking/sol/quota`: 查询产品配额和详细信息。 --- ## 2023-12-22 - 更新 staking 接口: - `GET /sapi/v1/eth-staking/eth/history/wbethRewardsHistory`: 新增接口以查询 WBETH 收益记录 - `POST /sapi/v2/eth-staking/eth/stake`: 新增接口质押 ETH 获得 WBETH。 现有 v1 接口`POST /sapi/v1/eth-staking/eth/stake` 将被弃用, 具体时间待定 - `GET /sapi/v2/eth-staking/account`: 新增接口查询已质押 ETH 的对应持仓和 30 天收益。现有 v1 接口`GET /sapi/v1/eth-staking/account` 将被弃用, 具体时间待定 - `POST /sapi/v1/eth-staking/wbeth/unwrap`: 移除本接口。`POST /sapi/v1/eth-staking/eth/redeem`已经支持相同功能 - `POST /sapi/v1/eth-staking/eth/redeem`: 新增入参`asset`, 新增返回字段`ethAmount`, `conversionRatio`。 - `GET /sapi/v1/eth-staking/eth/history/stakingHistory`: 新增返回字段 `distributeAsset`, `distributeAmount`, `conversionRatio` - `GET /sapi/v1/eth-staking/eth/history/redemptionHistory` 新增返回字段`asset`, `distributeAsset`, `distributeAmount`, `conversionRatio` - `POST /sapi/v1/eth-staking/wbeth/wrap`: 新增返回字段`wbethAmount`, `exchangeRate` --- ## 2023-06-29 - Staking 接口中新增一系列 ETH Staking 相关接口 - 新增杠杆接口: - `GET /sapi/v1/margin/dust`: 获取可以转换成 BNB 的小额资产列表 - `POST /sapi/v1/margin/dust`: 把小额资产转换成 BNB - 新增 VIP 借币接口(2023-06-30 生效): - `POST /sapi/v1/loan/vip/borrow`: VIP 借币借款 - `GET /sapi/v1/loan/vip/loanable/data`: 查询 VIP 借币可借币种数据 - `GET /sapi/v1/loan/vip/collateral/data`: 查询 VIP 借币抵押币种数据 - `GET /sapi/v1/loan/vip/request/data`: 查询申请状态 --- ## 2022-04-28 - 新增 Staking 接口: - `GET /sapi/v1/staking/productList` 以查询 Staking 可锁仓产品列表 - `POST /sapi/v1/staking/purchase` 以锁仓 Staking 产品 - `POST /sapi/v1/staking/redeem` 以赎回 Staking 产品 - `GET /sapi/v1/staking/position` 以查询 Staking 产品的持仓 - `GET /sapi/v1/staking/stakingRecord`以查询锁仓产品的历史记录 - `POST /sapi/v1/staking/setAutoStaking` 以设置 Staking 产品的自动续期 - `GET /sapi/v1/staking/personalLeftQuota` 以查询个人锁仓限额 --- ## Document: /products/staking/Introduction URL: /zh-CN/docs/products/staking/Introduction 币安质押 API 是一套全面的端点,允许用户无缝管理他们的质押活动。该 API 支持多种质押选项,包括 ETH 质押、SOL 质押、链上赚币和持币生息,帮助用户参与以太坊和 Solana 网络的权益证明(PoS)共识机制,并可精选链上协议进行质押,获取收益。 --- ## Document: /products/spot-block-matching/quick-start URL: /zh-CN/docs/products/spot-block-matching/quick-start # 快速开始 ## API Key 权限设置 - 新创建的API的默认权限是 `只读`。 - 如果需要通过API提款, 需要在UI修改权限, 选中 `允许提现`。 ## 账户 ### 现货账户 新注册的币安账号都会有一个现货(`SPOT`)账号。 ### 杠杆账户 为了开设杠杆(`MARGIN`)账户, 可以参考[Binance杠杆交易账户设置指南](https://www.binance.vision/zh/tutorials/binance-margin-trading-guide) ## API 代码库 ### Connectors 以下有一些轻量级的代码库,使不同语言的用户能够直接调用现货的 Binance 公共 API: - Python [https://github.com/binance/binance-connector-python](https://github.com/binance/binance-connector-python) - JavaScript [https://github.com/binance/binance-connector-js](https://github.com/binance/binance-connector-js) - Ruby [https://github.com/binance/binance-connector-ruby](https://github.com/binance/binance-connector-ruby) - DotNET C# [https://github.com/binance/binance-connector-dotnet](https://github.com/binance/binance-connector-dotnet) - Java [https://github.com/binance/binance-connector-java](https://github.com/binance/binance-connector-java) - Rust [https://github.com/binance/binance-spot-connector-rust](https://github.com/binance/binance-spot-connector-rust) - PHP [https://github.com/binance/binance-connector-php](https://github.com/binance/binance-connector-php) - Go [https://github.com/binance/binance-connector-go](https://github.com/binance/binance-connector-go) ### Postman Collections Postman 集合现已推出。推荐给寻求快速和轻松地开始使用 API 的新用户。 [https://github.com/binance/binance-api-postman](https://github.com/binance/binance-api-postman) ### Swagger 以下有提供包含 RESTful API 的 OpenAPI 规范的 YAML 文件,以及可供参考的 Swagger UI 页面。 [https://github.com/binance/binance-api-swagger](https://github.com/binance/binance-api-swagger) --- ## Document: /products/spot-block-matching/general-info URL: /zh-CN/docs/products/spot-block-matching/general-info # 基本信息 ## API 基本信息 - 接口可能需要用户的 API Key,如何创建API-KEY请参考[这里](https://www.binance.com/cn/support/articles/360002502072) - 本篇列出接口的 base URL 有: - **https://api.binance.com** - **https://api-gcp.binance.com** - **https://api1.binance.com** - **https://api2.binance.com** - **https://api3.binance.com** - **https://api4.binance.com** - 上述列表的最后4个接口 (`api1`-`api4`) 可能会提供更好的性能,但其稳定性略为逊色。因此,请务必使用最适合您现有配置的那款。 - 所有接口的响应都是 JSON 格式。 - 响应中如有数组,数组元素以时间**升序**排列,越早的数据越提前。 - 所有时间、时间戳均为UNIX时间,单位为**毫秒**。 ### HTTP 返回代码 - HTTP `4XX` 错误码用于指示错误的请求内容、行为、格式。问题在于请求者。 - HTTP `403` 错误码表示违反WAF限制(Web应用程序防火墙)。 - HTTP `409` 错误码表示重新下单(cancelReplace)的请求部分成功。(比如取消订单失败,但是下单成功了) - HTTP `429` 错误码表示警告访问频次超限,即将被封IP。 - HTTP `418` 表示收到429后继续访问,于是被封了。 - HTTP `5XX` 错误码用于指示Binance服务侧的问题。 ### 接口错误代码 - 使用接口 `/api/v3`, 以及 `/sapi/v1/margin`时, 每个接口都有可能抛出异常; > API 与 SAPI 的错误代码返回形式如下: ```javascript { "code": -1121, "msg": "Invalid symbol." } ``` - 具体的错误码及其解释在 [错误代码](./error-code). ### 接口的基本信息 - `GET` 方法的接口, 参数必须在 `query string`中发送。 - `POST`, `PUT`, 和 `DELETE` 方法的接口,参数可以在内容形式为`application/x-www-form-urlencoded`的 `query string` 中发送,也可以在 `request body` 中发送。 如果你喜欢,也可以混合这两种方式发送参数。 - 对参数的顺序不做要求。 - 但如果同一个参数名在query string和request body中都有,query string中的会被优先采用。 --- ## 访问限制 ### 访问限制基本信息 - 以下 是`intervalLetter` 作为头部值: - SECOND => S - MINUTE => M - HOUR => H - DAY => D - 在 `/api/v3/exchangeInfo` `rateLimits` 数组中包含与交易的有关RAW_REQUESTS,REQUEST_WEIGHT和ORDERS速率限制相关的对象。这些在 `限制种类 (rateLimitType)` 下的 `枚举定义` 部分中进一步定义。 - 违反任何一个速率限制时(访问频次限制或下单速率限制),将返回429。 ### IP 访问限制 - 每个请求将包含一个`X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,其中包含当前IP所有请求的已使用权重。 - 每一个接口均有一个相应的权重(weight),有的接口根据参数不同可能拥有不同的权重。越消耗资源的接口权重就会越大。 - 收到429时,您有责任停止发送请求,不得滥用API。 - **收到429后仍然继续违反访问限制,会被封禁IP,并收到418错误码** - 频繁违反限制,封禁时间会逐渐延长,**从最短2分钟到最长3天**。 - `Retry-After`的头会与带有418或429的响应发送,并且会给出**以秒为单位**的等待时长(如果是429)以防止禁令,或者如果是418,直到禁令结束。 - **访问限制是基于IP的,而不是API Key** ###下单频率限制 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - 当下单数超过限制时,会收到带有429但不含`Retry-After`头的响应。请检查 `GET api/v3/exchangeInfo` 的下单频率限制 (rateLimitType = ORDERS) 并等待封禁时间结束。 - 被拒绝或不成功的下单并不保证回报中包含以上头内容。 - **下单频率限制是基于每个账户计数的。** - 用户可以通过接口 `GET api/v3/rateLimit/order` 来查询当前的下单量. ### WEB SOCKET 连接限制 - Websocket服务器每秒最多接受5个消息。消息包括: - PING帧 - PONG帧 - JSON格式的消息, 比如订阅, 断开订阅. - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅 **1024** 个Streams。 - 每IP地址、每5分钟最多可以发送300次连接请求。 ### /api/ 与 /sapi/ 接口限频说明 `/api/*`接口和 `/sapi/*`接口采用两套不同的访问限频规则, 两者互相独立。 - `/api/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以 `/api/*`开头的接口按IP限频,**且所有接口共用每分钟6,000限制**。 - 每个请求将包含一个 `X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,包含当前IP所有请求的已使用权重。 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - `/sapi/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以`/sapi/*`开头的接口采用**单接口限频模式**。按IP统计的权重单接口权重总额为每分钟12000;按照UID统计的单接口权重总额是每分钟180000。 - 每个接口会标明是按照IP或者按照UID统计, 以及相应请求一次的权重值。 - 按照IP统计的接口, 请求返回头里面会包含`X-SAPI-USED-IP-WEIGHT-1M=`或`X-SAPI-USED-IP-WEIGHT-1S=`, 包含当前IP所有请求已使用权重。 - 按照UID统计的接口, 请求返回头里面会包含`X-SAPI-USED-UID-WEIGHT-1M=`或`X-SAPI-USED-UID-WEIGHT-1S=`, 包含当前账户所有已用的UID权重。 --- ## 数据来源 - 因为API系统是异步的, 所以返回的数据有延时很正常, 也在预期之中。 - 在每个接口中,都列出了其数据的来源,可以用于理解数据的时效性。 系统一共有3个数据来源,按照更新速度的先后排序。排在前面的数据最新,在后面就有可能存在延迟。 - **撮合引擎** - 表示数据来源于撮合引擎 - **缓存** - 表示数据来源于内部或者外部的缓存 - **数据库** - 表示数据直接来源于数据库 ## 请求鉴权类型 - 每个接口都有一个鉴权类型,指示所需的 API 密钥权限,显示在接口名称旁边(例如,[下新订单 (TRADE)](#place-new-order-trade))。 - 如果未指定,则鉴权类型为 `NONE`。 - 除了为 `NONE` 外,所有具有鉴权类型的接口均视为 `SIGNED` 请求(即包含 `signature`),[listenKey 管理](#user-data-stream-requests) 除外。 - 具有鉴权类型的接口需要提供有效的 API 密钥并验证通过。 - API 密钥可在您的 Binance 账户的 [API 管理](https://www.binance.com/en/support/faq/360002502072) 页面创建。 - **API 密钥和密钥对均为敏感信息,切勿与他人分享。** 如果发现账户有异常活动,请立即撤销所有密钥并联系 Binance 支持。 - API 密钥可配置为仅允许访问某些鉴权接口。 - 例如,您可以拥有具有 `TRADE` 权限的 API 密钥用于交易,同时使用具有 `USER_DATA` 权限的另一个 API 密钥来监控订单状态。 - 默认情况下,API 密钥无法进行 `TRADE`,您需要先在 API 管理中启用交易权限。 | 鉴权类型 | 描述 | | ----------- | ------------------------- | | NONE | 不需要鉴权的接口 | | TRADE | 需要有效的 API-Key 和签名 | | MARGIN | 需要有效的 API-Key 和签名 | | USER_DATA | 需要有效的 API-Key 和签名 | | USER_STREAM | 需要有效的 API-Key | | MARKET_DATA | 需要有效的 API-Key | ### 需要签名的接口 - 调用`SIGNED` 接口时,除了接口本身所需的参数外,还需要在 `query string` 或 `request body` 中传递 `signature`, 即签名参数。 #### 签名是否是大小写敏感的 - **HMAC:** 使用 HMAC 生成的签名**不区分大小写**。这意味着无论字母大小写如何,签名字符串都可以被验证。 - **RSA:** 使用 RSA 生成的签名是**大小写敏感的**。 - **Ed25519:** 使用 Ed25519 生成的签名也是**大小写敏感的**。 请参阅[已签名请求示例 (HMAC)](#hmac-keys)、[已签名请求示例 (RSA)](#rsa-keys) 和[已签名请求示例 (Ed25519)](#ed25519-keys),了解如何根据您使用的 API 密钥类型计算签名。 ### 时间同步安全 - `SIGNED` 请求还需要一个 `timestamp` 参数,该参数应为当前时间戳,单位为毫秒或微秒。(参见 [通用 API 信息](#general-api-information)) - 另一个可选参数 `recvWindow`,用以指定请求的有效期,只能以毫秒为单位。 - `recvWindow` 扩展为三位小数(例如 6000.346),以便可以指定微秒。 - 如果未发送 `recvWindow`,则 **默认值为 5000 毫秒**。 - `recvWindow` 的最大值为 60000 毫秒。 - 请求处理逻辑如下: ```javascript serverTime = getCurrentTime() if (timestamp < (serverTime + 1 second) && (serverTime - timestamp) <= recvWindow) { // 开始处理请求 serverTime = getCurrentTime() if (serverTime - timestamp) <= recvWindow { // 将请求转发到撮合引擎 } else { // 拒绝请求 } // 结束处理请求 } else { // 拒绝请求 } ``` **关于交易时效性** 互联网状况并不100%可靠,不可完全依赖,因此你的程序本地到币安服务器的时延会有抖动. 这是我们设置`recvWindow`的目的所在,如果你从事高频交易,对交易时效性有较高的要求,可以灵活设置`recvWindow`以达到你的要求。 **不推荐使用5秒以上的recvWindow。最大值不能超过60秒!** ### POST /api/v3/order 的签名示例 #### HMAC Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 以下示例分步演示如何使用 `echo`、`openssl` 和 `curl` 从 Linux 命令行发送有效的签名 payload。其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 API 密钥和密钥示例: | Key | Value | | ----------- | ---------------------------------------------------------------- | | `apiKey` | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A | | `secretKey` | NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j | **警告:请勿与任何人分享您的 API 密钥和秘钥。** 此处提供的示例密钥仅用于示范说明目的。 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | LTCBTC | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` **第二步: 计算签名。** 1. 使用 API 密钥中的 `secretKey` 作为 HMAC-SHA-256 算法的签名密钥。 2. 对步骤 1 中构建的签名 payload 进行签名。 3. 将 HMAC-SHA-256 的输出编码为十六进制字符串。 请注意,`secretKey` 和 payload 是**大小写敏感的**,而生成的签名值是不区分大小写的。 **示例命令** 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71 ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n "symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3 ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71" ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3" ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash apiKey="vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" secretKey="NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" payload="symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" # 对请求进行签名 signature=$(echo -n "$payload" | openssl dgst -sha256 -hmac "$secretKey") signature=${signature#*= } # Keep only the part after the "= " # 发送请求 curl -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?$payload&signature=$signature" ``` #### RSA Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 要获取 API 密钥,您需要将 RSA 公钥上传到您的帐户中,系统将为您提供相应的 API 密钥。 仅支持 `PKCS#8` 密钥。 在以下示例中,其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 这些示例假设私钥存储在文件 `./test-prv-key.pem` 中。 | Key | Value | | -------- | ---------------------------------------------------------------- | | `apiKey` | CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ | 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | BTCUSDT | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` **第二步: 计算签名。** 1. 使用 RSASSA-PKCS1-v1_5 算法和 SHA-256 哈希函数对步骤 1 中构建的签名 payload 进行签名。 2. 将输出结果编码为 base64 格式。 请注意,payload 和生成的`签名值`是**大小写敏感的**。 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n 'symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' HZ8HOjiJ1s/igS9JA+n7+7Ti/ihtkRF5BIWcPIEluJP6tlbFM/Bf44LfZka/iemtahZAZzcO9TnI5uaXh3++lrqtNonCwp6/245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH+XxaCmR0WcvlKjNQnp12/eKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang/1WOq+Jaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT/fNnMRxFc7u+j3qI//5yuGuu14KR0MuQKKCSpViieD+fIti46sxPTsjSemoUKp0oXA== ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n 'symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' qJtv66wyp/1mZE+mIFAAMUoTe8xkmLN7/eAZjuC9x1ocxovItHLl/sNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M+JNIMz5UFxfeA53rXjFlvsyH1Sig+OuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C/QMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt/GuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng== ``` 3. 对 base64 格式的字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符): ```console HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D' ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D' ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash function rawurlencode { local string="${1}" local strlen=${#string} local encoded="" local pos c o for (( pos=0 ; pos 错误JSON格式: ```javascript { "code":-1121, "msg":"Invalid symbol." } ``` 错误由两部分组成:错误代码和消息。 代码是通用的,但是消息可能会有所不同。 ## 10xx -常规服务器或网络问题 ### -1000 UNKNOWN - 处理请求时发生未知错误。 - 处理请求时发生未知错误。[%s] ### -1001 DISCONNECTED - 内部错误; 无法处理您的请求。 请再试一次. ### -1002 UNAUTHORIZED - 您无权执行此请求。 ### -1003 TOO_MANY_REQUESTS - 排队的请求过多。 - 请求权重过多; 当前限制是 %s 每 %s 的请求权重。 请使用 Websocket Streams 进行实时更新,以避免轮询API。 - 请求权重过多; IP被禁止,直到%s。 请使用 Websocket Streams 进行实时更新,以免被禁。 ### -1004 SERVER_BUSY - 服务器正忙,请稍候再试。 ### -1006 UNEXPECTED_RESP - 从消息总线收到意外的响应。 执行状态未知。 ### -1007 TIMEOUT - 等待后端服务器响应超时。 发送状态未知; 执行状态未知。 ### -1008 SERVER_BUSY - 现货交易服务器当前因其他请求而过载。 请在几分钟后重试。 ### -1014 UNKNOWN_ORDER_COMPOSITION - 不支持的订单组合。 ### -1015 TOO_MANY_ORDERS - 新订单太多。 - 新订单太多; 当前限制为每%s %s个订单。 ### -1016 SERVICE_SHUTTING_DOWN - 该服务不可用。 ### -1020 UNSUPPORTED_OPERATION - 不支持此操作。 ### -1021 INVALID_TIMESTAMP - 此请求的时间戳在recvWindow之外。 - 此请求的时间戳比服务器时间提前1000毫秒。 ### -1022 INVALID_SIGNATURE - 此请求的签名无效。 ### -1099 Not found, authenticated, or authorized - 替换错误代码-1999 ## 11xx - 2xxx Request issues ### -1100 ILLEGAL_CHARS - 在参数中发现非法字符。 - 在参数中发现非法字符。`%s` - 在参数`%s`中发现非法字符; 合法范围是`%s`。 ### -1101 TOO_MANY_PARAMETERS - 为此端点发送的参数太多。 - 参数太多; 预期为`%s`并收到了`%s`。 - 检测到的参数值重复。 ### -1102 MANDATORY_PARAM_EMPTY_OR_MALFORMED - 未发送强制性参数,该参数为空/空或格式错误。 - 强制参数`%s`未发送,为空/空或格式错误。 - 必须发送参数`%s`或`%s`,但两者均为空! ### -1103 UNKNOWN_PARAM - 发送了未知参数。 ### -1104 UNREAD_PARAMETERS - 并非所有发送的参数都被读取。 - 并非所有发送的参数都被读取; 读取了`%s`参数,但被发送了`%s`。 ### -1105 PARAM_EMPTY - 参数为空。 - 参数`%s`为空。 ### -1106 PARAM_NOT_REQUIRED - 不需要时已发送参数。 - 不需要时发送参数`%s`。 ### -1111 BAD_PRECISION - 精度超过为此资产定义的最大值。 ### -1112 NO_DEPTH - 交易对没有挂单。 ### -1114 TIF_NOT_REQUIRED - 不需要时发送了TimeInForce参数。 ### -1115 INVALID_TIF - 无效 timeInForce. ### -1116 INVALID_ORDER_TYPE - 无效订单类型。 ### -1117 INVALID_SIDE - 无效买卖方向。 ### -1118 EMPTY_NEW_CL_ORD_ID - 新的客户订单ID为空。 ### -1119 EMPTY_ORG_CL_ORD_ID - 客户自定义的订单ID为空。 ### -1120 BAD_INTERVAL - 无效时间间隔。 ### -1121 BAD_SYMBOL - 无效的交易对。 ### -1125 INVALID_LISTEN_KEY - 该listenKey不存在。 ### -1127 MORE_THAN_XX_HOURS - 查询间隔太大。 - 从开始时间到结束时间之间超过%s小时。 ### -1128 OPTIONAL_PARAMS_BAD_COMBO - 可选参数组合无效。 ### -1130 INVALID_PARAMETER - 发送的参数为无效数据。 - 发送参数`%s`的数据无效。 ### -1131 BAD_RECV_WINDOW - `recvWindow` 必须小于 60000 ### -1134 BAD_STRATEGY_TYPE - `strategyType` 必须小于 1000000 #### -1145 INVALID_CANCEL_RESTRICTIONS - `cancelRestrictions` 必须是 `ONLY_NEW` 或者 `ONLY_PARTIALLY_FILLED`。 #### -1151 重复的交易对 - Symbol is present multiple times in the list. ### -2010 NEW_ORDER_REJECTED - 新订单被拒绝 ### -2011 CANCEL_REJECTED - 取消订单被拒绝 ### -2013 NO_SUCH_ORDER - 订单不存在。 ### -2014 BAD_API_KEY_FMT - API-key 格式无效。 ### -2015 REJECTED_MBX_KEY - 无效的API密钥,IP或操作权限。 ### -2016 NO_TRADING_WINDOW - 找不到该交易对的交易窗口。 尝试改为24小时自动报价。 #### -2026 ORDER_ARCHIVED - 订单已被存档因为此订单被取消或过期,无交易数量而最后的更新已超过 90 天前。 ## 3xxx-5xxx SAPI 具体问题 ### -3000 INNER_FAILURE - 内部服务器错误。 ### -3001 NEED_ENABLE_2FA - 请先启用2FA。 ### -3002 ASSET_DEFICIENCY - 此资产不存在。 ### -3003 NO_OPENED_MARGIN_ACCOUNT - 杠杆账户不存在。 ### -3004 TRADE_NOT_ALLOWED - 禁止交易。 ### -3005 TRANSFER_OUT_NOT_ALLOWED - 不允许转账。 ### -3006 EXCEED_MAX_BORROWABLE - 您的已借金额已超过最高可借金额。 ### -3007 HAS_PENDING_TRANSACTION - 您有待处理的交易,请稍后再试。 ### -3008 BORROW_NOT_ALLOWED - 不允许借款。 ### -3009 ASSET_NOT_MORTGAGEABLE - 此资产目前不允许转入杠杆账户。 ### -3010 REPAY_NOT_ALLOWED - 不允许还款。 ### -3011 BAD_DATE_RANGE - 您输入的日期无效。 ### -3012 ASSET_ADMIN_BAN_BORROW - 此资产禁止借款。 ### -3013 LT_MIN_BORROWABLE - 借入金额少于最低借入金额。 ### -3014 ACCOUNT_BAN_BORROW - 此帐户禁止借款。 ### -3015 REPAY_EXCEED_LIABILITY - 还款额超过借款额。 ### -3016 LT_MIN_REPAY - 还款额少于最低还款额。 ### -3017 ASSET_ADMIN_BAN_MORTGAGE - 此资产目前不允许转入保证金账户。 ### -3018 ACCOUNT_BAN_MORTGAGE - 此帐户已禁止转入。 ### -3019 ACCOUNT_BAN_ROLLOUT - 此帐户禁止转出。 ### -3020 EXCEED_MAX_ROLLOUT - 转出金额超过上限。 ### -3021 PAIR_ADMIN_BAN_TRADE - 杠杆账户无法交易此交易对。 ### -3022 ACCOUNT_BAN_TRADE - 账号被禁止交易。 ### -3023 WARNING_MARGIN_LEVEL - 无法在当前杠杆倍数下转出资金或者下单 ### -3024 FEW_LIABILITY_LEFT - 付款之后未付款的债务太小 ### -3025 INVALID_EFFECTIVE_TIME - 输入时间有误。 ### -3026 VALIDATION_FAILED - 输入参数有误。 ### -3027 NOT_VALID_MARGIN_ASSET - 无效的杠杆资产。 ### -3028 NOT_VALID_MARGIN_PAIR - 无效的杠杆交易对。 ### -3029 TRANSFER_FAILED - 转账失败。 ### -3036 ACCOUNT_BAN_REPAY - 此账号无法还款。 ### -3037 PNL_CLEARING - `PNL`正在清帐,请稍等。 ### -3038 LISTEN_KEY_NOT_FOUND - 找不到`Listen key` ### -3041 BALANCE_NOT_CLEARED - 余额不足 ### -3042 PRICE_INDEX_NOT_FOUND - 该杠杆交易对无可用价格指数。 ### -3043 TRANSFER_IN_NOT_ALLOWED - 不允许转入。 ### -3044 SYSTEM_BUSY - 系统繁忙。 ### -3045 SYSTEM - 系统目前没有足够可借的资产。 ### -3999 NOT_WHITELIST_USER - 此功能只面向邀请的用户。 ### -4001 CAPITAL_INVALID - 非法操作 ### -4002 CAPITAL_IG - 非法获取 ### -4003 CAPITAL_IEV - 非法邮箱验证 ### -4004 CAPITAL_UA - 未登录或者认证。 ### -4005 CAPAITAL_TOO_MANY_REQUEST - 请求太频繁。 ### -4006 CAPITAL_ONLY_SUPPORT_PRIMARY_ACCOUNT - 只支持主账号。 ### -4007 CAPITAL_ADDRESS_VERIFICATION_NOT_PASS - 地址的没有通过校验。 ### -4008 CAPITAL_ADDRESS_TAG_VERIFICATION_NOT_PASS - 地址的标记信息(`tag`)没有通过校验。 ### -4010 CAPITAL_WHITELIST_EMAIL_CONFIRM - 确认电子邮件已经列入白名单。 ### -4011 CAPITAL_WHITELIST_EMAIL_EXPIRED - 列入白名单的电子邮件无效。 ### -4012 CAPITAL_WHITELIST_CLOSE - 白名单未打开。 ### -4013 CAPITAL_WITHDRAW_2FA_VERIFY - 2FA未打开。 ### -4014 CAPITAL_WITHDRAW_LOGIN_DELAY - 在登录后的2分钟之内不允许提款。 ### -4015 CAPITAL_WITHDRAW_RESTRICTED_MINUTE - 暂停提款 ### -4016 CAPITAL_WITHDRAW_RESTRICTED_PASSWORD - 在密码修改后的24小时之内不允许提款。 ### -4017 CAPITAL_WITHDRAW_RESTRICTED_UNBIND_2FA - 在2FA发行后的24小时之内不允许提款。 ### -4018 CAPITAL_WITHDRAW_ASSET_NOT_EXIST - 此资产不存在。 ### -4019 CAPITAL_WITHDRAW_ASSET_PROHIBIT - 此资产不允许提款。 ### -4021 CAPITAL_WITHDRAW_AMOUNT_MULTIPLE - 资产的提款数量必须是%s的%s倍。 ### -4022 CAPITAL_WITHDRAW_MIN_AMOUNT - 不须少于最低的提款数量%s。 ### -4023 CAPITAL_WITHDRAW_MAX_AMOUNT - 在24小时之内,不须超过最高的提款数量。 ### -4024 CAPITAL_WITHDRAW_USER_NO_ASSET - 当前用户没有此资产。 ### -4025 CAPITAL_WITHDRAW_USER_ASSET_LESS_THAN_ZERO - 持有资产的数量小于零。 ### -4026 CAPITAL_WITHDRAW_USER_ASSET_NOT_ENOUGH - 此资产余额不足。 ### -4027 CAPITAL_WITHDRAW_GET_TRAN_ID_FAILURE - 无法获取tranId。 ### -4028 CAPITAL_WITHDRAW_MORE_THAN_FEE - 提款金额必须多于佣金额。 ### -4029 CAPITAL_WITHDRAW_NOT_EXIST - 此提款记录不存在。 ### -4030 CAPITAL_WITHDRAW_CONFIRM_SUCCESS - 提款资产成功。 ### -4031 CAPITAL_WITHDRAW_CANCEL_FAILURE - 取消提款失败。 ### -4032 CAPITAL_WITHDRAW_CHECKSUM_VERIFY_FAILURE - 验证提款失败。 ### -4033 CAPITAL_WITHDRAW_ILLEGAL_ADDRESS - 提款地址不合法。 ### -4034 CAPITAL_WITHDRAW_ADDRESS_CHEAT - 当前地址有异常。 ### -4035 CAPITAL_WITHDRAW_NOT_WHITE_ADDRESS - 此地址不在白名单上。请加入然后重试。 ### -4036 CAPITAL_WITHDRAW_NEW_ADDRESS - 新地址在{0}小时后才可以提款。 ### -4037 CAPITAL_WITHDRAW_RESEND_EMAIL_FAIL - 重新发送邮件失败。 ### -4038 CAPITAL_WITHDRAW_RESEND_EMAIL_TIME_OUT - 请5分钟后重试。 ### -4039 CAPITAL_USER_EMPTY - 用户不存在。 ### -4041 CAPITAL_MINUTE_TOO_SMALL - 请一分钟后重试。 ### -4042 CAPITAL_CHARGE_NOT_RESET - 资产无法重新获取存款地址。 ### -4043 CAPITAL_ADDRESS_TOO_MUCH - 在24小时之内充值超过100多个地址。 ### -4044 CAPITAL_BLACKLIST_COUNTRY_GET_ADDRESS - 此国家在黑名单上。 ### -4045 CAPITAL_GET_ASSET_ERROR - 获得资产失败。 ### -4046 CAPITAL_AGREEMENT_NOT_CONFIRMED - 协议未确认。 ### -4047 CAPITAL_DATE_INTERVAL_LIMIT - 时间间隔必须在0-90天之内 ### -4060 CAPITAL_WITHDRAW_USER_ASSET_LOCK_DEPOSIT - 体现仍在区块确认中,暂时锁定部分资产 ### -4106 TAG_NOT_SUPPORTED_FOR_NETWORK - 该网络不支持 memo/tag。请移除 `addressTag` 字段后重试。 ### -5001 ASSET_DRIBBLET_CONVERT_SWITCH_OFF - 不允许转移到微型资产。 ### -5002 ASSET_ASSET_NOT_ENOUGH - 此余额不足。 ### -5003 ASSET_USER_HAVE_NO_ASSET - 此资产不存在。 ### -5004 USER_OUT_OF_TRANSFER_FLOAT - 剩余余额已超过0.001BTC,请重新选择。 - %s的剩余余额已超过0.001BTC,请重新选择。 ### -5005 USER_ASSET_AMOUNT_IS_TOO_LOW - BTC的剩余余额太低,请重新选择。 - %s的剩余余额太低,请重新选择。 ### -5006 USER_CAN_NOT_REQUEST_IN_24_HOURS - 24小时内只能转账一次。 ### -5007 AMOUNT_OVER_ZERO - 数量必须大于零。 ### -5008 ASSET_WITHDRAW_WITHDRAWING_NOT_ENOUGH - 可退回资产的金额不足。 ### -5009 PRODUCT_NOT_EXIST - 产品不存在。 ### -5010 TRANSFER_FAIL - 资产转移失败。 ### -5011 FUTURE_ACCT_NOT_EXIST - 合约帐户不存在。 ### -5012 TRANSFER_PENDING - 资产转移正在进行中。 ### -5021 PARENT_SUB_HAVE_NO_RELATION - 当前的子账户和母账户没有从属关系。 ### -5012 FUTURE_ACCT_OR_SUBRELATION_NOT_EXIST - 合约帐户或子账户关系不存在。 ## 6XXX - 币安宝相关 ### -6001 DAILY_PRODUCT_NOT_EXIST - 理财产品不存在. ### -6003 DAILY_PRODUCT_NOT_ACCESSIBLE - 产品不存在或者没有权限。 ### -6004 DAILY_PRODUCT_NOT_PURCHASABLE - 产品无法购买。 ### -6005 DAILY_LOWER_THAN_MIN_PURCHASE_LIMIT - 低于可以购买的最小限额。 ### -6006 DAILY_REDEEM_AMOUNT_ERROR - 赎回额度有误。 ### -6007 DAILY_REDEEM_TIME_ERROR - 不在赎回的时间内。 ### -6008 DAILY_PRODUCT_NOT_REDEEMABLE - 产品暂时无法赎回。 ### -6009 REQUEST_FREQUENCY_TOO_HIGH - 发送请求太频繁。 ### -6011 EXCEEDED_USER_PURCHASE_LIMIT - 超购每个月用户可以申购的最大次数。 ### -6012 BALANCE_NOT_ENOUGH - 余额不足。 ### -6013 PURCHASING_FAILED - 申购失败。 ### -6014 UPDATE_FAILED - 超过可以申购的最大上限。 ### -6015 EMPTY_REQUEST_BODY - 请求的`body`为空。 ### -6016 PARAMS_ERR - 请求的参数有误。 ### -6017 NOT_IN_WHITELIST - 不在白名单里面。 ### -6018 ASSET_NOT_ENOUGH - 资产不足。 ### -6019 PENDING - 需要进一步确认。 ### -6020 PROJECT_NOT_EXISTS - 此项目不存在。 ## 70xx - 期货 ### -7001 FUTURES_BAD_DATE_RANGE - 此日期范围不支持。 ### -7002 FUTURES_BAD_TYPE - 此数据请求类型不支持。 ## 20xxx - 合约/现货策略交易 ### -20121 Invalid symbol - 无效交易对。 ### -20124 Invalid algo id or it has been completed - 无效的策略订单ID或者它已经被执行。 ### -20130 Invalid data sent for a parameter - 无效数据。 ### -20132 The client algo id is duplicated - 用户自定义策略订单ID重复。 ### -20194 Duration is too short to execute all required quantity - Duration 时间太短不足以执行用户选择的订单数量。 ### -20195 The total size is too small - 下单数量太小。 ### -20196 The total size is too large - 下单数量太大。 ### -20198 Reach the max open orders allowed - 达到了最大挂单上限。 ### -20204 The notional of USD is less or more than the limit - 订单小于最小USD名义价值 ## 过滤器故障 | 报错信息 | 描述 | | ------------------------------------------ | ---------------------------------------------------------------------------------- | | "Filter failure: PRICE_FILTER" | "价格"过高,过低和/或不遵循交易对的最小价格规则。 | | "Filter failure: PERCENT_PRICE" | "价格"比最近Y分钟的平均加权价格高X%或X%太低。 | | "Filter failure: PERCENT_PRICE_BY_SIDE" | `price` 在当前方向上(`BUY`或者`SELL`)比`lastPrice`价格超过X%或者低于Y%。 | | "Filter failure: LOT_SIZE" | "数量"太高,太低和/或不遵循该交易对的步长规则。 | | "Filter failure: MIN_NOTIONAL" | 价格\*数量太低,无法成为该交易对的有效订单。 | | "Filter failure: ICEBERG_PARTS" | `ICEBERG` 订单会分成太多部分; icebergQty太小。 | | "Filter failure: MARKET_LOT_SIZE" | "MARKET"订单的"数量"过高,过低和/或未遵循交易对的步长规则。 | | "Filter failure: MAX_POSITION" | 达到账户的最大仓位限制。这包括了账户的余额总额,以及所有处于open的买单的数量总和。 | | "Filter failure: MAX_NUM_ORDERS" | 客户在交易对上有太多挂单。 | | "Filter failure: MAX_ALGO_ORDERS" | 账户有太多未平仓止损和/或在交易对上执行获利指令。 | | "Filter failure: MAX_NUM_ICEBERG_ORDERS" | 客户在交易对上有太多 iceberg 挂单。 | | "Filter failure: TRAILING_DELTA" | `trailingDelta` 值不在限定的范围内. | | "Filter failure: EXCHANGE_MAX_NUM_ORDERS" | 帐户上的交易所有太多挂单。 | | "Filter failure: EXCHANGE_MAX_ALGO_ORDERS" | 帐户有太多止损挂单和/或在交易所收取获利指令。 | ## 10xxx - 质押借币 ### -10001 SYSTEM_MAINTENANCE - 系统维护中,请稍后再试 ### -10002 INVALID_INPUT - 无效的输入参数 ### -10005 NO_RECORDS - 暂无记录 ### -10007 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10008 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10009 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10010 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10011 INSUFFICIENT_ASSET - 现货资产不足 ### -10012 INVALID_AMOUNT - 无效的还款金额 ### -10013 INSUFFICIENT_AMOUNT - 抵押资产不足 ### -10015 DEDUCTION_FAILED - 抵押资产扣款失败 ### -10016 LOAN_FAILED - 放贷失败 ### -10017 REPAY_EXCEED_DEBT - 还款金额超过负债金额 ### -10018 INVALID_AMOUNT - 无效的还款金额 ### -10019 CONFIG_NOT_EXIST - 配置不存在 ### -10020 UID_NOT_EXIST - 用户ID不存在 ### -10021 ORDER_NOT_EXIST - 订单不存在 ### -10022 INVALID_AMOUNT - 无效的调整金额 ### -10023 ADJUST_LTV_FAILED - 调整质押率失败 ### -10024 ADJUST_LTV_NOT_SUPPORTED - 暂不支持调整质押率 ### -10025 REPAY_FAILED - 还款失败 ### -10026 INVALID_PARAMETER - 无效的参数 ### -10028 INVALID_PARAMETER - 无效的参数 ### -10029 AMOUNT_TOO_SMALL - 借贷金额过小 ### -10030 AMOUNT_TOO_LARGE - 借贷金额过大 ### -10031 QUOTA_REACHED - 已达到个人借贷限额 ### -10032 REPAY_NOT_AVAILABLE - 暂不支持换款 ### -10034 REPAY_NOT_AVAILABLE - 抵押物还款暂时不支持,请尝试用借贷币还款。 ### -10039 AMOUNT_TOO_SMALL - 还款金额过小 ### -10040 AMOUNT_TOO_LARGE - 还款金额过大 ### -10041 INSUFFICIENT_AMOUNT - 由于借贷需求过多,系统剩余可借{0}额度不足。请调整借贷金额或明天再试。 ### -10042 ASSET_NOT_SUPPORTED - 暂不支持%s币种 ### -10043 ASSET_NOT_SUPPORTED - 暂不支持{0} 借贷 ### -10044 QUOTA_REACHED - 抵押物数量已达到限额,请调整抵押金额或使用其他抵押资产。 ### -10045 COLLTERAL_REPAY_NOT_SUPPORTED - 该借贷币种暂不支持抵押物还款,请稍后再试。 ### -10046 EXCEED_MAX_ADJUSTMENT - 调整抵押物超过最大限额,请重试。 ### -10047 REGION_NOT_SUPPORTED - 受当地法规管制,您所在地区暂不支持该币种。 ## 13xxx - 杠杆代币 ### -13000 BLVT_FORBID_REDEEM - 当前该杠杆代币关闭赎回 ### -13001 BLVT_EXCEED_DAILY_LIMIT - 超过该代币个人24小时赎回金额上限 ### -13002 BLVT_EXCEED_TOKEN_DAILY_LIMIT - 超过该代币全局24小时赎回金额上限 ### -13003 BLVT_FORBID_PURCHASE - 当前该杠杆代币关闭申购 ### -13004 BLVT_EXCEED_DAILY_PURCHASE_LIMIT - 超过该代币个人24小时申购金额上限 ### -13005 BLVT_EXCEED_TOKEN_DAILY_PURCHASE_LIMIT - 超过该代币全局24小时申购金额上限 ### -13006 BLVT_PURCHASE_LESS_MIN_AMOUNT - 申购金额低于规定下限 ### -13007 BLVT_PURCHASE_AGREEMENT_NOT_SIGN - 没有签署开通交易协议 ## 12xxx - 流动性挖矿 ### -12014 TOO MANY REQUESTS - 2秒内接收的请求数量多于1条 ## 18xxx - 币安码 ### -18002 - The total amount of codes you created has exceeded the 24-hour limit, please try again after UTC 0 - 24小时内制码总金额已超过限额,请UTC0点后再尝试 ### -18003 - Too many codes created in 24 hours, please try again after UTC 0 - 24小时内制码总次数已超过限额,请UTC0点后再尝试 ### -18004 - Too many invalid redeem attempts in 24 hours, please try again after UTC 0 - 24小时内兑现币安码输错次数已超过限额,请UTC0点后再尝试 ### -18005 - Too many invalid verify attempts, please try later - 参考号输错次数过多,请稍后再试 ### -18006 - The amount is too small, please re-enter - 金额过小,请重新输入 ### -18007 - This token is not currently supported, please re-enter - 尚未支持该币种,请重新输入 ## 21xxx - 統一帳戶 ### -21001 USER_IS_NOT_UNIACCOUNT - 尚未开通统一账户。 ### -21002 UNI_ACCOUNT_CANT_TRANSFER_FUTURE - 统一账户禁用margin向futures转账。 ### -21003 NET_ASSET_MUST_LTE_RATIO - margin资产更新失败。 ### -21004 USER_NO_LIABILITY - 用户不存在统一账户穿仓负债 ### -21005 NO_ENOUGH_ASSET - 用户现货钱包BUSD资产不足以偿还统一账户穿仓负债 ### -21006 HAD_IN_PROCESS_REPAY - 用户存在正在偿还的统一账户穿仓负债 ### -21007 IN_FORCE_LIQUIDATION - 强平进行中,用户偿还统一账户穿仓负债失败 ## 订单拒绝错误 以下错误代码表示撮合引擎返回的订单相关错误: - `-1010 ERROR_MSG_RECEIVED` - `-2010 NEW_ORDER_REJECTED` - `-2011 CANCEL_REJECTED` 结合以下消息将指示特定的错误: | 错误信息 | 描述 | | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | "Unknown order sent." | 找不到订单(通过"orderId","clientOrderId","origClientOrderId") | | "Duplicate order sent." | `clientOrderId`已经被使用 | | "Market is closed." | 该交易对不在交易范围 | | "Account has insufficient balance for requested action." | 没有足够的资金来完成行动 | | "Market orders are not supported for this symbol." | 交易对上未启用"MARKET" | | "Iceberg orders are not supported for this symbol." | 交易对上未启用`icebergQty` | | "Stop loss orders are not supported for this symbol." | 交易对上未启用 `STOP_LOSS` | | "Stop loss limit orders are not supported for this symbol." | 交易对上未启`STOP_LOSS_LIMIT` | | "Take profit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT` | | "Take profit limit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT_LIMIT` | | "Price \* QTY is zero or less." | `price` \* `quantity`太小 | | "IcebergQty exceeds QTY." | `icebergQty` 必须少于订单数量 | | "This action is disabled on this account." | 联系客户支持; 该账户已禁用了某些操作。 | | "This account may not place or cancel orders." | 联系客户支持: 该账户已被禁用了交易操作。 | | "Unsupported order combination" | 不允许组合`orderType`, `timeInForce`, `stopPrice`, 和/或 `icebergQty` 。 | | "Order would trigger immediately." | 与最后交易价格相比,订单的止损价无效。 | | "Cancel order is invalid. Check origClientOrderId and orderId." | 未发送`origClientOrderId` 或`orderId` 。 | | "Order would immediately match and take." | `LIMIT_MAKER` 订单类型将立即匹配并进行交易,而不是纯粹的生成订单。 | | "The relationship of the prices for the orders is not correct." | `OCO`订单中设置的价格不符合报价规则:

The rules are:

`SELL Orders`: Limit Price > Last Price > Stop Price

`BUY Orders`: Limit Price < Last Price < Stop Price | | "OCO orders are not supported for this symbol" | `OCO`订单不支持该交易对 | | "Quote order qty market orders are not support for this symbol." | 这个交易对,市价单不支持参数`quoteOrderQty` | | "Trailing stop orders are not supported for this symbol." | 此symbol不支持 `trailingDelta` | | | "Order cancel-replace is not supported for this symbol." | 此symbol不支持 `POST /api/v3/order/cancelReplace` 或者 `order.cancelReplace` (WebSocket API) | | | "This symbol is not permitted for this account." | 账户和交易对的权限不一致 (比如 `SPOT`, `MARGIN` 等)。| | | "This symbol is restricted for this account." | 账户没有权限在此交易对交易 (比如账户只拥有 `ISOLATED_MARGIN`权限,则无法下`SPOT` 订单)。 | | | "Order was not canceled due to cancel restrictions." | `cancelRestrictions` 设置为 `ONLY_NEW` 但订单状态不是 `NEW`

`cancelRestrictions` 设置为 `ONLY_PARTIALLY_FILLED` 但订单状态不是 `PARTIALLY_FILLED`。 | | ## 关于 POST /api/v3/order/cancelReplace 的错误 ### -2021 Order cancel-replace partially failed 收到该错误码代表撤单**或者**下单失败。 ### -2022 Order cancel-replace failed. 收到该错误码代表撤单**和**下单都失败。 --- ## Document: /products/spot-block-matching/change-log URL: /zh-CN/docs/products/spot-block-matching/change-log ## 2025-12-26 ### 时效性通知 - **以下有关于REST API变更将在 2026-01-15 07:OO UTC 发生:**
调用需要签名的接口时,请在计算签名之前对 payload 进行百分比编码(percent-encode)。不符合此顺序的请求将被拒绝,并返回错误代码 [`-1022 签名不正确`](./error-code.md#-1022-invalid_signature)。请检查并相应地更新您代码中的签名逻辑部分。 ### REST API - 更新了 REST API 文档中有关于 [签名请求示例](./general-info.md#post-apiv3order-的签名示例) 的部分。 --- ## 2025-06-27 - New endpoint for Spot Block Matching: - `POST /sapi/v1/block-match/order/cancel` 取消订单 - `POST /sapi/v1/block-match/order/extend` 在当前时间基础上增加 30 分钟,延长订单有效期 - `POST /sapi/v1/block-match/order/place` 现货匹配下单,订单有效期为 30 分钟,如不执行将自动失效 - `POST /sapi/v1/block-match/order/take` 接受订单,完成交易 - `POST /sapi/v1/block-match/order/query-open-order` 查询用户的未结订单 - `POST /sapi/v1/block-match/order/query-order-history` 查询用户的订单历史记录 - `POST /sapi/v1/block-match/symbols` 返回支持的交易对 --- ## Document: /products/spot-block-matching/Introduction URL: /zh-CN/docs/products/spot-block-matching/Introduction Spot Block Matching 是一个平台,使交易者能够绕过交易所订单簿,直接相互执行大额交易。这将增强自由裁量权,提高交易效率,最大限度地减少对市场的影响,并减少滑点。 确保您的主账户被列入白名单,以便参与现货大宗交易交易。一旦被列入白名单,您既可以做市商,也可以做市商。有关白名单申请,请联系您的销售/大客户现货覆盖团队;或 vip@binance.com。 有关这方面的更多信息,请参阅[现货大宗交易常见问题](https://www.binance.com/en/support/faq/detail/cc66271ed16f4e24a26a0dedd90e00c8)。 --- ## Document: /products/spot/web-socket-streams URL: /zh-CN/docs/products/spot/web-socket-streams # 通用 WebSocket 流信息 - 本篇所列出的所有wss接口的baseurl为: **wss://stream.binance.com:9443** 或者 **wss://stream.binance.com:443** - 所有stream均可以直接访问,或者作为组合streams的一部分。 - 直接访问时URL格式为 **/ws/\** - 组合streams的URL格式为 **/stream?streams=\/\/\** - 订阅组合streams时,事件payload会以这样的格式封装 **{"stream":"\","data":\}** - stream名称中所有交易对均为**小写** - 每个到**stream.binance.com**的链接有效期不超过24小时,请妥善处理断线重连。 - 当服务器即将关闭时,系统将发送 [`serverShutdown`](#服务器关闭) 事件,并导致连接断开。请尽快建立新连接,以防止中断。 - WebSocket 服务器**每20秒**发送 PING 消息。 - 如果 WebSocket 服务器没有在一分钟之内收到PONG 消息应答,连接会被断开。 - 当客户收到PING消息,必须尽快回复PONG消息,同时payload需要和PING消息一致。 - 服务器允许未经请求的PONG消息,但这不会保证连接不断开。**对于这些PONG 消息,建议payload为空。** - **wss://data-stream.binance.vision** 可以用来订阅仅有市场信息的数据流。账户信息**无法**从此URL获得。 - 所有时间和时间戳相关字段均以**毫秒为默认单位**。 要以微秒为单位接收信息,请在 URL 中添加参数 `timeUnit=MICROSECOND` 或 `timeUnit=microsecond`。 - 例如: `/stream?streams=btcusdt@trade&timeUnit=MICROSECOND` - 如果您的请求包含非 ASCII 字符的交易对名称,那么数据流事件中可能包含以 UTF-8 编码的非 ASCII 字符。 - [全市场所有 Symbol 的精简 Ticker](/products/spot/web-socket-streams#all-markets-mini-ticker) 和 [全市场滚动窗口统计](/products/spot/web-socket-streams#all-market-rolling-window-ticker) 事件可能包含以 UTF-8 编码的非 ASCII 字符。 ## WebSocket 连接限制 - WebSocket服务器每秒最多接受5个消息。消息包括: - PING帧 - PONG帧 - JSON格式的消息, 比如订阅, 断开订阅. - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅1024个Streams。 - 每IP地址、每5分钟最多可以发送300次连接请求。 ## 服务器关闭 `serverShutdown` 事件在服务器即将关闭时发送。 - `raw` 数据流: ```javascript { "e": "serverShutdown", // 事件类型 "E": 1770123456789 // 事件时间 } ``` - `combined` 数据流: ```javascript { "stream": "!serverShutdown", "data": { "e": "serverShutdown", // 事件类型 "E": 1770123456789 // 事件时间 } } ``` 请尽快建立新的连接以避免中断。 ## 实时订阅/取消数据流 - 以下数据可以通过 WebSocket 发送以实现订阅或取消订阅数据流。示例如下. - 请求中的`id`被用作唯一标识来区分来回传递的消息。以下格式被接受: - 64位有符号整数 - 字母数字字符串;最大长度36 - `null` - 如果相应内容中的`result` 为 `null`,表示请求发送成功。 ### 订阅一个信息流 - 请求 ```javascript { "method": "SUBSCRIBE", "params": [ "btcusdt@aggTrade", "btcusdt@depth" ], "id": 1 } ``` - 响应 ```javascript { "result": null, "id": 1 } ``` ### 取消订阅一个信息流 - 请求 ```javascript { "method": "UNSUBSCRIBE", "params": [ "btcusdt@depth" ], "id": 312 } ``` - 响应 ```javascript { "result": null, "id": 312 } ``` ### 已订阅信息流 - 请求 ```javascript { "method": "LIST_SUBSCRIPTIONS", "id": 3 } ``` - 响应 ```javascript { "result": [ "btcusdt@aggTrade" ], "id": 3 } ``` ### 设定属性 当前,唯一可以设置的属性是设置是否启用`combined`("组合")信息流。当使用`/ws/`("原始信息流")进行连接时,combined属性设置为`false`,而使用 `/stream/`进行连接时则将属性设置为`true`。 - 请求 ```javascript { "method": "SET_PROPERTY", "params": [ "combined", true ], "id": 5 } ``` - 响应 ```javascript { "result": null, "id": 5 } ``` ### 检索属性 - 请求 ```javascript { "method": "GET_PROPERTY", "params": [ "combined" ], "id": 2 } ``` - 响应 ```javascript { "result": true, // Indicates that combined is set to true. "id": 2 } ``` ### 错误信息 | 错误信息 | 描述 | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | | {"code": 0, "msg": "Unknown property","id": %s} | `SET_PROPERTY` 或 `GET_PROPERTY`中应用的参数无效 | | {"code": 1, "msg": "Invalid value type: expected Boolean"} | 仅接受`true`或`false` | | {"code": 2, "msg": "Invalid request: property name must be a string"} | 提供的属性名无效 | | {"code": 2, "msg": "Invalid request: request ID must be an unsigned integer"} | 参数`id`未提供或`id`值是无效类型 | | {"code": 2, "msg": "Invalid request: unknown variant %s, expected one of `SUBSCRIBE`, `UNSUBSCRIBE`, `LIST_SUBSCRIPTIONS`, `SET_PROPERTY`, `GET_PROPERTY` at line 1 column 28"} | 错字提醒,或提供的值不是预期类型 | | {"code": 2, "msg": "Invalid request: too many parameters"} | 数据中提供了不必要参数 | | {"code": 2, "msg": "Invalid request: property name must be a string"} | 未提供属性名 | | {"code": 2, "msg": "Invalid request: missing field `method` at line 1 column 73"} | 数据未提供`method` | | {"code":3,"msg":"Invalid JSON: expected value at line %s column %s"} | JSON 语法有误. | ## 如何正确在本地维护一个order book副本 1. 打开与 `wss://stream.binance.com:9443/ws/bnbbtc@depth` 的 WebSocket 连接。 2. 开始缓存收到的event。请记录您收到的第一个event的 `U`值。 3. 访问 `https://api.binance.com/api/v3/depth?symbol=BNBBTC&limit=5000` 获取深度快照。 4. 如果快照中的 `lastUpdateId` 小于等于步骤 2 中的 `U` 值,请返回步骤 3。 5. 在收到的event中,丢弃快照中 `u` <= `lastUpdateId` 的所有event。现在第一个event的 `lastUpdateId` 应该在 `[U;u]` 范围以内。 6. 将本地order book设置为快照。它的更新ID 为 `lastUpdateId`。 7. 更新所有缓存的event,以及后续的所有event。 要将一个event应用于您的本地order book,请遵循以下更新过程: 1. 判断是否需要处理event: - 如果event的最后一次更新ID(`u`)小于本地order book的更新ID,忽略该event。 - 如果event的首次更新ID(`U`)大于本地order book的更新ID加1,说明你错过了一些events。
请丢弃您的本地order book并从头开始重新同步。 - 通常,下一event的`U`等于上一event的`u + 1`。 1. 对买价(`b`)和卖价(`a`)中的每个价位,设置order book中的新数量: - 如果该价位在order book中不存在,则插入该价位及其数量。 - 如果数量为零,则从order book中删除此价位。 1. 将order book的更新ID设置为已处理event的最后一次更新ID(`u`)。 > [!NOTE] > 由于从 API 检索的深度快照对价位的数量有限制(每侧最多 5000 个),因此除非它们发生变化,否则您将无法了解初始快照之外的价位数量。
> 因此,在使用这些级别的信息时要小心,因为它们可能无法反映订单簿的完整视图。
> 但是,对于大多数场景,可以每侧看到 5000 个价位就足以了解市场并进行有效交易。 --- ## Document: /products/spot/web-socket-api URL: /zh-CN/docs/products/spot/web-socket-api # WebSocket API 基本信息 - 本篇所列出的 wss 接口的 base URL:**`wss://ws-api.binance.com:443/ws-api/v3`** - 如果使用标准443端口时遇到问题,可以使用替代端口9443。 - [现货测试网](https://testnet.binance.vision)的 base URL 是 `wss://ws-api.testnet.binance.vision/ws-api/v3`。 - 每个到 base URL 的链接有效期不超过24小时,请妥善处理断线重连。 - 当服务器即将关闭时,系统将发送 [`serverShutdown`](#serverShutdown) 事件,并导致连接断开。请尽快建立新连接,以防止中断。 - 我们支持 HMAC,RSA 以及 Ed25519 Key 类型。 如需进一步了解,请参考 [API Key 类型](faqs/api_key_types.md)。 - 响应默认为 JSON 格式。如果您想接收 SBE 格式的响应,请参考 [简单二进制编码 (SBE) 常见问题](./faqs/sbe_faq.md)。 - 如果您的请求包含非 ASCII 字符的交易对名称,那么响应中可能包含以 UTF-8 编码的非 ASCII 字符。 - 即使请求本身不包含非 ASCII 字符,某些方法也可能会返回包含以 UTF-8 编码的非 ASCII 字符的资产和/或交易对名称。 - WebSocket 服务器**每20秒**发送 PING 消息。 - 如果websocket 服务器没有在一分钟之内收到PONG 消息应答,连接会被断开。 - 当客户收到PING消息,必须尽快回复PONG消息,同时payload需要和PING消息一致。 - 服务器允许未经请求的PONG消息,但这不会保证连接不断开。**对于这些PONG 消息,建议payload为空。** - 除非另有说明,否则数据将按**时间顺序**返回。 - 如果未指定 `startTime` 或 `endTime`,则返回最近的条目,直至达到限制值。 - 如果指定 `startTime`,则返回从 `startTime` 到限制值为止最老的条目。 - 如果指定 `endTime`,则返回截至 `endTime` 和限制值为止最近的条目。 - 如果同时指定 `startTime` 和 `endTime`,则行为类似于 `startTime`,但不超过 `endTime`。 - JSON 响应中的所有时间和时间戳相关字段均以**UTC 毫秒为默认单位**。要以微秒为单位接收信息,请在 URL 中添加参数 `timeUnit=MICROSECOND` 或 `timeUnit=microsecond`。 - 时间戳参数(例如 `startTime`、`endTime`、`timestamp`)可以以毫秒或微秒为单位传递。 - 除非另有说明,所有字段名称和值都**大小写敏感**。 - 如需进一步了解枚举或术语,请参考 [现货交易API术语表](faqs/spot_glossary.md) 页面。 - API 处理请求的超时时间为 10 秒。如果撮合引擎的响应时间超过此时间,API 将返回 “Timeout waiting for response from backend server. Send status unknown; execution status unknown.”。[(-1007 超时)](errors.md#-1007-timeout) - 这并不总是意味着该请求在撮合引擎中失败。 - 如果请求状态未显示在 [用户数据流](user-data-stream.md) 中,请执行 API 查询以获取其状态。 - **请避免在请求中使用 SQL 关键字**,因为这可能会触发 Web 应用防火墙(WAF)规则导致安全拦截。详情请参见 https://www.binance.com/zh-CN/support/faq/detail/360004492232 ## 请求格式 请求必须在 **text 帧** 中以 JSON 格式发送,每帧一个请求。 请求示例: ```json { "id": "e2a85d9f-07a5-4f94-8d5f-789dc3deb097", "method": "order.place", "params": { "symbol": "BTCUSDT", "side": "BUY", "type": "LIMIT", "price": "0.1", "quantity": "10", "timeInForce": "GTC", "timestamp": 1655716096498, "apiKey": "T59MTDLWlpRW16JVeZ2Nju5A5C98WkMm8CSzWC4oqynUlTm1zXOxyauT8LmwXEv9", "signature": "5942ad337e6779f2f4c62cd1c26dba71c91514400a24990a3e7f5edec9323f90" } } ``` 请求字段: | 名称 | 类型 | 是否必需 | 描述 | | -------- | --------------------- | -------- | ------------------------------ | | `id` | INT / STRING / `null` | YES | 任意的 ID 用于匹配对请求的响应 | | `method` | STRING | YES | 请求函数名称 | | `params` | OBJECT | NO | 请求参数。如果没有参数可以省略 | - 请求 `id` 是任意的。可以使用 UUID、顺次 ID、当前时间戳等。服务器不会以任何方式解释 `id`,只是在响应中回显它。 可以在一个会话中自由重复使用 ID,不过请注意不要一次发送多个具有相同 ID 的请求,因为否则可能无法区分响应。 - 请求函数名称可以以显式版本为前缀,例如:`"v3/order.place"` - `params` 的顺序不重要。 ## 响应格式 响应在 **text 帧** 中以 JSON 格式返回,每帧一个响应。 成功响应示例: ```json { "id": "e2a85d9f-07a5-4f94-8d5f-789dc3deb097", "status": 200, "result": { "symbol": "BTCUSDT", "orderId": 12510053279, "orderListId": -1, "clientOrderId": "a097fe6304b20a7e4fc436", "transactTime": 1655716096505, "price": "0.10000000", "origQty": "10.00000000", "executedQty": "0.00000000", "origQuoteOrderQty": "0.000000", "cummulativeQuoteQty": "0.00000000", "status": "NEW", "timeInForce": "GTC", "type": "LIMIT", "side": "BUY", "workingTime": 1655716096505, "selfTradePreventionMode": "NONE" }, "rateLimits": [ { "rateLimitType": "ORDERS", "interval": "SECOND", "intervalNum": 10, "limit": 50, "count": 12 }, { "rateLimitType": "ORDERS", "interval": "DAY", "intervalNum": 1, "limit": 160000, "count": 4043 }, { "rateLimitType": "REQUEST_WEIGHT", "interval": "MINUTE", "intervalNum": 1, "limit": 6000, "count": 321 } ] } ``` 失败响应示例: ```json { "id": "e2a85d9f-07a5-4f94-8d5f-789dc3deb097", "status": 400, "error": { "code": -2010, "msg": "Account has insufficient balance for requested action." }, "rateLimits": [ { "rateLimitType": "ORDERS", "interval": "SECOND", "intervalNum": 10, "limit": 50, "count": 13 }, { "rateLimitType": "ORDERS", "interval": "DAY", "intervalNum": 1, "limit": 160000, "count": 4044 }, { "rateLimitType": "REQUEST_WEIGHT", "interval": "MINUTE", "intervalNum": 1, "limit": 6000, "count": 322 } ] } ``` 响应字段:
名称 类型 是否必需 描述
id INT / STRING / null YES 与原来请求的ID一样
status INT YES 响应状态。请看 状态代码
result OBJECT / ARRAY YES 响应内容。请求成功则显示
error OBJECT 错误描述。请求失败则显示
rateLimits ARRAY NO 速率限制状态。请看 速率限制
### 状态代码 `status` 字段的状态代码与HTTP的状态代码相同。 一些常见状态代码: - `200` 代码指示成功响应。 - `4XX` 错误码用于指示错误的请求内容、行为、格式。问题在于请求者。 - `400` – 错误码表示请求失败,请参阅 `error` 了解原因。 - `403` – 错误码表示违反 WAF 限制(Web应用程序防火墙)。这可能表示触发了速率限制或安全拦截。详情请参见 https://www.binance.com/zh-CN/support/faq/detail/360004492232 。 - `409` – 错误码表示请求有一部分成功,一部分失败。请参阅 `error` 了解更多详细 - `418` – 表示收到 429 后继续访问,于是被封了。 - `429` – 错误码表示警告访问频次超限,即将被封IP。 - `5XX` 错误码用于指示Binance服务侧的问题。 - **重要**:如果响应包含 5xx 状态码,**并不**一定意思请求失败。执行状态为 _unknown_,请求可能实际成功。请使用 query 函数确认状态。建议建立一个新 WebSocket 连接用于确认状态。 有关错误代码和消息的列表,请参阅 [Binance 的错误代码](errors.md)。 ## 事件格式 [用户数据流](user-data-stream.md)中的非 SBE 会话事件以 JSON 格式在 **text 帧** 中发送,每帧一个事件。 [SBE 会话](faqs/sbe_faq.md)中的事件将作为 **二进制帧** 发送。 有关如何在 WebSocket API 中订阅用户数据流的详细信息,请参阅 [`订阅用户数据流`](#user-data-stream-subscribe)。 事件示例: ```javascript { "subscriptionId": 0, "event": { "e": "outboundAccountPosition", "E": 1728972148778, "u": 1728972148778, "B": [ { "a": "BTC", "f": "11818.00000000", "l": "182.00000000" }, { "a": "USDT", "f": "10580.00000000", "l": "70.00000000" } ] } } ``` 事件字段: | 名称 | 类型 | 是否必须 | 描述 | | ---------------- | ------ | -------- | ----------------------------------------------------------------------------------------------- | | `event` | OBJECT | YES | 事件 payload。请看 [用户数据流](user-data-stream.md) | | `subscriptionId` | INT | NO | 用以标识事件来自于哪个订阅。详见 [用户数据流订阅](#general_info_user_data_stream_subscriptions) | ## 连接事件 ### 服务器关闭 当服务器即将关闭时,会发送 `serverShutdown` 事件。 ```javascript { "event": { "e": "serverShutdown", // 事件类型 "E": 1770123456789 // 事件时间 } } ``` 请尽快建立新连接,以防中断 ## 速率限制 ### 连接数量限制 每IP地址、每5分钟最多可以发送300次连接请求。 ### 速率限制基本信息 - [`exchangeInfo`](#exchangeInfo) 有包含与速率限制相关的信息。 - 根据不同的间隔,有多种频率限制类型。 - 从响应中的可选 `rateLimits` 字段,能看到当前的频率限制状态。 - 当您超出未成交订单计数或者请求速率限制时,请求会失败并返回 HTTP 状态代码 429。 #### 如何咨询频率限制 频率限制状态的响应可能如下所示: ```json { "id": "7069b743-f477-4ae3-81db-db9b8df085d2", "status": 200, "result": { "serverTime": 1656400526260 }, "rateLimits": [ { "rateLimitType": "REQUEST_WEIGHT", "interval": "MINUTE", "intervalNum": 1, "limit": 6000, "count": 70 } ] } ``` `rate Limits` 数组描述了受请求影响的所有当前的速率限制。 | 名称 | 类型 | 是否必须 | 描述 | | --------------- | ---- | -------- | ----------------------------------------------- | | `rateLimitType` | ENUM | YES | 频率限制类型: `REQUEST_WEIGHT`, `ORDERS` | | `interval` | ENUM | YES | 频率限制间隔: `SECOND`, `MINUTE`, `HOUR`, `DAY` | | `intervalNum` | INT | YES | 频率限制间隔乘数 | | `limit` | INT | YES | 每个间隔的请求限制 | | `count` | INT | YES | 每个间隔的当前使用情况 | 频率限制按间隔计算。 例如,`1 MINUTE` 间隔表示每分钟开始。在 00:01:23.456 提交的请求计入 00:01:00 分钟的限制。一旦 00:02:00 分钟开始,计数将再次重置为零。 其他间隔的行为方式类似。例如,`1 DAY` 频率限制是在每天 00:00 UTC 重置,并且 `10 SECOND` 间隔重置为每分钟的 00、10、20...秒。 API 有多种频率限制间隔。如果您用完了较短的间隔但较长的间隔仍然允许请求,您将不得不等待较短的间隔到期并重置。如果你用完了更长的间隔,你将不得不等待那个间隔重置,即使较短的频率限制计数为零。 #### 如何显示/隐藏频率限制信息 默认情况下,每个响应都包含 `rateLimits` 字段。 但是,频率限制信息可能非常大。如果您对每个请求的详细频率限制状态不感兴趣,可以从响应中省略 `rateLimits` 字段。 - 请求中的可选 `returnRateLimits` boolean 参数。 使用 `returnRateLimits` 参数控制是否包含 `rateLimits` 字段以响应单个请求。 默认请求和响应: ```json { "id": 1, "method": "time" } ``` ```json { "id": 1, "status": 200, "result": { "serverTime": 1656400526260 }, "rateLimits": [ { "rateLimitType": "REQUEST_WEIGHT", "interval": "MINUTE", "intervalNum": 1, "limit": 6000, "count": 70 } ] } ``` 没有频率限制状态的请求和响应: ```json { "id": 2, "method": "time", "params": { "returnRateLimits": false } } ``` ```json { "id": 2, "status": 200, "result": { "serverTime": 1656400527891 } } ``` - 连接 URL 中可选的 `returnRateLimits` boolean 参数。 如果您希望在默认情况下从所有响应中省略 `rateLimits`,可以在 query string 中使用 `returnRateLimits` 参数: ``` wss://ws-api.binance.com:443/ws-api/v3?returnRateLimits=false ``` 这将使通过此连接发出的所有请求的行为就像您已传了 `"returnRateLimits":false` 一样。 如果您*想*查看特定请求的频率限制,您需要特定传 `"returnRateLimits":true` 参数。 **注意:** 如果您在响应中隐藏 `rateLimits` 字段,您的请求仍然还是会受到频率限制的。 ### IP 访问限制 - 每个请求都有一个特定的 **权重**,它会添加到您的访问限制中。 - 越消耗资源的接口, 比如查询多个交易对, 权重就会越大。 - 连接到 WebSocket API 会用到2个权重。 - 当前权重使用由 `REQUEST_WEIGHT` 频率限制类型指示。 - 请使用[`exchangeInfo`](#exchangeInfo)请求来跟踪当前的重量限制。 - 权重是基于**每个 IP 地址**累积的,并由来自该地址的所有连接共享。 - 如果超多限制,客服端会收到 `429`。 - 这错误代码表示您有责任停止发送请求,不得滥用API。 - 响应会包含一个 `retryAfter` 字段,指示在什么时候您能重试。 - **屡次违反速率限制或者在收到429后未能退缩将导致自动 IP 封禁和断开连接。** - 被禁止 IP 地址的请求失败,状态为 `418`。 - `retryAfter` 字段表示解除禁令的timestamp。 - 频繁违反限制的封禁时间会**逐渐延长**,**从最短2分钟到最长3天**。 表示在1分钟内使用了(1200权重限制中的)70权重的成功响应: ```json { "id": "7069b743-f477-4ae3-81db-db9b8df085d2", "status": 200, "result": [], "rateLimits": [ { "rateLimitType": "REQUEST_WEIGHT", "interval": "MINUTE", "intervalNum": 1, "limit": 6000, "count": 70 } ] } ``` 表示已被封禁且封禁将在 epoch `1659146400000` 解锁的失败响应: ```json { "id": "fc93a61a-a192-4cf4-bb2a-a8f0f0c51e06", "status": 418, "error": { "code": -1003, "msg": "Way too much request weight used; IP banned until 1659146400000. Please use WebSocket Streams for live updates to avoid bans.", "data": { "serverTime": 1659142907531, "retryAfter": 1659146400000 } }, "rateLimits": [ { "rateLimitType": "REQUEST_WEIGHT", "interval": "MINUTE", "intervalNum": 1, "limit": 6000, "count": 2411 } ] } ``` ### 未成交订单计数 - 成功下单将更新 `订单` 速率限制类型。 - 被拒绝或不成功的订单可能会也可能不会更新 `订单` 速率限制类型。 - **请注意,如果您的订单一直顺利完成交易,您可以通过 API 持续下订单**。更多信息,请参见 [现货未成交订单计数规则](./faqs/order_count_decrement.md)。 - 使用 [`account.rateLimits.orders`](#query-unfilled-order-count) 请求来跟踪您在此时间间隔内下了多少订单。 - 如果超过此值,请求将失败,状态为 `429`。 - 此状态代码表示您应退出并停止向 API 滥发信息。 - 状态为 `429` 的响应会包含 `retryAfter` 字段,用以指示何时可以重试请求。 - 这是按 **每一个账户** 维护的,并由该账户的所有 API 密钥共享。 表示在10秒内下了12个订单和在24小时内下了4043个订单的成功响应: ```json { "id": "e2a85d9f-07a5-4f94-8d5f-789dc3deb097", "status": 200, "result": { "symbol": "BTCUSDT", "orderId": 12510053279, "orderListId": -1, "clientOrderId": "a097fe6304b20a7e4fc436", "transactTime": 1655716096505, "price": "0.10000000", "origQty": "10.00000000", "executedQty": "0.00000000", "origQuoteOrderQty": "0.000000", "cummulativeQuoteQty": "0.00000000", "status": "NEW", "timeInForce": "GTC", "type": "LIMIT", "side": "BUY", "workingTime": 1655716096505, "selfTradePreventionMode": "NONE" }, "rateLimits": [ { "rateLimitType": "ORDERS", "interval": "SECOND", "intervalNum": 10, "limit": 50, "count": 12 }, { "rateLimitType": "ORDERS", "interval": "DAY", "intervalNum": 1, "limit": 160000, "count": 4043 }, { "rateLimitType": "REQUEST_WEIGHT", "interval": "MINUTE", "intervalNum": 1, "limit": 6000, "count": 321 } ] } ``` ## 请求鉴权类型 - 每个方法都有一个鉴权类型,指示所需的 API 密钥权限,显示在方法名称旁边(例如,[下新订单 (TRADE)](#order-place))。 - 如果未指定,则鉴权类型为 `NONE`。 - 除了为 `NONE` 外,所有具有鉴权类型的方法均视为 `SIGNED` 请求(即包含 `signature`),[listenKey 管理](#user-data-stream-requests) 除外。 - 具有鉴权类型的方法需要提供有效的 API 密钥并验证通过。 - API 密钥可在您的 Binance 账户的 [API 管理](https://www.binance.com/en/support/faq/360002502072) 页面创建。 - **API 密钥和密钥对均为敏感信息,切勿与他人分享。** 如果发现账户有异常活动,请立即撤销所有密钥并联系 Binance 支持。 - API 密钥可配置为仅允许访问某些鉴权类型。 - 例如,您可以拥有具有 `TRADE` 权限的 API 密钥用于交易,同时使用具有 `USER_DATA` 权限的另一个 API 密钥来监控订单状态。 - 默认情况下,API 密钥无法进行 `TRADE`,您需要先在 API 管理中启用交易权限。 | 鉴权类型 | 描述 | | ------------- | ------------------------------------ | | `NONE` | 公开市场数据 | | `TRADE` | 在交易所交易,下单和取消订单 | | `USER_DATA` | 私人账户信息,例如订单状态和交易历史 | | `USER_STREAM` | 管理用户数据流订阅 | ### 需要签名的请求 - 为了授权请求,`SIGNED` 请求必须带 `signature` 参数。 #### 签名区分大小写 - **HMAC:** 使用 HMAC 生成的签名**不区分大小写**。这意味着无论字母大小写如何,签名字符串都可以被验证。 - **RSA:** 使用 RSA 生成的签名**区分大小写**。 - **Ed25519:** 使用 Ed25519 生成的签名也**区分大小写**。 ### 时间同步安全 - `SIGNED` 请求还需要一个 `timestamp` 参数,该参数应为当前时间戳,单位为毫秒或微秒。(参见 [通用 API 信息](#general-api-information)) - 另一个可选参数 `recvWindow`,用以指定请求的有效期,只能以毫秒为单位。 - `recvWindow` 扩展为三位小数(例如 6000.346),以便可以指定微秒。 - 如果未发送 `recvWindow`,则 **默认为 5000 毫秒**。 - `recvWindow` 的最大值为 60000 毫秒。 - 请求处理逻辑如下: ```javascript serverTime = getCurrentTime() if (timestamp < (serverTime + 1 second) && (serverTime - timestamp) <= recvWindow) { // 开始处理请求 serverTime = getCurrentTime() if (serverTime - timestamp) <= recvWindow { // 将请求转发到撮合引擎 } else { // 拒绝请求 } // 结束处理请求 } else { // 拒绝请求 } ``` **关于交易时效性** 互联网状况并不完全稳定可靠,因此你的程序本地到币安服务器的时延会有抖动, 这是我们设置 `recvWindow` 的目所在。如果你从事高频交易,对交易时效性有较高的要求,可以灵活设置 `recvWindow` 以达到你的要求。 **建议使用5000毫秒以下的 `recvWindow`!** ### SIGNED 请求示例 (HMAC) 这是有关如何用一个 HMAC secret key 签署请求的分步指南。 示例 API key 和 secret key: | Key | Value | | ----------- | ------------------------------------------------------------------ | | `apiKey` | `vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A` | | `secretKey` | `NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j` | **警告:请勿与任何人分享您的 API 密钥和秘钥。** 此处提供的示例密钥仅用于示范说明目的。 交易对名称完全由 ASCII 字符组成的请求示例: 请求示例: ```json { "id": "4885f793-e5ad-4c3b-8f6c-55d891472b71", "method": "order.place", "params": { "symbol": "BTCUSDT", "side": "SELL", "type": "LIMIT", "timeInForce": "GTC", "quantity": "0.01000000", "price": "52000.00", "newOrderRespType": "ACK", "recvWindow": 100, "timestamp": 1645423376532, "apiKey": "vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A", "signature": "------ 未填写 ------" } } ``` 交易对名称包含非 ASCII 字符的请求示例: ```json { "id": "4885f793-e5ad-4c3b-8f6c-55d891472b71", "method": "order.place", "params": { "symbol": "123456", "side": "BUY", "type": "LIMIT", "timeInForce": "GTC", "quantity": "0.01000000", "price": "0.10000000", "recvWindow": 5000, "timestamp": 1645423376532, "apiKey": "4yNzx3yWC5bS6YTwEkSRaC0nRmSQIIStAUOh1b6kqaBrTLIhjCpI5lJH8q8R8WNO", "signature": "------ FILL ME ------" } } ``` **第一步:创建签名内容** 除了 `signature` 之外,获取所有请求 `params`,然后**按参数名称的字母顺序对它们进行排序**: 对于第一组示例参数(仅限 ASCII 字符): | 参数 | 取值 | | ------------- | ---------------------------------------------------------------- | | `apiKey` | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A | | `price` | 52000.00 | | `quantity` | 0.01000000 | | `recvWindow` | 100 | | `side` | SELL | | `symbol` | BTCUSDT | | `timeInForce` | GTC | | `timestamp` | 1645423376532 | | `type` | LIMIT | 对于第二组示例参数(包含一些 Unicode 字符): | 参数 | 取值 | | ------------- | ---------------------------------------------------------------- | | `apiKey` | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A | | `price` | 0.10000000 | | `quantity` | 1.00000000 | | `recvWindow` | 5000 | | `side` | BUY | | `symbol` | 123456 | | `timeInForce` | GTC | | `timestamp` | 1645423376532 | | `type` | LIMIT | 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。数值需要采用 UTF-8 编码。 对于第一组示例参数(仅限 ASCII 字符),签名有效负载将如下所示: ```console apiKey=vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A&price=52000.00&quantity=0.01000000&recvWindow=100&side=SELL&symbol=BTCUSDT&timeInForce=GTC×tamp=1645423376532&type=LIMIT ``` 对于第二组示例参数(包含一些 Unicode 字符),签名有效负载将如下所示: ```console apiKey=vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A&price=0.10000000&quantity=1.00000000&recvWindow=5000&side=BUY&symbol=123456&timeInForce=GTC×tamp=1645423376532&type=LIMIT ``` **第二步:计算签名** 1. 使用 API 密钥中的 `secretKey` 作为 HMAC-SHA-256 算法的签名密钥。 2. 对步骤 1 中构建的签名 payload 进行签名。 3. 将 HMAC-SHA-256 的输出编码为十六进制字符串。 请注意,`apiKey`、`secretKey` 和有效负载是**大小写敏感的**。而生成的签名值是不区分大小写的。 可以使用 OpenSSL 交叉检查您的签名算法实现: 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n 'apiKey=vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A&price=52000.00&quantity=0.01000000&recvWindow=100&side=SELL&symbol=BTCUSDT&timeInForce=GTC×tamp=1645423376532&type=LIMIT' \ | openssl dgst -hex -sha256 -hmac 'NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j' aa1b5712c094bc4e57c05a1a5c1fd8d88dcd628338ea863fec7b88e59fe2db24 ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n 'apiKey=vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A&price=0.10000000&quantity=1.00000000&recvWindow=5000&side=BUY&symbol=123456&timeInForce=GTC×tamp=1645423376532&type=LIMIT' \ | openssl dgst -hex -sha256 -hmac 'NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j' b33892ae8e687c939f4468c6268ddd4c40ac1af18ad19a064864c47bae0752cd ``` **第三步:添加 `signature` 到 `params` 中** 通过在对请求中添加 `signature` 参数和签名字串来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```json { "id": "4885f793-e5ad-4c3b-8f6c-55d891472b71", "method": "order.place", "params": { "symbol": "BTCUSDT", "side": "SELL", "type": "LIMIT", "timeInForce": "GTC", "quantity": "0.01000000", "price": "52000.00", "recvWindow": 100, "timestamp": 1645423376532, "apiKey": "vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A", "signature": "aa1b5712c094bc4e57c05a1a5c1fd8d88dcd628338ea863fec7b88e59fe2db24" } } ``` 对于第二组示例参数(包含一些 Unicode 字符): ```json { "id": "4885f793-e5ad-4c3b-8f6c-55d891472b71", "method": "order.place", "params": { "symbol": "123456", "side": "BUY", "type": "LIMIT", "timeInForce": "GTC", "quantity": "1.00000000", "price": "0.10000000", "recvWindow": 5000, "timestamp": 1645423376532, "apiKey": "vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A", "signature": "b33892ae8e687c939f4468c6268ddd4c40ac1af18ad19a064864c47bae0752cd" } } ``` ### SIGNED 请求示例 (RSA) 这是有关如何用一个 RSA private key 签署请求的分步指南。 | Key | Value | | -------- | ------------------------------------------------------------------ | | `apiKey` | `CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ` | 这些示例假设私钥存储在文件 `test-prv-key.pem` 中。 **警告:请勿与任何人分享您的 API 密钥和私钥。** 此处提供的示例密钥仅用于示范说明目的。 交易对名称完全由 ASCII 字符组成的请求示例: ```json { "id": "4885f793-e5ad-4c3b-8f6c-55d891472b71", "method": "order.place", "params": { "symbol": "BTCUSDT", "side": "SELL", "type": "LIMIT", "timeInForce": "GTC", "quantity": "0.01000000", "price": "52000.00", "recvWindow": 100, "timestamp": 1645423376532, "apiKey": "CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ", "signature": "------ FILL ME ------" } } ``` 交易对名称包含非 ASCII 字符的请求示例: ```json { "id": "4885f793-e5ad-4c3b-8f6c-55d891472b71", "method": "order.place", "params": { "symbol": "123456", "side": "BUY", "type": "LIMIT", "timeInForce": "GTC", "quantity": "0.01000000", "price": "0.10000000", "recvWindow": 5000, "timestamp": 1645423376532, "apiKey": "CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ", "signature": "------ FILL ME ------" } } ``` **第一步:创建签名内容** 除了 `signature`,获取请求的所有其它 `params`,然后**按参数名称的字母顺序对它们进行排序**: 对于第一组示例参数(仅限 ASCII 字符): | 参数 | 取值 | | ------------- | ---------------------------------------------------------------- | | `apiKey` | CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ | | `price` | 52000.00 | | `quantity` | 0.01000000 | | `recvWindow` | 100 | | `side` | SELL | | `symbol` | BTCUSDT | | `timeInForce` | GTC | | `timestamp` | 1645423376532 | | `type` | LIMIT | 对于第二组示例参数(包含一些 Unicode 字符): | 参数 | 取值 | | ------------- | ---------------------------------------------------------------- | | `apiKey` | CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ | | `price` | 0.10000000 | | `quantity` | 1.00000000 | | `recvWindow` | 5000 | | `side` | BUY | | `symbol` | 123456 | | `timeInForce` | GTC | | `timestamp` | 1645423376532 | | `type` | LIMIT | 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。数值需要采用 UTF-8 编码。 对于第一组示例参数(仅限 ASCII 字符),签名有效负载将如下所示: ```console apiKey=CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ&price=52000.00&quantity=0.01000000&recvWindow=100&side=SELL&symbol=BTCUSDT&timeInForce=GTC×tamp=1645423376532&type=LIMIT ``` 对于第二组示例参数(包含一些 Unicode 字符),签名有效负载将如下所示: ```console apiKey=CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ&price=0.10000000&quantity=1.00000000&recvWindow=5000&side=BUY&symbol=123456&timeInForce=GTC×tamp=1645423376532&type=LIMIT ``` **第二步:计算签名** 1. 使用 RSASSA-PKCS1-v1_5 算法和 SHA-256 哈希函数对步骤 1 中构造的签名有效载荷的 UTF-8 字节进行签名。 2. 将输出编码为 base64。 请注意,`apiKey`, payload 和生成的`签名值`都是**大小写敏感**的。 您可以使用 OpenSSL 交叉检查您的签名算法: 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n 'apiKey=CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ&price=52000.00&quantity=0.01000000&recvWindow=100&side=SELL&symbol=BTCUSDT&timeInForce=GTC×tamp=1645423376532&type=LIMIT' \ | openssl dgst -sha256 -sign test-rsa-prv.pem \ | openssl enc -base64 -A OJJaf8C/3VGrU4ATTR4GiUDqL2FboSE1Qw7UnnoYNfXTXHubIl1iaePGuGyfct4NPu5oVEZCH4Q6ZStfB1w4ssgu0uiB/Bg+fBrRFfVgVaLKBdYHMvT+ljUJzqVaeoThG9oXlduiw8PbS9U8DYAbDvWN3jqZLo4Z2YJbyovyDAvDTr/oC0+vssLqP7NmlNb3fF3Bj7StmOwJvQJTbRAtzxK5PP7OQe+0mbW+D7RqVkUiSswR8qJFWTeSe4nXXNIdZdueYhF/Xf25L+KitJS5IHdIHcKfEw3MQzHFb2ZsGWkjDQwxkwr7Noi0Zaa+gFtxCuatGFm9dFIyx217pmSHtA== ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n 'apiKey=CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ&price=0.10000000&quantity=1.00000000&recvWindow=5000&side=BUY&symbol=123456&timeInForce=GTC×tamp=1645423376532&type=LIMIT' \ | openssl dgst -sha256 -sign test-rsa-prv.pem \ | openssl enc -base64 -A F3o/79Ttvl2cVYGPfBOF3oEOcm5QcYmTYWpdVIrKve5u+8paMNDAdUE+teqMxFM9HcquetGcfuFpLYtsQames5bDx/tskGM76TWW8HaM+6tuSYBSFLrKqChfA9hQGLYGjAiflf1YBnDhY+7vNbJFusUborNOloOj+ufzP5q42PvI3H0uNy3W5V3pyfXpDGCBtfCYYr9NAqA4d+AQfyllL/zkO9h9JSdozN49t0/hWGoD2dWgSO0Je6MytKEvD4DQXGeqNlBTB6tUXcWnRW+FcaKZ4KYqnxCtb1u8rFXUYgFykr2CbcJLSmw6ydEJ3EZ/NaZopRr+cU0W2m0HZ3qucw== ``` **第三步:在请求的 `params` 参数添加签名值** 通过在对请求中添加 `signature` 参数和签名字串来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```json { "id": "4885f793-e5ad-4c3b-8f6c-55d891472b71", "method": "order.place", "params": { "symbol": "BTCUSDT", "side": "SELL", "type": "LIMIT", "timeInForce": "GTC", "quantity": "0.01000000", "price": "52000.00", "newOrderRespType": "ACK", "recvWindow": 100, "timestamp": 1645423376532, "apiKey": "CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ", "signature": "OJJaf8C/3VGrU4ATTR4GiUDqL2FboSE1Qw7UnnoYNfXTXHubIl1iaePGuGyfct4NPu5oVEZCH4Q6ZStfB1w4ssgu0uiB/Bg+fBrRFfVgVaLKBdYHMvT+ljUJzqVaeoThG9oXlduiw8PbS9U8DYAbDvWN3jqZLo4Z2YJbyovyDAvDTr/oC0+vssLqP7NmlNb3fF3Bj7StmOwJvQJTbRAtzxK5PP7OQe+0mbW+D7RqVkUiSswR8qJFWTeSe4nXXNIdZdueYhF/Xf25L+KitJS5IHdIHcKfEw3MQzHFb2ZsGWkjDQwxkwr7Noi0Zaa+gFtxCuatGFm9dFIyx217pmSHtA==" } } ``` 对于第二组示例参数(包含一些 Unicode 字符): ```json { "id": "4885f793-e5ad-4c3b-8f6c-55d891472b71", "method": "order.place", "params": { "symbol": "123456", "side": "SELL", "type": "LIMIT", "timeInForce": "GTC", "quantity": "1.00000000", "price": "0.10000000", "recvWindow": 5000, "timestamp": 1645423376532, "apiKey": "CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ", "signature": "F3o/79Ttvl2cVYGPfBOF3oEOcm5QcYmTYWpdVIrKve5u+8paMNDAdUE+teqMxFM9HcquetGcfuFpLYtsQames5bDx/tskGM76TWW8HaM+6tuSYBSFLrKqChfA9hQGLYGjAiflf1YBnDhY+7vNbJFusUborNOloOj+ufzP5q42PvI3H0uNy3W5V3pyfXpDGCBtfCYYr9NAqA4d+AQfyllL/zkO9h9JSdozN49t0/hWGoD2dWgSO0Je6MytKEvD4DQXGeqNlBTB6tUXcWnRW+FcaKZ4KYqnxCtb1u8rFXUYgFykr2CbcJLSmw6ydEJ3EZ/NaZopRr+cU0W2m0HZ3qucw==" } } ``` ### SIGNED 请求示例 (Ed25519) **我们强烈建议使用 Ed25519 API keys,因为它在所有受支持的 API key 类型中提供最佳性能和安全性。** 这是有关如何用一个 Ed25519 private key 签署请求的分步指南。 | Key | Value | | -------- | ------------------------------------------------------------------ | | `apiKey` | `4yNzx3yWC5bS6YTwEkSRaC0nRmSQIIStAUOh1b6kqaBrTLIhjCpI5lJH8q8R8WNO` | 这些示例假设私钥存储在文件 `test-ed25519-prv.pem` 中。 **警告:请勿与任何人分享您的 API 密钥和私钥。** 此处提供的示例密钥仅用于示范说明目的。 交易对名称完全由 ASCII 字符组成的请求示例: ```json { "id": "4885f793-e5ad-4c3b-8f6c-55d891472b71", "method": "order.place", "params": { "symbol": "BTCUSDT", "side": "SELL", "type": "LIMIT", "timeInForce": "GTC", "quantity": "0.01000000", "price": "52000.00", "recvWindow": 100, "timestamp": 1645423376532, "apiKey": "4yNzx3yWC5bS6YTwEkSRaC0nRmSQIIStAUOh1b6kqaBrTLIhjCpI5lJH8q8R8WNO", "signature": "------ FILL ME ------" } } ``` 交易对名称包含非 ASCII 字符的请求示例: ```json { "id": "4885f793-e5ad-4c3b-8f6c-55d891472b71", "method": "order.place", "params": { "symbol": "123456", "side": "BUY", "type": "LIMIT", "timeInForce": "GTC", "quantity": "0.01000000", "price": "0.10000000", "recvWindow": 5000, "timestamp": 1645423376532, "apiKey": "4yNzx3yWC5bS6YTwEkSRaC0nRmSQIIStAUOh1b6kqaBrTLIhjCpI5lJH8q8R8WNO", "signature": "------ FILL ME ------" } } ``` **第一步:创建签名内容** 除了 `signature`,获取请求的所有其它 `params`,然后**按参数名称的字母顺序对它们进行排序**: 对于第一组示例参数(仅限 ASCII 字符): | 参数 | 取值 | | ------------- | ---------------------------------------------------------------- | | `apiKey` | 4yNzx3yWC5bS6YTwEkSRaC0nRmSQIIStAUOh1b6kqaBrTLIhjCpI5lJH8q8R8WNO | | `price` | 52000.00 | | `quantity` | 0.01000000 | | `recvWindow` | 100 | | `side` | SELL | | `symbol` | BTCUSDT | | `timeInForce` | GTC | | `timestamp` | 1645423376532 | | `type` | LIMIT | 对于第二组示例参数(包含一些 Unicode 字符): | 参数 | 取值 | | ------------- | ---------------------------------------------------------------- | | `apiKey` | 4yNzx3yWC5bS6YTwEkSRaC0nRmSQIIStAUOh1b6kqaBrTLIhjCpI5lJH8q8R8WNO | | `price` | 0.20000000 | | `quantity` | 1.00000000 | | `recvWindow` | 5000 | | `side` | SELL | | `symbol` | 123456 | | `timeInForce` | GTC | | `timestamp` | 1668481559918 | | `type` | LIMIT | 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。数值需要采用 UTF-8 编码。 对于第一组示例参数(仅限 ASCII 字符),签名有效负载将如下所示: ```console apiKey=4yNzx3yWC5bS6YTwEkSRaC0nRmSQIIStAUOh1b6kqaBrTLIhjCpI5lJH8q8R8WNO&price=52000.00&quantity=0.01000000&recvWindow=100&side=SELL&symbol=BTCUSDT&timeInForce=GTC×tamp=1645423376532&type=LIMIT ``` 对于第二组示例参数(包含一些 Unicode 字符),签名有效负载将如下所示: ```console apiKey=4yNzx3yWC5bS6YTwEkSRaC0nRmSQIIStAUOh1b6kqaBrTLIhjCpI5lJH8q8R8WNO&price=0.10000000&quantity=1.00000000&recvWindow=5000&side=BUY&symbol=123456&timeInForce=GTC×tamp=1645423376532&type=LIMIT ``` **第二步:计算签名** 1. 使用 Ed25519 密钥对步骤 1 中构造的签名有效载荷的 UTF-8 字节进行签名。 2. 将输出编码为 base64。 请注意,`apiKey`, payload 和生成的`签名值`都是**大小写敏感**的。 您可以使用 OpenSSL 交叉检查您的签名算法: 对于第一组示例参数(仅限 ASCII 字符): ```console echo -n "apiKey=4yNzx3yWC5bS6YTwEkSRaC0nRmSQIIStAUOh1b6kqaBrTLIhjCpI5lJH8q8R8WNO&price=52000.00&quantity=0.01000000&recvWindow=100&side=SELL&symbol=BTCUSDT&timeInForce=GTC×tamp=1645423376532&type=LIMIT" \ | openssl dgst -sign ./test-ed25519-prv.pem \ | openssl enc -base64 -A EocljwPl29jDxWYaaRaOo4pJ9wEblFbklJvPugNscLLuKd5vHM2grWjn1z+rY0aJ7r/44enxHL6mOAJuJ1kqCg== ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console echo -n "apiKey=4yNzx3yWC5bS6YTwEkSRaC0nRmSQIIStAUOh1b6kqaBrTLIhjCpI5lJH8q8R8WNO&price=0.10000000&quantity=1.00000000&recvWindow=5000&side=BUY&symbol=123456&timeInForce=GTC×tamp=1645423376532&type=LIMIT" \ | openssl dgst -sign ./test-ed25519-prv.pem \ | openssl enc -base64 -A dtNHJeyKry+cNjiGv+sv5kynO9S40tf8k7D5CfAEQAp0s2scunZj+ovJdz2OgW8XhkB9G3/HmASkA9uY9eyFCA== ``` **第三步:在请求的 `params` 参数添加签名值** 对于第一组示例参数(仅限 ASCII 字符): ```json { "id": "4885f793-e5ad-4c3b-8f6c-55d891472b71", "method": "order.place", "params": { "symbol": "BTCUSDT", "side": "SELL", "type": "LIMIT", "timeInForce": "GTC", "quantity": "0.01000000", "price": "52000.00", "newOrderRespType": "ACK", "recvWindow": 100, "timestamp": 1645423376532, "apiKey": "4yNzx3yWC5bS6YTwEkSRaC0nRmSQIIStAUOh1b6kqaBrTLIhjCpI5lJH8q8R8WNO", "signature": "EocljwPl29jDxWYaaRaOo4pJ9wEblFbklJvPugNscLLuKd5vHM2grWjn1z+rY0aJ7r/44enxHL6mOAJuJ1kqCg==" } } ``` 对于第二组示例参数(包含一些 Unicode 字符): ```json { "id": "4885f793-e5ad-4c3b-8f6c-55d891472b71", "method": "order.place", "params": { "symbol": "123456", "side": "SELL", "type": "LIMIT", "timeInForce": "GTC", "quantity": "1.00000000", "price": "0.10000000", "recvWindow": 5000, "timestamp": 1645423376532, "apiKey": "4yNzx3yWC5bS6YTwEkSRaC0nRmSQIIStAUOh1b6kqaBrTLIhjCpI5lJH8q8R8WNO", "signature": "dtNHJeyKry+cNjiGv+sv5kynO9S40tf8k7D5CfAEQAp0s2scunZj+ovJdz2OgW8XhkB9G3/HmASkA9uY9eyFCA==" } } ``` 下面的 Python 示例代码能执行上述所有步骤。 ```python #!/usr/bin/env python3 import base64 import time import json from cryptography.hazmat.primitives.serialization import load_pem_private_key from websocket import create_connection # 设置身份验证: API_KEY='替换成您的 API Key' PRIVATE_KEY_PATH='test-prv-key.pem' # 加载 private key。 # 在这个例子中,private key 没有加密 # 但我们建议使用强密码以提高安全性。 with open(PRIVATE_KEY_PATH, 'rb') as f: private_key = load_pem_private_key(data=f.read(), password=None) # 设置请求参数: params = { 'apiKey': API_KEY, 'symbol': '123456', 'side': 'SELL', 'type': 'LIMIT', 'timeInForce': 'GTC', 'quantity': '1.0000000', 'price': '0.10000000', 'recvWindow': 5000 } # 参数中加时间戳: timestamp = int(time.time() * 1000) # UNIX timestamp in milliseconds params['timestamp'] = timestamp # 按参数名称的字母顺序进行排序 params = dict(sorted(params.items())) # 计算签名有效负载 payload = '&'.join([f"{k}={v}" for k,v in params.items()]) # no percent encoding here! # 对请求进行签名 signature = base64.b64encode(private_key.sign(payload.encode('UTF-8'))) params['signature'] = signature.decode('ASCII') # 发送请求: request = { 'id': 'my_new_order', 'method': 'order.place', 'params': params } ws = create_connection("wss://ws-api.binance.com:443/ws-api/v3") ws.send(json.dumps(request)) result = ws.recv() ws.close() print(result) ``` ## 会话身份验证 **注意:** 仅支持 _Ed25519_ 密钥用于此功能。 如果你不想在每个单独的请求中指定`apiKey`和`signature`,你可以为有效的WebSocket会话进行API密钥身份验证。 一旦完成身份验证,你将不需在需要它们的请求中指定`apiKey`和`signature`。这些请求将代表拥有已验证API密钥的帐户执行。 **注意:** 对于`SIGNED`请求,你仍需要指定`timestamp`参数。 ### 连接后进行身份验证 你可以使用会话身份验证请求对已经建立的连接进行身份验证: - [`session.logon`](#session-logon) – 进行身份验证,或更改与连接相关联的API密钥。 - [`session.status`](#query-session-status) – 检查连接状态和当前API密钥。 - [`session.logout`](#session-logout) – 忘记与连接关联的API密钥。 **关于吊销API密钥:** 如果在活动会话期间,由于 _任何_ 原因(例如IP地址未被加入白名单、API密钥被删除、API密钥没有正确的权限等),在下一个请求后,会话将被吊销,并显示以下错误消息: ```javascript { "id": null, "status": 401, "error": { "code": -2015, "msg": "Invalid API-key, IP, or permissions for action." } } ``` ### 授权 _临时_ 请求 WebSocket连接只能通过一个API密钥进行身份验证。默认情况下,经过身份验证的API密钥将用于需要`apiKey`参数的请求。但是,你始终可以为单个请求明确指定`apiKey`和`signature`,覆盖已认证的API密钥,以使用不同的API密钥授权特定请求。 例如,你可能希望用默认密钥来验证 `USER_DATA`,但在下单时使用`TRADE`密钥来签名。 ## 数据源 - API 系统是异步的。响应中一些延迟是正常和预期的。 - 每种函数都会有一个数据源, 用来指示数据的来源,以及它的最新程度。 | 数据源 | 延迟 | 描述 | | -------- | ---- | -------------------------------- | | 撮合引擎 | 最低 | 表示撮合引擎直接产生响应 | | 缓存 | 低 | 表示数据来源于内部或者外部的缓存 | | 数据库 | 中度 | 表示数据直接来源于数据库 | - 某些函数有多个数据源(例如,缓存 => 数据库)。 这代表 API 将按该顺序查找最新数据:首先是缓存,然后是数据库。 --- ## Document: /products/spot/user-data-stream URL: /zh-CN/docs/products/spot/user-data-stream # WebSocket 账户接口 ## 一般信息 - 通过使用 API Key 订阅 [WebSocket API](/products/spot/web-socket-api#user-data-stream-subscribe)。 - 支持 [SBE](/products/spot/faqs/sbe_faq) 和 JSON 输出格式。 - 账户事件以 **实时** 方式推送。 - JSON 数据中的所有时间戳默认均为 **毫秒**。 - 如果您持有或交易任何名称包含非 ASCII 字符的资产或交易对,那么事件中可能包含以 UTF-8 编码的非 ASCII 字符。 ## 用户数据流事件 ### 账户更新 每当帐户余额发生更改时,都会发送一个事件`outboundAccountPosition`,其中包含可能由生成余额变动的事件而变动的资产。 > **Schema:** > [`outboundAccountPosition`](/catalog/core-trading-spot-trading/api/ws-streams/~schemas#outboundaccountposition) ### 余额更新 当下列情形发生时更新: - 账户发生充值或提取 - 交易账户之间发生划转(例如 现货向杠杆账户划转) **Payload** > **Schema:** > [`balanceUpdate`](/catalog/core-trading-spot-trading/api/ws-streams/~schemas#balanceupdate) ### 订单更新 订单通过`executionReport`事件进行更新。 **Payload:** > **Schema:** > [`executionReport`](/catalog/core-trading-spot-trading/api/ws-streams/~schemas#executionreport) **备注:** 通过将`Z`除以`z`可以找到平均价格。 #### `executionReport` 中的特定条件时才会出现的字段 这些字段仅在满足特定条件时才会出现。有关这些参数的更多信息,请参阅 [现货交易API术语表](/products/spot/faqs/spot_glossary)。 | 字段 | 名称 | 描述 | | ----- | ----------------------------- | ------------------------------------------------ | | `d` | Trailing Delta | 出现在追踪止损订单中。 | | `D` | Trailing Time | 出现在追踪止损订单中。 | | `j` | Strategy Id | 如果在请求中添加了`strategyId`参数,则会出现。 | | `J` | Strategy Type | 如果在请求中添加了`strategyType`参数,则会出现。 | | `v` | Prevented Match Id | 只有在因为 STP 导致订单失效时可见。 | | `A` | Prevented Quantity | 只有在因为 STP 导致订单失效时可见。 | | `B` | Last Prevented Quantity | 只有在因为 STP 导致订单失效时可见。 | | `u` | Trade Group Id | 只有在因为 STP 导致订单失效时可见。 | | `U` | Counter Order Id | 只有在因为 STP 导致订单失效时可见。 | | `Cs` | Counter Symbol | 只有在因为 STP 导致订单失效时可见。 | | `pl` | Prevented Execution Quantity | 只有在因为 STP 导致订单失效时可见。 | | `pL` | Prevented Execution Price | 只有在因为 STP 导致订单失效时可见。 | | `pY` | Prevented Execution Quote Qty | 只有在因为 STP 导致订单失效时可见。 | | `W` | Working Time | 只有在订单在订单簿上时可见 | | `b` | Match Type | 只有在订单有分配时可见 | | `a` | Allocation ID | 只有在订单有分配时可见 | | `k` | Working Floor | 只有在订单可能有分配时可见 | | `uS` | UsedSor | 只有在订单使用 SOR 时可见 | | `gP` | Pegged Price Type | 仅出现在挂钩订单中 | | `gOT` | Pegged Offset Type | 仅出现在挂钩订单中 | | `gOV` | Pegged Offset Value | 仅出现在挂钩订单中 | | `gp` | Pegged Price | 仅出现在挂钩订单中 | #### 订单拒绝原因 有关更多详细信息,请查阅 [错误代码汇总](/products/spot/errors#other-errors) 文档中的错误消息。 | 拒绝原因 (`r`) | 错误信息 | | -------------------------------------- | --------------------------------------------------------------- | | `NONE` | N/A (i.e. The order was not rejected.) | | `INSUFFICIENT_BALANCES` | "Account has insufficient balance for requested action." | | `STOP_PRICE_WOULD_TRIGGER_IMMEDIATELY` | "Order would trigger immediately." | | `WOULD_MATCH_IMMEDIATELY` | "Order would immediately match and take." | | `OCO_BAD_PRICES` | "The relationship of the prices for the orders is not correct." | 如果是一个订单组,则除了显示 `executionReport` 事件外,还将显示一个名为 `ListStatus` 的事件。 **Payload** > **Schema:** [`listStatus`](/catalog/core-trading-spot-trading/api/ws-streams/~schemas#liststatus) **可能的执行类型:** - `NEW` - 新订单已被引擎接受。 - `CANCELED` - 订单被用户取消。 - `REPLACED` - 订单已被修改。 - `REJECTED` - 新订单被拒绝 (e.g. 在撤消挂单再下单时,其中新订单被拒绝但撤消挂单请求成功)。 - `TRADE` - 订单有新成交。 - `EXPIRED` - 订单已根据 Time In Force 参数的规则取消(e.g. 没有成交的 LIMIT FOK 订单或部分成交的 LIMIT IOC 订单)或者被交易所取消(e.g. 强平或维护期间取消的订单)。 - `TRADE_PREVENTION` - 订单因 STP 触发而过期。 请查阅 [枚举定义](/products/spot/enums) 文档获取更多枚举定义。 ## 事件流已终止 `eventStreamTerminated` 会在以下情况下发送: - 当 [Listen Token 订阅](/products/margin-trading/trade-data-stream/Listen-Token-Websocket-API) 因 Token 过期而失效时。 - 在发送 [`session.logout`](/products/spot/web-socket-api#log-out-of-the-session) 方法后,[登录订阅](/products/spot/web-socket-api#log-in-with-api-key-signed) 结束时。 - 通过 [`userDataStream.unsubscribe`](/products/spot/web-socket-api#unsubscribe-from-user-data-stream) 方法终止订阅时。 **Payload:** > **Schema:** > [`eventStreamTerminated`](/catalog/core-trading-spot-trading/api/ws-streams/~schemas#eventstreamterminated) ## 外部锁定更新 当您的现货钱包余额被外部系统锁定/解锁时 (例如,当用作保证金抵押品时),新事件 `externalLockUpdate` 将会被发送。 **Payload:** > **Schema:** > [`externalLockUpdate`](/catalog/core-trading-spot-trading/api/ws-streams/~schemas#externallockupdate) --- ## Document: /products/spot/sbe-market-data-streams URL: /zh-CN/docs/products/spot/sbe-market-data-streams # SBE 市场数据流 ## WSS 基本信息 - 基本访问地址是 **stream-sbe.binance.com** 或 **stream-sbe.binance.com:9443**。 - 要以 JSON 格式检索市场数据,请参阅 [此页面](web-socket-streams.md)。 - 可以在[此处](/products/spot/sbe/schemas/stream_1_0.xml)找到用于对数据流进行解码的 SBE 模式。 - stream 名称中所有交易对均为**小写**。 - 订阅单个streams时,可用的URL格式示例: **/ws/\**。 - 订阅组合streams时,可用的URL格式示例: **/stream?streams=\/\/\**。 - 每个到**stream-sbe.binance.com**的链接有效期不超过24小时,请妥善处理断线重连。 - 当服务器即将关闭时,系统将发送 [`serverShutdown`](#serverShutdown) 事件,并导致连接断开。请尽快建立新连接,以防止中断。 - 所有时间和时间戳相关的字段均以 **微秒** 为单位。 - **需要 API Key 身份验证。** - 只允许使用 Ed25519 密钥。 - 打开连接时,请将您的 API Key 放在 `X-MBX-APIKEY` 标头中。时间戳和签名不是必需的。 - 无需额外的 API 密钥权限即可访问公开市场数据。交易对白名单也不会影响对 SBE 市场数据流的访问。 - 但是,如果 API 密钥使用 IP 白名单,则仅允许指定的 IP 地址使用 API 密钥。 - WebSocket 服务器会**每20秒**发送 PING 帧。 - 如果websocket 服务器没有在一分钟之内收到 PONG 帧响应,连接会被断开。 - 当客户收到 PING 帧,必须尽快回复 PONG 帧,同时 payload 需要和 PING 帧一致。 - 服务器允许未经请求的 PONG 帧,但这不会保证连接不断开。**对于这种类型的 PONG 帧,建议设置其 payload 为空。** - [支持实时订阅和取消订阅](web-socket-streams.md#实时订阅取消数据流)。 - 您必须以 JSON 格式通过 WebSocket text 帧发送订阅请求;订阅响应也将以 JSON 格式通过 WebSocket text 帧返回。 - [`serverShutdown`](#serverShutdown) 事件将以 JSON 格式通过 WebSocket text 帧发送。 - 市场数据事件将以 SBE 格式通过 WebSocket 二进制帧发送。 - 如果您的请求包含非 ASCII 字符的交易对名称,那么数据流事件中可能包含以 UTF-8 编码的非 ASCII 字符。 ## WebSocket 连接限制 - WebSocket服务器**每秒最多接受5个消息**。 - 消息包括: - PING 帧 - PONG 帧 - Text 帧JSON格式的控制请求 - 由服务器推送的事件不受速率限制。 - 如果用户发送的消息数超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅1024个 Streams。 - 每个IP地址的请求限制为 **每5分钟最多可以发送300次连接请求**。 ## 服务器关闭 当服务器即将关闭时,会发送 `serverShutdown` 事件。 请注意,此消息将以 JSON 格式发送。 ```javascript { "e": "serverShutdown", // 事件类型 "E": 1770123456789 // 事件时间 } ``` 请尽快建立新连接,以防中断。 ## 可供用户使用的 Stream ### 逐笔交易 实时推送的原始交易信息 **SBE 消息名称:** `TradesStreamEvent` **Stream 名称**: \@trade **更新速度:** 实时 ### 最优挂单信息 当订单簿发生变化时,会实时推送最优买入价和卖出价和数量。 **SBE 消息名称:** `BestBidAskStreamEvent` **Stream 名称**: \@bestBidAsk **更新速度**: 实时 SBE 最优挂单信息使用 **自动剔除(auto-culling)**:当系统负载较高时,可能会丢弃过时的事件,而不是将所有事件排队并延迟发送。 例如,如果在时间 T2 生成了一个最优买/卖报价事件,而此时仍有一个未发送的事件排队在时间 T1(且 T1 < T2),则会丢弃时间 T1 的事件,系统只会发送时间 T2 的事件。此操作是基于每个交易对分别进行的。 ### 增量深度信息 定期推送订单簿的增量更新。使用此流来维护本地订单簿。 [如何管理本地订单簿。](web-socket-streams.md#如何正确在本地维护一个order-book副本) **SBE 消息名称:** `DepthDiffStreamEvent` **Stream 名称**: \@depth **更新速度:** 25ms ### 有限档深度信息 订单簿前 20 档的快照,定期推送。 **SBE 消息名称:** `DepthSnapshotStreamEvent` **Stream 名称**: \@depth20 **更新速度:** 50ms --- ## Document: /products/spot/rest-api URL: /zh-CN/docs/products/spot/rest-api # REST API 基本信息 - 本篇列出接口的 base URL 有: - **https://api.binance.com** - **https://api-gcp.binance.com** - **https://api1.binance.com** - **https://api2.binance.com** - **https://api3.binance.com** - **https://api4.binance.com** - 上述列表的最后4个接口 (`api1`-`api4`) 会提供更好的性能,但其稳定性略为逊色。因此,请务必使用最适合的URL。 - 响应默认为 JSON 格式。如果您想接收 SBE 格式的响应,请参考 [简单二进制编码 (SBE) 常见问题](/products/spot/faqs/sbe_faq.md)。 - 除非另有说明,否则数据将按**时间顺序**返回。 - 如果未指定 `startTime` 或 `endTime`,则返回最近的条目,直至达到限制值。 - 如果指定 `startTime`,则返回从 `startTime` 到限制值为止最老的条目。 - 如果指定 `endTime`,则返回截至 `endTime` 和限制值为止最近的条目。 - 如果同时指定 `startTime` 和 `endTime`,则行为类似于 `startTime`,但不超过 `endTime`。 - JSON 响应中的所有时间和时间戳相关字段均以**毫秒为默认单位**。要以微秒为单位接收信息,请添加报文头 `X-MBX-TIME-UNIT:MICROSECOND` 或 `X-MBX-TIME-UNIT:microsecond`。 - 我们支持 HMAC,RSA 以及 Ed25519 Key 类型。 如需进一步了解,请参考 [API Key 类型](/products/spot/faqs/api_key_types.md)。 - 时间戳参数(例如 `startTime`、`endTime`、`timestamp`)可以以毫秒或微秒为单位传递。 - 对于仅发送公开市场数据的 API,您可以使用接口的 base URL https://data-api.binance.vision 。请参考 [Market Data Only](/products/spot/faqs/market_data_only.md) 页面。 - 如需进一步了解枚举或术语,请参考 [现货交易API术语表](/products/spot/faqs/spot_glossary.md) 页面。 - API 处理请求的超时时间为 10 秒。如果撮合引擎的响应时间超过此时间,API 将返回 “Timeout waiting for response from backend server. Send status unknown; execution status unknown.”。[(-1007 超时)](/products/spot/errors.md#-1007-timeout) - 这并不总是意味着该请求在撮合引擎中失败。 - 如果请求状态未显示在 [用户数据流](/products/spot/user-data-stream.md) 中,请执行 API 查询以获取其状态。 - **请避免在请求中使用 SQL 关键字**,因为这可能会触发 Web 应用防火墙(WAF)规则导致安全拦截。详情请参见 https://www.binance.com/zh-CN/support/faq/detail/360004492232 - 如果您的请求包含非 ASCII 字符的交易对名称,那么响应中可能会包含以 UTF-8 编码的非 ASCII 字符。 - 即使请求中不包含非 ASCII 字符,某些接口也可能返回包含以 UTF-8 编码的非 ASCII 字符的资产和/或交易对名称。 ## HTTP 返回代码 - HTTP `4XX` 错误码用于指示错误的请求内容、行为、格式。问题在于请求者。 - HTTP `403` 错误码表示违反WAF限制(Web应用程序防火墙)。详情请参见 https://www.binance.com/zh-CN/support/faq/detail/360004492232 。 - HTTP `409` 错误码表示重新下单(cancelReplace)的请求部分成功。(比如取消订单失败,但是下单成功了) - HTTP `429` 错误码表示警告访问频次超限,即将被封IP。 - HTTP `418` 表示收到429后继续访问,于是被封了。 - HTTP `5XX` 错误码用于指示Binance服务侧的问题。 ## 接口错误代码 - 每个接口都有可能抛出异常,异常响应格式如下: ```javascript { "code": -1121, "msg": "Invalid symbol." } ``` - 具体的错误码及其解释在[错误代码汇总](/products/spot/errors.md) ## 接口的基本信息 - `GET` 方法的接口, 参数必须在 `query string`中发送。 - `POST`, `PUT`, 和 `DELETE` 方法的接口,参数可以在内容形式为`application/x-www-form-urlencoded`的 `query string` 中发送,也可以在 `request body` 中发送。 如果你喜欢,也可以混合这两种方式发送参数。 - 对参数的顺序不做要求。 - 但如果同一个参数名在`query string`和`request body`中都有,`query string`中的会被优先采用。 ## 访问限制 ### 访问限制基本信息 - 以下是 `intervalLetter` 作为头部值: - SECOND => S - MINUTE => M - HOUR => H - DAY => D - 在 `/api/v3/exchangeInfo`接口中`rateLimits`数组里包含有REST接口(不限于本篇的REST接口)的访问限制。包括带权重的访问频次限制、下单速率限制。参考 [枚举定义](/products/spot/enums.md) 中有关有限制类型的进一步说明。 - 当您超出请求速率限制时,请求会失败并返回 HTTP 状态代码 429。 ### IP 访问限制 - 每个请求将包含一个`X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,其中包含当前IP所有请求的已使用权重。 - 每一个接口均有一个相应的权重(weight),有的接口根据参数不同可能拥有不同的权重。越消耗资源的接口权重就会越大。 - 收到429时,您有责任停止发送请求,不得滥用API。 - **收到429后仍然继续违反访问限制,会被封禁IP,并收到418错误码** - 频繁违反限制,封禁时间会逐渐延长,**从最短2分钟到最长3天**. - `Retry-After`的头会与带有418或429的响应发送,并且会给出**以秒为单位**的等待时长(如果是429)以防止禁令,或者如果是418,直到禁令结束。 - **访问限制是基于IP的,而不是API Key** ### 未成交订单计数 - 每个成功的订单响应都将包含一个 `X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)` 报文头,用于标识您在该时间间隔内下了多少订单。

如果您想要对此进行监控,请参阅 [`GET api/v3/rateLimit/order`](#query-unfilled-order-count)。 - 被拒绝/不成功的订单不保证在响应中有 `X-MBX-ORDER-COUNT-**` 报文头。 - 如果超过此值,您将收到一个 429 错误,而且不带 `Retry-After` 报文头。 - **请注意,如果您的订单一直顺利完成交易,您可以通过 API 持续下订单**。更多信息,请参见[现货未成交订单计数规则](./faqs/order_count_decrement.md)。 - **未成交订单数量是按照每个账户来统计的**。 ## 数据来源 - 因为API系统是异步的, 所以返回的数据有延时很正常, 也在预期之中。 - 在每个接口中,都列出了其数据的来源,可以用于理解数据的时效性。 系统一共有3个数据来源,按照更新速度的先后排序。排在前面的数据最新,在后面就有可能存在延迟。 - **撮合引擎** - 表示数据来源于撮合引擎 - **缓存** - 表示数据来源于内部或者外部的缓存 - **数据库** - 表示数据直接来源于数据库 有些接口有不止一个数据源, 比如 `缓存 => 数据库`, 这表示接口会先从第一个数据源检查,如果没有数据,则检查下一个数据源。 ## 请求鉴权类型 - 每个接口都有一个鉴权类型,指示所需的 API 密钥权限,显示在接口名称旁边(例如,[下新订单 (TRADE)](#place-new-order-trade))。 - 如果未指定,则鉴权类型为 `NONE`。 - 除了为 `NONE` 外,所有具有鉴权类型的接口均视为 `SIGNED` 请求(即包含 `signature`)。 - 具有鉴权类型的接口需要提供有效的 API 密钥并验证通过。 - API 密钥可在您的 Binance 账户的 [API 管理](https://www.binance.com/en/support/faq/360002502072) 页面创建。 - **API 密钥和密钥对均为敏感信息,切勿与他人分享。** 如果发现账户有异常活动,请立即撤销所有密钥并联系 Binance 支持。 - API 密钥可配置为仅允许访问某些鉴权接口。 - 例如,您可以拥有具有 `TRADE` 权限的 API 密钥用于交易,同时使用具有 `USER_DATA` 权限的另一个 API 密钥来监控订单状态。 - 默认情况下,API 密钥无法进行 `TRADE`,您需要先在 API 管理中启用交易权限。 | 鉴权类型 | 描述 | | ------------- | ------------------------------------ | | `NONE` | 公开市场数据 | | `TRADE` | 在交易所交易,下单和取消订单 | | `USER_DATA` | 私人账户信息,例如订单状态和交易历史 | | `USER_STREAM` | 管理用户数据流订阅 | ### 需要签名的接口 - 调用`SIGNED` 接口时,除了接口本身所需的参数外,还需要在 `query string` 或 `request body` 中传递 `signature`, 即签名参数。 #### 签名是否是大小写敏感的 - **HMAC:** 使用 HMAC 生成的签名**不区分大小写**。这意味着无论字母大小写如何,签名字符串都可以被验证。 - **RSA:** 使用 RSA 生成的签名是**大小写敏感的**。 - **Ed25519:** 使用 Ed25519 生成的签名也是**大小写敏感的**。 请参阅[已签名请求示例 (HMAC)](#hmac-keys)、[已签名请求示例 (RSA)](#rsa-keys) 和[已签名请求示例 (Ed25519)](#ed25519-keys),了解如何根据您使用的 API 密钥类型计算签名。 ### 时间同步安全 - `SIGNED` 请求还需要一个 `timestamp` 参数,该参数应为当前时间戳,单位为毫秒或微秒。(参见 [通用 API 信息](#general-api-information)) - 另一个可选参数 `recvWindow`,用以指定请求的有效期,只能以毫秒为单位。 - `recvWindow` 扩展为三位小数(例如 6000.346),以便可以指定微秒。 - 如果未发送 `recvWindow`,则 **默认值为 5000 毫秒**。 - `recvWindow` 的最大值为 60000 毫秒。 - 请求处理逻辑如下: ```javascript serverTime = getCurrentTime() if (timestamp < (serverTime + 1 second) && (serverTime - timestamp) <= recvWindow) { // 开始处理请求 serverTime = getCurrentTime() if (serverTime - timestamp) <= recvWindow { // 将请求转发到撮合引擎 } else { // 拒绝请求 } // 结束处理请求 } else { // 拒绝请求 } ``` **关于交易时效性** 互联网状况并不100%可靠,不可完全依赖,因此你的程序本地到币安服务器的时延会有抖动. 这是我们设置`recvWindow`的目的所在,如果你从事高频交易,对交易时效性有较高的要求,可以灵活设置`recvWindow`以达到你的要求。 **不推荐使用5秒以上的recvWindow。最大值不能超过60秒!** ### POST /api/v3/order 的签名示例 #### HMAC Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 以下示例分步演示如何使用 `echo`、`openssl` 和 `curl` 从 Linux 命令行发送有效的签名 payload。其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 API 密钥和密钥示例: | Key | Value | | ----------- | ---------------------------------------------------------------- | | `apiKey` | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A | | `secretKey` | NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j | **警告:请勿与任何人分享您的 API 密钥和秘钥。** 此处提供的示例密钥仅用于示范说明目的。 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | LTCBTC | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` **第二步: 计算签名。** 1. 使用 API 密钥中的 `secretKey` 作为 HMAC-SHA-256 算法的签名密钥。 2. 对步骤 1 中构建的签名 payload 进行签名。 3. 将 HMAC-SHA-256 的输出编码为十六进制字符串。 请注意,`secretKey` 和 payload 是**大小写敏感的**,而生成的签名值是不区分大小写的。 **示例命令** 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71 ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n "symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3 ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71" ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3" ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash apiKey="vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" secretKey="NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" payload="symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" # 对请求进行签名 signature=$(echo -n "$payload" | openssl dgst -sha256 -hmac "$secretKey") signature=${signature#*= } # Keep only the part after the "= " # 发送请求 curl -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?$payload&signature=$signature" ``` #### RSA Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 要获取 API 密钥,您需要将 RSA 公钥上传到您的帐户中,系统将为您提供相应的 API 密钥。 仅支持 `PKCS#8` 密钥。 在以下示例中,其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 这些示例假设私钥存储在文件 `./test-prv-key.pem` 中。 | Key | Value | | -------- | ---------------------------------------------------------------- | | `apiKey` | CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ | 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | BTCUSDT | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` **第二步: 计算签名。** 1. 使用 RSASSA-PKCS1-v1_5 算法和 SHA-256 哈希函数对步骤 1 中构建的签名 payload 进行签名。 2. 将输出结果编码为 base64 格式。 请注意,payload 和生成的`签名值`是**大小写敏感的**。 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n 'symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' HZ8HOjiJ1s/igS9JA+n7+7Ti/ihtkRF5BIWcPIEluJP6tlbFM/Bf44LfZka/iemtahZAZzcO9TnI5uaXh3++lrqtNonCwp6/245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH+XxaCmR0WcvlKjNQnp12/eKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang/1WOq+Jaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT/fNnMRxFc7u+j3qI//5yuGuu14KR0MuQKKCSpViieD+fIti46sxPTsjSemoUKp0oXA== ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n 'symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' qJtv66wyp/1mZE+mIFAAMUoTe8xkmLN7/eAZjuC9x1ocxovItHLl/sNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M+JNIMz5UFxfeA53rXjFlvsyH1Sig+OuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C/QMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt/GuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng== ``` 3. 对 base64 格式的字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符): ```console HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D' ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D' ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash function rawurlencode { local string="${1}" local strlen=${#string} local encoded="" local pos c o for (( pos=0 ; pos [!NOTE] 此 API 只能用于现货 (`SPOT`) 交易所。 ## 一般 API 信息 - FIX 连接需要 TLS 加密。请使用本地 TCP+TLS 连接或设置本地代理如 [stunnel](https://www.stunnel.org/) 来处理 TLS 加密。 - API 处理请求的超时时间为 10 秒。如果撮合引擎的响应时间超过此时间,API 将返回 “Timeout waiting for response from backend server. Send status unknown; execution status unknown.”。[(-1007 超时)](errors.md#-1007-timeout) - 这并不总是意味着该请求在撮合引擎中失败。 - 如果请求状态未显示在 [WebSocket 账户接口](user-data-stream.md) 中,请执行 API 查询以获取其状态。 - 如果您的请求包含非 ASCII 字符的交易对名称,那么响应中可能包含以 UTF-8 编码的非 ASCII 字符。 - 为确保连接不中断,请确保您的客户端在 TLS 握手过程中发送 **SNI(服务器名称指示)**,并对目标主机名进行证书验证。 - 未发送 SNI 的客户端可能会收到证书错误的消息,导致 TLS 握手或主机名验证失败。
示例实现 ### NodeJS 如果你正在使用 Node.js,并且通过原始 TLS 套接字(`tls.connect()`)进行连接,你必须显式设置 servername 选项。请参考下面的示例: ```javascript const tls = require("tls"); const hostname = "fix-dc.binance.com"; //示例 const options = { host: hostname, port: 9002, servername: hostname, // 启用 SNI }; ``` 注意:NodeJS 默认不启用 TLS 的 SNI(详见 [https://nodejs.org/api/tls.html#tlsconnectoptions-callback](https://nodejs.org/api/tls.html#tlsconnectoptions-callback))。如果您使用 Node.js 中的标准 HTTPS 库(例如 `https.request()`、`axios`、`fetch`),通常在通过主机名/URL 连接时会自动设置 SNI。 ### 其他语言/自定义 TLS 实现 使用自定义 TLS 代理或 TLS API 时,请确保将相应字段(通常名为 `server_hostname`、`hostname` 或 `ServerName`)设置为目标主机名,以便发送 SNI。
**FIX 会话仅支持 Ed25519 密钥。** 关于如何设置 Ed25519 密钥对,请参考 [本教程](https://www.binance.com/zh-CN/support/faq/%E5%A6%82%E4%BD%95%E7%94%9F%E6%88%90ed25519%E5%AF%86%E9%92%A5%E5%AF%B9%E5%9C%A8%E5%B8%81%E5%AE%89%E5%8F%91%E9%80%81api%E8%AF%B7%E6%B1%82-6b9a63f1e3384cf48a2eedb82767a69a)。 ### FIX API 订单接入会话 - 端点为:`tcp+tls://fix-oe.binance.com:9000` - 支持下单,取消订单和查询当前限制使用情况。 - 支持接收账户的所有 [ExecutionReport`<8>`](#executionreport) 和 [List Status``](#liststatus)。 - 仅允许带有 `FIX_API` 的 API Key 连接。 - 关于 QuickFIX 模式文件, 请点击 [这里](/products/spot/fix/schemas/spot-fix-oe.xml)。 ### FIX API Drop Copy 会话 - 端点为:`tcp+tls://fix-dc.binance.com:9000` - 支持接收账户的所有 [ExecutionReport`<8>`](#executionreport) 和 [List Status``](#liststatus)。 - 仅允许连接带有 `FIX_API` 或 `FIX_API_READ_ONLY` 的 API Key。 - 关于 QuickFIX 模式文件, 请点击 [这里](/products/spot/fix/schemas/spot-fix-oe.xml)。 - Drop Copy 会话中的数据存在 1 秒的延迟。 ### FIX API Market Data 会话 - 端点为:`tcp+tls://fix-md.binance.com:9000` - 支持市场数据流和活动工具查询。 - 不支持下订单或取消订单。 - 仅允许连接带有“FIX_API”或“FIX_API_READ_ONLY”的 API 密钥。 关于 QuickFIX 模式 (Schema) 文件, 请点击 [这里](/products/spot/fix/schemas/spot-fix-oe.xml)。 FIX 连接需要 TLS 加密。请使用本地 TCP+TLS 连接或设置本地代理如 [stunnel](https://www.stunnel.org/) 来处理 TLS 加密。 FIX Market Data 的 QuickFIX Schema 可以在 [这里](/products/spot/fix/schemas/spot-fix-md.xml) ### FIX 连接生命周期 - 所有 FIX API 会话将尽最大努力,尽可能长时间地保持开放状态。 - 没有最短连接时间保证,服务器可能随时进入维护状态。 - 当服务器进入维护状态时,系统将会向客户端**每隔 10 秒发送一条** [News ``](#news) 消息,**直到断开连接**,以提示客户端重新连接。收到此消息后,客户端应建立新会话并关闭旧会话。如果客户端在服务器断开连接前没有关闭旧会话,那么服务器会将其注销并关闭会话。 - 连接后,客户端必须发送 Logon `` 请求。有关详情,请参阅 [如何签署登录请求](#signaturecomputation)。 - 客户端应在断开连接之前发送 Logout `<5>` 消息来关闭会话。未能发送注销消息将导致在 2x `HeartInt (108)` 定义的时间间隔内无法将会话的 `SenderCompID (49)` 用于新会话的建立。 - 系统允许在登录过程中协商 `HeartInt (108)` 值。可接受值的范围为 5 到 60 秒。 - 如果服务器在 `HeartInt (108)` 间隔内没有发送任何消息,将发送 [HeartBeat `<0>`](#heartbeat)。 - 如果服务器在 `HeartInt (108)` 间隔内没有收到任何消息,将发送 [TestRequest `<1>`](#testrequest)。如果服务器在 `HeartInt (108)` 秒内没有收到来自客户端的包含预期 `TestReqID (112)` 的 HeartBeat `<0>` 消息,服务器将发送 Logout `<5>` 消息并关闭连接。 - 如果客户端在 `HeartInt (108)` 间隔内未收到任何消息,那么客户端应负责发送 TestRequest `<1>` 消息以确保连接正常。收到这样的 TestRequest `<1>` 后,服务器会发送包含预期 `TestReqID (112)` 的 HeartBeat `<0>` 消息来进行响应。如果客户端在 `HeartInt (108)` 间隔内没有收到服务器的响应,那么客户端应关闭现有的会话和连接,并且建立新的会话和连接。 ### API Key 权限 如果您需要使用 FIX API 的订单接入会话,您的 API key 必须配置 `FIX_API` 权限。如果您需要使用 FIX API 的 Drop Copy 会话,您的 API key 必须配置 `FIX_API_READ_ONLY` 或 `FIX_API` 权限。要访问 FIX Market Data 会话,您的 API 密钥必须配置为 `FIX_API` 或 `FIX_API_READ_ONLY` 权限 **FIX 会话仅支持 Ed25519 密钥。** 关于如何设置 Ed25519 密钥对,请参考 [本教程](https://www.binance.com/zh-CN/support/faq/%E5%A6%82%E4%BD%95%E7%94%9F%E6%88%90ed25519%E5%AF%86%E9%92%A5%E5%AF%B9%E5%9C%A8%E5%B8%81%E5%AE%89%E5%8F%91%E9%80%81api%E8%AF%B7%E6%B1%82-6b9a63f1e3384cf48a2eedb82767a69a)。 ### 关于消息处理顺序 初始 [Logon``](#logon-request) 消息中必需的 `MessageHandling (25035)` 字段控制客户端消息在被撮合引擎处理之前是否可以被重新排序。 | 模式 | 描述 | | --------------- | ------------------------------------------------------ | | `UNORDERED(1)` | 客户端消息可以按任意顺序发送到撮合引擎。 | | `SEQUENTIAL(2)` | 客户端消息始终按 `MsgSeqNum (34)` 顺序发送到撮合引擎。 | 在所有模式下,客户端的 `MsgSeqNum (34)` 必须单调递增,即每条后续消息的序列号都比前一条消息正好大 1。 > [!TIP] 在有多个消息需要从客户端传输到服务器的情况时, `UNORDERED(1)` 应该会提供更好的性能。 ### 响应模式 默认情况下,所有并发订单录入会话都会接收到账户所有成功的 [ExecutionReport `<8>` ](#executionreport) 和 [ListStatus `` ](#liststatus) 消息,包括从其他 FIX 会话和通过非 FIX API 下达的订单。 用户可以在初始消息 [Logon``](#logon-request) 中使用 `ResponseMode (25036)` 字段来改变这种行为。 - `EVERYTHING(1)`: 默认模式。 - `ONLY_ACKS(2)`: 无论操作成功还是失败,都只接收 ACK 消息。禁用 `ExecutionReport` 推送。 ### 时间同步安全 - 所有请求都需要一个 `SendingTime(52)` 字段,该字段应为当前时间戳。 - 另有一个可选字段 `RecvWindow(25000)` ,用以指定请求的有效期(以毫秒为单位)。 - `RecvWindow(25000)` 扩展为三位小数(例如 6000.346),以便可以指定微秒。 - 如果未指定 `RecvWindow(25000)`,则仅对 Logon`` 请求默认为 5000 毫秒。对于其他请求,如果未设置,则不会执行 RecvWindow 检查。 - `RecvWindow(25000)` 的最大有效时间为 60000 毫秒。 - 请求处理逻辑如下: ```javascript serverTime = getCurrentTime() if (SendingTime < (serverTime + 1 second) && (serverTime - SendingTime) <= RecvWindow) { // 开始处理请求 serverTime = getCurrentTime() if (serverTime - SendingTime) <= RecvWindow { // 将请求转发到撮合引擎 } else { // 拒绝请求 } // 结束处理请求 } else { // 拒绝请求 } ``` ### 如何签署 Logon<A> 请求 [Logon``](#logon-main) 消息用于验证您与 FIX API 的连接。这条消息必须是客户端发送的第一条消息。 - `Username (553)` 字段必须包含 API key。 - `RawData (96)` 字段必须包含使用 API key 生成的有效签名。 签名 payload 是一个文本字符串。该字符串通过按以下所列顺序去连接下列字段来构成, 并且以 SOH 字符作为分隔符: 1. `MsgType (35)` 2. `SenderCompId (49)` 3. `TargetCompId (56)` 4. `MsgSeqNum (34)` 5. `SendingTime (52)` 请使用您的密钥签署 payload。请使用 **base64** 对签名进行编码。生成的文本字符串是 `RawData (96)` 字段的值。 以下是实现签名算法的 Python 代码示例: ```python import base64 from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from cryptography.hazmat.primitives.serialization import load_pem_private_key def logon_raw_data(private_key: Ed25519PrivateKey, sender_comp_id: str, target_comp_id: str, msg_seq_num: str, sending_time: str): """ Computes the value of RawData (96) field in Logon message. """ payload = chr(1).join([ 'A', sender_comp_id, target_comp_id, msg_seq_num, sending_time, ]) signature = private_key.sign(payload.encode('ASCII')) return base64.b64encode(signature).decode('ASCII') with open('private_key.pem', 'rb') as f: private_key = load_pem_private_key(data=f.read(), password=None) raw_data = logon_raw_data(private_key, sender_comp_id='5JQmUOsm', target_comp_id='SPOT', msg_seq_num='1', sending_time='20240612-08:52:21.613') ``` 以下值可用于验证签名计算实现的正确性: | 字段 | 取值 | | ----------------- | ----------------------- | | MsgType (35) | `A` | | SenderCompID (49) | `EXAMPLE` | | TargetCompID (56) | `SPOT` | | MsgSeqNum (34) | `1` | | SendingTime (52) | `20240627-11:17:25.223` | 示例计算中使用的 Ed25519 密钥如下所示: > [!CAUTION] > 以下密钥仅用于示范说明目的。请务必不要在任何实际应用中使用该密钥,因为它不安全,可能会危及您的加密实现。请在实际使用中生成属于您自己的唯一且安全的密钥。 ``` -----BEGIN PRIVATE KEY----- MC4CAQAwBQYDK2VwBCIEIIJEYWtGBrhACmb9Dvy+qa8WEf0lQOl1s4CLIAB9m89u -----END PRIVATE KEY----- ``` 经过计算生成的签名: ``` 4MHXelVVcpkdwuLbl6n73HQUXUf1dse2PCgT1DYqW9w8AVZ1RACFGM+5UdlGPrQHrgtS3CvsRURC1oj73j8gCA== ``` 生成的 Logon `` 消息: ``` 8=FIX.4.4|9=247|35=A|34=1|49=EXAMPLE|52=20240627-11:17:25.223|56=SPOT|95=88|96=4MHXelVVcpkdwuLbl6n73HQUXUf1dse2PCgT1DYqW9w8AVZ1RACFGM+5UdlGPrQHrgtS3CvsRURC1oj73j8gCA==|98=0|108=30|141=Y|553=sBRXrJx2DsOraMXOaUovEhgVRcjOvCtQwnWj8VxkOh1xqboS02SPGfKi2h8spZJb|25035=2|10=227| ``` ## 限制 ### 消息限制 - 每个连接都有一个关于 **可以发送到交易所的消息数量** 的限制。 - 消息限制 **不计算从接口发回到客户端的响应消息数量**。 - 违反消息限制会立即导致 [Logout `<5>`](#logout) 并断开连接。 - 要了解当前的限制和使用情况,请发送 [LimitQuery``](#limitquery) 消息。接口将发送 [LimitResponse``](#limitresponse) 消息作为响应,其中包含了有关订单速率限制和消息限制的信息。 - FIX API 订单输入会话的限制为每 10 秒 10,000 条消息。 - FIX Drop Copy 会话的限制为每 60 秒 60 条消息。 - FIX Market Data 会话的限制为每 60 秒 2000 条消息。 ### 未成交订单计数 - 要了解您在特定时间间隔内下了多少订单,请发送 [LimitQuery``](#limitquery) 消息。系统将发送一条 [LimitResponse``](#limitresponse) 消息作为响应,其中会包含有关未成交订单计数和消息限制的信息。 - **请注意,如果您的订单一直顺利完成交易,您可以在 API 持续下订单**。更多信息,请参见[现货未成交订单计数规则](./faqs/order_count_decrement.md)。 - 如果您超过了未成交的订单计数限制,您的消息将被拒绝,并且信息将用该接口的拒绝消息格式传回给您。 - **未成交订单数量是按照每个账户来统计的**。 ### 连接限制 - 每个账户都有一个关于 **可以同时建立的 TCP 连接数量** 的限制。 - 当 TCP 连接关闭时,限制值会减少。如果限制值没有立即减少,请等待最长不超过2倍于在 `HeartBtInt (108)` 内所定义的时间。比如说,如果 `HeartBtInt` 的值为5, 那么请等待10秒钟。 - 违反限制时, [Reject `<3>`](#reject) 消息会被发送给用户。该消息包含了有关违反连接限制和当前限制的信息。 - FIX 订单接入会话限制: - 在 30 秒内 15 次连接尝试的限制 - 每个账户 最多 10 个并发 TCP 连接的限制 - FIX Drop Copy 会话限制: - 在 30 秒内 15 次连接尝试的限制 - 每个账户 10 个并发 TCP 连接的限制 - FIX Market Data 会话限制: - 在 300 秒内 300 次连接尝试的限制 - 每个账户 100 个并发 TCP 连接的限制 - 单一连接最多能监听 1000 个数据流 ## 错误处理 包含句法错误,缺少必填字段,或引用未知交易对的客户端消息将被服务器拒绝,并返回 [Reject `<3>`](#reject) 消息。 如果有效消息无法被处理并被拒绝,服务器将发送相应的拒绝响应。请参阅各个消息的相关文档以了解可能会发生的响应。 请参阅响应中的 `Text (58)` 和 `ErrorCode (25016)` 字段以了解拒绝原因。 错误代码列表可以在 [错误代码](errors.md) 页面找到。 ## 类型 仅支持可打印的 ASCII 字符和 SOH。 | 类型 | 描述 | | -------------- | ------------------------------------------------------------------------- | | `BOOLEAN` | Enum:`Y` 或 `N`. | | `CHAR` | 单个字符。 | | `INT` | 有符号的 64 位整数。 | | `LENGTH` | 无符号的 64 位整数。 | | `NUMINGROUP` | 无符号的 64 位整数。 | | `PRICE` | 定点数。精度取决于 symbol 定义。 | | `QTY` | 定点数。精度取决于 symbol 定义。 | | `SEQNUM` | 无符号的 32 位整数。达到最大值 4,294,967,295 后会归 0,然后重新开始计数。 | | `STRING` | 可打印的 ASCII 字符串。 | | `UTCTIMESTAMP` | 表示 UTC 日期时间的字符串。 | 支持的 `UTCTIMESTAMP` 格式: - `20011217-09:30:47` - 秒 - `20011217-09:30:47.123` - 毫秒 - `20011217-09:30:47.123456` - 微秒(用于来自交易所的消息) 客户端订单 ID 字段必须符合正则表达式 `^[a-zA-Z0-9-_]{1,36}$`: - `ClOrdID (11)` - `OrigClOrdID (41)` - `MDReqID (262)` - `ClListID (25014)` - `OrigClListID (25015)` - `CancelClOrdID (25034)` ## 消息组件 在示例消息中, `|` 字符用于表示 SOH 字符: ``` 8=FIX.4.4|9=113|35=A|34=1|49=SPOT|52=20240612-08:52:21.636837|56=5JQmUOsm|98=0|108=30|25037=4392a152-3481-4499-921a-6d42c50702e2|10=051| ``` ### Header 出现在每条消息的开头。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | ----- | ------------ | ------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 8 | BeginString | STRING | Y | 始终为 `FIX.4.4`。

必须是消息的第一个字段。 | | 9 | BodyLength | LENGTH | Y | 消息长度(以字节为单位)。

必须是消息的第二个字段。 | | 35 | MsgType | STRING | Y | 必须是消息的第三个字段。

可能的值:

`0` - [HEARTBEAT](#heartbeat)

`1` - [TEST_REQUEST](#testrequest)

`3` - [REJECT](#reject)

`5` - [LOGOUT](#logout)

`8` - [EXECUTION_REPORT](#executionreport)

`9` - [ORDER_CANCEL_REJECT](#ordercancelreject)

`A` - [LOGON](#logon-main)

`D` - [NEW_ORDER_SINGLE](#newordersingle)

`E` - [NEW_ORDER_LIST](#neworderlist)

`F` - [ORDER_CANCEL_REQUEST](#ordercancelrequest)

`N` - [LIST_STATUS](#liststatus)

`q` - [ORDER_MASS_CANCEL_REQUEST](#ordermasscancelrequest)

`r` - [ORDER_MASS_CANCEL_REPORT](#ordermasscancelreport)

`XCN` - [ORDER_CANCEL_REQUEST_AND_NEW_ORDER_SINGLE](#ordercancelrequestandnewordersingle)

`XLQ` - [LIMIT_QUERY](#limitquery)

`XLR` - [LIMIT_RESPONSE](#limitresponse)

`B` - [NEWS](#news)

`x`- [INSTRUMENT_LIST_REQUEST](#instrumentlistrequest)

`y` - [INSTRUMENT_LIST](#instrumentlist)

`V` - [MARKET_DATA_REQUEST](#marketdatarequest)

`Y` - [MARKET_DATA_REQUEST_REJECT](#marketdatarequestreject)

`W` - [MARKET_DATA_SNAPSHOT](#marketdatasnapshot)

`X` - [MARKET_DATA_INCREMENTAL_REFRESH](#marketdataincrementalrefresh)

`XAK` - [ORDER_AMEND_KEEP_PRIORITY_REQUEST](#orderamendkeeppriorityrequest)

`XAR` - [ORDER_AMEND_REJECT](#orderamendreject) | | 49 | SenderCompID | STRING | Y | 在账户的活动会话中必须是独特的。

必须使用正则表达式:`^[a-zA-Z0-9-_]{1,8}$` | | 56 | TargetCompID | STRING | Y | 在客户端的消息中必须设置为`SPOT`。 | | 34 | MsgSeqNum | SEQNUM | Y | 整数消息序列号。

会导致间隙的值将被拒绝。 | | 52 | SendingTime | UTCTIMESTAMP | Y | 消息传输时间(始终以 UTC 表示)。 | | 25000 | RecvWindow | FLOAT | N | 在`SendingTime (52)` 后,用于标识请求有效时间的毫秒数。

在 [Logon``](#logon-request) 中默认为 `5000` 毫秒,最大值为 `60000` 毫秒。
支持最多三位小数的精度(例如 6000.346),以便可以指定微秒。 |
### Trailer 出现在每条消息的末尾。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | --- | -------- | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 10 | CheckSum | STRING | Y | 始终为3个字符的数字字符串。其取值是通过对消息中每个前导字符的 ASCII 值进行求和计算得出的,其中包括 start-of-header(SOH)。

结果总和除以 256,余数形成 CheckSum 值。

为保持固定长度,CheckSum 字段采用右对齐并按需要进行零填充。 | ## Administrative Messages ### Heartbeat <0> 如果在心跳间隔([Logon``](#logon-main) 中的 `HeartBtInt (108)`)的期间没有传出流量,则由服务器发送。 由客户端发送则用于指示会话正常。 由客户端或服务器发送,用于给予 [TestRequest`<1>`](#testrequest) 消息有关响应。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | --- | --------- | ------ | -------- | ------------------------------------------------------------------------------------------- | | 112 | TestReqID | STRING | N | 当 Heartbeat`<35>` 作为对 TestRequest`<1>` 的响应发送时,必须镜像 TestRequest`<1>` 中的值。 | ### TestRequest <1> 如果在心跳间隔([Logon``](#logon-main) 中的 `HeartBtInt (108)`)的期间没有传入流量,则由服务器发送。 由客户端发送用于请求 [Heartbeat`<0>`](#heartbeat) 响应。 > [!NOTE] 如果客户端未能在超时范围内发送带有正确 `TestReqID (112)` 的 Heartbeat`<0>` > 来响应 TestRequest`<1>` ,其连接将被断开。 | Tag | 名称 | 类型 | 必填 | 描述 | | --- | --------- | ------ | ---- | ---------------------------------------------- | | 112 | TestReqID | STRING | Y | 任意字符串,必须包含在 Heartbeat`<0>` 响应中。 | ### Reject <3> 由服务器发送,用以响应无法处理的无效消息。 如果无法接受新连接,则由服务器发送。请参阅 [Connection Limits](#connection-limits)。 请参阅 `Text (58)` 和 `ErrorCode (25016)` 字段以了解拒绝原因。 | Tag | 名称 | 类型 | 必填 | 描述 | | ----- | ------------------- | ------ | ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 45 | RefSeqNum | INT | N | 导致此 Reject`<3>` 发送的被拒绝消息的 `MsgSeqNum (34)`。 | | 371 | RefTagID | INT | N | 如果存在,标识直接导致此 Reject`<3>` 消息发送的字段。 | | 372 | RefMsgType | STRING | N | 导致此 Reject`<3>` 发送的被拒绝消息的 `MsgType (35)`。 | | 373 | SessionRejectReason | INT | N | 拒绝的原因,可以是以下值之一。

通常伴随附加的文字描述

可能的值:

`0`- INVALID_TAG_NUMBER

`1` - REQUIRED_TAG_MISSING

`2` - TAG_NOT_DEFINED_FOR_THIS_MESSAGE_TYPE

`3` - UNDEFINED_TAG

`5` - VALUE_IS_INCORRECT

`6` - INCORRECT_DATA_FORMAT_FOR_VALUE

`8` - SIGNATURE_PROBLEM

`10` - SENDINGTIME_ACCURACY_PROBLEM

`12` - XML_VALIDATION_ERROR

`13` - TAG_APPEARS_MORE_THAN_ONCE

`14` - TAG_SPECIFIED_OUT_OF_REQUIRED_ORDER

`15` - REPEATING_GROUP_FIELDS_OUT_OF_ORDER

`16` - INCORRECT_NUMINGROUP_COUNT_FOR_REPEATING_GROUP

`99` - OTHER | | 25016 | ErrorCode | INT | N | API 错误代码(参见 [错误代码](errors.md))。 | | 58 | Text | STRING | N | 人类可读的错误信息。 | ### Logon<A> 由客户端发送,用以验证连接。Logon`` 必须是客户端发送的第一条消息。 由服务器发送,用以响应成功的登录。 > [!NOTE] Logon`` 在整个会话期间只能发送一次。 #### Logon Request | Tag | 名称 | 类型 | 是否必须 | 描述 | | ----- | --------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------- | | 98 | EncryptMethod | INT | Y | 必须为 `0`。 | | 108 | HeartBtInt | INT | Y | 必须在 [5, 60] 范围内。Heartbeat 间隔(秒)。 | | 95 | RawDataLength | LENGTH | Y | 紧随此字段之后的 `RawData (96)` 字段的长度。 | | 96 | RawData | DATA | Y | 签名。 [如何签署 Logon`` 请求](#signaturecomputation)。 | | 141 | ResetSeqNumFlag | BOOLEAN | Y | 必须为 `Y`。 | | 553 | Username | STRING | Y | API key。**仅支持 Ed25519 API keys。** | | 25035 | MessageHandling | INT | Y | 可能的值:

`1` - UNORDERED

`2` - SEQUENTIAL

请参阅 [关于消息处理顺序](#orderedmode) 了解更多信息。 | | 25036 | ResponseMode | INT | N | 请参阅 [响应模式](#responsemode)。 | | 9406 | DropCopyFlag | BOOLEAN | N | 登录到 Drop Copy 会话时,必须设置为"Y"。 | **示例消息:** ``` 8=FIX.4.4|9=248|35=A|34=1|49=5JQmUOsm|52=20240612-08:52:21.613|56=SPOT|95=88|96=KhJLbZqADWknfTAcp0ZjyNz36Kxa4ffvpNf9nTIc+K5l35h+vA1vzDRvLAEQckyl6VDOwJ53NOBnmmRYxQvQBQ==|98=0|108=30|141=Y|553=W5rcOD30c0gT4jHK8oX5d5NbzWoa0k4SFVoTHIFNJVZ3NuRpYb6ZyJznj8THyx5d|25035=1|10=000| ```
#### Logon Response | Tag | 名称 | 类型 | 是否必须 | 描述 | | ----- | ------------- | ------ | -------- | -------------------------------- | | 98 | EncryptMethod | INT | Y | 始终为 `0`。 | | 108 | HeartBtInt | INT | Y | 镜像 Logon 请求中的值。 | | 25037 | UUID | STRING | Y | 提供请求服务的 FIX API 的 UUID。 | **示例消息:** ``` 8=FIX.4.4|9=113|35=A|34=1|49=SPOT|52=20240612-08:52:21.636837|56=5JQmUOsm|98=0|108=30|25037=4392a152-3481-4499-921a-6d42c50702e2|10=051| ``` ### Logout <5> 发送此消息以启动关闭连接的过程,并对 Logout 进行响应。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | --- | ---- | ------ | -------- | ---- | | 58 | Text | STRING | N | | **示例消息:** Logout 请求 ``` 8=FIX.4.4|9=55|35=5|34=3|49=GhQHzrLR|52=20240611-09:44:25.543|56=SPOT|10=249| ``` Logout 响应 ``` 8=FIX.4.4|9=84|35=5|34=4|49=SPOT|52=20240611-09:44:25.544001|56=GhQHzrLR|58=Logout acknowledgment.|10=212| ``` ### News <B> 当服务器进入维护状态时,系统将会向客户端**每隔 10 秒发送一条** `News` 消息,并倒计时至断开连接。 如果客户端在服务器断开连接前没有关闭旧会话,那么服务器会将其注销并关闭会话。 收到此消息后,客户端应建立新会话并关闭旧会话。 发送的倒计时消息将是: ``` You'll be disconnected in %d seconds. Please reconnect. ``` 剩余 10 秒时,系统将发送以下消息: ``` Your connection is about to be closed. Please reconnect. ``` 如果客户端在收到上述消息后的 10 秒内没有关闭旧会话,那么服务器会将其注销并关闭会话。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | --- | -------- | ------ | -------- | ---- | | 148 | Headline | STRING | Y | | **示例消息:** ``` 8=FIX.4.4|9=0000113|35=B|49=SPOT|56=OE|34=4|52=20240924-21:07:35.773537|148=Your connection is about to be closed. Please reconnect.|10=165| ``` ### Resend Request <2> 目前不支持重新发送请求。 ## Application Messages ### 下单消息 > [!NOTE] 以下消息只能用于 FIX 订单接入会话和 FIX Drop Copy 会话 #### NewOrderSingle<D> 由客户端发送,用以提交新订单并进行执行。 这个请求会把1个订单添加到 `EXCHANGE_MAX_ORDERS` 过滤器和 `MAX_NUM_ORDERS` 过滤器中。 **未成交的订单计数:** 1 请参阅 [支持的订单类型](#ordertype) 了解支持的字段组合。 > [!NOTE] 许多字段会根据订单类型变为必填。请参阅 [支持的订单类型](#NewOrderSingle-required-fields)。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | ----- | ------------------------ | ------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 11 | ClOrdID | STRING | Y | 分配给订单的 `ClOrdID`。 | | 38 | OrderQty | QTY | N | 订单数量 | | 40 | OrdType | CHAR | Y | 请参阅 [表格](#ordertype) 了解支持的订单类型和所需字段。

可能的值:

`1` - MARKET

`2` - LIMIT

`3` - STOP

`4` - STOP_LIMIT

`P`- PEGGED | | 18 | ExecInst | CHAR | N | 可能的值:

`6` - PARTICIPATE_DONT_INITIATE | | 44 | Price | PRICE | N | 订单价格 | | 54 | Side | CHAR | Y | 订单方向。

可能的值:

`1` - BUY

`2` - SELL | | 55 | Symbol | STRING | Y | 下单的交易对。 | | 59 | TimeInForce | CHAR | N | 可能的值:

`1` - GOOD_TILL_CANCEL

`3` - IMMEDIATE_OR_CANCEL

`4` - FILL_OR_KILL | | 111 | MaxFloor | QTY | N | 用于冰山订单,指定订单在订单簿上的可见数量。 | | 152 | CashOrderQty | QTY | N | 以报价资产单位指定的订单数量,用于反向市场订单。 | | 847 | TargetStrategy | INT | N | 该值不能小于 `1000000`。 | | 7940 | StrategyID | INT | N | | | 25001 | SelfTradePreventionMode | CHAR | N | 可能的值:

`1` - NONE

`2` - EXPIRE_TAKER

`3` - EXPIRE_MAKER

`4` - EXPIRE_BOTH

`5` - DECREMENT
`6` - TRANSFER | | 211 | PegOffsetValue | FLOAT | N | 使用了 `PegOffsetType` 后,添加到挂钩的偏移值 | | 1094 | PegPriceType | CHAR | N | 定义了挂钩价格的类型
可能的值:
`4` - MARKET_PEG
`5` - PRIMARY_PEG | | 835 | PegMoveType | CHAR | N | 描述挂钩是固定的还是浮动的。挂钩订单必用且必须为 `1` (FIXED) | | 836 | PegOffsetType | CHAR | N | 定义了挂钩价格偏移类型。
可能的值:

`3` - PRICE_TIER | | 1100 | TriggerType | CHAR | N | 可能的值: `4` - PRICE_MOVEMENT | | 1101 | TriggerAction | CHAR | N | 可能的值:

`1` - ACTIVATE | | 1102 | TriggerPrice | PRICE | N | 止盈止损订单的激活价格。请参阅 [表格](#ordertype) | | 1107 | TriggerPriceType | CHAR | N | 可能的值:

`2` - LAST_TRADE | | 1109 | TriggerPriceDirection | CHAR | N | 用于区分 StopLoss 和 TakeProfit 订单。请参阅 [表格](#ordertype)。

可能的值:

`U` - TRIGGER_IF_THE_PRICE_OF_THE_SPECIFIED_TYPE_GOES_UP_TO_OR_THROUGH_THE_SPECIFIED_TRIGGER_PRICE

`D` - TRIGGER_IF_THE_PRICE_OF_THE_SPECIFIED_TYPE_GOES_DOWN_TO_OR_THROUGH_THE_SPECIFIED_TRIGGER_PRICE | | 25009 | TriggerTrailingDeltaBips | INT | N | 提供以创建追踪订单。 | | 25032 | SOR | BOOLEAN | N | 是否为此订单激活 SOR。 | **示例消息:** ``` 8=FIX.4.4|9=114|35=D|34=2|49=qNXO12fH|52=20240611-09:01:46.228|56=SPOT|11=1718096506197867067|38=5|40=2|44=10|54=1|55=LTCBNB|59=4|10=016| ``` **响应:** - 如果订单被接受, [ExecutionReport`<8>`](#executionreport)的 `ExecType (150)` 值为 `NEW (0)`。 - 如果订单被拒绝, [ExecutionReport`<8>`](#executionreport)的 `ExecType (150)` 值为 `REJECTED (8)`。 - 如果消息被拒绝,则为 [Reject`<3>`](#reject)。 ##### 支持的订单类型 | 订单名称 | Binance OrderType | 方向 | 必填字段值 | 用户值必填字段 | | ------------------------------------- | ------------------- | ----------- | ----------------------------------------------------------------------- | -------------- | | Market order | `MARKET` | BUY 或 SELL | 40=1| | | | Limit order | `LIMIT` | BUY 或 SELL | 40=2| | | | Limit maker order | `LIMIT_MAKER` | BUY 或 SELL | 40=2|18=6| | | | Buy stop loss order | `STOP_LOSS` | BUY | 40=3|1100=4|1101=1|1107=2|1109=U| | 1102 | | Buy trailing stop loss order | `STOP_LOSS` | BUY | 40=3|1100=4|1101=1|1107=2|1109=U| | 1102,25009 | | Buy stop loss limit order | `STOP_LOSS_LIMIT` | BUY | 40=4|1100=4|1101=1|1107=2|1109=U| | 1102 | | Buy trailing stop loss limit order | `STOP_LOSS_LIMIT` | BUY | 40=4|1100=4|1101=1|1107=2|1109=U| | 1102,25009 | | Sell stop loss order | `STOP_LOSS` | SELL | 40=3|1100=4|1101=1|1107=2|1109=D| | 1102 | | Sell trailing stop loss order | `STOP_LOSS` | SELL | 40=3|1100=4|1101=1|1107=2|1109=D| | 1102,25009 | | Sell stop loss limit order | `STOP_LOSS_LIMIT` | SELL | 40=4|1100=4|1101=1|1107=2|1109=D| | 1102 | | Sell trailing stop loss limit order | `STOP_LOSS_LIMIT` | SELL | 40=4|1100=4|1101=1|1107=2|1109=D| | 1102,25009 | | Buy take profit order | `TAKE_PROFIT` | BUY | 40=3|1100=4|1101=1|1107=2|1109=D| | 1102 | | Buy trailing take profit order | `TAKE_PROFIT` | BUY | 40=3|1100=4|1101=1|1107=2|1109=D| | 1102,25009 | | Buy trailing take profit order | `TAKE_PROFIT` | BUY | 40=3|1100=4|1101=1|1107=2| | 25009 | | Buy take profit order | `TAKE_PROFIT_LIMIT` | BUY | 40=4|1100=4|1101=1|1107=2|1109=D| | 1102 | | Buy trailing take profit limit order | `TAKE_PROFIT_LIMIT` | BUY | 40=4|1100=4|1101=1|1107=2|1109=D| | 1102,25009 | | Buy trailing take profit limit order | `TAKE_PROFIT_LIMIT` | BUY | 40=4|1100=4|1101=1|1107=2| | 25009 | | Sell take profit order | `TAKE_PROFIT` | SELL | 40=3|1100=4|1101=1|1107=2|1109=U| | 1102 | | Sell trailing take profit order | `TAKE_PROFIT` | SELL | 40=3|1100=4|1101=1|1107=2|1109=U| | 1102,25009 | | Sell trailing take profit order | `TAKE_PROFIT` | SELL | 40=3|1100=4|1101=1|1107=2| | 25009 | | Sell take profit limit order | `TAKE_PROFIT_LIMIT` | SELL | 40=4|1100=4|1101=1|1107=2|1109=U| | 1102 | | Sell trailing take profit limit order | `TAKE_PROFIT_LIMIT` | SELL | 40=4|1100=4|1101=1|1107=2|1109=U| | 1102,25009 | | Sell trailing take profit limit order | `TAKE_PROFIT_LIMIT` | SELL | 40=4|1100=4|1101=1|1107=2| | 25009 | 基于 Binance OrderType 的必填字段: | Binance OrderType | 额外的必填字段 | 额外的信息 | | ------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `LIMIT` | 38, 44, 59 | | | `MARKET` | 38 或 152 | `MARKET` 订单使用 `OrderQty (38)` 字段来指定用户希望以市场价格买入或卖出的 `base asset` 数量。

例如,用户可以使用交易对为 `BTCUSDT` 的 `MARKET` 订单来指定买入或卖出多少 BTC。



用户使用 `MARKET` 订单中的 `quoteOrderQty` 字段来指定花费(买入时)或接收(卖出时)`quote` 资产。正确的 `quantity` 将由市场流动性和 `quoteOrderQty` 来决定。

用交易对 BTCUSDT来举例:

`BUY` 方订单将使用由 `quoteOrderQty` 定义的 USDT 数额来购买尽可能多的 BTC。

`SELL` 方订单将出售 BTC 来换取尽可能多的由 `CashOrderQty(152)` 定义的 USDT 数额。 | | `STOP_LOSS` | 38, 1102 或 25009 | 当满足条件时,将执行 `MARKET` 订单。(例如,满足 `TriggerPrice (1102)` 的条件或激活 `TriggerTrailingDeltaBips (25009)`) | | `STOP_LOSS_LIMIT` | 38, 44, 59, 1102 或 25009 | | | `TAKE_PROFIT` | 38, 1102 或 25009 | 当满足条件时,这将执行`MARKET`订单。(例如,满足 `TriggerPrice (1102)` 的条件或激活 `TriggerTrailingDeltaBips (25009)`) | | `TAKE_PROFIT_LIMIT` | 38, 44, 59, 1102 或 25009 | | | `LIMIT_MAKER` | 38, 44 | 这是一个 `LIMIT` 订单。如果订单被立即匹配并作为 taker 进行交易,那么该订单将被拒绝。

这也称为 POST-ONLY 订单。 | #### ExecutionReport<8> 每当订单状态发生变化时由服务器发送。 > [!NOTE] > > - 默认情况下,ExecutionReport`<8>` 会发送该账户的所有订单,包括在不同连接中提交的订单。 请参阅 > [响应模式](#responsemode) 来了解其他行为选项。 > - FIX API 应该为 ExecutionReport<8> 推送提供更好的性能。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | ----- | ------------------------ | ------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 17 | ExecID | STRING | N | 被拒绝订单时省略。 | | 11 | ClOrdID | STRING | N | 列表中分配的 `ClOrdID`。 | | 41 | OrigClOrdID | STRING | N | 订单的原始 `ClOrdID`。 | | 37 | OrderID | INT | N | 由交易所分配。 | | 38 | OrderQty | QTY | N | 订单数量。 | | 40 | OrdType | CHAR | Y | 可能的值:

`1` - MARKET

`2` - LIMIT

`3` - STOP_LOSS

`4` - STOP_LIMIT

`P` - PEGGED | | 54 | Side | CHAR | Y | 可能的值:

`1` - BUY

`2` - SELL | | 55 | Symbol | STRING | Y | 订单的交易对。 | | 18 | ExecInst | CHAR | N | 可能的值:

`6` - PARTICIPATE_DONT_INITIATE | | 44 | Price | PRICE | N | 订单价格。 | | 59 | TimeInForce | CHAR | N | 可能的值:

`1` - GOOD_TILL_CANCEL

`3` - IMMEDIATE_OR_CANCEL

`4` - FILL_OR_KILL | | 60 | TransactTime | UTCTIMESTAMP | N | 此事件发生的时间戳。 | | 25018 | OrderCreationTime | INT | N | | | 111 | MaxFloor | QTY | N | 出现在冰山订单中。 | | 66 | ListID | STRING | N | 出现在列表订单中。 | | 152 | CashOrderQty | QTY | N | 以 quote asset 单位指定的订单数量。 | | 847 | TargetStrategy | INT | N | 订单提交请求中的 `TargetStrategy (847)`。 | | 7940 | StrategyID | INT | N | 订单提交请求中的 `StrategyID (7940)`。 | | 25001 | SelfTradePreventionMode | CHAR | N | 可能的值:

`1` - NONE

`2` - EXPIRE_TAKER

`3` - EXPIRE_MAKER

`4` - EXPIRE_BOTH

`5` - DECREMENT
`6` - TRANSFER | | 150 | ExecType | CHAR | Y | **注意:** 如果订单因 `SelfTradePreventionMode(25013)` 过期,字段 `PreventedMatchID(25024)` 会被显示。

可能的值:

`0` - NEW

`4` - CANCELED

`5` - REPLACED

`8` - REJECTED

`F` - TRADE

`C` - EXPIRED | | 14 | CumQty | QTY | Y | 在此订单上交易的 base asset 总数。 | | 151 | LeavesQty | QTY | N | 剩余的可执行数量。 | | 25017 | CumQuoteQty | QTY | N | 在此订单上交易的 quote asset 总数。 | | 1057 | AggressorIndicator | BOOLEAN | N | 出现在 trade execution reports 中。

指示订单在交易中是否为 taker。 | | 1003 | TradeID | STRING | N | 出现在 trade execution reports 中。 | | 31 | LastPx | PRICE | N | 最后一次执行的价格。 | | 32 | LastQty | QTY | Y | 最后一次执行的数量。 | | 39 | OrdStatus | CHAR | Y | 可能的值:

`0` - NEW

`1` - PARTIALLY_FILLED

`2` - FILLED

`4` - CANCELED `6` - PENDING_CANCEL

`8` - REJECTED

`A` - PENDING_NEW

`C` - EXPIRED

注意 FIX 不支持 `EXPIRED_IN_MATCH` 状态,并在 FIX 中转换为 `EXPIRED`。 | | 70 | AllocID | INT | N | 由交易所分配的分配 ID。 | | 574 | MatchType | INT | N | 可能的值:

`1` - ONE_PARTY_TRADE_REPORT

`4` - AUTO_MATCH | | 25021 | WorkingFloor | INT | N | 出现在可能有分配的订单中。 | | 25022 | TrailingTime | UTCTIMESTAMP | N | 仅出现在追踪止损订单中。 | | 636 | WorkingIndicator | BOOLEAN | N | 当此订单进入订单簿时会被设置为 `Y`。 | | 25023 | WorkingTime | UTCTIMESTAMP | N | 此订单出现在订单簿上的时间。 | | 25024 | PreventedMatchID | INT | N | 仅出现在因 STP 过期的订单中。 | | 25025 | PreventedExecutionPrice | PRICE | N | 仅出现在因 STP 过期的订单中。 | | 25026 | PreventedExecutionQty | QTY | N | 仅出现在因 STP 过期的订单中。 | | 25027 | TradeGroupID | INT | N | 仅出现在因 STP 过期的订单中。 | | 25028 | CounterSymbol | STRING | N | 仅出现在因 STP 过期的订单中。 | | 25029 | CounterOrderID | INT | N | 仅出现在因 STP 过期的订单中。 | | 25030 | PreventedQty | QTY | N | 仅出现在因 STP 过期的订单中。 | | 25031 | LastPreventedQty | QTY | N | 仅出现在因 STP 过期的订单中。 | | 25032 | SOR | BOOLEAN | N | 出现在使用 SOR 的订单中。 | | 25016 | ErrorCode | INT | N | API 错误代码(请参阅 [错误代码](errors.md))。 | | 58 | Text | STRING | N | 可读的错误消息。 | | 136 | NoMiscFees | NUMINGROUP | N | 杂费的重复组数量。 | | =>137 | MiscFeeAmt | QTY | Y | 以 `MiscFeeCurr(138)` 资产计价的费用金额 | | =>138 | MiscFeeCurr | STRING | Y | 杂费的货币。 | | =>139 | MiscFeeType | INT | Y | 可能的值:

`4` - EXCHANGE_FEES | | 1100 | TriggerType | CHAR | N | 可能的值:

`4` - PRICE_MOVEMENT | | 1101 | TriggerAction | CHAR | N | 可能的值:

`1` - ACTIVATE | | 1102 | TriggerPrice | PRICE | N | 止盈止损订单的激活价格。请参阅 [表格](#ordertype) | | 1107 | TriggerPriceType | CHAR | N | 可能的值:

`2` - LAST_TRADE | | 1109 | TriggerPriceDirection | CHAR | N | 用于区分止损和止盈订单。请参阅 [表格](#ordertype)。

可能的值:

`U` - TRIGGER_IF_THE_PRICE_OF_THE_SPECIFIED_TYPE_GOES_UP_TO_OR_THROUGH_THE_SPECIFIED_TRIGGER_PRICE

`D` - TRIGGER_IF_THE_PRICE_OF_THE_SPECIFIED_TYPE_GOES_DOWN_TO_OR_THROUGH_THE_SPECIFIED_TRIGGER_PRICE | | 25009 | TriggerTrailingDeltaBips | INT | N | 仅出现在追踪止损订单中。 | | 211 | PegOffsetValue | FLOAT | N | 使用了 `PegOffsetType` 后,添加到挂钩的偏移值 | | 1094 | PegPriceType | CHAR | N | 定义了挂钩价格的类型
可能的值:
`4` - MARKET_PEG
`5` - PRIMARY_PEG | | 835 | PegMoveType | CHAR | N | 描述挂钩是固定的还是浮动的。挂钩订单必用且必须为 `1` (FIXED) | | 836 | PegOffsetType | CHAR | N | 定义了挂钩价格偏移类型。
可能的值:

`3` - PRICE_TIER | | 839 | PeggedPrice | PRICE | N | 订单所挂钩的当前价格 | **示例消息:** ``` 8=FIX.4.4|9=330|35=8|34=2|49=SPOT|52=20240611-09:01:46.228950|56=qNXO12fH|11=1718096506197867067|14=0.00000000|17=144|32=0.00000000|37=76|38=5.00000000|39=0|40=2|44=10.00000000|54=1|55=LTCBNB|59=4|60=20240611-09:01:46.228000|150=0|151=5.00000000|636=Y|1057=Y|25001=1|25017=0.00000000|25018=20240611-09:01:46.228000|25023=20240611-09:01:46.228000|10=095| ``` #### OrderCancelRequest<F> 由客户发送的,用以取消订单或订单列表。 - 要取消订单,需要 `OrderID (11)` 或 `OrigClOrdID (41)`。 - 当同时提供 `OrderID (37)` 和 `OrigClOrdID (41)` 两个参数时,系统首先将会使用 `OrderID` 来搜索订单。然后, 查找结果中的 `OrigClOrdID` 的值将会被用来验证订单。如果两个条件都不满足,则请求将被拒绝。 - 要取消订单列表,需要 `ListID (66)` 或 `OrigClListID (25015)`。 - 当同时提供 `ListID (66)` 和 `OrigClListID (25015)` 两个参数时,系统首先将会使用 `ListID` 来搜索订单列表。然后, 查找结果中的 `OrigClListID` 将会被用来验证订单列表。如果两个条件都不满足,请求将被拒绝。 如果已取消的订单是订单列表的一部分,则整个订单列表将被取消。 **注意:** - 当仅发送 `orderId` 时,取消订单的执行(单个 Cancel 或作为 Cancel-Replace 的一部分)总是更快。发送 `origClientOrderId` 或同时发送 `orderId` + `origClientOrderId` 会稍慢。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | ----- | ------------------ | ------ | -------- | ------------------------------------------------------------------------------------ | | 11 | ClOrdID | STRING | Y | 请求的 `ClOrdID`。 | | 41 | OrigClOrdID | STRING | N | 要取消订单的 `ClOrdID (11)`。 | | 37 | Order ID | STRING | N | 要取消订单的 `OrderID (37)`。 | | 25015 | OrigClListID | STRING | N | 要取消订单列表的 `ClListID (25014)`。 | | 66 | ListID | STRING | N | 要取消订单列表的 `ListID (66)`。 | | 55 | Symbol | STRING | Y | 要取消订单的交易对。 | | 25002 | CancelRestrictions | INT | N | 取消的限制。可能的值:

`1` - ONLY_NEW

`2` - ONLY_PARTIALLY_FILLED | **示例消息:** ``` 8=FIX.4.4|9=93|35=F|34=2|49=ieBwvCKy|52=20240613-01:11:13.784|56=SPOT|11=1718241073695674483|37=2|55=LTCBNB|10=210| ``` **响应:** - 对于每个被取消的订单,[ExecutionReport`<8>`](#executionreport)的 `ExecType (150)` 值为 `CANCELED (4)`。 - 如果订单列表中的订单被取消,则为 [ListStatus``](#liststatus)。 - 如果取消被拒绝,则为 [OrderCancelReject`<9>`](#ordercancelreject)。 - 如果消息被拒绝,则为 [Reject`<3>`](#reject)。 #### OrderCancelReject <9> 当 [OrderCancelRequest``](#ordercancelrequest) 失败时,由服务器发送的消息。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | ----- | ------------------ | ------ | -------- | --------------------------------------------------------------------------------------------------- | | 11 | ClOrdID | STRING | Y | 来自取消请求的 `ClOrdID (11)`。 | | 41 | OrigClOrdID | STRING | N | 来自取消请求的 `OrigClOrdID (41)`。 | | 37 | OrderID | INT | N | 来自取消请求的 `OrderID (37)`。 | | 25015 | OrigClListID | STRING | N | 来自取消请求的 `OrigClListID (25015)`。 | | 66 | ListID | STRING | N | 来自取消请求的 `ListID (66)`。 | | 55 | Symbol | STRING | Y | 来自取消请求的 `Symbol (55)`。 | | 25002 | CancelRestrictions | INT | N | 来自取消请求的 `CancelRestrictions (25002)`。 | | 434 | CxlRejResponseTo | CHAR | Y | 此 OrderCancelReject`<9>` 响应的请求类型。

可能的值:

`1` - ORDER_CANCEL_REQUEST | | 25016 | ErrorCode | INT | Y | API error code (参考 [错误代码](errors.md)). | | 58 | Text | STRING | Y | 可读的错误消息。 | **示例消息:** ``` 8=FIX.4.4|9=137|35=9|34=2|49=SPOT|52=20240613-01:12:41.320869|56=OlZb8ht8|11=1718241161272843932|37=2|55=LTCBNB|58=Unknown order sent.|434=1|25016=-1013|10=087| ``` #### OrderCancelRequestAndNewOrderSingle<XCN> 由客户发送,用以取消订单并提交新订单以供执行。 - 要取消订单,需要 `OrderID (11)` 或 `OrigClOrdId (41)`。 - 当同时提供 `OrderID (37)` 和 `OrigClOrdID (41)` 两个参数时,系统首先将会使用 `OrderID` 来搜索订单。然后, 查找结果中的 `OrigClOrdID` 的值将会被用来验证订单。如果两个条件都不满足,则请求将被拒绝。 在撤消订单和下单前会判断: 1) 过滤器参数, 以及 2) 目前下单数量。 即使请求中没有尝试发送新订单,比如(`newOrderResult: NOT_ATTEMPTED`),未成交订单的数量仍然会加1。 **未成交的订单计数:** 1 在描述新订单时,请参阅 [支持的订单类型](#ordertype) 了解支持的字段组合。 > [!NOTE] 取消始终是优先处理的,紧接着的是提交新订单。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | ----- | --------------------------------------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 25033 | OrderCancelRequestAndNewOrderSingleMode | INT | Y | 用于定义: 如果取消失败,将会采取的后续操作 。
可能的值 :
`1` - STOP_ON_FAILURE

`2` -ALLOW_FAILURE | | 25038 | OrderRateLimitExceededMode | INT | N | 用于定义: 如果超过未成交订单计数,将会如何处理取消请求。
可能的值 :
`1` - DO_NOTHING

`2` - CANCEL_ONLY | | 37 | OrderID | INT | N | 来自于取消订单的 `OrderID`。 | | 25034 | CancelClOrdID | STRING | N | 待取消的 `ClOrdID`。 | | 41 | OrigClOrdID | STRING | N | 来自待取消订单的 `ClOrdID`。 | | 11 | ClOrdID | STRING | Y | 用于分配给新订单的 `ClOrdID`。 | | 25002 | CancelRestrictions | INT | N | 取消的限制。可能值 :

`1` - ONLY_NEW

`2` - ONLY_PARTIALLY_FILLED | | 38 | OrderQty | QTY | N | 新订单的数量 | | 40 | OrdType | CHAR | Y | 请参阅 [表格](#ordertype)以了解支持的订单类型以及相关的必填字段 。

可能的值 :

`1` - MARKET

`2` - LIMIT

`3` - STOP

`4` - STOP_LIMIT

`P` - PEGGED | | 18 | ExecInst | CHAR | N | 可能的值:

`6` - PARTICIPATE_DONT_INITIATE | | 44 | Price | PRICE | N | 新订单的价格 | | 54 | Side | CHAR | Y | 订单方向。

可能的值:

`1` - BUY

`2` - SELL | | 55 | Symbol | STRING | Y | 取消并下新订单所用的交易对。 | | 59 | TimeInForce | CHAR | N | 可能的值 :

`1` - GOOD_TILL_CANCEL

`3` - IMMEDIATE_OR_CANCEL

`4` - FILL_OR_KILL | | 111 | MaxFloor | QTY | N | 用于冰山订单,用于定义订单在 orderbook 上的可见数量。 | | 152 | CashOrderQty | QTY | N | 用于反向市价单,用于定义 quote asset 单位中的订单数量。 | | 847 | TargetStrategy | INT | N | 该值不能小于 `1000000`。 | | 7940 | StrategyID | INT | N | | | 25001 | SelfTradePreventionMode | CHAR | N | 可能的值:

`1` - NONE

`2` - EXPIRE_TAKER

`3` - EXPIRE_MAKER

`4` - EXPIRE_BOTH

`5` - DECREMENT
`6` - TRANSFER | | 211 | PegOffsetValue | FLOAT | N | 使用了 `PegOffsetType` 后,添加到挂钩的偏移值 | | 1094 | PegPriceType | CHAR | N | 定义了挂钩价格的类型
可能的值:
`4` - MARKET_PEG
`5` - PRIMARY_PEG | | 835 | PegMoveType | CHAR | N | 描述挂钩是固定的还是浮动的。挂钩订单必用且必须为 `1` (FIXED) | | 836 | PegOffsetType | CHAR | N | 定义了挂钩价格偏移类型。
可能的值:

`3` - PRICE_TIER | | 1100 | TriggerType | CHAR | N | 可能的值: `4` - PRICE_MOVEMENT | | 1101 | TriggerAction | CHAR | N | 可能的值:

`1` - ACTIVATE | | 1102 | TriggerPrice | PRICE | N | 止盈止损订单的激活价格。参见 [表格](#ordertype) | | 1107 | TriggerPriceType | CHAR | N | 可能的值

`2` - LAST_TRADE | | 1109 | TriggerPriceDirection | CHAR | N | 用于区分止损订单和止盈订单。参考 [表格](#ordertype) .

可能的值 :

`U` - TRIGGER_IF_THE_PRICE_OF_THE_SPECIFIED_TYPE_GOES_UP_TO_OR_THROUGH_THE_SPECIFIED_TRIGGER_PRICE

`D` -TRIGGER_IF_THE_PRICE_OF_THE_SPECIFIED_TYPE_GOES_DOWN_TO_OR_THROUGH_THE_SPECIFIED_TRIGGER_PRICE | | 25009 | TriggerTrailingDeltaBips | INT | N | 用以创建追踪订单。 | **示例消息:** ``` 8=FIX.4.4|9=160|35=XCN|34=2|49=JS8iiXK6|52=20240613-02:31:53.753|56=SPOT|11=1718245913721036458|37=8|38=5|40=2|44=4|54=1|55=LTCBNB|59=1|111=1|25033=1|25034=1718245913721036819|10=229| ``` **响应:** - 对于每个被取消的订单,[ExecutionReport`<8>`](#executionreport) 的 `ExecType (150)` 值为 `CANCELED (4)`。 - 对于新订单,[ExecutionReport`<8>`](#executionreport) 的 `ExecType (150)` 值为 `NEW (0)`。 - 如果新订单被拒绝,[ExecutionReport`<8>`](#executionreport) 的 `ExecType (150)` 值为 `REJECTED (8)`。 - 如果取消订单的请求被拒绝,则为 [OrderCancelReject`<9>`](#ordercancelreject)。 - 如果消息被拒绝,则为 [Reject`<3>`](#reject)。 #### OrderMassCancelRequest<q> 由客户端发送,用以取消交易品种上的所有挂单。 > [!NOTE] 该账户的所有订单都将被取消,包括从不同连接中下的订单。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | --- | --------------------- | ------ | -------- | ---------------------------------------------- | | 11 | ClOrdID | STRING | Y | 此批量取消请求的`ClOrdId`。 | | 55 | Symbol | STRING | Y | 取消订单的交易对。 | | 530 | MassCancelRequestType | CHAR | Y | 可能的值:

`1` - CANCEL_SYMBOL_ORDERS | **示例消息:** ``` 8=FIX.4.4|9=95|35=q|34=2|49=dpYPesqv|52=20240613-01:24:36.948|56=SPOT|11=1718241876901971671|55=BTCUSDT|530=1|10=243| ``` **响应:** - 对于每个被取消的订单,[ExecutionReport`<8>`](#executionreport) 的 `ExecType (150)` 值为 `CANCELED (4)`。 - 对于请求是否被接受或者拒绝,请参考 [OrderMassCancelReport``](#ordermasscancelreport) 的字段 `MassCancelResponse (531)`。 - 如果消息被拒绝,则为 [Reject`<3>`](#reject)。 由服务器发送,用以响应 [OrderMassCancelRequest``](#ordermasscancelrequest)。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | ----- | ---------------------- | ------ | -------- | --------------------------------------------------------------------------------------- | | 55 | Symbol | STRING | Y | 取消请求中的 `Symbol (55)` 。 | | 11 | ClOrdID | STRING | Y | 取消请求中的 `ClOrdID (11)`。 | | 530 | MassCancelRequestType | CHAR | Y | 取消请求中的 `MassCancelRequestType (530)`。 | | 531 | MassCancelResponse | CHAR | Y | 可能的值:

`0` - CANCEL_REQUEST_REJECTED

`1` - CANCEL_SYMBOL_ORDERS | | 532 | MassCancelRejectReason | INT | N | 可能的值:

`99` - OTHER | | 533 | TotalAffectedOrders | INT | N | 取消了多少订单。 | | 25016 | ErrorCode | INT | N | API 错误代码 (参考 [错误代码](errors.md)). | | 58 | Text | STRING | N | 可读的错误消息。 | **示例消息:** ``` 8=FIX.4.4|9=109|35=r|34=2|49=SPOT|52=20240613-01:24:36.949763|56=dpYPesqv|11=1718241876901971671|55=LTCBNB|530=1|531=1|533=5|10=083| ``` #### NewOrderList<E> 由客户发送,用以提交需要执行的订单列表。 - `OTO` 或 `OTO` 订单将**2 个订单**添加到 `EXCHANGE_MAX_NUM_ORDERS` 过滤器和 `MAX_NUM_ORDERS` 过滤器中。 - `OTOCO` 在 `EXCHANGE_MAX_NUM_ORDERS` 过滤器和 `MAX_NUM_ORDERS` 过滤器的基础上添加**3个订单**。 **未成交的订单计数:** - OCO: 2 - OTO: 2 - OTOCO: 3 订单列表中的订单是相互依赖的。欲了解支持的订单类型和触发说明,请参考[支持的订单列表类型](#order-list-types)。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | -------- | ---------------------------- | ---------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 25014 | ClListID | STRING | Y | `ClListID`,用于分配给订单列表。 | | 1385 | ContingencyType | INT | N | 可能的值 :

`1` -ONE_CANCELS_THE_OTHER

`2` - ONE_TRIGGERS_THE_OTHER | | 25046 | OPO | BOOLEAN | N | 设置为 `true` 时,将此订单列表设为 [OPO](./faqs/opo.md)。 | | 73 | NoOrders | NUMINGROUP | N | `Orders` 数组中的元素个数。只允许输入2或者3。 | | =>11 | ClOrdID | STRING | Y | 用于分配给订单的`ClOrdID` | | =>38 | OrderQty | QTY | N | 订单数量 | | =>40 | OrdType | CHAR | Y | 请参阅 [表格](#ordertype) 以了解支持的订单类型及相关的必填字段 。

可能的值 :

`1` - MARKET

`2` - LIMIT

`3` - STOP

`4` - STOP_LIMIT

`P` - PEGGED | | =>18 | ExecInst | CHAR | N | 可能的值:

`6` - PARTICIPATE_DONT_INITIATE | | =>44 | Price | PRICE | N | 订单价格 | | =>54 | Side | CHAR | Y | 订单的方向。 可能的值 :

`1` - BUY

`2` - SELL | | =>55 | Symbol | STRING | Y | 订单的交易对。 | | =>59 | TimeInForce | CHAR | N | 可能的值 :

`1` - GOOD_TILL_CANCEL

`3` - IMMEDIATE_OR_CANCEL

`4` - FILL_OR_KILL | | =>111 | MaxFloor | QTY | N | 用于冰山订单,这指定了订单在 order book上的可见数量。 | | =>152 | CashOrderQty | QTY | N | 对于反向市场订单,在报价资产单位中指定的订单数量。 | | =>847 | TargetStrategy | INT | N | 该值不能小于 `1000000`。 | | =>7940 | StrategyID | INT | N | | | =>25001 | SelfTradePreventionMode | CHAR | N | 可能的值:

`1` - NONE

`2` - EXPIRE_TAKER

`3` - EXPIRE_MAKER

`4` - EXPIRE_BOTH

`5` - DECREMENT
`6` - TRANSFER | | =>211 | PegOffsetValue | FLOAT | N | 使用了 `PegOffsetType` 后,添加到挂钩的偏移值 | | =>1094 | PegPriceType | CHAR | N | 定义了挂钩价格的类型
可能的值:
`4` - MARKET_PEG
`5` - PRIMARY_PEG | | =>835 | PegMoveType | CHAR | N | 描述挂钩是固定的还是浮动的。挂钩订单必用且必须为 `1` (FIXED) | | =>836 | PegOffsetType | CHAR | N | 定义了挂钩价格偏移类型。
可能的值:

`3` - PRICE_TIER | | =>1100 | TriggerType | CHAR | N | 可能的值:

`4` - PRICE_MOVEMENT | | =>1101 | TriggerAction | CHAR | N | 可能的值:

`1` - ACTIVATE | | =>1102 | TriggerPrice | PRICE | N | 止盈止损订单的激活价格。参见 [表格](#ordertype) | | =>1107 | TriggerPriceType | CHAR | N | 可能的值:

`2` - LAST_TRADE | | =>1109 | TriggerPriceDirection | CHAR | N | 用于区分止损订单和止盈订单。 参见 [表格](#ordertype).

可能的值:

`U` - TRIGGER_IF_THE_PRICE_OF_THE_SPECIFIED_TYPE_GOES_UP_TO_OR_THROUGH_THE_SPECIFIED_TRIGGER_PRICE

`D` - TRIGGER_IF_THE_PRICE_OF_THE_SPECIFIED_TYPE_GOES_DOWN_TO_OR_THROUGH_THE_SPECIFIED_TRIGGER_PRICE | | =>25009 | TriggerTrailingDeltaBips | INT | N | 用于追踪订单。 | | =>25010 | NoListTriggeringInstructions | NUMINGROUP | N | `ListTriggeringInstructions` 数组中的元素个数。 | | ==>25011 | ListTriggerType | CHAR | N | 为了触发 pending order, working order 所需进行的操作。

可能的值:

`1` - ACTIVATED

`2` - PARTIALLY_FILLED

`3` - FILLED | | ==>25012 | ListTriggerTriggerIndex | INT | N | 条件单的触发 Index:0-indexed。 | | ==>25013 | ListTriggerAction | CHAR | N | 在满足 ListTriggerType 条件后对此订单执行的操作。

可能的值:

`1` - RELEASE

`2` - CANCEL | **示例消息:** ``` 8=FIX.4.4|9=236|35=E|34=2|49=Eg13pOvN|52=20240607-02:19:07.836|56=SPOT|73=2|11=w1717726747805308656|55=LTCBNB|54=2|38=1|40=2|44=0.25|59=1|11=p1717726747805308656|55=LTCBNB|54=2|38=1|40=1|25010=1|25011=3|25012=0|25013=1|1385=2|25014=1717726747805308656|10=171| ``` #### 支持的订单列表类型 > [!NOTE] 订单必须按照下表中 _订单名称_ 中指定的顺序排列。 | 订单列表名称 | 应急类型(1385) | 订单名称 | 订单方 | 允许的币安订单类型 | 列出触发指令 | | ------------ | ---------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | OCO | `1` | 1. below order



2. above order | 1. below order=`SELL`



2. above order=`SELL` | 1. below order=`STOP_LOSS` 或 `STOP_LOSS_LIMIT`



2. above order=`LIMIT_MAKER` | 1. below order:

25010=1|25011=2|25012=1|25013=2|



2. above order:

25010=1|25011=1|25012=0|25013=2| | | OCO | `1` | 1. below order



2. above order | 1. below order=`BUY`



2. above order=`BUY` | 1. below order=`LIMIT_MAKER`



2. above order=`STOP_LOSS` 或 `STOP_LOSS_LIMIT` | 1. below order:

25010=1|25011=1|25012=1|25013=2|



2. above order:

25010=1|25011=2|25012=0|25013=2| | | OCO | `1` | 1. below order



2. above order | 1. below order=`SELL`



2. above order=`SELL` | 1. below order=`STOP_LOSS` 或 `STOP_LOSS_LIMIT`



2. above order= `TAKE_PROFIT` | 1. below order:

25010=1|25011=1|25012=1|25013=2|



2. above order:

25010=1|25011=1|25012=0|25013=2| | | OCO | `1` | 1. below order



2. above order | 1. below order=`BUY`



2. above order=`BUY` | 1. below order=`TAKE_PROFIT`



2. above order = `STOP_LOSS` 或 `STOP_LOSS_LIMIT` | 1. below order:

25010=1|25011=1|25012=1|25013=2|



2. above order:

25010=1|25011=1|25012=0|25013=2| | | OTO | `2` | 1. working order



2. pending order | 1. working order=`SELL` 或 `BUY`



2. pending order=`SELL` 或 `BUY` | 1. working order=`LIMIT` 或 `LIMIT_MAKER`



2. pending order=ANY | 1. working order:

NONE



2. pending order:

25010=1|25011=3|25012=0|25013=1| | | OTOCO | `2` | 1. working order



2. pending below order



3. pending above order | 1. working order=`SELL` 或 `BUY`



2. pending below order=`SELL`



3. pending above order=`SELL` | 1. working order=`LIMIT` 或 `LIMIT_MAKER`



2. pending below order=`STOP_LOSS` 或 `STOP_LOSS_LIMIT`



3. pending above order=`LIMIT_MAKER` | 1. working order:

NONE



2. pending below order:

25010=2|25011=3|25012=0|25013=2|25011=2|25012=2|25013=2|



3. pending above order:

25010=2|25011=3|25012=0|25013=2|25011=1|25012=1|25013=2| | | OTOCO | `2` | 1. working order



2. pending below order



3. pending above order | 1. working order=`SELL` 或 `BUY`



2. pending below order=`BUY`



3. pending above order=`BUY` | 1. working order=`LIMIT` 或 `LIMIT_MAKER`



2. pending below order=`LIMIT_MAKER`



3. pending above order=`STOP_LOSS` 或 `STOP_LOSS_LIMIT` | 1. working order:

NONE



2. pending below order:

25010=2|25011=3|25012=0|25013=2|25011=1|25012=2|25013=2|



3. pending above order:

25010=2|25011=3|25012=0|25013=2|25011=2|25012=1|25013=2| | | OTOCO | `2` | 1. working order



2. pending below order



3. pending above order | 1. working order=`SELL` 或 `BUY`



2. pending below order=`SELL`



3. pending above order=`SELL` | 1. working order=`LIMIT` 或 `LIMIT_MAKER`



2. pending below order=`STOP_LOSS` 或 `STOP_LOSS_LIMIT`



3. pending above order=`TAKE_PROFIT` | 1. working order:

NONE



2. pending below order:

25010=2|25011=3|25012=0|25013=2|25011=1|25012=2|25013=2|



3. pending above order:

25010=2|25011=3|25012=0|25013=2|25011=1|25012=1|25013=2| | | OTOCO | `2` | 1. working order



2. pending below order



3. pending above order | 1. working order=`SELL` 或 `BUY`



2. pending below order=`BUY`



3. pending above order=`BUY` | 1. working order=`LIMIT` 或 `LIMIT_MAKER`



2. pending below order=`TAKE_PROFIT`



3. pending above order=`STOP_LOSS` 或 `STOP_LOSS_LIMIT` | 1. working order:

NONE



2. pending below order:

25010=2|25011=3|25012=0|25013=2|25011=1|25012=2|25013=2|



3. pending above order:

25010=2|25011=3|25012=0|25013=2|25011=1|25012=1|25013=2| | | OPO | `2` | 1. working order



2. pending order | 1. working order=`BUY`



2. pending order=`SELL` | 1. working order=`LIMIT` or `LIMIT_MAKER`



2. pending order=ANY | 1. working order:

NONE



2. pending order:

25010=1|25011=3|25012=0|25013=1| | | OPOCO | `2` | 1. working order



2. pending below order



3. pending above order | 1. working order=`BUY`



2. pending below order=`SELL`



3. pending above order=`SELL` | 1. working order=`LIMIT` or `LIMIT_MAKER`



2. pending below order=`STOP_LOSS` or `STOP_LOSS_LIMIT`



3. pending above order=`LIMIT_MAKER` | 1. working order:

NONE



2. pending below order:

25010=2|25011=3|25012=0|25013=2|25011=2|25012=2|25013=2|



3. pending above order:

25010=2|25011=3|25012=0|25013=2|25011=1|25012=1|25013=2| | | OPOCO | `2` | 1. working order



2. pending below order



3. pending above order | 1. working order=`BUY`

2. pending below order=`SELL`



3. pending above order=`SELL` | 1. working order=`LIMIT` or `LIMIT_MAKER`



2. pending below order=`STOP_LOSS` or `STOP_LOSS_LIMIT`



3. pending above order=`TAKE_PROFIT` or `TAKE_PROFIT_LIMIT` | 1. working order:

NONE



2. pending below order:

25010=2|25011=3|25012=0|25013=2|25011=1|25012=2|25013=2|



3. pending above order:

25010=2|25011=3|25012=0|25013=2|25011=1|25012=1|25013=2| | #### ListStatus<N> 每当订单列表状态发生变化时,由服务器发送的消息。 > [!NOTE] 默认情况下,ListStatus`` > 会含有该账户的所有订单列表,包括在不同连接中提交的订单列表。请参阅 [响应模式](#responsemode) > 来了解其他行为选项。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | -------- | ---------------------------- | ------------ | -------- | ----------------------------------------------------------------------------------------------------------------- | | 55 | Symbol | STRING | N | 订单列表的交易对。 | | 66 | ListID | STRING | N | 由交易所分配的订单列表 `ListID`。 | | 25014 | ClListID | STRING | N | 分配给请求的订单列表 `ClListID` 。 | | 25015 | OrigClListID | STRING | N | | | 1385 | ContingencyType | INT | N | 可能的值:

`1` - ONE_CANCELS_THE_OTHER

`2` - ONE_TRIGGERS_THE_OTHER | | 429 | ListStatusType | INT | Y | 可能的值:

`2` - RESPONSE

`4` - EXEC_STARTED

`5` - ALL_DONE

`100` - UPDATED | | 431 | ListOrderStatus | INT | Y | 可能的值:

`3` - EXECUTING

`6` - ALL_DONE

`7` - REJECT | | 1386 | ListRejectReason | INT | N | 可能的值:

`99` - OTHER | | 103 | OrdRejReason | INT | N | 可能的值:

`99` - OTHER | | 60 | TransactTime | UTCTIMESTAMP | N | 发生此事件时的时间戳。 | | 25016 | ErrorCode | INT | N | API 错误代码 (参考 [错误代码](errors.md) )。 | | 58 | Text | STRING | N | 可读的错误消息。 | | 73 | NoOrders | NUMINGROUP | N | `Orders` 数组中的元素个数。 | | =>55 | Symbol | STRING | Y | 订单的交易对。 | | =>37 | OrderID | INT | Y | 由交易所分配的订单 `OrderID`。 | | =>11 | ClOrdID | STRING | Y | 分配给请求的订单 `ClOrdID`。 | | =>25010 | NoListTriggeringInstructions | NUMINGROUP | N | `ListTriggeringInstructions` 数组中的元素个数。 | | ==>25011 | ListTriggerType | CHAR | N | 可能的值:

`1` - ACTIVATED

`2` - PARTIALLY_FILLED

`3` - FILLED | | ==>25012 | ListTriggerTriggerIndex | INT | N | | | ==>25013 | ListTriggerAction | CHAR | N | 可能的值

`1` - RELEASE

`2` - CANCEL | **示例消息:** ``` 8=FIX.4.4|9=293|35=N|34=2|49=SPOT|52=20240607-02:19:07.837191|56=Eg13pOvN|55=BTCUSDT|60=20240607-02:19:07.836000|66=25|73=2|55=BTCUSDT|37=52|11=w1717726747805308656|55=BTCUSDT|37=53|11=p1717726747805308656|25010=1|25011=3|25012=0|25013=1|429=4|431=3|1385=2|25014=1717726747805308656|25015=1717726747805308656|10=162| ``` #### OrderAmendKeepPriorityRequest<XAK> 由客户发送以减少其订单的原始数量。 这个请求将添加0个订单到 `EXCHANGE_MAX_ORDERS` 过滤器和 `MAX_NUM_ORDERS` 过滤器中。 **未成交的订单计数:** 0 **注意:** - `ClOrdID(11)` 不需要与原订单的 `ClOrdID` 不同。当请求的 `ClOrdID` 与待修改订单的 `ClOrdID` 相同时,`ClOrdID` 将保持不变。 - 当同时提供 `OrderID (37)` 和 `OrigClOrdID (41)` 两个参数时,系统首先将会使用 `OrderID` 来搜索订单。然后, 查找结果中的 `OrigClOrdID (41)` 的值将会被用来验证订单。如果两个条件都不满足,则请求将被拒绝。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | :-- | :---------- | :----- | :------- | --------------------------------------------------------------------------- | | 11 | ClOrdID | STRING | Y | 分配给请求的订单 `ClOrdID`。 | | 41 | OrigClOrdID | STRING | N | 待修改订单的 `ClOrdID (11)`。 需提供 `OrigClOrdID (41)` 或 `OrderId (37)`。 | | 37 | OrderID | INT | N | 待修改订单的 `OrderID (37)`。 需提供 `OrigClOrdID (41)` 或 `OrderId (37)`。 | | 55 | Symbol | STRING | Y | 待修改订单的交易对。 | | 38 | OrderQty | QTY | N | 交易的新数量。 必须比订单的原始 OrderQty 小。 | **示例消息:** ``` 8=FIX.4.4|9=103|35=XAK|34=2|49=EXAMPLE|52=20250319-12:35:21.087|56=SPOT|11=O2EIAS01742387721086|37=0|38=0.9|55=BTCUSDT|10=254| ``` **响应:** - [Reject `<3>`](#reject) 请求会由于缺少必填字段,无效字段,引用无效的符号,或超过消息限制而成为无效请求。 - [OrderAmendReject ``](#orderamendreject) 如果请求失败,则由于订单速率限制不足,指向不存在的订单,数量无效等。 - [ExecutionReport `<8>`](#executionreport) 请求成功修改了单个订单。 - [ExecutionReport `<8>`](#executionreport) \+ [ListStatus ``](#liststatus) 请求成功修改了隶属于订单列表中的单个订单。 ### OrderAmendReject<XAR> 当 OrderAmendKeepPriorityRequest `` 请求失败时,由服务器发送。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | :---- | :---------- | :----- | :------- | :------------------------------------------- | | 11 | ClOrdID | STRING | Y | 待修改订单的 `ClOrdId`。 | | 41 | OrigClOrdID | STRING | N | 待修改订单的 `OrigClOrdId (41)`。 | | 37 | OrderID | INT | N | 待修改订单的 `OrderId (37)`。 | | 55 | Symbol | STRING | Y | 待修改订单的 `Symbol (55)`。 | | 38 | OrderQty | QTY | Y | | | 25016 | ErrorCode | INT | Y | API 错误代码 (参考 [错误代码](errors.md) )。 | | 58 | Text | STRING | Y | 人类可读的错误消息。 | **示例消息:** ``` 8=FIX.4.4|9=0000176|35=XAR|49=SPOT|56=OE|34=2|52=20250319-14:27:32.751074|11=1WRGW5J1742394452749|37=0|55=BTCUSDT|38=1.000000|25016=-2038|58=The requested action would change no state; rejecting.|10=235| ``` ### Limit Messages #### LimitQuery<XLQ> 由客户端发送,用于查询当前限制。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | ---- | ----- | ------ | -------- | ----------- | | 6136 | ReqID | STRING | Y | 此请求的 ID | **示例消息:** ``` 8=FIX.4.4|9=82|35=XLQ|34=2|49=7buKHZxZ|52=20240614-05:35:35.357|56=SPOT|6136=1718343335357229749|10=170| ``` #### LimitResponse<XLR> 由服务器发送,以响应 [LimitQuery``](#limitquery) 请求。 | Tag | 名称 | 类型 | 是否必须 | 描述 | | ------- | ---------------------------- | ---------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- | | 6136 | ReqID | STRING | Y | `ReqID`。 | | 25003 | NoLimitIndicators | NUMINGROUP | Y | `LimitIndicator` 数组中的元素个数。 | | =>25004 | LimitType | CHAR | Y | 可能的值

`1` - ORDER_LIMIT

`2` - MESSAGE_LIMIT | | =>25005 | LimitCount | INT | Y | 此限制的当前使用情况。 | | =>25006 | LimitMax | INT | Y | 此限制允许的最大值。 | | =>25007 | LimitResetInterval | INT | N | 限制重置的频率。 | | =>25008 | LimitResetIntervalResolution | CHAR | N | `LimitResetInterval` 的时间单位。可能的值:

`s` - SECOND

`m` - MINUTE

`h` - HOUR

`d` - DAY | **示例消息:** ``` 8=FIX.4.4|9=225|35=XLR|34=2|49=SPOT|52=20240614-05:42:42.724057|56=uGnG0ef8|6136=1718343762723730315|25003=3|25004=2|25005=1|25006=1000|25007=10|25008=s|25004=1|25005=0|25006=200|25007=10|25008=s|25004=1|25005=0|25006=200000|25007=1|25008=d|10=241| ``` ### 市场数据流 > [!NOTE] 以下消息只能用于 FIX 市场数据流。 #### InstrumentListRequest<x> 由客户端发送,用于查询有关交易对的信息。 | Tag | Name | Type | Required | Description | | --- | ------------------------- | ------ | -------- | ---------------------------------------------------------------------------- | | 320 | InstrumentReqID | STRING | Y | 此请求的 ID | | 559 | InstrumentListRequestType | INT | Y | 可能的值:

`0` - SINGLE_INSTRUMENT

`4` - ALL_INSTRUMENTS | | 55 | Symbol | STRING | N | 当 `InstrumentListRequestType` 设置为 `SINGLE_INSTRUMENT (0)` 时是必需的 | **示例消息:** ``` 8=FIX.4.4|9=92|35=x|49=BMDWATCH|56=SPOT|34=2|52=20250114-08:46:56.096691|320=BTCUSDT_INFO|559=0|55=BTCUSDT|10=164| ``` #### InstrumentList<y> 由服务器在响应 [InstrumentListRequest``](#instrumentlistrequest) 时发送。 > [!NOTE] 有关交易对(例如,过滤器)的其他信息可通过 > [exchangeInfo]/products/spot/rest-api.md#exchangeInfo)请求来获得。 | Tag | Name | Type | Required | Description | | ------- | --------------------- | ---------- | -------- | ----------------------------------------------------------- | | 320 | InstrumentReqID | STRING | Y | `InstrumentReqID` 从请求中得到 | | 146 | NoRelatedSym | NUMINGROUP | Y | 交易数量 | | =>55 | Symbol | STRING | Y | 交易对 | | =>15 | Currency | STRING | Y | 此交易品种的报价资产 | | 146 | NoRelatedSym | NUMINGROUP | Y | 交易品种数量 | | =>55 | Symbol | STRING | Y | | | =>15 | Currency | STRING | Y | 此交易品种的 Quote asset | | =>562 | MinTradeVol | QTY | N | 对应于 [LOT_SIZE](filters.md#lot_size) 过滤器 | | =>1140 | MaxTradeVol | QTY | N | 对应于 [LOT_SIZE](filters.md#lot_size) 过滤器 | | =>25039 | MinQtyIncrement | QTY | N | 对应于 [LOT_SIZE](filters.md#lot_size) 过滤器 | | =>25040 | MarketMinTradeVol | QTY | N | 对应于 [MARKET_LOT_SIZE](filters.md#market_lot_size) 过滤器 | | =>25041 | MarketMaxTradeVol | QTY | N | 对应于 [MARKET_LOT_SIZE](filters.md#market_lot_size) 过滤器 | | =>25042 | MarketMinQtyIncrement | QTY | N | 对应于 [MARKET_LOT_SIZE](filters.md#market_lot_size) 过滤器 | | =>969 | MinPriceIncrement | PRICE | N | 对应于 [PRICE](filters.md#price) 过滤器 | | =>2551 | StartPriceRange | PRICE | N | 对应于 [PRICE](filters.md#price) 过滤器 | | =>2552 | EndPriceRange | PRICE | N | 对应于 [PRICE](filters.md#price) 过滤器 | **示例消息:** ``` 8=FIX.4.4|9=218|35=y|49=SPOT|56=BMDWATCH|34=2|52=20250114-08:46:56.100147|320=BTCUSDT_INFO|146=1|55=BTCUSDT|15=USDT|562=0.00001000|1140=9000.00000000|25039=0.00001000|25040=0.00000001|25041=76.79001236|25042=0.00000001|969=0.01000000|10=093|| ``` #### MarketDataRequest<V> 由客户发送,用于订阅或取消订阅市场数据流。 **交易数据流** 交易数据流推送原始交易信息;每笔交易都有唯一的买家和卖家。 **订阅所需的字段:** - `SubscriptionRequestType` 的值为 `SUBSCRIBE(1)` - `MDEntryType` 的值为 `TRADE(2)` **更新速度:** 实时 **book ticker数据流** 将指定交易对最佳买价,卖价以及数量的更新进行实时推送。 **订阅所需的字段** - `SubscriptionRequestType` 值为 `SUBSCRIBE(1)` - `MDEntryType` 值为 `BID (0)` - `MDEntryType` 值为 `OFFER(1)` - `MarketDepth` 值为 `1` \ **Individual Symbol Book Ticker Stream** 将指定交易品种的任何更新实时推送到最佳买价或卖价或数量。 **订阅所需的字段** - 值为 `SUBSCRIBE(1)` 的 `SubscriptionRequestType` - 值为 `BID (0)` 的 `MDEntryType` - 值为 `OFFER(1)` 的 `MDEntryType` - 值为 `1` 的 `MarketDepth` **更新速度:** 实时 > [!NOTE] 在 [单个交易对订单簿数据流](#symbolbooktickerstream) > 中,在[MarketDataIncrementalRefresh``](#marketdataincrementalrefresh) 消息里 `MDUpdateAction` > 取代了之前的 Best Quote, **增量深度数据流** 用于本地订单簿管理的价格和数量深度更新。 **订阅所需的字段** - `SubscriptionRequestType` 值为 `SUBSCRIBE(1)` - `MDEntryType` 值为 `BID (0)` - `MDEntryType` 值为 `OFFER (1)` - `MarketDepth` 值介于 `2` 和 `5000` 之间,用于控制初始快照的大小,对后续的 [MarketDataIncrementalRefresh `` ](#marketdataincrementalrefresh) 消息没有影响 **更新速度:** 100 毫秒 > [!NOTE] 由于 [MarketDataSnapshot``](#marketdatasnapshot) > 对价格的深度有限制,所在初始快照之外没有数量变化的价格不会在增量深度信息数据流中。

因此,即使更新所有推送的数据流信息,依然会导致本地订单簿与真实订单簿有些微差异。

对于大多数情况,5000 的深度限制就足以理解市场和进行有效的交易。 | Tag | Name | Type | Required | Description | | :---- | ----------------------- | ---------- | -------- | ------------------------------------------------------------------------------------------------ | | 262 | MDReqID | STRING | Y | 此请求的 ID | | 263 | SubscriptionRequestType | CHAR | Y | 订阅请求类型。 可能的值:

`1` - SUBSCRIBE

`2` - UNSUBSCRIBE | | 264 | MarketDepth | INT | N | 订阅深度。

可能的值:

`1` - Book Ticker 订阅

`2`-`5000` - 增量深度流 | | 266 | AggregatedBook | NUMINGROUP | N | 可能的值:

`Y` - 每个价格每侧 1 个帐簿条目 | | 146 | NoRelatedSym | NUMINGROUP | N | 交易对数量 | | =>55 | Symbol | STRING | Y | | | 267 | NoMDEntryTypes | NUMINGROUP | N | 条目类型数量 | | =>269 | MDEntryType | CHAR | Y | 可使用的值:

`0` - BID

`1` - OFFER

`2` - TRADE | **示例消息:** ``` # Subscriptions # BOOK TICKER Stream 8=FIX.4.4|9=132|35=V|49=TRADER1|56=SPOT|34=4|52=20241122-06:17:14.183428|262=BOOK_TICKER_STREAM|263=1|264=1|266=Y|146=1|55=BTCUSDT|267=2|269=0|269=1|10=010| # DEPTH Stream 8=FIX.4.4|9=127|35=V|49=TRADER1|56=SPOT|34=7|52=20241122-06:17:14.443822|262=DEPTH_STREAM|263=1|264=10|266=Y|146=1|55=BTCUSDT|267=2|269=0|269=1|10=111| # TRADE Stream 8=FIX.4.4|9=120|35=V|49=TRADER1|56=SPOT|34=3|52=20241122-06:34:14.775606|262=TRADE_STREAM|263=1|264=1|266=Y|146=1|55=BTCUSDT|267=1|269=2|10=040| # Unsubscription from TRADE Stream 8=FIX.4.4|9=79|35=V|49=TRADER1|56=SPOT|34=7|52=20241122-06:41:56.966969|262=TRADE_STREAM|263=2|264=1|10=113| ``` ### MarketDataRequestReject<Y> 服务器对不正确的 MarketDataRequest 的响应消息 ``. | Tag | Name | Type | Required | Description | | ----- | -------------- | ------ | -------- | ---------------------------------------------------------------------------------------- | | 262 | MDReqID | STRING | Y | 不正确的ID [MarketDataRequest``](#marketdatarequest) | | 281 | MDReqRejReason | CHAR | N | 可能的错误原因:

`1` - DUPLICATE_MDREQID

`2` - TOO_MANY_SUBSCRIPTIONS | | 25016 | ErrorCode | INT | N | API 错误代码 [参见 错误代码](errors.md)。 | | 58 | Text | STRING | N | 错误信息。 | **示例消息:** ``` 8=FIX.4.4|9=0000218|35=Y|49=SPOT|56=EXAMPLE|34=5|52=20241019-05:39:36.688964|262=BOOK_TICKER_2|281=2|25016=-1191|58=Similar subscription is already active on this connection. Symbol='BNBBUSD', active subscription id: 'BOOK_TICKER_1'.|10=137| ``` ### MarketDataSnapshot<W> 服务器对 [MarketDataRequest``](#marketdatarequest),激活 [单个 Symbol Book Ticker Stream](#symbolbooktickerstream) 或 [增量深度流](#diffdepthstream) 订阅的响应消息。 | Tag | Name | Type | Required | Description | | ----- | ---------------- | ---------- | -------- | -------------------------------------------------------------------------- | | 262 | MDReqID | STRING | Y | 激活此订阅的 [MarketDataRequest``](#marketdatarequest) 的 ID | | 55 | Symbol | STRING | Y | | | 25044 | LastBookUpdateID | INT | N | | | 268 | NoMDEntries | NUMINGROUP | Y | 条目数 | | =>269 | MDEntryType | CHAR | Y | 可能的值:

`0` - BID

`1` - OFFER

`2` - TRADE | | =>270 | MDEntryPx | PRICE | Y | 价格 | | =>271 | MDEntrySize | QTY | Y | 数量 | **示例消息:** ``` 8=FIX.4.4|9=0000107|35=W|49=SPOT|56=EXAMPLE|34=34|52=20241019-05:41:52.867164|262=BOOK_TICKER_1_2|55=BNBBUSD|25044=0|268=0|10=151| ``` ### MarketDataIncrementalRefresh<X> 当一个订阅的数据流发生变化时,服务器发出的响应消息。 | Tag | Name | Type | Required | Description | | ------- | ----------------- | ------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 262 | MDReqID | STRING | Y | 激活此订阅的 [MarketDataRequest ``](#marketdatarequest) 的 ID | | 268 | NoMDEntries | NUMINGROUP | Y | 条目数 | | =>279 | MDUpdateAction | CHAR | Y | 可能的值:

`0` - NEW

`1` - CHANGE

`2` - DELETE | | =>270 | MDEntryPx | PRICE | Y | 价格 | | =>271 | MDEntrySize | QTY | N | 数量 | | =>269 | MDEntryType | CHAR | Y | 可能的值:

`0` - BID

`1` - OFFER

`2` - TRADE | | =>55 | Symbol | STRING | N | 如果未指定`交易对`,则默认使用同一市场数据流消息中前一个消息的交易对 | | =>60 | TransactTime | UTCTIMESTAMP | N | | | =>1003 | TradeID | INT | N | | | =>2446 | AggressorSide | CHAR | N | 可能的值:

`1` - BUY

`2` - SELL | | =>25043 | FirstBookUpdateID | INT | N | 只会在 [增量深度数据流](#diffdepthstream) 中出现.

如果 `LastBookUpdateID` 没有指定,市场数据消息的 `FirstBookUpdateID` 将会默认设置为与之前消息一样的 `FirstBookUpdateID` | | =>25044 | LastBookUpdateID | INT | N | 只会在 [增量深度数据流](#diffdepthstream) 和 [单个交易对订单簿数据流](#symbolbooktickerstream) 中出现.

如果 `LastBookUpdateID` 没有指定,市场数据消息的 `LastBookUpdateID` 将会默认设置为与之前消息一样的 `LastBookUpdateID` | **示例消息:** ``` 8=FIX.4.4|9=0000303|35=X|49=SPOT|56=EXAMPLE|34=16|52=20241019-05:40:11.466313|262=TRADE_3|268=3|279=0|269=2|270=10.00000|271=0.01000|55=BNBBUSD|1003=0|60=20241019-05:40:11.464000|279=0|269=2|270=10.00000|271=0.01000|1003=1|60=20241019-05:40:11.464000|279=0|269=2|270=10.00000|271=0.01000|1003=2|60=20241019-05:40:11.464000|10=042| ``` ## FIX SBE FIX SBE(简单二进制编码)可以替代 FIX,请使用 [spot_fix_prod_latest.xml](/products/spot/sbe/schemas/spot_fix_prod_latest.xml) 模式文件。 ### SBE 请阅读 [简单二进制编码 (SBE) 常见问题](./faqs/sbe_faq.md) 了解有关将 SBE 与币安 API 配合使用的重要信息。 - 在使用 FIX SBE 之前,请务必阅读并理解 [SBE 规范](https://www.fixtrading.org/standards/sbe-online/)。 - 在对 SBE payload 进行编码和解码时,建议使用 [`SbeTool`](https://github.com/aeron-io/simple-binary-encoding) 所生成的代码,以确保符合FIX SBE 规范。 ### 端点 除了在 9000 端口支持的 FIX 编码外,还支持两种请求/响应编码方案,分别在额外的 TCP 端口上。以下是各个 API 的端点说明。 #### 订单录入 - `tcp+tls://fix-oe.binance.com:9001`:发送 FIX 请求;接收 FIX SBE 响应 - FIX `SbeSchemaId` 标签(=25050)必须设置为 FIX SBE 模式 ID(例如 1) - FIX `SbeSchemaVersion` 标签(=25051)必须设置为 FIX SBE 模式版本(例如 0) - `tcp+tls://fix-oe.binance.com:9002`:发送 FIX SBE 请求;接收 FIX SBE 响应 #### Drop Copy(订单副本) - `tcp+tls://fix-dc.binance.com:9001`:发送 FIX 请求;接收 FIX SBE 响应 - FIX `SbeSchemaId` 标签(=25050)必须设置为 FIX SBE 模式 ID(例如 1) - FIX `SbeSchemaVersion` 标签(=25051)必须设置为 FIX SBE 模式版本(例如 0) - `tcp+tls://fix-dc.binance.com:9002`:发送 FIX SBE 请求;接收 FIX SBE 响应 #### 市场数据 - `tcp+tls://fix-md.binance.com:9001`:发送 FIX 请求;接收 FIX SBE 响应 - FIX `SbeSchemaId` 标签(=25050)必须设置为 FIX SBE 模式 ID(例如 1) - FIX `SbeSchemaVersion` 标签(=25051)必须设置为 FIX SBE 模式版本(例如 0) - `tcp+tls://fix-md.binance.com:9002`:发送 FIX SBE 请求;接收 FIX SBE 响应 ### FIX SBE 编码设计 FIX SBE 请求/响应 消息总会包含一个 SOFH (Simple Open Framing Header) 和消息头. 一个 N 字节的FIX SBE 消息包含下面的格式: ` <消息头 (20 字节)> <消息 (N 字节)>` SOFH:有关模式文件中的组合类型 "sofh"。这个字段作为一个帧头用来让FIX SBE 服务器端/客户端 来确定 SBE 消息的长度和保证在反序列化之前已经接收到完整的消息。 注意: - SOFH 中的两个字段必须是小端序编码(little-endian) - FIX 服务器仅支持编码类型字段 `0xEB50` , 例如只有小端序(little-endian) 在所有字段被支持 消息头: 这对应于模式文件中的组合类型 "messageHeader". ### Logon 登录签名(RawData)的计算方法如[签名计算](#signaturecomputation)部分所述。 #### FIX SBE `Logon` 请求消息示例 请参阅下方根据上述说明获取的 FIX SBE `Logon` 十六进制消息示例。 | Bytes | Description | | ---------------------------------------------- | -------------------------- | | 0xd1, 0x00, 0x00, 0x00 | sofh.messageLength | | 0x50, 0xeb | sofh.encodingType | | 0x0e, 0x00 | messageHeader.blockLength | | 0x28, 0x4e | messageHeader.templateId | | 0x01, 0x00 | messageHeader.schemaId | | 0x00, 0x00 | messageHeader.version | | 0x01, 0x00, 0x00, 0x00 | messageHeader.seqNum | | 0x58, 0x7a, 0x5f, 0x99, 0xdb, 0x1b, 0x06, 0x00 | messageHeader.sendingTime | | 0x00 | Logon.EncryptMethod | | 0x1e, 0x00, 0x00, 0x00 | Logon.HeartBtInt | | 0x01 | Logon.ResetSeqNumFlag | | 0x02 | Logon.MessageHandling | | 0xff | Logon.ResponseMode | | 0xff | Logon.ExecutionReportType | | 0xff | Logon.DropCopyFlag | | 0xff, 0xff, 0xff, 0xff | Logon.RecvWindow | | 0x07 | Logon.SenderCompId.length | | 0x45, 0x58, 0x41, 0x4d, 0x50, 0x4c, 0x45 | Logon.SenderCompId.varData | | 0x04 | Logon.TargetCompId.length | | 0x53, 0x50, 0x4f, 0x54 | Logon.TargetCompId.varData | | 0x58, 0x00 | Logon.RawData.length | | 0x34, 0x4d, 0x48, 0x58, 0x65, 0x6c, 0x56, 0x56 | Logon.RawData.varData | | 0x63, 0x70, 0x6b, 0x64, 0x77, 0x75, 0x4c, 0x62 | Logon.RawData.varData | | 0x6c, 0x36, 0x6e, 0x37, 0x33, 0x48, 0x51, 0x55 | Logon.RawData.varData | | 0x58, 0x55, 0x66, 0x31, 0x64, 0x73, 0x65, 0x32 | Logon.RawData.varData | | 0x50, 0x43, 0x67, 0x54, 0x31, 0x44, 0x59, 0x71 | Logon.RawData.varData | | 0x57, 0x39, 0x77, 0x38, 0x41, 0x56, 0x5a, 0x31 | Logon.RawData.varData | | 0x52, 0x41, 0x43, 0x46, 0x47, 0x4d, 0x2b, 0x35 | Logon.RawData.varData | | 0x55, 0x64, 0x6c, 0x47, 0x50, 0x72, 0x51, 0x48 | Logon.RawData.varData | | 0x72, 0x67, 0x74, 0x53, 0x33, 0x43, 0x76, 0x73 | Logon.RawData.varData | | 0x52, 0x55, 0x52, 0x43, 0x31, 0x6f, 0x6a, 0x37 | Logon.RawData.varData | | 0x33, 0x6a, 0x38, 0x67, 0x43, 0x41, 0x3d, 0x3d | Logon.RawData.varData | | 0x40, 0x00 | Logon.Username.length | | 0x73, 0x42, 0x52, 0x58, 0x72, 0x4a, 0x78, 0x32 | Logon.Username.varData | | 0x44, 0x73, 0x4f, 0x72, 0x61, 0x4d, 0x58, 0x4f | Logon.Username.varData | | 0x61, 0x55, 0x6f, 0x76, 0x45, 0x68, 0x67, 0x56 | Logon.Username.varData | | 0x52, 0x63, 0x6a, 0x4f, 0x76, 0x43, 0x74, 0x51 | Logon.Username.varData | | 0x77, 0x6e, 0x57, 0x6a, 0x38, 0x56, 0x78, 0x6b | Logon.Username.varData | | 0x4f, 0x68, 0x31, 0x78, 0x71, 0x62, 0x6f, 0x53 | Logon.Username.varData | | 0x30, 0x32, 0x53, 0x50, 0x47, 0x66, 0x4b, 0x69 | Logon.Username.varData | | 0x32, 0x68, 0x38, 0x73, 0x70, 0x5a, 0x4a, 0x62 | Logon.Username.varData | ### FIX 与 FIX SBE 模式对比 通用说明: - `sofh.messageLength` 字段 _必须_ 包含 SOFH 的大小(6 字节) - FIX SBE 没有 `Checksum` 字段 - 在端口 9002 上发送 FIX SBE 请求时 - payload 中必须设置所有字段 - 未设置的可选字段必须设置为相应的 `nullValue` - `SbeTool` 生成的编码器可以正确处理这种情况 - 如果 payload 是手动编码生成的,请参阅 [SBE 规范](https://www.fixtrading.org/standards/sbe-online/) 中有关 `nullValue` 的定义 小数位编码: - 在请求消息中,`PriceExponent` 和 `QtyExponent` 的值不得超过其所处理的交易对精度。交易对的精度可以从 `InstrumentList` 响应中获取。 **Logon(登录)消息:** - `SenderCompID`、`TargetCompID` 和 `RecvWindow` 字段包含在 `Logon` FIX SBE 消息中,而不是消息头 - `Logon` 消息中设置的 `RecvWindow` 字段适用于 FIX SBE 会话内的所有交易请求消息。 - 设置后,`RecvWindow` 字段的单位为微秒。 - 当 `ResponseMode` 字段设置为 `OnlyAcks` 时,`ExecutionReportType` 字段可以设置为 `Mini`,以接收 `ExecutionReportAck` 消息,而非 `ExecutionReport` - 注意:只有订单录入和 Drop Copy(订单副本)接口的 9001 端口和 9002 端口会支持 `ExecutionReportType` 字段 **MarketDataIncrementalRefresh(市场数据增量刷新)** 消息: - FIX 模式中的单条消息被拆分为以下 FIX SBE 消息:`MarketDataIncrementalTrade`、`MarketDataIncrementalBookTicker` 和 `MarketDataIncrementalDepth` - 市场数据快照和刷新消息中省略了 `MDReqID` 字段,因为这些消息可以通过 `Symbol` 字段和消息的模板 ID 与订阅请求关联起来。 - `MDReqID` 在 `MarketDataRequest` 消息中是必需的,以便它可以在 `MarketDataRequestReject` 中使用。 - `MDReqID` 的值在所有订阅中必须是唯一的。 **MarketDataIncrementalTrade(市场数据增量交易)** 消息: - FIX 模式中可用的 `MDUpdateAction` 字段在 FIX SBE 中被省略,因为其值始终为 `NEW`。 **MarketDataIncrementalBookTicker(市场数据增量订单簿数据流)** 消息: - FIX SBE 最优挂单信息订阅使用 **自动剔除(auto-culling)**:当系统负载较高时,可能会丢弃过时的事件,而不是将所有事件排队并延迟发送。 - 例如,如果在时间 T2 生成了一个最优买/卖单报价事件,而此时仍有一个未发送的事件排队在时间 T1(且 T1 < T2),则会丢弃时间 T1 的事件,系统只会发送时间 T2 的事件。此操作是基于每个交易对分别进行的。 - FIX 模式中可用的 `MDUpdateAction` 字段在 FIX SBE 中被省略,因为其值可能源自 `MDEntrySize`。 - 当 `MDEntrySize` 未设置(`NullVal`)时,`MDUpdateAction` 为 `DELETE`。 - 当 `MDEntrySize` 已设置时: - 如果价格水平已存在于本地订单簿中,则 `MDUpdateAction` 为 `CHANGE` - 否则,`MDUpdateAction` 为 `NEW`。 **MarketDataIncrementalDepth(市场数据增量深度)** 消息: - FIX SBE 深度更新速度:25 毫秒 - FIX 模式中可用的 `MDUpdateAction` 字段在 FIX SBE 中被省略,因为其值可能源自 `MDEntrySize`。 - 当 `MDEntrySize` 未设置(`NullVal`)时,`MDUpdateAction` 为 `DELETE`。 - 当 `MDEntrySize` 已设置时: - 如果价格水平已存在于本地订单簿中,则 `MDUpdateAction` 为 `CHANGE` - 否则,`MDUpdateAction` 为 `NEW`。 ### 连接限制 FIX 和 FIX SBE 分享连接限制。 ### 错误代码 可能返回以下 FIX SBE 特定错误代码: | 代码 | 消息 | 描述 | | ----- | ------------------------------- | ------------------------------------------------ | | -1152 | 无效的 SBE 消息头。 | 解码 FIX SBE 请求中的 `messageHeader` 时出错 | | -1153 | 指定的 SBE 模式 ID 或版本无效。 | 解析/解码 FIX SBE 模式 ID/版本时出错 | | -1177 | 无效的编码类型。 | 解码 sofh 复合类型中的 `encodingType` 字段时出错 | | -1221 | SBE 消息中字段无效或缺失。 | 解码 FIX SBE 请求时字段无效或缺失 | 注意:对于语义等效的 FIX 和 FIX SBE 请求,返回的错误代码可能不完全相同。 ### 常见问题 有关生成 SBE 解码器和处理模式更新的更多信息,请参见 [SBE FAQ](./faqs/sbe_faq.md)。 --- ## Document: /products/spot/filters URL: /zh-CN/docs/products/spot/filters # 过滤器 过滤器,即Filter,定义了一系列交易规则。共有三类,分别是针对交易对的过滤器 `symbol filters`,针对整个交易所的过滤器 `exchange filters` 和针对资产的过滤器 `asset filters`。 ## 交易对过滤器 ### PRICE_FILTER 价格过滤器 价格过滤器用于检测order订单中price参数的合法性 - `minPrice` 定义了 `price`/`stopPrice` 允许的最小值; `minPrice` == 0 的时候则失效。 - `maxPrice` 定义了 `price`/`stopPrice` 允许的最大值; `maxPrice` == 0 的时候则失效。 - `tickSize` 定义了 `price`/`stopPrice` 的步进间隔; `tickSize` == 0 的时候则失效。 以上每一项均可为0,为0时代表这一项不再做限制。 订单需满足以下条件,方可通过该过滤器校验: - `price` >= `minPrice` - `price` <= `maxPrice` - `price` % `tickSize` == 0 **/exchangeInfo 响应中的格式:** ```javascript { "filterType": "PRICE_FILTER", "minPrice": "0.00000100", "maxPrice": "100000.00000000", "tickSize": "0.00000100" } ``` ### PERCENT_PRICE 价格振幅过滤器 `PERCENT_PRICE` 过滤器会根据`前序交易的平均成交价`来定义订单`价格`的有效范围。 - 当该交易对存在非空的 [参考价格](./faqs/price_range_execution_rules.md) 时,过滤器校验将使用该参考价格。 - 当该交易对不存在非空的参考价格时,过滤器校验将使用 `avgPriceMins` 分钟前的成交量加权平均价。 - 如果 `avgPriceMins` 为 0,那么过滤器校验将使用最新成交价。 订单需满足以下条件,方可通过该过滤器校验: - `price` <= `average of previous trade prices` \* `multiplierUp` - `price` >= `average of previous trade prices` \* `multiplierDown` **/exchangeInfo 响应中的格式:** ```javascript { "filterType": "PERCENT_PRICE", "multiplierUp": "1.3000", "multiplierDown": "0.7000", "avgPriceMins": 5 } ``` #### PERCENT_PRICE_BY_SIDE `PERCENT_PRICE_BY_SIDE` 过滤器会根据`前序交易的平均成交价`来定义订单`价格`的有效范围。 - 当该交易对存在非空的 [参考价格](./faqs/price_range_execution_rules.md) 时,过滤器校验将使用该参考价格。 - 当该交易对不存在非空的参考价格时,过滤器校验将使用 `avgPriceMins` 分钟前的成交量加权平均价。 - `avgPriceMins` 为 0,那么过滤器校验将使用最新成交价。 `买方`订单需满足以下条件,方可通过该过滤器校验: - `price` <= `average of previous trade prices` \* `bidMultiplierUp` - `price` >= `average of previous trade prices` \* `bidMultiplierDown` `卖方`订单需满足以下条件,方可通过该过滤器校验: - `price` <= `average of previous trade prices` \* `askMultiplierUp` - `price` >= `average of previous trade prices` \* `askMultiplierDown` **/exchangeInfo 响应中的格式:** ```javascript { "filterType": "PERCENT_PRICE_BY_SIDE", "bidMultiplierUp": "1.2", "bidMultiplierDown": "0.2", "askMultiplierUp": "5", "askMultiplierDown": "0.8", "avgPriceMins": 1 } ``` ### LOT_SIZE 订单尺寸 "lots" 是拍卖术语,这个过滤器对订单中的 `quantity` 也就是数量参数进行合法性检查。包含三个部分: - `minQty` 表示 `quantity`/`icebergQty` 允许的最小值. - `maxQty` 表示 `quantity`/`icebergQty` 允许的最大值 - `stepSize` 表示 `quantity`/`icebergQty` 允许的步进值。 订单需满足以下条件,方可通过该过滤器校验: - `quantity` >= `minQty` - `quantity` <= `maxQty` - `quantity` % `stepSize` == 0 **/exchangeInfo 响应中的格式:** ```javascript { "filterType": "LOT_SIZE", "minQty": "0.00100000", "maxQty": "100000.00000000", "stepSize": "0.00100000" } ``` ### MIN_NOTIONAL 最小金额 `MIN_NOTIONAL` 过滤器定义了交易对订单所允许的最小名义价值(成交额)。 - 订单的名义价值是 `价格` \* `数量` 。 - `applyToMarket` 确定 `MIN_NOTIONAL` 过滤器是否也将应用于 `MARKET` 订单。 - 由于 `MARKET` 订单没有`价格`,因此会使用`前序交易的平均成交价`。 - 当该交易对存在非空的 [参考价格](./faqs/price_range_execution_rules.md) 时,过滤器校验将使用该参考价格来作为`价格`。 - 当该交易对不存在非空的参考价格时,过滤器校验将使用 `avgPriceMins` 分钟前的成交量加权平均价来作为`价格`。 - 如果 `avgPriceMins` 为 0,那么过滤器校验将使用最新成交价来作为`价格`。 订单需满足以下条件,方可通过该过滤器校验: - `price` \* `quantity` >= `minNotional` **/exchangeInfo 响应中的格式:** ```javascript { "filterType": "MIN_NOTIONAL", "minNotional": "0.00100000", "applyToMarket": true, "avgPriceMins": 5 } ``` ### NOTIONAL 名义价值 名义价值过滤器(`NOTIONAL`)定义了订单在一个交易对上可以下单的名义价值区间。 - `applyMinToMarket` 定义了 `minNotional` 是否适用于市价单(`MARKET`)。 - `applyMaxToMarket` 定义了 `maxNotional` 是否适用于市价单(`MARKET`)。 - 由于 `MARKET` 订单没有`价格`,因此会使用`前序交易的平均成交价`。 - 当该交易对存在非空的 [参考价格](./faqs/price_range_execution_rules.md) 时,过滤器校验将使用该参考价格来作为`价格`。 - 当该交易对不存在非空的参考价格时,过滤器校验将使用 `avgPriceMins` 分钟前的成交量加权平均价来作为`价格`。 - 如果 `avgPriceMins` 为 0,那么过滤器校验将使用最新成交价来作为`价格`。 订单需满足以下条件,方可通过该过滤器校验: - `price` \* `quantity` <= `maxNotional` - `price` \* `quantity` >= `minNotional` **/exchangeInfo 响应中的格式:** ```javascript { "filterType": "NOTIONAL", "minNotional": "10.00000000", "applyMinToMarket": false, "maxNotional": "10000.00000000", "applyMaxToMarket": false, "avgPriceMins": 5 } ``` ### ICEBERG_PARTS 冰山订单拆分数 `ICEBERG_PARTS` 代表冰山订单最多可以拆分成多少个小订单。计算方法为 `向上取整(qty / icebergQty)`. **/exchangeInfo 响应中的格式:** ```javascript { "filterType": "ICEBERG_PARTS", "limit": 10 } ``` ### MARKET_LOT_SIZE 市价订单尺寸 `MARKET_LOT_SIZE`过滤器为交易对上的`MARKET`订单定义了`数量`(即拍卖中的"手数")规则。 共有3部分: - `minQty`定义了允许的最小`quantity`。 - `maxQty`定义了允许的最大数量。 - `stepSize`定义了可以增加/减少数量的间隔。 为了通过 `market lot size`,`quantity` 必须满足以下条件: - `quantity` >= `minQty` - `quantity` <= `maxQty` - `quantity` % `stepSize` == 0 **/exchangeInfo 响应中的格式:** ```javascript { "filterType": "MARKET_LOT_SIZE", "minQty": "0.00100000", "maxQty": "100000.00000000", "stepSize": "0.00100000" } ``` ### MAX_NUM_ORDERS 最多订单数 定义了某个交易对最多允许的挂单数量(不包括已关闭的订单)普通订单与条件订单均计算在内 **/exchangeInfo 响应中的格式:** ```javascript { "filterType": "MAX_NUM_ORDERS", "maxNumOrders": 25 } ``` ### MAX_NUM_ALGO_ORDERS 最多条件单数 `MAX_NUM_ALGO_ORDERS`过滤器定义允许账户在交易对上开设的"algo"订单的最大数量。"Algo"订单是`STOP_LOSS`,`STOP_LOSS_LIMIT`,`TAKE_PROFIT`和`TAKE_PROFIT_LIMIT`止盈止损单。 **/exchangeInfo 响应中的格式:** ```javascript { "filterType": "MAX_NUM_ALGO_ORDERS", "maxNumAlgoOrders": 5 } ``` ### MAX_NUM_ICEBERG_ORDERS 最多冰山单数 `MAX_NUM_ICEBERG_ORDERS`过滤器定义了允许在交易对上开设账户的`ICEBERG`订单的最大数量。 `ICEBERG`订单是icebergQty大于0的任何订单。 **/exchangeInfo 响应中的格式:** ```javascript { "filterType": "MAX_NUM_ICEBERG_ORDERS", "maxNumIcebergOrders": 5 } ``` ### MAX_POSITION 过滤器 这个过滤器定义账户允许的基于`base asset`的最大仓位。一个用户的仓位可以定义为如下资产的总和: 1. `base asset`的可用余额 1. `base asset`的锁定余额 1. 所有处于open的买单的数量总和 如果用户的仓位大于最大的允许仓位,买单会被拒绝。 如果一个订单的数量(`quantity`) 可能导致持有仓位溢出, 会触发过滤器 `MAX_POSITION`. **/exchangeInfo 响应中的格式:** ```javascript { "filterType": "MAX_POSITION", "maxPosition": "10.00000000" } ``` ### TRAILING_DELTA 过滤器 此过滤器定义了参数[`trailingDelta`](faqs/trailing-stop-faq.md)的最大和最小值. 下追踪止损订单, 需要满足条件: 对于 `STOP_LOSS BUY`, `STOP_LOSS_LIMIT_BUY`, `TAKE_PROFIT SELL` 和 `TAKE_PROFIT_LIMIT SELL` 订单: - `trailingDelta` >= `minTrailingAboveDelta` - `trailingDelta` <= `maxTrailingAboveDelta` 对于 `STOP_LOSS SELL`, `STOP_LOSS_LIMIT SELL`, `TAKE_PROFIT BUY`, 和 `TAKE_PROFIT_LIMIT BUY` 订单: - `trailingDelta` >= `minTrailingBelowDelta` - `trailingDelta` <= `maxTrailingBelowDelta` **/exchangeInfo format:** ```javascript { "filterType": "TRAILING_DELTA", "minTrailingAboveDelta": 10, "maxTrailingAboveDelta": 2000, "minTrailingBelowDelta": 10, "maxTrailingBelowDelta": 2000 } ``` ### MAX_NUM_ORDER_AMENDS 过滤器 此过滤器定义了指定交易对的订单修改次数上限。 如果单笔订单的修改次数过多,您将会收到 `-2038` 错误代码。 **/exchangeInfo format:** ```javascript { "filterType": "MAX_NUM_ORDER_AMENDS", "maxNumOrderAmends": 10 } ``` ### MAX_NUM_ORDER_LISTS 此过滤器定义了账户在交易对上可持有的最大未平仓订单列表数量。请注意,OTOCO 交易计为一个订单列表。 **/exchangeInfo format:** ```javascript { "filterType": "MAX_NUM_ORDER_LISTS", "maxNumOrderLists": 20 } ``` ## 交易所级别过滤器 ### EXCHANGE_MAX_NUM_ORDERS 最多订单数 `EXCHANGE_MAX_NUM_ORDERS`过滤器定义了允许在交易对上开设账户的最大订单数。请注意,此过滤器同时计算"algo"订单和常规订单。 **/exchangeInfo 响应中的格式:** ```javascript { "filterType": "EXCHANGE_MAX_NUM_ORDERS", "maxNumOrders": 1000 } ``` ### EXCHANGE_MAX_NUM_ALGO_ORDERS 最多条件单数 `EXCHANGE_MAX_NUM_ALGO_ORDERS` 过滤器定义了允许在交易上开设账户的"algo"订单的最大数量。"Algo"订单是`STOP_LOSS`,`STOP_LOSS_LIMIT`,`TAKE_PROFIT`和`TAKE_PROFIT_LIMIT`订单。 **/exchangeInfo 响应中的格式:** ```javascript { "filterType": "EXCHANGE_MAX_NUM_ALGO_ORDERS", "maxNumAlgoOrders": 200 } ``` ### EXCHANGE_MAX_NUM_ICEBERG_ORDERS 冰山订单的最大订单数 此过滤器定义了允许账号持有的最大冰山订单数量. **/exchangeInfo 响应中的格式:** ```javascript { "filterType": "EXCHANGE_MAX_NUM_ICEBERG_ORDERS", "maxNumIcebergOrders": 10000 } ``` ### EXCHANGE_MAX_NUM_ORDER_LISTS 此过滤器定义了允许账号持有的最大未平仓订单列表数量。请注意,OTOCO 交易计为一个订单列表。 **/exchangeInfo format:** ```javascript { "filterType": "EXCHANGE_MAX_NUM_ORDER_LISTS", "maxNumOrderLists": 20 } ``` ## 资产过滤器 ### MAX_ASSET `MAX_ASSET` 过滤器定义了一个账户在单笔订单中可交易的资产最大数量。 - 当资产是交易对的基础资产时,该限制适用于订单的数量。 - 当资产是交易对的报价资产时,该限制适用于订单的名义价值。 - 例如,针对 USDC 的 MAX_ASSET 过滤器适用于所有以 USDC 作为基础资产或报价资产的交易对,例如: - USDCBNB - BNBUSDC **/myFilters format:** ```javascript { "filterType": "MAX_ASSET", "asset": "USDC", "limit": "42.00000000" } ``` --- ## Document: /products/spot/errors URL: /zh-CN/docs/products/spot/errors # 错误代码汇总 币安Rest接口(包括wapi)返回的错误包含两部分,错误码与错误信息. 错误码是大类,一个错误码可能对应多个不同的错误信息。以下是一个完整错误码实例 ```javascript { "code":-1121, "msg":"Invalid symbol." } ``` ## 10xx - 服务器或网络问题 ### -1000 未知错误 - 未知错误 ### -1001 连接断开 - 通常是一个内部错误,一般重试即可解决。 ### -1002 未授权 - 请检查你的(API)权限 ### -1003 请求过多 - 排队的请求过多。 - 请求权重过多; 当前限制是 %s 每 %s 的请求权重。 请使用 Websocket Streams 进行实时更新,以避免轮询API。 - 请求权重过多; IP被禁止,直到%s。 请使用 Websocket Streams 进行实时更新,以免被禁。 ### -1006 非常规响应 - (从内部)接收到了不符合预设格式的消息,下单状态未知。 ### -1007 超时 - 后端服务超时,下单状态未知。 ### -1008 SERVER_BUSY - 现货交易服务器当前因其他请求而过载。 请在几分钟后重试。 ### -1013 消息无效 - 请求被 API 拒绝 (在这个情况中,此请求并没有到达撮合引擎)。 - 潜在的错误信息可以在 [订单未能通过过滤器](#filter-failures) 或 [下单失败](#other-errors) 中找到。 ### -1014 不支持的订单参数(组合) - 不支持的订单参数组合. ### -1015 订单太多 - 下单(撤单)太多 ### -1016 服务器下线 - 服务器下线 ### -1020 不支持的操作 - 不支持的操作 ### -1021 时间同步问题 - 时延过大,服务器根据接请求中的时间戳判定耗时已经超出了recevWindow。请改善网络条件或者增大recevWindow。 - 时间偏移过大,服务器根据请求中的时间戳判定客户端时间比服务器时间提前了1秒钟以上。(该参数不可由客户端调节) ### -1022 签名不正确 - 请求中携带的signature与服务器根据规则计算得到的signature不一致。通常是因为客户端代码中使用的apisecret错误。 ### -1033 正在使用的 Comp ID - `SenderCompId(49)` is currently in use. Concurrent use of the same SenderCompId within one account is not allowed. ### -1034 连接太多 - Too many concurrent connections; current limit is '%s'. - Too many connection attempts for account; current limit is %s per '%s'. - Too many connection attempts from IP; current limit is %s ### -1035 会话注销 - Please send [Logout`<5>`](fix-api.md#logout) message to close the session. ## 11xx - 请求内容中的问题 ### -1100 非法字符 - Illegal characters found in a parameter. - Illegal characters found in parameter '%s'; legal range is '%s'. ### -1101 参数太多 - Too many parameters sent for this endpoint. - Too many parameters; expected '%s' and received '%s'. - Duplicate values for a parameter detected. ### -1102 缺少必须参数 - A mandatory parameter was not sent, was empty/null, or malformed. - Mandatory parameter '%s' was not sent, was empty/null, or malformed. - Param '%s' or '%s' must be sent, but both were empty/null! - Required tag '%s' missing. - Field value was empty or malformed. - '%s' contains unexpected value. Cannot be greater than %s. ### -1103 无法识别的参数 - An unknown parameter was sent. - Undefined Tag. ### -1104 冗余参数 - Not all sent parameters were read. - Not all sent parameters were read; read '%s' parameter(s) but was sent '%s'. ### -1105 空参数(仅有参数名) - A parameter was empty. - Parameter '%s' was empty. ### -1106 非必需参数 - A parameter was sent when not required. - Parameter '%s' sent when not required. - A tag '%s' was sent when not required. ### -1108 参数溢出 - Parameter '%s' overflowed. ### -1111 精度过高 - Parameter '%s' has too much precision. ### -1112 空白的orderbook - No orders on book for symbol. ### -1114 错误地发送了不需要的TIF参数 - TimeInForce parameter sent when not required. ### -1115 无效的TIF参数 - Invalid timeInForce. ### -1116 无效的订单类型 - Invalid orderType. ### -1117 无效的订单方向 - Invalid side. ### -1118 空白的newClientOrderId - New client order ID was empty. ### -1119 空白的originalClientOrderId - Original client order ID was empty. ### -1120 无效的间隔(interval) - Invalid interval. ### -1121 无效的交易对 - Invalid symbol. ### -1122 无效的交易对状态 - Invalid symbolStatus. ### -1125 无效的listenKey - This listenKey does not exist. ### -1127 查询间隔过长 - Lookup interval is too big. - More than %s hours between startTime and endTime. ### -1128 无效的可选参数组合 - Combination of optional parameters invalid. - Combination of optional fields invalid. Recommendation: '%s' and '%s' must both be sent. - Fields [%s] must be sent together or omitted entirely. - Invalid 'MDEntryType (269)' combination. BID and OFFER must be requested together. - Conflicting fields: ['%s'...] ### -1130 无效参数(值) - Invalid data sent for a parameter. - Data sent for parameter '%s' is not valid. ### -1134 strategyType不符合需求 - `strategyType` was less than 1000000. - `TargetStrategy (847)` was less than 1000000. ### -1135 无效的JSON - Invalid JSON Request - JSON sent for parameter '%s' is not valid ### -1139 无效的Ticker类型 - Invalid ticker type. ### -1145 无效的取消限制 - `cancelRestrictions` has to be either `ONLY_NEW` or `ONLY_PARTIALLY_FILLED`. ### -1151 重复的交易对 - Symbol is present multiple times in the list. ### -1152 无效的SBE报文头部 - Invalid `X-MBX-SBE` header; expected `:`. - Invalid SBE message header. ### -1153 不支持的SCHEMA_ID - Unsupported SBE schema ID or version specified in the `X-MBX-SBE` header. - Invalid SBE schema ID or version specified. ### -1155 SBE 没有开启 - SBE is not enabled. ### -1158 OCO 订单类型被拒绝 - Order type not supported in OCO. - If the order type provided in the `aboveType` and/or `belowType` is not supported. ### -1160 OCO 订单类型的冰山数量参数与 time in force 参数的组合有问题 - Parameter '%s' is not supported if `aboveTimeInForce`/`belowTimeInForce` is not GTC. - If the order type for the above or below leg is `STOP_LOSS_LIMIT`, and `icebergQty` is provided for that leg, the `timeInForce` has to be `GTC` else it will throw an error. - `TimeInForce (59)` must be `GTC (1)` when `MaxFloor (111)` is used. ### -1161 被弃用的模式 - Unable to encode the response in SBE schema 'x'. Please use schema 'y' or higher. ### -1165 买入 OCO 限价单必须较低 - A limit order in a buy OCO must be below. ### -1166 卖出 OCO 限价单必须较高 - A limit order in a sell OCO must be above. ### -1168 两个 OCO 订单不能都是是限价单 - At least one OCO order must be contingent. ### -1169 Tag无效 - Invalid tag number. ### -1170 Tag未被定义 - Tag '%s' not defined for this message type. ### -1171 Tag重复出现 - Tag '%s' appears more than once. ### -1172 Tag顺序错误 - Tag '%s' specified out of required order. ### -1173 分组字段顺序错误 - Repeating group '%s' fields out of order. ### -1174 无效组件 - Component '%s' is incorrectly populated on '%s' order. Recommendation: '%s' ### -1175 序列号重置错误 - Continuation of sequence numbers to new session is currently unsupported. Sequence numbers must be reset for each new session. ### -1176 已登录 - [Logon``](fix-api.md#logon-main) should only be sent once. ### -1177 错误消息 - `CheckSum(10)` contains an incorrect value. - `BeginString (8)` is not the first tag in a message. - `MsgType (35)` is not the third tag in a message. - `BodyLength (9)` does not contain the correct byte count. - Only printable ASCII characters and SOH (Start of Header) are allowed. - Tag specified without a value. - Invalid encodingType. ### -1178 Compid错误 - `SenderCompId(49)` contains an incorrect value. The SenderCompID value should not change throughout the lifetime of a session. ### -1179 序列号错误 - `MsgSeqNum(34)` contains an unexpected value. Expected: '%d'. ### -1180 登陆消息错误 - [Logon``](fix-api.md#logon-main) must be the first message in the session. ### -1181 消息太多 - Too many messages; current limit is '%d' messages per '%s'. ### -1182 错误的参数组合 - Conflicting fields: [%s] ### -1183 不允许在 Drop Copy 会话中使用 - Requested operation is not allowed in DropCopy sessions. ### -1184 不允许使用 Drop Copy 会话 - DropCopy sessions are not supported on this server. Please reconnect to a drop copy server. ### -1185 需要使用 Drop Copy 会话 - Only DropCopy sessions are supported on this server. Either reconnect to order entry server or send `DropCopyFlag (9406)` field. ### -1186 不允许在订单输入会话中使用 - Requested operation is not allowed in order entry sessions. ### -1187 不允许在 Market Data 会话中使用 - Requested operation is not allowed in market data sessions. ### -1188 组计数中的数字不正确 - Incorrect NumInGroup count for repeating group '%s'. ### -1189 组中包含重复条目 - Group '%s' contains duplicate entries. ### -1190 无效的请求 ID - `MDReqID (262)` contains a subscription request id that is already in use on this connection. - `MDReqID (262)` contains an unsubscription request id that does not match any active subscription. ### -1191 订阅数量过多 - Too many subscriptions. Connection may create up to '%s' subscriptions at a time. - Similar subscription is already active on this connection. Symbol='%s', active subscription id: '%s'. ### -1194 错误的时间单位 - Invalid value for time unit; expected either MICROSECOND or MILLISECOND. ### -1196 买方 `OCO` 单的止损限价单必须是上方(`above`) 订单 - A stop loss order in a buy OCO must be above. ### -1197 卖方 `OCO` 单的止损限价单必须是下方(`below`) 订单 - A stop loss order in a sell OCO must be below. ### -1198 买方 `OCO` 单的止盈单必须是下方(`below`) 订单 - A take profit order in a buy OCO must be below. ### -1199 卖方 `OCO` 单的止盈单必须是上方(`above`) 订单 - A take profit order in a sell OCO must be above. ### -1210 错误的挂钩订单价格类型 - Invalid pegPriceType. ### -1211 错误的挂钩订单偏移类型 - Invalid pegOffsetType. ### -1220 交易对与状态不匹配 - The symbol's status does not match the requested symbolStatus. ### -1221 SBE 消息中包含错误的字段 - Invalid/missing field(s) in SBE message. ### -1222 OPO 的生效订单必须是买单 - Working order in an OPO list must be a bid. ### -1223 OPO 的待处理订单必须是卖单 - Pending orders in an OPO list must be asks. ### -1224 生效订单缺少必须的 Tag - Working order must include the '{param}' tag. ### -1225 待处理订单包含不需要的 Tag - Pending orders should not include the '%s' tag. ### -2010 新订单被拒绝 - NEW_ORDER_REJECTED ### -2011 撤销订单被拒绝 - CANCEL_REJECTED ### -2013 不存在的订单 - Order does not exist. ### -2014 API Key格式无效 - API-key format invalid. ### -2015 API Key权限,例如该Key不存在、请求并非来自允许的IP范围、或者该接口对应权限未开放 - Invalid API-key, IP, or permissions for action. ### -2016 非交易窗口 - No trading window could be found for the symbol. Try ticker/24hrs instead. ### -2026 交易被归档 - Order was canceled or expired with no executed qty over 90 days ago and has been archived. ### -2035 有效的订阅 - User Data Stream subscription already active. ### -2036 非有效的订阅 - User Data Stream subscription not active. ### -2039 ClientOrderId 无效 - Client order ID is not correct for this order ID. ### -2042 最大订阅 ID - Maximum subscription ID reached for this connection. ## 消息 -1010 收到了错误消息, -2010 新订单被拒绝,-2011 撤销订单被拒绝,还有 -2038 保留优先权的修改订单被拒绝 这个错误代码是由撮合引擎抛出的。下面的消息会指明具体的错误: | 错误消息 | 描述 | | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | "Unknown order sent." | 找不到订单, (根据请求里发送的 `orderId`, `clOrdId`, `origClOrdId`)。 | | "Duplicate order sent." | 客户自定义的订单号重复了。 | | "Market is closed." | 该交易对交易关闭了。 | | "Account has insufficient balance for requested action." | 账户金额不足。 | | "Market orders are not supported for this symbol." | 该交易对无法发起市价单。 | | "Iceberg orders are not supported for this symbol." | 该交易对无法发起冰山订单。 | | "Stop loss orders are not supported for this symbol." | 该交易对无法发起止损单。 | | "Stop loss limit orders are not supported for this symbol." | 该交易对无法发起止损限价单。 | | "Take profit orders are not supported for this symbol." | 该交易对无法发起止盈单。 | | "Take profit limit orders are not supported for this symbol." | 该交易对无法发起止盈限价单。 | | "Order amend is not supported for this symbol." | 该交易对无法发起保持优先级的修改订单操作。 | | "Price \* QTY is zero or less." | 订单金额必须大于0。 | | "IcebergQty exceeds QTY." | 冰山订单中小订单的Quantity必须小于总的Quantity。 | | "This action is disabled on this account." | 联系客户支持; 该账户已禁用了某些操作。 | | "This account may not place or cancel orders." | 联系客户支持: 该账户已被禁用了交易操作。 | | "Unsupported order combination" | `orderType`, `timeInForce`, `stopPrice`, `icebergQty` 某些参数取某些值的时候另一些参数必须/不得提供。 | | "Order would trigger immediately." | 止盈、止损单必须在未来触发,如果条件太弱现在的市场行情就可以触发(通常是误操作填错了条件),就会报这个错误。 | | "Cancel order is invalid. Check origClOrdId and orderId." | 撤销订单必须提供 `origClOrdId` 或者 `orderId` 中的一个。 | | "Order would immediately match and take." | `LIMIT_MAKER` 订单如果按照规则会成为Taker,就会报此错。 | | "The relationship of the prices for the orders is not correct." | `OCO`订单中设置的价格不符合报价规则:
请参考以下示例:
`BUY`:`LIMIT_MAKER` `price` < Last Traded Price < `stopPrice`
`SELL`:`LIMIT_MAKER` `price` > Last Traded Price > `stopPrice`
| | "OCO orders are not supported for this symbol" | `OCO`订单不支持该交易对。 | | "Quote order qty market orders are not support for this symbol." | 这个交易对,市价单不支持参数 `quoteOrderQty`。 | | "Trailing stop orders are not supported for this symbol." | 此symbol不支持 `trailingDelta`。 | | "Order cancel-replace is not supported for this symbol." | 此symbol不支持 `POST /api/v3/order/cancelReplace` 或者 `order.cancelReplace` (WebSocket API)。 | | "This symbol is not permitted for this account." | 账户和交易对的权限不一致 (比如 `SPOT`, `MARGIN` 等)。 | | "This symbol is restricted for this account." | 账户没有权限在此交易对交易 (比如账户只拥有 `ISOLATED_MARGIN`权限,则无法下`SPOT` 订单)。 | | "Order was not canceled due to cancel restrictions." | `cancelRestrictions` 设置为 `ONLY_NEW` 但订单状态不是 `NEW`

`cancelRestrictions` 设置为 `ONLY_PARTIALLY_FILLED` 但订单状态不是 `PARTIALLY_FILLED`。 | | "Rest API trading is not enabled." / "WebSocket API trading is not enabled." | 下单时,服务器没有设置为允许访问 `TRADE` 的接口。 | | "FIX API trading is not enabled. | 订单放置在未启用 TRADE 的 FIX 服务器上. | | "Order book liquidity is less than `LOT_SIZE` filter minimum quantity." | 当订单簿流动性小于 `LOT_SIZE` 过滤器配置的最小数量时,无法提交包含 `quoteOrderQty` 的市价单。 | | "Order book liquidity is less than `MARKET_LOT_SIZE` filter minimum quantity." | 当订单簿流动性小于 `MARKET_LOT_SIZE` 过滤器的最小数量时,无法提交包含 `quoteOrderQty` 的市价单。 | | "Order book liquidity is less than symbol minimum quantity." | 当订单簿里没有订单时,无法提交包含 `quoteOrderQty` 的市价单。 | | "Order amend (quantity increase) is not supported." | `newQty` 必须小于原来订单的数量 (`quantity`)。 | | "The requested action would change no state; rejecting". | 发送的请求将不会改变现状;拒绝。

(比如, `newQty` 不能和原来订单的数量 (`quantity`)是一样的。) | | "Pegged orders are not supported for this symbol." | `pegInstructionsAllowed` 还没有启用。 | | "This order type may not use pegged price." | 在不被支持的订单类型上使用 `pegPriceType` 参数 (例如, `MARKET`)。 | | "This price peg cannot be used with this order type." | 在 `LIMIT_MAKER` 订单上使用 `pegPriceType`=`MARKET_PEG`。 | | "Order book liquidity is too low for this pegged order." | 订单簿中没有最佳价格水平可用以固定价格。 | | OPO orders are not supported for this symbol. | 该交易对不支持 OPO 订单 | | Order amend (pending OPO order) is not supported. | OPO 订单中的待处理订单无法修改数量 | ## 有关使用 cancelReplace 下订单的错误 ### -2021 Order cancel-replace partially failed - 收到该错误码代表撤单**或者**下单失败。 ### -2022 Order cancel-replace failed. - 收到该错误码代表撤单**和**下单都失败。 ## 订单未能通过过滤器 | 错误信息 | 描述 | | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | | "Filter failure: PRICE_FILTER" | 检查价格的上限、下限、步进间隔。 | | "Filter failure: PERCENT_PRICE" | 检查订单中价格是否相对于过去N分钟的平均价格变动超过了百分之X。 | | "Filter failure: LOT_SIZE" | 检查订单中数量的上限、下线、步进间隔。 | | "Filter failure: MIN_NOTIONAL" | `price` \* `quantity`,也就是订单金额,是否超过了最小值。 | | "Filter failure: NOTIONAL" | `price` \* `quantity` 不在 `minNotional` 和 `maxNotional` 的范围内 | | "Filter failure: ICEBERG_PARTS" | 冰山订单只能被分割成有限个小订单。 | | "Filter failure: MARKET_LOT_SIZE" | 与 `LOT_SIZE` 含义一致,只是对市价单生效。 | | "Filter failure: MAX_POSITION" | 账户的仓位已达到定义的最大限额。
它是由基础资产余额的总和以及所有未平仓买入订单的数量之和组成的。 | | "Filter failure: MAX_NUM_ORDERS" | 账户在该交易对下最多挂单数。 | | "Filter failure: MAX_NUM_ALGO_ORDERS" | 账户在该交易对下最多的止盈/止损挂单数。 | | "Filter failure: MAX_NUM_ICEBERG_ORDERS" | 账户在该交易对下最多的冰山订单数。 | | "Filter failure: MAX_NUM_ORDER_AMENDS" | 账户在该交易对下针对单一订单的最多修改次数。 | | "Filter failure: MAX_NUM_ORDER_LISTS" | 账户在该交易对下最多的订单列表数。 | | "Filter failure: TRAILING_DELTA" | `trailingDelta` 不在该订单类型的筛选器的定义范围内。 | | "Filter failure: EXCHANGE_MAX_NUM_ORDERS" | 账户在交易所有太多未结订单。 | | "Filter failure: EXCHANGE_MAX_NUM_ALGO_ORDERS" | 账户在交易所有太多的未平仓止损和/或止盈订单。 | | "Filter failure: EXCHANGE_MAX_NUM_ICEBERG_ORDERS" | 账户在交易所有太多未平仓的冰山订单。 | | "Filter failure: EXCHANGE_MAX_NUM_ORDER_LISTS" | 账户在交易所有太多未平仓的订单列表。 | --- ## Document: /products/spot/enums URL: /zh-CN/docs/products/spot/enums # 枚举定义 这将适用于 REST API 和 WebSocket API。 ## 交易对的状态(status) - `TRADING` - 正常交易中 - `END_OF_DAY` - 收盘 - `HALT` - 交易终止(该交易对已下线) - `BREAK` - 交易暂停 ## 账户与交易对权限(permissions) - `SPOT` - 现货 - `MARGIN` - 杠杆 - `LEVERAGED` - 杠杆代币 - `TRD_GRP_002` - 交易组 002 - `TRD_GRP_003` - 交易组 003 - `TRD_GRP_004` - 交易组 004 - `TRD_GRP_005` - 交易组 005 - `TRD_GRP_006` - 交易组 006 - `TRD_GRP_007` - 交易组 007 - `TRD_GRP_008` - 交易组 008 - `TRD_GRP_009` - 交易组 009 - `TRD_GRP_010` - 交易组 010 - `TRD_GRP_011` - 交易组 011 - `TRD_GRP_012` - 交易组 012 - `TRD_GRP_013` - 交易组 013 - `TRD_GRP_014` - 交易组 014 - `TRD_GRP_015` - 交易组 015 - `TRD_GRP_016` - 交易组 016 - `TRD_GRP_017` - 交易组 017 - `TRD_GRP_018` - 交易组 018 - `TRD_GRP_019` - 交易组 019 - `TRD_GRP_020` - 交易组 020 - `TRD_GRP_021` - 交易组 021 - `TRD_GRP_022` - 交易组 022 - `TRD_GRP_023` - 交易组 023 - `TRD_GRP_024` - 交易组 024 - `TRD_GRP_025` - 交易组 025 ## 订单状态(status) | 状态 | 描述 | | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `NEW` | 该订单被交易引擎接受。 | | `PENDING_NEW` | 该订单处于待处理 (`PENDING`) 阶段,直到其所属订单列表(order list) 中的 `working order` 完全成交。 | | `PARTIALLY_FILLED` | 部分订单已被成交。 | | `FILLED` | 订单已完全成交。 | | `CANCELED` | 用户撤销了订单。 | | `PENDING_CANCEL` | 撤销中(目前并未使用) | | `REJECTED` | 订单没有被交易引擎接受,也没被处理。 | | `EXPIRED` | 该订单根据订单类型的规则被取消(例如,没有成交的 LIMIT FOK 订单, LIMIT IOC 或部分成交的 MARKET 订单)
或者被交易引擎取消(例如,在强平期间被取消的订单,在交易所维护期间被取消的订单) | | `EXPIRED_IN_MATCH` | 表示订单由于 STP 而过期。(例如,带有 `EXPIRE_TAKER` 的订单与账簿上同属相同帐户或相同 `tradeGroupId` 的现有订单匹配) | ## 订单列表(order list)状态 (状态类型集 listStatusType) | 状态 | 描述 | | -------------- | ------------------------------------------------------------------------------ | | `RESPONSE` | 在 ListStatus 用于响应失败的操作时会被使用。(例如,下订单列表或取消订单列表) | | `EXEC_STARTED` | 订单列表已被下达或订单列表状态有更新。 | | `UPDATED` | 订单列表里的某个订单的 clientOrderId 被改变。 | | `ALL_DONE` | 订单列表执行结束,因此不再处于活动状态。 | ## 订单列表(order list)中的订单状态 (订单状态集 listOrderStatus) | 状态 | 描述 | | ----------- | ------------------------------------------------------------------------ | | `EXECUTING` | 订单列表已被下达或订单列表状态有更新。 | | `ALL_DONE` | 订单列表执行结束,因此不再处于活动状态。 | | `REJECT` | 在 ListStatus 用于响应在下单阶段或取消订单列表期间的失败操作时会被使用, | ## 订单列表的类型 - `OCO` - `OTO` ## 分配类型 - `SOR` ## 订单类型(orderTypes, type) - `LIMIT` - 限价单 - `MARKET` - 市价单 - `STOP_LOSS` - 止损单 - `STOP_LOSS_LIMIT` - 限价止损单 - `TAKE_PROFIT` - 止盈单 - `TAKE_PROFIT_LIMIT` - 限价止盈单 - `LIMIT_MAKER` - 限价做市单 ## 订单返回类型 (newOrderRespType) - `ACK` - `RESULT` - `FULL` ## 工作平台 - `EXCHANGE` - 常规交易 - `SOR` - 智能订单路由 ## 订单方向 (side) - `BUY` - 买入 - `SELL` - 卖出 ## 生效时间 (timeInForce) 这里定义了订单在失效前的有效时间。 | 状态 | 描述 | | ----- | ----------------------------------------------------------- | | `GTC` | 成交为止
订单会一直有效,直到被成交或者取消。 | | `IOC` | 无法立即成交的部分就撤销
订单在失效前会尽量多的成交。 | | `FOK` | 无法全部立即成交就撤销
如果无法全部成交,订单会失效。 | ## 速率限制种类(rateLimitType) - REQUEST_WEIGHT - 单位时间请求权重之和上限 ```json { "rateLimitType": "REQUEST_WEIGHT", "interval": "MINUTE", "intervalNum": 1, "limit": 6000 } ``` - ORDERS - 单位时间下单次数上限 ```json { "rateLimitType": "ORDERS", "interval": "SECOND", "intervalNum": 1, "limit": 10 } ``` - RAW_REQUESTS - 单位时间请求次数上限 ```json { "rateLimitType": "RAW_REQUESTS", "interval": "MINUTE", "intervalNum": 5, "limit": 61000 } ``` ## 速率限制间隔 (interval) - SECOND - MINUTE - DAY ## STP 模式 请参阅 [自我交易预防 (Self Trade Prevention - STP) 常见问题](faqs/stp_faq.md)。 - `NONE` - `EXPIRE_MAKER` - `EXPIRE_TAKER` - `EXPIRE_BOTH` - `DECREMENT` - `TRANSFER` ## 可能的执行类型: | 状态 | 描述 | | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- | | `NEW` | 新订单已被引擎接受。 | | `CANCELED` | 订单被用户取消。 | | `REPLACED` | 订单已被修改。 | | `REJECTED` | 新订单被拒绝 (e.g. 在撤消挂单再下单时,其中新订单被拒绝但撤消挂单请求成功)。 | | `TRADE` | 订单有新成交。 | | `EXPIRED` | 订单已根据 Time In Force 参数的规则取消(e.g. 没有成交的 LIMIT FOK 订单或部分成交的 LIMIT IOC 订单)或者被交易所取消(e.g. 强平或维护期间取消的订单)。 | | `TRADE_PREVENTION` | 订单因 STP 触发而过期。 | ## 执行规则 - `PRICE_RANGE` ## 过期原因 - `NONE` - `REJECTED` - `EXCHANGE_CANCELED` - `OCO_TRIGGER` - `OTO_PHASE_ONE_EXPIRED` - `UNFILLED_IOC_QUANTITY_EXPIRED` - `UNFILLED_FOK_ORDER_EXPIRED` - `INSUFFICIENT_LIQUIDITY` - `EXECUTION_RULE_PRICE_RANGE_EXCEEDED` --- ## Document: /products/spot/PROD-TERMS-OF-USE URL: /zh-CN/docs/products/spot/PROD-TERMS-OF-USE # SPOT 交易所使用条款 使用币安产品和服务须遵守 [产品使用条款](https://www.binance.com/zh-CN/terms)。
在继续之前,请仔细阅读。 --- ## Document: /products/spot/CHANGELOG URL: /zh-CN/docs/products/spot/CHANGELOG # 更新日志 **最近更新:2026-06-24** ### 2026-06-24 - 自 **2026-07-09 07:00 UTC** 起,[WebSocket 行情接口](/products/spot/web-socket-streams) 将进行基础设施升级,整个升级过程最长耗时 1 小时。 - 升级期间,您的 WebSocket 连接可能会断开;如发生此情况,请重新连接。 --- ### 2026-06-22 REST 和 WebSocket API: - 注意:根据我们的 SBE 政策,[在被废止 6 个月后](/products/spot/faqs/sbe_faq#sbe-schema),SBE 3:1 模式将于 2026 年 06 月 29 日被停用。 - [面向生产的 SBE 生命周期](https://github.com/binance/binance-spot-api-docs/blob/master/sbe/schemas/sbe_schema_lifecycle_prod.json) 已基于本次更改进行了更新。 --- ### 2026-06-10 #### FIX API - 文档更新:从 [FIX API](/products/spot/fix-api#marketdataincrementalrefresh) 中移除了 `LastFragment (893)`。 - 正如[此前公告](#2025-12-02)中所述,`MarketDataIncrementalRefresh ` 消息已于 2025-12-18 起不再分片,服务器也不再发送 `LastFragment (893)`。 - 该字段已从 [FIX API](/products/spot/fix-api) 字段列表和对应的 [QuickFIX MD schema](https://github.com/binance/binance-spot-api-docs/blob/master/fix/schemas/spot-fix-md.xml) 中移除。 - 文档更新:更新了 [News ``](/products/spot/fix-api#news-b) 消息的说明,以与 [2026-06-09](#2026-06-09) 的公告保持一致。 --- ### 2026-06-09 **更新:** - 更新了 [价格区间执行规则 FAQ](/products/spot/faqs/price_range_execution_rules#externalCalculationId1),新增了外部参考价格计算方法。 当**服务器即将关闭**时,系统将发送 `serverShutdown` 事件;当您收到此事件时,请断开连接并建立新连接。 文档中所有关于服务器关闭前固定时间的描述均已移除。 - 在 [SBE 行情接口](/products/spot/sbe-market-data-streams#serverShutdown) 中补充了 `serverShutdown` 事件的说明。 - ~~系统会在断开连接前 10 分钟发送 `serverShutdown` 事件。~~ - 请尽快建立新连接,以防中断。 - 请注意,`serverShutdown` 事件将以 JSON 格式通过 WebSocket text 帧发送。 --- ### 2026-06-03 - 中文文档术语统一与文字校对: - 统一中文术语:`手续费`/`交易费` → `佣金`,`智能指令路由` → `智能订单路由`,`WebSocket 账户信息推送` → `用户数据流`,`订单薄` → `订单簿` 等。 - 修正了部分文档中的措辞与排版问题。 --- ### 2026-05-11 **注意:以下变更将于 2026 年 05 月 12 日 07:00 (UTC) 左右发生。** - 新增对 [大宗交易](https://www.binance.info/zh-CN/support/faq/detail/557f95eaf8fb4460aed0a891d42a1425) 的 WebSocket 行情接口支持。 - 新 Stream: - `@blockTrade` --- ### 2026-05-06 **注意:以下变更将于 2026 年 05 月 08 日 06:00 (UTC) 推出,可能需要几个小时才能完成部署。** - 在 [WebSocket API](/products/spot/web-socket-api#serverShutdown) 和 [WebSocket 行情接口](/products/spot/web-socket-streams#serverShutdown) 中新增了 `serverShutdown` 事件。 - 系统会在断开连接前 10 分钟发送 `serverShutdown` 事件。 - 当 [`参考价格`](/products/spot/faqs/price_range_execution_rules) 存在且不为空时, [`PERCENT_PRICE`](/products/spot/filters#percent_price)、[`PERCENT_PRICE_BY_SIDE`](/products/spot/filters#percent_price_by_side)、[`MIN_NOTIONAL`](/products/spot/filters#min_notional) 和 [`NOTIONAL`](/products/spot/filters#notional) 过滤器现在将使用`参考价格`。当参考价格不存在或为空时,这些过滤器将改为使用原有行为。 - [大宗交易](https://www.binance.info/zh-CN/support/faq/detail/557f95eaf8fb4460aed0a891d42a1425) 的市场数据。 - 新增端点/方法 - REST API: - `GET /api/v3/historicalBlockTrades` - WebSocket API: - `blockTrades.historical` - 订单查询响应中可能会包含 [`expiryReason`](/products/spot/enums#expiryreasons) 字段。 - 该字段仅针对**已过期订单**返回,用于帮助用户了解订单过期的原因,包括因**价格区间执行规则**而导致订单过期的情况。 - 该字段会包含在 JSON 和 SBE 3:4 响应中。 - 适用于以下端点/方法: - REST API: - `GET /api/v3/order` - `GET /api/v3/allOrders` - `GET /api/v3/orderList` - `GET /api/v3/allOrderList` - WebSocket API: - `order.status` - `allOrders` - `orderList.status` - `allOrderLists` - REST 和 WebSocket API SBE schema 3:4 - 当前的 schema 3:3 [spot_3_3.xml](/products/spot/sbe/schemas/spot_3_3.xml) 已被弃用,将根据我们的 schema 弃用政策在 6 个月后停用。 - schema 3:4 中的变更: - 新增消息 `BlockTradesResponse` - 新增类型 `blockTradeId` - 在 `OrderResponse` 和 `OrdersResponse` 中新增字段 `expiryReason` --- ### 2026-04-28 - 更正了 `价格区间执行规则 FAQ` 内 [`价格区间执行规则如何工作?`](/products/spot/faqs/price_range_execution_rules#how-does-the-price-range-execution-rule-work)问题中所对应的 JSON 内容。 --- ### 2026-04-17 以下事项将于 **2026年5月5日 大约10:00 UTC** 发生。 - 以下SBE 市场数据流中的更新速度将从 **50毫秒调整为25毫秒**。 - SBE 市场数据流: [增量深度信息](/products/spot/sbe-market-data-streams#diff-depth-streams) - FIX SBE: [市场数据增量深度](/products/spot/fix-api#marketdataincrementaldepth) --- ### 2026-04-16 - 更新了文档,明确说明了如果某个交易对从未设置过参考价格,那么查询参考价格时就会返回错误代码 [`-2043`](/products/spot/errors#-2043-no_reference_price)。此规则适用于以下接口/方法: - REST API:`GET /api/v3/referencePrice` - WebSocket API:`referencePrice` --- ### 2026-04-15 - “WebSocket 账户接口”文档已更名为“用户数据流”,详见:[用户数据流](/products/spot/user-data-stream)。相关词条的引用部分也已同步更新。 - 对中文版与英文版因翻译或排版导致的部分差异进行了修正。 --- ### 2026-04-06 - 补充了有关 [价格区间执行规则](/products/spot/faqs/price_range_execution_rules#price_range_enforcement) 中规则执行的更多信息。 --- ### 2026-04-02 关于 [2026-03-27](#2026-03-27) 公告中针对部分端点请求权重计算的说明: 对于被修改的订单,只有当订单因该次修改过期时,请求权重才会变为 0。未导致订单过期的成功请求,仍会按文档中说明的方法消耗权重值。失败的请求,同样会按文档中说明的计算方法消耗权重值。 此规则适用于以下端点和方法: - REST API: `PUT /api/v3/order/amend/keepPriority` - WebSocket API: `order.amend.keepPriority` --- ### 2026-03-30 - 更新了[价格区间执行规则](/products/spot/faqs/price_range_execution_rules#execution_price_limits),以说明订单的执行价格限制。 --- ### 2026-03-27 以下内容将于**2026年4月2日大约07:00 UTC**生效。 - `RAW_REQUESTS` 速率限制提升至每5分钟300,000次。 - 以下端点和方法的请求权重在请求成功时变为0。请求失败仍会按照文档中规定的方法计算权重。
仅有成功调用这些端点的IP将永远不会受到 `REQUEST_WEIGHT` 速率限制。 - REST API - `POST /api/v3/order` - `POST /api/v3/sor/order` - `DELETE /api/v3/order` - `DELETE /api/v3/openOrders` - `POST /api/v3/order/cancelReplace` - `POST /api/v3/order/oco` - `POST /api/v3/orderList/oco` - `POST /api/v3/orderList/oto` - `POST /api/v3/orderList/otoco` - `POST /api/v3/orderList/opo` - `POST /api/v3/orderList/opoco` - `DELETE /api/v3/orderList` - `PUT /api/v3/order/amend/keepPriority` (请参见 [2026-04-02](#2026-04-02) 的更新) - WebSocket API - `order.place` - `sor.order.place` - `order.cancel` - `openOrders.cancelAll` - `order.cancelReplace` - `orderList.place` - `orderList.place.oco` - `orderList.place.oto` - `orderList.place.otoco` - `orderList.place.opo` - `orderList.place.opoco` - `orderList.cancel` - `order.amend.keepPriority` (请参见 [2026-04-02](#2026-04-02) 的更新) - [STP TRANSFER 模式](/products/spot/faqs/stp_faq) 将在 **2026-04-02 07:00 UTC** 生效 --- ### 2026-03-13 - 在[价格区间执行规则](/products/spot/faqs/price_range_execution_rules#externalCalculationId0) 中新增了外部参考价格计算方法。 --- ### 2026-03-11 **通知:** FIX TLS 连接更新将于 **2026-06-08**,从 **03:00 UTC** 开始,预计耗时约 1 小时完成。 **请注意及时处理:** - 在更新期间,现有的 FIX 连接可能会间歇性断开。为确保更新后能够成功重新连接和建立新连接,请在我们更新之前确认您的客户端在 TLS 握手过程中发送了 SNI(服务器名称指示)并且对目标主机名进行了证书验证。 - 未发送 SNI 的客户端可能会在更新期间或之后收到证书错误的消息,导致 TLS 握手或主机名验证失败。这种情况可能发生在某些未配置 SNI 的 Node.js 客户端上。 - 请查阅 [FIX API 文档](/products/spot/fix-api#general-api-information) 以获取完整信息。 --- ### 2026-03-10 说明了关于[价格区间执行规则](/products/spot/faqs/price_range_execution_rules#matching-engine-calculation) 中参考价格的计算方法。 --- ### 2026-03-09 **注意:** 本部分的变更将逐步推出,预计大约需要三周时间完成。 #### 新功能 - [价格区间执行规则](/products/spot/faqs/price_range_execution_rules)) - 新增接口/方法 - REST API: - `GET /api/v3/executionRules` - `GET /api/v3/referencePrice` - `GET /api/v3/referencePrice/calculation` - WebSocket API: - `executionRules` - `referencePrice` - `referencePrice.calculation` - 新增 JSON 数据流:`@referencePrice` - REST 和 WebSocket API SBE schema 3:3 - 当前的 schema 3:2 [spot_3_2.xml](/products/spot/sbe/schemas/spot_3_2.xml) 已被废止,将根据我们的 schema 废止政策在6个月内停止使用。 - schema 3:3 的变更内容: - 新消息 `ExecutionRulesResponse` - 新消息 `PriceRangeExecutionRule`(嵌入于 `ExecutionRulesResponse` 中) - 新消息 `ReferencePriceResponse` - 新消息 `ReferencePriceCalculationResponse` - 新枚举 `executionRuleType` - 新枚举 `expiryReason` - 新枚举 `calculationType` - 在 `NewOrderResultResponse`、`NewOrderFullResponse`、`NewOrderListResultResponse` 和 `NewOrderListFullResponse` 中新增字段 `expiryReason` - 在 `ExecutionReportEvent` 中新增字段 `expiryReason` - 新消息 `ServerShutdownEvent`(仅限 WebSocket API) - FIX SBE schema 1:1 - 该 schema 将用于 FIX 订单接入、FIX Drop Copy 和 FIX 市场数据流。 - 当前的 FIX schema 1:0 [spot-fixsbe-1_0.xml](/products/spot/sbe/schemas/spot-fixsbe-1_0.xml) 已被废止,将根据我们的 schema 废止政策在6个月内停用。 - schema 1:1 的变更内容: - 新枚举 `expiryReason` - 在 `ExecutionReport` 中新增字段 `ExpiryReason` #### FIX API - 在 ExecutionReport `` 消息中可选新增字段 ExpiryReason `<25056>`。 - 更新了用于 FIX 市场数据流和 FIX 订单接入的 QuickFIX Schema。 #### WebSocket API - 新增 `serverShutdown` 事件。 #### 未来的更新 - 以下接口已在 **2019-11-13** 废止,将于 **2026-03-25** 停用: - `GET /api/v1/ping` - `GET /api/v1/time` - `POST /api/v1/userDataStream` - `PUT /api/v1/userDataStream` - `GET /api/v1/ticker/bookTicker` - `GET /api/v1/ticker/price` - `GET /api/v1/klines` - `GET /api/v1/historicalTrades` - `GET /api/v1/depth` - `GET /api/v1/aggTrades` - `GET /api/v1/ticker/24hr` - 以下接口将于 **2026-03-25** 停用: - `GET /api/v1/userDataStream` - `DELETE /api/v1/userDataStream` - `GET /api/v1/trades` - **以下变更将于 2026-03-26 约 07:00 UTC 生效** - 下单及订单列表下单接口的响应将根据 `newOrderRespAck` 的值显示订单过期原因: - 如果 `newOrderRespType=ACK`,则不显示过期原因。 - 如果 `newOrderRespType=RESULT` 或 `newOrderRespType=FULL` 模式,如果出现订单过期,则在字段 `expiryReason` 中显示过期原因。 - 影响的接口/方法包括: - REST API - `POST /api/v3/order` - `POST /api/v3/sor/order` - `POST /api/v3/order/cancelReplace` - `POST /api/v3/order/oco` - `POST /api/v3/orderList/oco` - `POST /api/v3/orderList/oto` - `POST /api/v3/orderList/otoco` - `POST /api/v3/orderList/opo` - `POST /api/v3/orderList/opoco` - WebSocket API - `order.place` - `sor.order.place` - `order.cancelReplace` - `orderList.place` - `orderList.place.oco` - `orderList.place.oto` - `orderList.place.otoco` - `orderList.place.opo` - `orderList.place.opoco` - 在用户数据流中,`executionReport` 事件新增可选字段 `eR`,如果出现订单过期,则用于显示订单过期原因。 --- ### 2026-02-24 - 所有交易对的 [ICEBERG_PARTS](/products/spot/filters#iceberg_parts-%E5%86%B0%E5%B1%B1%E8%AE%A2%E5%8D%95%E6%8B%86%E5%88%86%E6%95%B0) 将于 **2026-03-12 07:00 UTC** 提升至 100。 - 根据[2025-12-02](#2025-12-02)的公告,`!ticker@arr` 将于 **2026-03-24 07:00 UTC** 停用。 --- ### 2026-02-12 REST 和 WebSocket API: - 注意:根据我们的 SBE 政策,[在被废止 6 个月后](/products/spot/faqs/sbe_faq#sbe-schema), SBE 3:0 模式将于 2026 年 02 月 19 日被停用。 - [面向生产的 SBE 生命周期](/products/spot/sbe/schemas/sbe_schema_lifecycle_prod.json) 已基于本次更改进行了更新。 --- ### 2026-02-09 - 在 [FIX SBE 文档](/products/spot/fix-api#fix-sbe) 中阐明了有关指数字段的要求 --- ### 2026-02-02 - 记录了 [FIX Drop Copy 会话](/products/spot/fix-api#fix-api-drop-copy-sessions) 数据存在 1 秒的延迟。自 FIX API 推出以来,该延迟一直存在。 --- ### 2026-01-29 - [模拟交易](./demo-mode/general-info) 现已开放。 - 有关现货模拟交易环境因维护而不可用的时间信息,请参阅 [模拟交易更新日志](./demo-mode/CHANGELOG)。 --- ### 2026-01-27 **通知:以下变更将于 2026-02-11 07:00 UTC 生效**: - 所有交易对的 [ICEBERG_PARTS](/products/spot/filters#iceberg_parts-%E5%86%B0%E5%B1%B1%E8%AE%A2%E5%8D%95%E6%8B%86%E5%88%86%E6%95%B0) 将增加到 50。 --- ### 2026-01-26 - 在 `userDataStream.subscribe.signature` 中添加了字段 `recvWindow`的说明。 --- ### 2026-01-21 根据 **2025-10-24** 的公告,以下端点和方法将从 **2026-02-20 07:00 UTC** 起不再可用。 ## REST API - `POST /api/v3/userDataStream` - `PUT /api/v3/userDataStream` - `DELETE /api/v3/userDataStream` ## WebSocket API - `userDataStream.start` - `userDataStream.ping` - `userDataStream.stop` --- ### 2025-12-18 - [FIX SBE 文档](/products/spot/fix-api#fix-sbe) 已更新。 - 澄清了用户数据流文档中关于 [`eventStreamTerminated`](/products/spot/user-data-stream#event-stream-terminated) 的说明 - 资产 `这是测试币` 和 `456` 以及交易对 `这是测试币456` 已被添加到 [现货测试网](http://testnet.binance.vision) 以供用户测试含有 Unicode 交易对的端点/方法。 预知详情,请参考 [现货测试网的相关更新日志](/products/spot/testnet)。 --- ### 2025-12-17 #### 时效性通知 - **以下有关于REST API变更将在 2026-01-15 07:OO UTC 发生:**
调用需要签名的接口时,请在计算签名之前对 payload 进行百分比编码(percent-encode)。不符合此顺序的请求将被拒绝,并返回错误代码 [`-1022 签名不正确`](/products/spot/errors#-1022-invalid_signature)。请检查并相应地更新您代码中的签名逻辑部分。这项功能现已在 [SPOT Testnet](http://testnet.binance.vision) 上启用。 #### REST API - 更新了 REST API 文档中有关于 [签名请求示例](rest-api#hmac-keys) 的部分。 #### WebSocket API - 更新了 WebSocket API 文档中有关于 [签名请求示例](/products/spot/web-socket-api#hmac) 的部分。 --- ### 2025-12-15 **关于 UTF-8 编码的说明:** - 在 [FIX API](/products/spot/fix-api)、[REST API](rest-api) 和 [WebSocket API](/products/spot/web-socket-api) 中,如果您的请求包含非 ASCII 字符的交易对名称,那么响应中可能包含以 UTF-8 编码的非 ASCII 字符。 - 在 REST 和 WebSocket API 中,即使请求本身不包含非 ASCII 字符,某些端点/方法也可能返回包含以 UTF-8 编码的非 ASCII 字符的资产和/或交易对名称。 - 在 [WebSocket 行情接口](/products/spot/web-socket-streams) 中,如果您的请求包含非 ASCII 字符的交易对名称,那么数据流事件中可能包含以 UTF-8 编码的非 ASCII 字符。 - 在 WebSocket 行情接口中,[全市场所有 Symbol 的精简 Ticker](/products/spot/web-socket-streams#all-markets-mini-ticker) 和 [全市场滚动窗口统计](/products/spot/web-socket-streams#all-market-rolling-window-ticker) 事件可能包含以 UTF-8 编码的非 ASCII 字符。 - 在 [SBE 市场数据流](/products/spot/sbe-market-data-streams) 中,如果您的请求包含包含非 ASCII 字符的交易对名称,那么数据流事件中可能包含以 UTF-8 编码的非 ASCII 字符。 - 如果您持有或交易任何名称包含非 ASCII 字符的资产或交易对,那么 [用户数据流](/products/spot/user-data-stream) 中可能包含以 UTF-8 编码的非 ASCII 字符。 - 为了与币安 API 完全兼容,请务必确保您的代码能够处理 UTF-8 编码的字符串。 --- ### 2025-12-09 - [FIX SBE Schema](/products/spot/sbe/schemas/spot-fixsbe-1_0.xml) 已更新,会在 `MarketDataSnapshot` 中使用 `smallGroupSize16Encoding`。并在增量单个交易对订单簿数据流/深度数据流的 `MDEntrySize` 的字段中使用 `presence="optional"`。 - 更新了关于 [FIX 与 FIX SBE](/products/spot/fix-api#fix-vs-fix-sbe) 的文档说明 - 在 REST 和 WebSocket API 文档中新增说明:**请避免在请求中使用 SQL 关键字**,因为这可能会触发 Web 应用防火墙(WAF)规则导致安全拦截。详情请参见 https://www.binance.com/zh-CN/support/faq/detail/360004492232 。 --- ### 2025-12-02 **注意: 本节中的变更将逐步推出,预计大约需要两周时间完成。** #### 常规更改 - 参数 `symbol` 和 `symbols` 现在支持以 UTF-8 编码的 Unicode 值。 - 根据 [2025-11-14](#2025-11-14) 的公告,所有与 `!ticker@arr` 相关的内容已经在文档被移除。 - 该功能将在未来弃用公告发布前继续可用。 - 请改用 `@ticker` 或 `!miniTicker@arr`。 #### FIX API - 现在 FIX 消息中可以接受以 UTF-8 编码的 Unicode 值。仅允许以下标签使用: - `Currency (15)` - `MiscFeeCurr (138)` - `Symbol (55)` - `SecondarySymbol (25019)` - `CounterSymbol (25028)` - `SecurityDesc (107)` - 当 Unicode 出现在非上述标签的值中时,FIX API 会在拒绝消息 `<3>` 中返回 `RefTagID (371)` 标签,指明具体哪个标签不允许包含 Unicode。 - NewOrderList `` 可以接受没有 `TriggerPrice (1102)` 的 `TriggerPriceDirection (1109)`。 #### WebSocket 数据流 - WebSocket 市场数据流支持 URL 编码的 URL。

**注意:以下变更预计于 2025-12-18 07:00 UTC 左右生效**: - [ICEBERG_PARTS](/products/spot/filters#iceberg_parts) 将对所有交易对提升至 25。 - [FIX SBE 支持](/products/spot/fix-api) 将上线。 - [一个订单支付另一个订单(OPO)](/products/spot/faqs/opo) 将在所有交易对上线。 - `opoAllowed` 将开始出现在 `Exchange Information` 请求中,指示每个交易对是否支持一个订单支付另一个订单(OPO)。 - REST API: `GET /api/v3/exchangeInfo` - WebSocket API: `exchangeInfo` - OPO 新请求: - REST API: - `POST /api/v3/orderList/opo` - `POST /api/v3/orderList/opoco` - WebSocket API: - `orderList.place.opo` - `orderList.place.opoco` - FIX API: - NewOrderList `` 新增字段 `OPO (25046)`。请更新至最新 QuickFIX 模式以支持 OPO。 - 新增 STP 模式 [`TRANSFER`](/products/spot/faqs/stp_faq)。STP `TRANSFER` 启用的具体日期尚未确定。 - **SBE:新增 schema 3:2 版本 ([spot_3_2.xml](/products/spot/sbe/schemas/spot_3_2.xml))。** - 当前 schema 3:1 ([spot_3_1.xml](/products/spot/sbe/schemas/spot_3_1.xml)) 已被弃用,将根据我们的 schema 弃用政策在 6 个月后停用。 - 3:2 版本变更: - 为 `selfTradePreventionMode` 和 `allowedSelfTradePreventionModes` 新增枚举值 `TRANSFER`。 - 所有低于 3:1 的 schema 无法返回包含 STP 模式 `TRANSFER` 的响应(例如 Exchange Information、下单、撤单或订单状态查询)。
当响应无法用请求的 schema 表示时,将返回错误。 - FIX API 变更: - `LastFragment (893)` 被弃用。 - 这意味着 MarketIncrementalRefresh `` 消息将不再分片,可能包含超过 10,000 条目。 - 文档已更新以反映此变更。 - ListStatus `` 将不再发送可选的 `symbol` 字段。 - 适用于 FIX 订单接入和 FIX Drop Copy。 - 文档已更新以反映此变更。 --- ### 2025-11-14 - 全市场所有交易对的完整Ticker(`!ticker@arr`)已被弃用;这意味着该接口将在后续从文档和系统中移除,具体时间另行通知。 - 请改用 [`@ticker`](/products/spot/web-socket-streams#twentyfourhourticker) 或 [`!miniTicker@arr`](/products/spot/web-socket-streams#all-markets-mini-ticker)。 --- ### 2025-11-12 - 关于[如何正确管理本地订单簿](/products/spot/web-socket-streams#how-to-maintain-orderbook)的步骤已被修正。 --- ### 2025-11-11 #### SBE 市场数据流 - **从 2025 年 11 月 26 日 07:00 UTC 起,`@depth` 和 `@depth20` 数据流的更新速度将变为 50 毫秒**。 - 此变更将自动部署到 SBE 市场数据的所有用户端,因此客户无需进行任何操作。 - 每秒可接收的总数据量将增加(最高可达 2 倍速)。 - [SPOT 测试网](https://testnet.binance.vision/) 将会从 **2025 年 11 月 11 日 07:00 UTC** 起应用这些变更。 - [SBE 市场数据流](/products/spot/sbe-market-data-streams) 已更新以反映这些变更。 --- ### 2025-11-10 - 除了更新日志之外,所有文档中的“最近更新”日期将被移除。 - 今后,更新日志将作为所有文档变更时间的唯一参考来源。 --- ### 2025-10-28 **注意:以下变更将于 2025 年 10 月 28 日 04:00 (UTC) 推出,可能需要几个小时才能完成部署。** - 可选参数 `symbolStatus` 已添加到以下端点: - **REST API** - `GET /api/v3/depth` - `GET /api/v3/ticker/price` - `GET /api/v3/ticker/bookTicker` - `GET /api/v3/ticker/24hr` - `GET /api/v3/ticker/tradingDay` - `GET /api/v3/ticker` - **WebSocket API** - `depth` - `ticker.price` - `ticker.book` - `ticker.24hr` - `ticker.tradingDay` - `ticker` - 当提供参数 `symbolStatus=` 时,只有交易状态与指定的 `STATUS` 相匹配的交易对才会包含在响应中: - 如果使用 `symbol=` 参数指定单个交易对,但是这个交易对的状态与指定的 `STATUS` 不匹配时,端点将返回错误代码 [`-1220 SYMBOL_DOES_NOT_MATCH_STATUS`](/products/spot/errors#-1220-symbol_does_not_match_status)。 - 如果使用 `symbols=[...]` 参数指定了多个交易对,那么响应将是一个数组。该数组中将不会包括交易状态与 `STATUS` 不匹配的交易对。当 symbols 参数中所指定的交易对中没有任何一个交易对的状态与 `STATUS` 相匹配时,响应将为一个空数组。 - 对于 `symbol` 和 `symbols` 参数为可选参数的端点,省略这些参数将被视为在 `symbols=[...]` 参数中指定了所有交易对。有关 `symbolStatus=` 的行为,请参阅上一行。 --- ### 2025-10-24 #### SBE - SBE:schema 3:1([spot_3_1.xml](/products/spot/sbe/schemas/spot_3_1.xml))已更新,支持保证金交易的[listenToken 订阅方法](/products/zh-CN/margin_trading/trade-data-stream/Listen-Token-Websocket-API)。 #### REST 和 WebSocket API 根据 [2025-04-07](#2025-04-07) 的公告,所有关于在 `wss://stream.binance.com` 上使用 `listenKey` 的文档已被移除。请参阅以下请求和方法列表以获取详细信息。该功能将在未来发布停用公告之前继续可用。 **特此提醒您: 您应该通过订阅 [在 WebSocket API 内的用户数据流](/products/spot/websocket-api/user-data-stream-requests) 来获得用户账户更新。这样可以提供更好的性能(更低的延迟)。** 请参阅下方请求和方法列表来了解更多详情。 这些功能将持续可用,直至另行发布停用公告。 - REST API - `POST /api/v3/userDataStream` - `PUT /api/v3/userDataStream` - `DELETE /api/v3/userDataStream` - WebSocket API - `userDataStream.start` - `userDataStream.ping` - `userDataStream.stop` --- ### 2025-10-21 REST 和 WebSocket API: - 注意:根据我们的 SBE 政策,[在被废止 6 个月后](/products/spot/faqs/sbe_faq#sbe-schema), SBE 2:1 模式将于 2025 年 10 月 24 日被禁用。 - [面向生产的 SBE 生命周期](/products/spot/sbe/schemas/sbe_schema_lifecycle_prod.json) 已基于本次更改进行了更新。 --- ### 2025-10-08 - 更新了用于 FIX 市场数据的 [QuickFIX Schema](/products/spot/fix/schemas/spot-fix-md.xml): - 更新了 `RecvWindow(25000)`,以便对在 [2025-08-12](#2025-08-12) 公布的微秒级进行支持。 - 更新了 [`InstrumentList`](/products/spot/fix-api#instrumentlist) 消息: - 新增字段:`StartPriceRange`、`EndPriceRange`。 - 以下字段改为可选:`MinTradeVol`、`MaxTradeVol`、`MinQtyIncrement`、`MarketMinTradeVol`、`MarketMaxTradeVol`、`MarketMinQtyIncrement`、`MinPriceIncrement`。 - **InstrumentList `` 的变更属于破坏性变更,预计将于 2025-10-23 07:00 UTC 左右发布。请在此之前更新到新的模式。** - 在[SPOT 测试网](https://testnet.binance.vision/) 上已经启用了这个重大更改。 --- ### 2025-09-29 **注意:以下变更将于 2025 年 9 月 29 日 10:00 (UTC) 推出,可能需要几个小时才能完成部署。** - 新增一个端点,用于检索与指定交易品种的账户相关的过滤器列表。这是唯一一个目前会显示账户是否应用了 `MAX_ASSET` 过滤器的端点。 - REST API: [`GET /api/v3/myFilters`](rest-api#myFilters) - WebSocket API: [`myFilters`](/products/spot/web-socket-api#myFilters) - 对 **SBE: schema 3:1 ([spot_3_1.xml](/products/spot/sbe/schemas/spot_3_1.xml))** 中的部分注释进行了添加、修改和删除。虽然 `3:1` 用户无需更新到此版本的模式,但我们建议您进行更新以保持一致性。 - 新增了有关过滤器 [`MAX_ASSET`](/products/spot/filters#max_asset) 的文档。 --- ### 2025-09-18 - 更新了文档中有关 `recvWindow` 的部分, 用以体现在 [2025-08-12](#2025-08-12) 发表的微秒级支持。 - REST API: [时间同步安全](rest-api#timingsecurity) - WebSocket API: [时间同步安全](/products/spot/web-socket-api#timingsecurity) --- ### 2025-09-12 - 更新了 FIX 订单接入 API 的 [QuickFix 模式](/products/spot/fix/schemas/spot-fix-oe.xml),用以支持挂钩订单。 - 在 FIX API 文档中, 对以下部分的 `RecvWindow` 进行了更新: - [消息组件](/products/spot/fix-api#header) - [时间同步安全](/products/spot/fix-api#timingsecurity) --- ### 2025-08-28 - 更新了 “简单二进制编码(SBE)常见问题” 文档中 [关于对旧版本的支持](/products/spot/faqs/sbe_faq#regarding-legacy-support) 部分,增加了关于模式兼容性的更多细节,并解释了 `NonRepresentable` 和 `NonRepresentableMessage` 的用法。 --- ### 2025-08-26 - 更新了 [REST API](rest-api#request-security) 和 [WebSocket API](/products/spot/web-socket-api#request-security) 文档的 “请求鉴权类型” 部分,不过相关的功能没有改动。 --- ### 2025-08-25 - **SBE: 模式 3:1 ([spot_3_1.xml](/products/spot/sbe/schemas/spot_3_1.xml))**将于**2025-08-25 05:00 UTC** 进行更新。 - 以下字段已被重命名,用于解决通过 [SbeTool](/products/spot/faqs/sbe_faq#generate-sbe-decoders) 代码生成器所生成的 Java 代码被发现无法进行编译的问题。 - 虽然只有受此问题影响的用户才需要更新模式文档,但我们建议所有用户都升级到最新版本以保持一致性。 - 消息 `MaxAssetFilter` - 字段 `limitExponent` 重命名为 `qtyExponent` - 字段 `limit` 重命名为 `maxQty` --- ### 2025-08-19 - `userDataStream.subscribe` 在响应中返回 `subscriptionId`。
这在 [previous](#2025-08-12) 变更日志条目中被遗漏了 --- ### 2025-08-12 **通知:** 本节中的更改将逐步推出,需要大约两周时间才能完成部署。 #### 常规更改 - 新的错误代码 `-1120` 和 `1211`。有关详情,请参阅 [错误代码汇总](/products/spot/errors)。 - 以下请求包含一个名为 `specialCommission` 的新结构。请参阅 [佣金率](/products/spot/faqs/commission_faq)。 - REST API - `GET /api/v3/account/commission` - `POST /api/v3/order/test` 并设置 `computeCommissionRates=true` - `POST /api/v3/sor/order/test` 并设置 `computeCommissionRates=true` - WebSocket API - `account.commission` - `order.test` 并设置 `computeCommissionRates=true` - `sor.order.test` 并设置 `computeCommissionRates=true` - **SBE: 新模式 3:1 ([spot_3_1.xml](/products/spot/sbe/schemas/spot_3_1.xml)) 将可以使用。** - 现行模式 3:0 ([spot_3_0.xml](/products/spot/sbe/schemas/spot_3_0.xml)) 将会被废止并根据我们的废止政策,在6个月内停止使用。 - 模式 3:1 中的更改: - `ExchangeInfoResponse`:增加新字段 `pegInstructionsAllowed` - `ExecutionReportEvent`:增加新字段 `pricePeg`,`pricePegOffsetLevel` 和 `peggedPrice` - `UserDataStreamSubscribeResponse`:新字段 `subscriptionId` - 所有的用户数据流事件都增加了新字段 `subscriptionId`。 - 对于 `WebSocketSessionLogonResponse`,`WebSocketSessionStatusResponse` 和 `WebSocketSessionLogoutResponse`,字段 `apiKey` 被改名为 `loggedOnApiKey` - `OrderTestWithCommissionsResponse`:增加2个新字段 `specialCommissionForOrderMaker` 和 `specialCommissionForOrderTaker` - `AccountCommissionResponse`:增加4个新字段 `specialCommissionMaker`,`specialCommissionTaker`,`specialCommissionBuyer` 和 `specialCommissionSeller` - 支持 `EXCHANGE_MAX_NUM_ORDER_LISTS`,`MAX_NUM_ORDER_LISTS` 和 `MAX_NUM_ORDER_AMENDS` 过滤器。 - `ExecutionReportEvent`:字段 `rejectReason` 和 `origClientOrderId` 在 SBE 格式也会显示它们的默认值,以和 JSON 格式保持一致, - `NonRepresentableMessage`:添加了一条新消息,用于表示无法使用现有 `schema ID` 和 `version` 来显示的信息。收到此消息则表示应该有可用内容,但不适用于当前使用的 SBE 模式。 - 最终状态为 `EXPIRED_IN_MATCH`(即因 STP 而过期的订单)且累计数量为 0 的订单将在 90 天后做归档处理。 - 查询订单列表请求将首先查询缓存中的数据,如果找不到,再去查询数据库。 - REST API:`GET /api/v3/openOrderLists` - WebSocket API:`openOrderLists.status` #### WebSocket API - 单个 WebSocket 连接可以同时订阅多个用户数据流。 - 单个连接上,每个帐户只能有一个订阅。 - 新增了 `userDataStream.subscribe.signature` 方法,允许您无需事先登录即可订阅用户数据流。 - 此方法也不需要 Ed25519 API 密钥,并且可以与任何 [API Key 类型](/products/spot/faqs/api_key_types) 配合使用。 - 为了获得 [SBE 支持](/products/spot/faqs/sbe_faq),您至少需要使用架构 3:1。 - 新增了 `session.subscriptions` 方法,用于列出当前会话中所有有效的订阅。 - 会话请求中字段 `userDataStream` 的含义略有变化。 - 之前,如果您订阅了已登录帐户的用户数据流,则此方法返回 `true`。 - 现在,如果您至少有一个有效的用户数据流订阅,它将返回 `true`,否则为 `false`。 - `userDataStream.unsubscribe` 支持关闭多个订阅。 - 调用时不带参数,将关闭所有订阅。 - 调用时传入 `subscriptionId`,如果该 ID 存在的话,将尝试关闭与该 ID 匹配的订阅。 - 此请求的授权已更改为 `NONE`。 - 通过 [WebSocket API](/products/spot/web-socket-api#user-data-stream-subscribe) 进行监听时,用户数据流事件负载中新增了字段 `subscriptionId`。这个字段会标识事件来自哪个订阅。 #### FIX API - 当客户端发送拒绝消息时,FIX API 将不再向客户端返回 `<3>` 拒绝消息。 - 现在,当标签无效、缺少值、字段值为空或格式错误时,错误消息将更加清晰明了。 - ```json { "code": -1169, "msg": "Invalid tag number." } ``` - ```json { "code": -1177, "msg": "Tag specified without a value." } ``` - ```json { "code": -1102, "msg": "Field value was empty or malformed." } ``` #### 将会发生的更改 以下变更将于**2025-08-27 07:00 UTC 开始发生**: - 交易所信息请求将发送字段 `pegInstructionsAllowed`。 - 已修复的问题:撮合引擎不会再接受数量超出订单数量过滤器上限的订单列表。受到影响的过滤器包括: - `MAX_NUM_ORDERS` - `MAX_ALGO_ORDERS` - `MAX_ICEBERG_ORDERS` - `EXCHANGE_MAX_NUM_ORDERS` - `EXCHANGE_MAX_ALGO_ORDERS` - `EXCHANGE_MAX_ICEBERG_ORDERS` 以下变更将于**2025-08-28 07:00 UTC 开始发生**: - [挂钩订单](/products/spot/faqs/pegged_orders) 功能将可以使用。 - `pegInstructionsAllowed` 将在所有的交易对上被设为 `true`, 在所有的 API 上正式启用挂钩订单相关功能。 - 如果订单是挂钩订单,那么以下条件字段 `pegPriceType`, `pegOffSetType`, `pegOffsetValues` 和 `peggedPrice` 将出现在以下请求的响应中: - REST API - `GET /api/v3/order` - `GET /api/v3/orderList` - `GET /api/v3/openOrderList` - `GET /api/v3/allOrders` - `DELETE /api/v3/order` - `DELETE /api/v3/orderList` - `DELETE /api/v3/openOrders` - `PUT /api/v3/order/amend/keepPriority` - WebSocket API - `order.status` - `orderList.status` - `allOrders` - `order.cancel` - `orderList.cancel` - `openOrders.cancelAll` - `order.amend.keepPriority` - FIX API - `OrdType(40)` 支持新的数值 `P(PEGGED)` - 字段 `PegOffsetValue(211)`,`PegPriceType(1094)`,`PegMoveType(835)` 和 `PegOffsetType(836)` 被添加到以下消息中: - NewOrderSingle `` - NewOrderList `` - OrderCancelRequestAndNewOrderSingle `` - 下单时,`ExecutionReport` `<8>` 消息将回显 PegInstructions,并带有一个额外的可选字段 `PeggedPrice (839)` - 添加了新的挂钩订单错误消息。欲知详情,请参阅 [错误代码汇总](/products/spot/errors) 文档。 - `recvWindow` 上的变更将被启用。 - 当您的消息离开我方的消息代理后,在即将发送到撮合引擎之前,将进行第三次检查。 - 这不包括撮合引擎本身内部的潜在延迟。 - `recvWindow` 支持微秒级。 - 该值仍然以毫秒为单位指定,但现在可以采用小数部分来指定更高的精度。 - 这意味着该参数现在支持**最大精度为 3 位小数**。(例如, 6000.346) - 受影响的 API: - FIX API - REST API - WebSocket API - 新的 [`MAX_NUM_ORDER_LISTS`](/products/spot/filters_CN#max_num_order_lists) 过滤器将被启用:会允许每个交易对上最多有 20 个订单列表挂单。 - 新的 [`MAX_NUM_ORDER_AMENDS`](/products/spot/filters#max_num_order_amends) 过滤器将被启用:会以 10 次为上限来限制订单修改次数。 --- ### 2025-08-07 - 更新了 FIX API 文档 - [FIX 市场数据限制](/products/spot/fix-api#connection-limits):订阅限制一直存在,但之前未有文档说明。 - [消息处理顺序](/products/spot/fix-api#orderedmode):重新措辞并调整了格式。 --- ### 2025-07-03 - 自 **2025-07-08 07:00 UTC** 起,[WebSocket 行情接口](/products/spot/web-socket-streams) 将会进行升级。 - 升级期间,**现有连接和新连接可能会在 24 小时内断开**。 - 升级过程最多可能需要 2 小时。若有不便之处,敬请谅解。 --- ### 2025-06-04 REST 和 WebSocket API: - 注意:根据我们的 SBE 政策,[在被废止 6 个月后](/products/spot/faqs/sbe_faq#sbe-schema), SBE 2:0 模式将于 2025 年 06 月 12 日被禁用。 - [面向生产的 SBE 生命周期](/products/spot/sbe/schemas/sbe_schema_lifecycle_prod.json) 已基于本次更改进行了更新。 --- ### 2025-05-28 - 在 “API 基本信息” 下,记录每个 API 的超时值和错误: - [FIX](/products/spot/fix-api#general-api-information) - [REST](rest-api#general-api-information) - [WebSocket](/products/spot/web-socket-api#general-api-information) --- ### 2025-05-22 **注意:以下变更将于 2025 年 6 月 6 日 7:00 (UTC) 生效。** - 将通过一项额外的检查,对 FIX、REST 和 WebSocket API 上先前关于`recvWindow` 的行为进行强化。 - 让我们回顾一下现有行为: - 如果在接收请求时, `timestamp` 大于 `serverTime` + 1 秒,则请求会被拒绝。此检查被拒绝的话,将会增加消息限制(FIX API)和 IP 限制(REST 和 WebSocket API),但不会增加未成交订单计数(所有 API 的下单端点)。 - 如果在接收请求时, `timestamp` 和 `serverTime` 之间的差值大于 `recvWindow`,则请求被拒绝。此检查被拒绝的话,将会增加消息限制(FIX API)和 IP 限制(REST 和 WebSocket API),但不会增加未成交订单计数(所有 API 的下单端点)。 - 附加检查: - 在请求转发到撮合引擎之前,如果 `timestamp` 与当前 `serverTime` 之间的差值大于 `recvWindow`,则拒绝该请求。此检查被拒绝的话,将会增加消息限制(FIX API)、IP 限制(REST 和 WebSocket API)以及未成交订单计数(所有 API 的下单端点)。 - 已更新 Timing 安全性文档,以反映新增的附加检查。 - [REST API](rest-api#timingsecurity) - [WebSocket API](/products/spot/web-socket-api#timingsecurity) - [FIX API](/products/spot/fix-api#timingsecurity) - 修复了 FIX Market Data 消息 InstrumentList `` 中的一个错误。之前,`NoRelatedSym(146)` 的值可能会不正确。 --- ### 2025-04-29 - 目前需要 Ed25519 API 密钥才能使用的功能将很快会对 HMAC 和 RSA 密钥开放。 - 例如,在 listenKeys 被移除前,您可以使用任何 API 密钥类型在 WebSocket API 中订阅账户数据流。 - 我们仍然鼓励用户迁移到 Ed25519 API 密钥,因为它们在币安现货交易中更安全、性能更佳。 - 更多详情即将公布,敬请关注,不要错过。 --- ### 2025-04-25 - 以下请求权重将从 1 增加到 4: - REST API: `PUT /api/v3/order/amend/keepPriority` - WebSocket API: `order.amend.keepPriority` - REST 和 WebSocket API 的文档均已更新,以反映即将发生的更改。 - 澄清了 FIX-API 中的 `SEQNUM` 是一个累计到最大值后将会归 0,然后重新开始计数的 32 位无符号整数。自 FIX-API 诞生以来,它一直是 `SEQNUM` 数据类型。 --- ### 2025-04-21 **关于 [保留优先级的修改订单请求 (Order Amend Keep Priority)](/products/spot/faqs/order_amend_keep_priority) 和 [STP 方式 `DECREMENT`(递减)](/products/spot/faqs/stp_faq) 发布的说明:** - 于 **2025-05-07 07:00 UTC** - 所有交易对将启用 ”保留优先级的修改订单请求“ 功能。 - 所有交易对将允许 “STP 递减”。 - 自**2025年4月24日 07:00 UTC**起,`amendAllowed` 字段将在交易所信息请求中可见,但该功能尚未启用。 - [SPOT 测试网](https://testnet.binance.vision/) 在所有交易对上都启用了这两项功能。 --- ### 2025-04-08 **通知:** 本节中的更改将逐步推出,需要一周时间才能完成. - 新的错误代码 `-2039`,如果查询同时具有 `orderId` 和 `origClientOrderId` 的订单,并且未找到具有此组合的订单. - 受影响的请求: - REST API:`GET /api/v3/order` - WebSocket API:`order.status` - [错误代码文档](/products/spot/errors) 在错误代码 `-1034` 中更新了新的错误消息, 当超过 FIX 连接速率限制时会出现。(更多细节参看昨天的 [更新](#2025-04-07)) --- ### 2025-04-07 #### 常规更改 **通知:** 本节中的更改将逐步推出,需要一周时间才能完成. - 在2025 年 1 月 16 日,FIX Market Data 会话的连接限制从 5 个增加到了 100 个。这个改变没有在之前的更改日志中被明示。 - 新的错误代码 `-2038`,将在保留优先权的修改订单请求失败时出现。 - 错误代码 `-1034` 有了新消息。 - 如果未成交订单计数超过了在 `intervalNum:DAY` 里定义的限制, 那么 `intervalNum:SECOND` 下的未成交订单计数将不再递增。 - 以前,无论提供的参数如何,myTrades 请求的权重都是 20。现在,如果您提供 `orderId` ,请求的权重将为 5。 - REST API:`GET /api/v3/myTrades` - WebSocket API:`myTrades` - 查询和删除订单的变化: - 现在,当 `orderId` 和 `origClientOrderId` 都不存在时,请求将被拒绝,并显示 `-1102` 而不是 `-1128`。 - 受影响的请求: - REST API: - `GET /api/v3/order` - `DELETE /api/v3/order` - WebSocket API: - `order.status` - `order.cancel` - FIX API: - OrderCancelRequest `` #### FIX API **通知:** 以下变更将于 2025 年 4 月 21 日期间发生。 - FIX API 会验证 `EncryptMethod(98)` 在登录 Logon `` 时是否为 0。 - FIX 订单接入会话的每个账户有 10 个并发 TCP 连接的限制。 - 现在强制实施连接速率限制.请注意,这些限制是针对账户和 IP 地址独立检查的。 - FIX 订单接入会话:在 30 秒内 15 次连接尝试的限制 - FIX Drop Copy 会话:在 30 秒内 15 次连接尝试的限制。 - FIX Market Data 会话:在 300 秒内 300 次连接尝试的限制。 - News `` 在 Headline 字段中包括了一个倒计时消息。 - 在本次更新完成后: 当服务器进入维护状态时,将向客户端**每隔 10 秒发送一条** `News` 消息,并**持续 10 分钟**。在10分钟过后,客户端将被注销,其会话将被关闭。 - OrderCancelRequest `` 和 OrderCancelRequestAndNewOrderSingle `` 现在允许使用 `orderId` 和 `clientOrderId`。 - [FIX 订单接入会话的 QuickFix 模式](/products/spot/fix/schemas/spot-fix-oe.xml) 已被更新,将支持保留优先级的修改订单请求(Order Amend Keep Priority)和新的 STP 方式 `DECREMENT`。 #### User Data Streams - **我们将弃用此功能: 通过使用 `listenKey` 来访问 wss://stream.binance.com:9443 以监听账户信息的。** - 以后但不是当前,此功将被能从我们的系统中删除。 - **您应该通过订阅 [在 WebSocket API 内的用户数据流](/products/spot/websocket-api/user-data-stream-requests) 来获得用户账户更新。** - 这个方式会提供稍好的性能 **(较低的延迟)**。 - 必须使用 Ed25519 API 密钥 - 在未来的更新中,将删除有关账户数据流的 WebSocket 基本访问地址的信息。 - 在未来的更新中,以下请求将被从文档中删除: - `POST /api/v3/userDataStream` - `PUT /api/v3/userDataStream` - `DELETE /api/v3/userDataStream` - `userDataStream.start` - `userDataStream.ping` - `userDataStream.stop` - [用户数据流](/products/spot/user-data-stream) 将保留可以接收的有效负载,以供您参考。 #### 将会发生的更改 以下变更将于**2025 年 4 月 24 日 07:00 UTC**发生: - ~~[保留优先级的修改订单请求(Order Amend Keep Priority)](/products/spot/faqs/order_amend_keep_priority) 将可以使用。 (请注意,必须在相应交易对上启用该功能后才能使用。)~~ - 新字段 `amendAllowed` 会出现在 Exchange Information 响应中。 - **2025-04-21 更新 :"保留优先级的修改订单请求" 的具体启用日期尚未确定** - REST API: `GET /api/v3/exchangeInfo` - WebSocket API: `exchangeInfo` - FIX API:新的 Order Entry 消息 **OrderAmendKeepPriorityRequest** 和 **OrderAmendReject** - REST API:`PUT /api/v3/order/amend/keepPriority` - WebSocket API: `order.amend.keepPriority` - ~~如果已在交易对上作了相应配置,那么 STP 方式 `DECREMENT` (递减) 将在 Exchange Information 中可见。~~ - **2025-04-21 更新 :"STP 方式 DECREMENT" 的具体启用日期尚未确定。** - 通过不仅仅使挂单或吃单过期,或无条件地让两种订单都过期,STP 递减会减少**两种**订单的可用数量,并将通过阻止匹配的数量来增加**两种**订单的 `prevented quantity` 值。 - 这将使可用数量较少的订单过期,因为(`filled quantity` \+ `prevented quantity`)等于 `order quantity`。如果两个订单的可用数量相等,那么两个订单都将过期。这种情况被称为“递减”,因为可用数量减少了。 - 使用 `orderId` 和 `origClientOrderId/cancelOrigClientOrderId` 来查询和/或取消订单: - 以前,当两个参数都提供时,在各个端点的上行为并不一致。 - 以后,当同时提供两个参数时,系统首先将会使用订单的 `orderId` 来搜索订单。如果订单被找到, `origClientOrderId`/`cancelOrigClientOrderId` 的值将会被用来验证被找到的订单。如果两个检测条件都通过,那么请求成功。如果两个条件都不满足,则请求将被拒绝。 - 受影响的请求: - REST API: - `GET /api/v3/order` - `DELETE /api/v3/order` - `POST /api/v3/order/cancelReplace` - WebSocket API: - `order.status` - `order.cancel` - `order.cancelReplace` - FIX API: - OrderCancelRequest `` - OrderCancelRequestAndNewOrderSingle `` - 使用 `listOrderId` 和 `listClientOrderId` 来取消订单: - 以前,当两个参数都提供时,在各个端点的上行为并不一致。 - 以后,当同时提供两个参数时,系统首先将会使用 `listOrderId` 来搜索订单列表。如果找到相应的订单列表,`listClientOrderId` 将会被用来验证被找到的订单列表。如果两个条件都不满足,请求将被拒绝。 - 受影响的请求 - REST API - `DELETE /api/v3/orderList` - WebSocket API - `orderList.cancel` - **SBE: 新模式 3:0 ([spot_3_0.xml](/products/spot/sbe/schemas/spot_3_0.xml)) 将可以使用。** - 现行模式 2:1 ([spot_2_1.xml](/products/spot/sbe/schemas/spot_2_1.xml)) 将会被废止并根据我们的废止政策,在6个月内停止使用。 - 请注意:在新模式被发布前,尝试使用模式 3:0 将导致错误。 - 3:0 中的更改: - 将会支持保留优先级的修改订单(Order Amend Keep Priority)请求: - 在 ExchangeInfoResponse 中添加了 `amendAllowed` 字段。 - 新消息 `OrderAmendmentsResponse` 和 `OrderAmendKeepPriorityResponse`。 - 所有的枚举类型都有了新变量:`NON_REPRESENTABLE`。这将用于将来,对新的枚举值进行编码。新模式的枚举类型可能会与 3:0 不兼容。 - 新增针对 `selfTradePreventionMode` 和 `allowedSelfTradePreventionModes` 的新枚举变量 `DECREMENT`。 - `symbolStatus` 枚举下的值 `AUCTION_MATCH`, `PRE_TRADING` 以及 `POST_TRADING` 已被删除。 - 字段 `usedSor`, `orderCapacity`, `workingFloor`,`preventedQuantity` 以及 `matchType` 将不再是可选的参数。 - 更改了 `ExecutionReportEvent`:现在,字段 `orderCreationTime` 是可选的。 - 通过 WebSocket API 来使用被废止的 2:1 版本的模式来侦听账户数据流: - `ListStatusEvent` 的字段 `listStatusType` 在 `Updated` 时,会呈现为 `ExecStarted`。升级到模式 3:0 来获取正确的值。 - `ExecutionReportEvent` 的字段 `selfTradePreventionMode` 在 `Decrement` 时,会呈现为 `None`。 这将只在 `executionType` 为 `TradePrevention` 时发生。 - `ExecutionReportEvent` 的字段 `orderCreationTime` 在没有值时将呈现为 -1。 - 所有低于 3:0 版本的模式不会支持对保留优先级修改订单请求(Order Amend Keep Priority)的响应,以及任何可能包含 STP 方式 `DECREMENT` 的响应(比如,Exchange Information,下单,取消订单或查询您的订单状态)。当响应无法用被指定的模式来表达时,系统将返回错误。 --- ### 2025-04-03 关注 SPOT 测试网的最新更新,将 WebSocket API 中的 URL 更新为 [SPOT Testnet] 的最新 URL(https://testnet.binance.vision/). --- ### 2025-03-31 - 添加了对取消订单性能的说明. --- ### 2025-03-10 - **注意:以下变更将于 2025 年 3 月 13 日 09:00 UTC 发生。** - FIX Drop Copy 会话的限制将会为**每分钟 60 条消息**。 - FIX Market Data 会话的限制将会为**每分钟 2000 条消息**。 - FIX API 文档已更新,以反映即将发生的更改。 - **SBE 市场数据流将于 2025 年 3 月 18 日 07:00 UTC 上线。** 这些流会提供较小的有效负载,将为部分对延迟比较敏感的市场数据连接提供更快的响应时间。 - 以 SBE 格式提供的数据流: - 实时:逐笔交易 - 实时:最优挂单信息 - 每 100 毫秒:增量深度信息 - 每 100 毫秒:有限档深度信息 - 有关更多信息,请参阅 [SBE 市场数据连流](/products/spot/sbe-market-data-streams)。 --- ### 2025-03-05 - **注意:以下变更将于 2025 年 3 月 10 日 12:00 UTC 发生。**
以下请求权重将从 2 增加到 4: - REST API: `GET /api/v3/aggTrade` - WebSocket API: `trades.aggregate` - REST 和 WebSocket API 的文档均已更新,以反映即将发生的更改。 --- ### 2025-02-12 - \*\*注意:这些更改将于 2025 年 2 月 26 日 05:00 UTC 生效。请确保在此之前您已下载最新的模式。 - `AggressorSide (2446)` 将在 FIX 市场数据流中提供。QuickFIX 模式 [file](/products/spot/fix/schemas/spot-fix-md.xml) 也已更新。 --- ### 2024-01-28 **注意: 该变更会在2025年2月3日到2025年2月14日之间逐步推出。** - **以下变更将会同时应用于用户数据流,WebSocket 行情接口 和 WebSocket API:** - WebSocket 服务将会**每20秒**发送发送 PING 消息而不是每3分钟。 - PONG 消息的延迟将会是每1分钟而不是每10分钟。 - 相关服务的更改所对应的文档都已经更新。 --- ### 2025-01-09 - FIX 市场数据将在 **January 16, 05:00 UTC** 提供。FIX API 文档已更新有关此功能。 - 请参阅此 [链接](/products/spot/fix/schemas/spot-fix-md.xml)以获取 FIX市场数据的 QuickFIX 模式。 --- ### 2024-12-17 常规更改: 系统现在在所有相关时间和/或时间戳的字段中支持微秒。微秒支持是 **opt-in**,默认情况下,请求和响应仍然使用毫秒。文档中的示例也在可预见的将来使用毫秒。 WebSocket Streams - 可以在连接 URL 中使用新的可选参数 `timeUnit` 来选择时间单位。 - 例如:`/stream?streams=btcusdt@trade&timeUnit=millisecond` - 支持的值为: - `MILLISECOND` - `millisecond` - `MICROSECOND` - `microsecond` - 如果未选择时间单位,则默认使用毫秒。 REST API - 可以在请求中发送新的可选报文头 `X-MBX-TIME-UNIT` 来选择时间单位。 - 支持的值: - `MILLISECOND` - `millisecond` - `MICROSECOND` - `microsecond` - 时间单位会影响 JSON 响应中的时间戳字段(例如,`time`、`transactTime`)。 - 无论时间单位如何,SBE 响应都将继续以微秒为单位。 - 如果未选择时间单位,则默认使用毫秒。 - 时间戳参数(例如 'startTime'、'endTime'、'timestamp)' 现在可以以毫秒或微秒为单位传递。 WebSocket API - 可以在连接 URL 中使用新的可选参数 `timeUnit` 来选择时间单位。 - 支持的值: - `MILLISECOND` - `millisecond` - `MICROSECOND` - `microsecond` - 时间单位会影响 JSON 响应中的时间戳字段(例如,`time`、`transactTime`)。 - 无论时间单位如何,SBE 响应都将继续以微秒为单位。 - 如果未选择时间单位,则默认使用毫秒。 - 时间戳参数(例如 `startTime`、`endTime`、`timestamp`) 现在可以以毫秒或微秒为单位传递。 User Data Streams - 可以在连接 URL 中使用新的可选参数 `timeUnit` 来选择时间单位。 - 支持的值 - `MILLISECOND` - `MICROSECOND` - `microsecond` - `millisecond` --- ### 2024-12-09 **注意:** 以下的变更会从**2024 年 12 月 12日**开始推出,可能需要大约一周的时间才能完成。 常规更改: - 现在会拒绝距离过去或未来太远的时间戳参数值。 - 时间戳数值在 2017 年 1 月 1 日之前(小于 1483228800000) - 时间戳数值超过当前时间 10 秒以后(例如,如果当前时间为 1729745280000, 那么使用 1729745290000 或更大是错误的) - 如果 `startTime` 和/或 `endTime` 的值超出范围,数值会被调整至正确的范围。 - 已将 `quote order quantity` (`origQuoteOrderQty`) 字段添加到原先没有该字段的响应中。请注意,对于下单相关的接口,该字段将仅针对 `newOrderRespType` 设置为 `RESULT` 或 `FULL` 的请求显示。 请参阅以下列表,以便了解因带有: `origQuoteOrderQty` 而受影响的请求: | 服务 | 请求 | | :------------ | :--------------------------------- | | REST | `POST /api/v3/order` | | | `POST /api/v3/sor/order` | | | `POST /api/v3/order/oco` | | | `POST /api/v3/orderList/oco` | | | `POST /api/v3/orderList/oto` | | | `POST /api/v3/orderList/otoco` | | | `DELETE /api/v3/order` | | | `DELETE /api/v3/orderList` | | | `POST /api/v3/order/cancelReplace` | | WebSocket API | `order.place` | | | `sor.order.place` | | | `orderList.place` | | | `orderList.place.oco` | | | `orderList.place.oto` | | | `orderList.place.otoco` | | | `order.cancel` | | | `orderList.cancel` | | | `order.cancelReplace` | SBE - 已发布新模式 2:1 [spot_2_1.xml](/products/spot/sbe/schemas/spot_2_1.xml)。 当前模式 2:0 [spot_2_0.xml](/products/spot/sbe/schemas/spot_2_0.xml) 将被弃用。根据我们的模式弃用政策,当前模式 2:0 会将在 6个月内从 API 中停用。 - 模式 2:1 是 模式 2:0 的向后兼容更新版本。当您请求模式 2:0 或 2:1 时,您将始终收到 2:1 格式的有效载荷。 - SBE 模式 2:1 中的更改: - 下单/取消订单响应中的新字段 `origQuoteOrderQty` (注意:使用 2:0 模式生成的解码器将忽略此字段): - `NewOrderResultResponse` - `NewOrderFullResponse` - `CancelOrderResponse` - `NewOrderListResultResponse` - `NewOrderListFullResponse` - `CancelOrderListResponse` - 仅限 WebSocket API:会话状态响应中的新字段 `userDataStream`: - `WebSocketSessionLogonResponse` - `WebSocketSessionStatusResponse` - `WebSocketSessionLogoutResponse` - 仅限 WebSocket API:在 User Data Stream 中会支持的新消息: - `UserDataStreamSubscribeResponse` - `UserDataStreamUnsubscribeResponse` - `BalanceUpdateEvent` - `EventStreamTerminatedEvent` - `ExecutionReportEvent` - `ExternalLockUpdateEvent` - `ListStatusEvent` - `OutboundAccountPositionEvent` WebSocket API - 您现在可以通过 WebSocket API 连接订阅账户数据流事件。 - 请注意:此功能仅适用于使用 Ed25519 API 密钥的用户。 - 请注意:如果您要订阅使用 SBE 格式的账户数据流,则需使用新的 SBE 模式 2:1。 - 新请求: - `userDataStream.subscribe` - `userDataStream.unsubscribe` - 对于 `session.logon`、 `session.status` 和 `session.logout` 的更改。 - 添加了一个新字段 `userDataStream`,用于显示账户数据流订阅是否处于活跃状态。 - 修复了在 `session.logon` 之后使用 `userDataStream.start` 不会收到新 listenKey 的错误。 User Data Stream - 仅限于 WebSocket API:当您从 websocket 会话注销或取消订阅账户数据流时,新事件 `eventStreamTerminated` 将会被发出。 - 当您的现货钱包余额被外部系统锁定/解锁时,新事件 `externalLockUpdate` 将会被发送。 FIX API - [模式](/products/spot/fix/schemas/spot-fix-oe.xml) 中已添加了新的管理消息 News \,该消息可用于所有 FIX 服务。收到此消息意味着您的连接即将关闭。 以下更改将在**2024 年 12 月 16 日到 2024 年 12 月 20日之间**发生: - 修复一个错误: `BUY` 方 OCO 单如果不提供 `stopPrice` 就会被阻止下单。 - 在 OCO 中添加了对 `TAKE_PROFIT` 和 `TAKE_PROFIT_LIMIT` 的支持。 - 以前,OCO 只能由以下订单类型组成: - `LIMIT_MAKER` + '`STOP_LOSS` - `LIMIT_MAKER` + `STOP_LOSS_LIMIT` - 现在,OCO 可以由以下订单类型组成: - `LIMIT_MAKER` + `STOP_LOSS` - `LIMIT_MAKER` + `STOP_LOSS_LIMIT` - `TAKE_PROFIT` + `STOP_LOSS` - `TAKE_PROFIT` + `STOP_LOSS_LIMIT` - `TAKE_PROFIT_LIMIT` + `STOP_LOSS` - `TAKE_PROFIT_LIMIT` + `STOP_LOSS_LIMIT` - 以下请求支持此功能: - `POST /api/v3/orderList/oco` - `POST /api/v3/orderList/otoco` - `orderList.place.oco` - `orderList.place.otoco` - `NewOrderList` - 错误代码 -1167 将在此次更新后过时,并将在以后的更新中从文档中删除。 --- ### 2024-10-18 Rest 和 WebSocket API: - 注意:根据我们的 SBE 政策,SBE 1:0 模式将于 2024 年 10 月 25 日被禁用 [废止后 6 个月](/products/spot/faqs/sbe_faq)。 - [面向生产的 SBE 生命周期](/products/spot/sbe/schemas/sbe_schema_lifecycle_prod.json) 已基于本次更改进行了更新。 --- ### 2024-10-17 Exchange Information 的更改 (即 REST API 的 [`GET /api/v3/exchangeInfo`](rest-api#exchangeInfo) 和 WebSocket API 的 [`exchangeInfo`](/products/spot/web-socket-api#exchangeInfo))。 - 新的可选参数 `showPermissionSets` 可用于隐藏 `permissionsSets` 的权限信息;这可用于减小消息大小。 - 新的可选参数 `symbolStatus` 用于仅显示具有指定状态的交易对。(例如:`TRADING`, `HALT`, `BREAK`) --- ### 2024-08-26 - [现货未成交订单计数规则](/products/spot/faqs/order_count_decrement) 已更新,解释了如何在下订单时减少未成交的订单数量。 --- ### 2024-08-16 **注意:** 以下的变更正在逐步推出,可能需要大约一周的时间才能完成。 常规更改: - 在市场流动性低的情况下,当提交包含 `quoteOrderQty` 的市价单(又名反向市价单)被拒绝时,添加了新的错误消息。 --- ### 2024-08-01 - [FIX API 和 Drop Copy 会话](/products/spot/fix-api) 将于 **8 月 8 日 05:00 UTC** 上线。 --- ### 2024-07-26 - [FIX API 和 Drop Copy 会话](/products/spot/fix-api) 已添加到文档中。 - 实时交换的发布日期尚未确定。 --- ### 2024-07-22 常规更改: - 修复了 klines 的时间戳不正确的 bug。 - REST API: 带有 `timeZone` 参数的 `GET /api/v3/klines` 和 `GET /api/v3/uiKlines` - WebSocket API: 带有 `timeZone` 参数的 `klines` 和 `uiKlines` - WebSocket Streams: `@kline_@+08:00` --- ### 2024-06-11 - 在 **6月11日 UTC 时间 05:00**,我们将开始推出新功能 `One-Triggers-the-Other` (OTO) 订单和 `One-Triggers-a-One-Cancels-The-Other` (OTOCO) 订单。(请注意,我们可能需要花几个小时来部署到所有服务器。) - 有关详细信息,请参阅以下页面: - REST API: - `POST /api/v3/orderList/oto` - `POST /api/v3/orderList/otoco` - WebSocket API: - `orderList.place.oto` - `orderList.place.otoco` - 在 **6月18日 UTC 时间 05:00**,我们将会把买方的订单 ID(`b`) 和卖方的订单 ID(`a`) 从交易流中删除(i.e. `@trade`)。 (请注意,我们可能需要花几个小时来部署到所有服务器。) - [WebSocket 行情接口](/products/spot/web-socket-streams) 与其相关的文档已经被更改了。 - 要监控您的订单是否是交易的一部分,请订阅 [用户数据流](/products/spot/user-data-stream)。 --- ### 2024-06-06 此功能将在**6月6日 UTC时间11:59**前上线。 REST API - `POST /api/v3/order/cancelReplace` 新加可选参数 `orderRateLimitExceededMode`。 WebSocket API - `order.cancelReplace` 新加可选参数 `orderRateLimitExceededMode`。 --- ### 2024-05-30 WebSocket Streams - Kline 新增加了对 UTC+8 时区的支持。(例如,`btcusdt@kline_1d@+08:00`) --- ### 2024-04-10 以下更新的生效时间已被推迟到 **4月25日 05:00 UTC** - "交易规范信息"响应中的交易对权限信息已从字段 `permissions` 移至字段 `permissionSets`。 - 字段 `permissions` 将为空,并将在未来版本中删除。 - 以前,`"permissions":["SPOT","MARGIN"]` 代表如果您的账户具有 `SPOT` 或 `MARGIN` 权限,您就可以在该交易对上下订单。现在,等效项是 `"permissionSets":[["SPOT","MARGIN"]]`(请注意额外的方括号)。`permissionSets`数组中的每个权限数组称为 "permission set"。 - 交易对的权限现在可以有更多权限类型。例如,`"permissionSets":[["SPOT","MARGIN"],["TRD_GRP_004","TRD_GRP_005"]]` 指示除了支持以上提过的权限集,也接受 `TRD_GRP_004` 或 `TRD_GRP_005`。交易对的 `permissionSets` 中可以有任意排列组合的权限集。 REST API - `otoAllowed` 现在将出现在 `GET /api/v3/exchangeInfo` 上,指示该交易品种是否支持 One-Triggers-the-Other (OTO) 订单。 WebSocket API - `otoAllowed` 现在将出现在 `exchangeInfo` 上,指示该交易品种是否支持 One-Triggers-the-Other (OTO) 订单。 SBE - 已发布新模式 2:0 [Spot_2_0.xml](/products/spot/sbe/schemas/spot_2_0.xml)。 当前模式 1:0 [spot_1_0.xml](/products/spot/sbe/schemas/spot_1_0.xml) 将被弃用,并从根据我们模式弃用政策,会将在 6 个月内下线。 - 在 REST API 或 WebSocket API 上使用模式 1:0 时,消息 `ExchangeInfoResponse` 中的组"权限"将始终为空。在升级到模式 2:0后, 您才可以在 `permissionSets` 组中查找权限信息。 - 最新模式仍将支持已弃用的 OCO 请求。 - 请注意,在模式 2:0 实际发布之前尝试使用它会导致错误。 --- ### 2024-04-02 **注意:** 以下的变更将逐步推出,并预计需要大约一周的时间完成。 - `GET /api/v3/account` 新加可选参数 `omitZeroBalances`,如果启用,则会隐藏所有零余额。 - `account.status` 新加可选参数 `omitZeroBalances`,如果启用,则会隐藏所有零余额。 - **以下请求的权重已从 10 增加到 25 (该规定将于2024年4月4日生效)**: - `GET /api/v3/trades` - `GET /api/v3/historicalTrades` - `trades.recent` - `trades.historical` User Data Stream - 如果 `listenKey` 过期,将在流中发出新事件 `listenKeyExpired`。 REST API - REST API 上现已弃用 `POST /api/v3/order/oco` 接口。从今开始,请使用新的 `POST /api/v3/orderList/oco` 接口(请注意,新接口使用不同的参数)。 WebSocket API - WebSocket API 上现已弃用 `orderList.place` 请求。从今开始,请使用新的 `orderList.place.oco` 请求(请注意,新接口使用不同的参数)。 **以下内容将于发布日期 _大约_ 一周后生效:** - "交易规范信息"响应中的交易对权限信息已从字段 `permissions` 移至字段 `permissionSets`。 - 字段 `permissions` 将为空,并将在未来版本中删除。 - 以前,`"permissions":["SPOT","MARGIN"]` 代表如果您的账户具有 `SPOT` 或 `MARGIN` 权限,您就可以在该交易对上下订单。现在,等效项是 `"permissionSets":[["SPOT","MARGIN"]]`(请注意额外的方括号)。`permissionSets`数组中的每个权限数组称为 "permission set"。 - 交易对的权限现在可以有更多权限类型。例如,`"permissionSets":[["SPOT","MARGIN"],["TRD_GRP_004","TRD_GRP_005"]]` 指示除了支持以上提过的权限集,也接受 `TRD_GRP_004` 或 `TRD_GRP_005`。交易对的 `permissionSets` 中可以有任意排列组合的权限集。 REST API - `otoAllowed` 现在将出现在 `GET /api/v3/exchangeInfo` 上,指示该交易品种是否支持 One-Triggers-the-Other (OTO) 订单。 WebSocket API - `otoAllowed` 现在将出现在 `exchangeInfo` 上,指示该交易品种是否支持 One-Triggers-the-Other (OTO) 订单。 SBE - 已发布新模式 2:0 [Spot_2_0.xml](/products/spot/sbe/schemas/spot_2_0.xml)。 当前模式 1:0 [spot_1_0.xml](/products/spot/sbe/schemas/spot_1_0.xml) 将被弃用,并从根据我们模式弃用政策,会将在 6 个月内下线。 - 在 REST API 或 WebSocket API 上使用模式 1:0 时,消息 `ExchangeInfoResponse` 中的组"权限"将始终为空。在升级到模式 2:0后, 您才可以在 `permissionSets` 组中查找权限信息。 - 最新模式仍将支持已弃用的 OCO 请求。 - 请注意,在模式 2:0 实际发布之前尝试使用它会导致错误。 ### 2024-02-28 **将于 2024 年 3 月 5 日生效。** 简单二进制编码 (SBE) 将部署到现货的 Rest API 和 WebSocket API 生产系统上。 更多关于SBE的信息, 请参考[常见问题解答 (FAQ)](/products/spot/faqs/sbe_faq) --- ### 2024-02-08 现货的 WebSocket API 现在在[测试网](https://testnet.binance.vision)上支持简单二进制编码(SBE)。 SBE 模式已经更新了 WebSocket API 元数据,但并没有增加 `schemaId` 或者 `version`。 - 仅在 REST API 上使用 SBE 的用户可以继续使用 SBE 模式 [`128b94b2591944a536ae427626b795000100cf1d`](/products/spot/sbe/schemas/spot_1_0.xml),或者更新到新提交的 SBE 模式。 - 希望在 WebSocket API 上使用 SBE 的用户,需要更新到[最新的 SBE 模式](/products/spot/sbe/schemas/spot_1_0.xml)。 SBE 的 [FAQ](/products/spot/faqs/sbe_faq) 已经更新。 --- ### 2023-12-08 简单二进制编码 (SBE) 已经在[现货测试网](https://testnet.binance.vision)上线。生产系统会在随后支持。更多关于SBE的信息, 请参考[常见问题解答 (FAQ)](/products/spot/faqs/sbe_faq) --- ### 2023-12-04 **注意**: 以下的变更将逐步推出,并预计需要大约一周的时间完成。 - 错误消息 `Precision is over the maximum defined for this asset.` 被改为 `Parameter '%s' has too much precision.` - 当参数的精度超出允许范围时,将返回此错误消息。例如,如果基础资产(`base asset`)精度为6,但是设置`quantity=0.1234567`,则会出现此错误消息。 - 这会影响所有具有以下参数的请求: - `quantity` - `quoteOrderQty` - `icebergQty` - `limitIcebergQty` - `stopIcebergQty` - `price` - `stopPrice` - `stopLimitPrice` - 现在,请求查询OCO开单时会正确返回**升序**的结果。这会影响以下请求: - REST API: `GET /api/v3/openOrderList` - WebSocket API: `openOrderList.status` - 现在,当指定`startTime`或`fromId`时,请求查询所有 OCO 订单会正确返回**升序**的结果。这会影响以下请求: - REST API: `GET /api/v3/allOrderList` - WebSocket API: `allOrderLists` - 修复了一个错误。订单查询请求不再会对新下的订单错误返回[`-2026 ORDER_ARCHIVED`](/products/spot/errors_CN#-2026-order_archived)错误。 - REST API: `GET /api/v3/order` - WebSocket API: `order.status` REST API - 新接口 `GET /api/v3/account/commission` - 新接口 `GET /api/v3/ticker/tradingDay` - `GET /api/v3/avgPrice` 新加字段 `closeTime`, 用于显示最后交易时间。 - `GET /api/v3/klines` 和 `/api/v3/uiKlines` 新加可选参数 `timeZone`。 - `POST /api/v3/order/test` 和 `POST /api/v3/sor/order/test` 新加可选参数 `computeCommissionRates`。 - 关于发送无效接口的变动: - 以前,如果查询一个不存在的端点(例如 `curl -X GET "https://api.binance.com/api/v3/exchangie"`),你会收到 HTTP 404 状态码,以及响应 "`

404 Not found

`"。 - 从现在开始,只有当接受请求头中包含`text/html`时,HTML响应才会出现在这种情况下。HTTP状态码将保持不变。 WebSocket API - 新请求 `account.commission` - 新增请求以允许会话身份验证: **(请注意,这些请求只能使用Ed25519密钥。)** - `session.logon` - `session.logout` - `session.status` - 新请求 `ticker.tradingDay` - 方法 `avgPrice` 新加字段 `closeTime`, 用于显示最后交易时间。 - 方法 `klines` 和 `uiKlines` 新加可选参数 `timeZone`。 - 方法 `order.test` 和 `sor.order.test` 新加可选参数 `computeCommissionRates`. - 修复了一个错误。之前在发送 ping 之前未经请求发送的 pongs 会导致断开连接。 WebSocket Streams - 新数据流 `@avgPrice` - 请求中的`id`现在支持和 WebSocket API 里`id`一样的值: - 64位有符号整数 (之前是无符号整数) - 字母数字字符串;最大长度36 - `null` - 修复了一个错误,之前在发送 ping 之前未经请求发送的 pongs 会导致断开连接。 User Data Streams - 当事件类型为 `executionReport`,而执行类型(x)为`TRADE_PREVENTION`时,字段`l`、`L`和`Y`现在将始终为0。新增字段`pl`、`pL`和`pY`将描述被阻止执行的数量、被阻止执行的价格和被阻止执行的名义金额。这些新字段显示了如果接收方订单没有启用自成交防止功能时,`l`、`L`和`Y`会是什么值。 **以下将在发布日期后*大约*一周后生效:** - 交易对权限将仅影响下单,而不影响取消订单。 - `permissions`仍然适用于撤消挂单再下单(Cancel-Replace orders)(比如,如果您的账户有使用此请求下单的权限,则将不允许取消操作)。 --- ### 2023-10-19 **从 2023-10-19 00:00 UTC 开始生效** - 调高如下接口的请求权重:
REST API WebSocket API 条件 之前的权重 调整后权重
GET /api/v3/trades trades.recent N/A 2 10
GET /api/v3/depth depth Limit 1-100 2 5
Limit 101-500 10 25
Limit 501-1000 20 50
Limit 1001-5000 100 250
--- ### 2023-10-03 - **下单量的退回(`Order decrement`)功能在 06:15 UTC上线.** - 此功能的更详细信息, 请参考 [FAQ](/products/spot/faqs/order_count_decrement) --- ### 2023-08-25 - Websocket API 的 `exchangeInfo` 中的 `RAW REQUESTS` 被移除,新增了用于表示WebSocket连接数限制的 `CONNECTIONS`。 **下面的变更会在UTC时间 2023-08-25 00:00 上线** - WebSocket API 的 `CONNECTIONS` 被调整为每5分钟300。 - REST API 和 WebSocket API 的 `REQUEST_WEIGHT` 调整为每分钟6,000。 - REST API 中的 `RAW_REQUESTS` 调整为每5分钟61,000。 - 之前连接到 WebSocket API 的权重为1。**现权重调整到 2**。 - 下表的 REST API 和 WebSocket API 请求的权重被调整: | 请求接口 | 之前请求权重 | 新请求权重 | | ------------------------------------------------------------------------------------------------------- | ------------ | ---------- | | `GET /api/v3/order`
`order.status` | 2 | 4 | | `GET /api/v3/orderList`
orderList.status | 2 | 4 | | `GET /api/v3/openOrders`
`openOrders.status` - **带 `symbol`** | 3 | 6 | | `GET /api/v3/openOrders`
`openOrders.status` - **不带 `symbol`** | 40 | 80 | | `GET /api/v3/openOrderList`
`openOrderLists.status` | 3 | 6 | | `GET /api/v3/allOrders`
`allOrders` | 10 | 20 | | `GET /api/v3/allOrderList`
`allOrderLists` | 10 | 20 | | `GET /api/v3/myTrades`
`myTrades` | 10 | 20 | | `GET /api/v3/myAllocations`
`myAllocations` | 10 | 20 | | `GET /api/v3/myPreventedMatches`
`myPreventedMatches` - **使用 `preventedMatchId`** | 1 | 2 | | `GET /api/v3/myPreventedMatches`
`myPreventedMatches` - **使用 `orderId`** | 10 | 20 | | `GET /api/v3/account`
`account.status` | 10 | 20 | | `GET /api/v3/rateLimit/order`
`account.rateLimits.orders` | 20 | 40 | | `GET /api/v3/exchangeInfo`
`exchangeInfo` | 10 | 20 | | `GET /api/v3/depth`
`depth` - **Limit 1-100** | 1 | 2 | | `GET /api/v3/depth`
`depth` - **Limit 101-500** | 5 | 10 | | `GET /api/v3/depth`
`depth` - **Limit 501-1000** | 10 | 20 | | `GET /api/v3/depth`
`depth` - **Limit 1001-5000** | 50 | 100 | | `GET /api/v3/aggTrades`
`trades.aggregate` | 1 | 2 | | `GET /api/v3/trades`
`trades.recent` | 1 | 2 | | `GET /api/v3/historicalTrades`
`trades.historical` | 5 | 10 | | `GET /api/v3/klines`
`klines` | 1 | 2 | | `GET /api/v3/uiKlines`
`uiKlines` | 1 | 2 | | `GET /api/v3/ticker/bookTicker`
`ticker.book` - **带 `symbol`** | 1 | 2 | | `GET /api/v3/ticker/bookTicker`
`ticker.book` - **不带 `symbol`** 或者 **带 `symbols`** | 2 | 4 | | `GET /api/v3/ticker/price`
`ticker.price` - **带 `symbol`** | 1 | 2 | | `GET /api/v3/ticker/price`
`ticker.price` - **不带 `symbol`** 或者 **带 `symbols`** | 2 | 4 | | `GET /api/v3/ticker/24hr`
`ticker.24hr` - **带 `symbol`** 或者 ** `symbols` 带 1-20 交易对** | 1 | 2 | | `GET /api/v3/ticker/24hr`
`ticker.24hr` - **带 `symbols` 21-100 交易对** | 20 | 40 | | `GET /api/v3/ticker/24hr`
`ticker.24hr` - **不带 `symbol` 或者 `symbols` 带 101 个或者更多交易对** | 40 | 80 | | `GET /api/v3/avgPrice`
`avgPrice` | 1 | 2 | | `GET /api/v3/ticker`
`ticker` | 2 | 4 | | `GET /api/v3/ticker`
`ticker` - 请求的最大权重 | 100 | 200 | | `POST /api/v3/userDataStream`
`userDataStream.start` | 1 | 2 | | `PUT /api/v3/userDataStream`
`userDataStream.ping` | 1 | 2 | | `DELETE /api/v3/userDataStream`
`userDataStream.stop` | 1 | 2 | --- ### 2023-08-08 智能订单路由(Smart Order Routing:SOR)添加到 API 中。您可以在[SOR 常见问题](/products/spot/faqs/sor_faq) 文档中找到更多详细信息。具体上线时间请关注相关公告。 REST API - `GET /api/v3/exchangeInfo` 变动: - 返回数据中添加新字段: `sors`, 用于描述交易中是否使用了 SOR。 - `GET /api/v3/myPreventedMatches` 变动: - 对于所有的 Prevented Matches, 返回数据中添加新字段 `makerSymbol` 。 - 为了在下单时使用 SOR 而添加的新接口: - `POST /api/v3/sor/order` - `POST /api/v3/sor/order/test` - 添加新接口: `GET /api/v3/myAllocations` WEBSOCKET API - `exchangeInfo` 变动: - 返回数据中添加新字段: `sors` , 用于描述交易中是否使用了 SOR。 - `myPreventedMatches` 变动: - 对于所有的 Prevented Matches, 返回数据中添加新字段 `makerSymbol`。 - 为了在下单时使用 SOR 而添加的新请求: - `sor.order.place` - `sor.order.test` - 添加新请求 `myAllocations` USER DATA STREAM - `executionReport` 变动: - 以下这些字段只适用于下单时使用 SOR 的情况: - 新字段 `b` 代表 `matchType` - 新字段 `a` 代表 `allocId` - 新字段 `k` 代表 `workingFloor` - 这个字段只适用于订单因为触发 STP 而将过期的情况: - 新字段 `Cs` 代表 `counterSymbol` --- ### 2023-07-18 - 现在支持使用 Ed25519 类型的 API key。(UI 会在本周发布更新支持) - Ed25519 API keys 是 RSA API keys 的替代品,使用非对称加密技术来验证您的 API 请求。 - **我们建议切换到 Ed25519** 以提高性能和安全性。
详情请参考[API Key 类型](/products/spot/faqs/api_key_types)。 - 文档已更新,包括了有关如何使用 Ed25519 key 对有效载荷进行签名的说明。 --- ### 2023-07-11 **注意:** 所有更改都将逐步推出,可能需要一周时间才能完成。 - 错误消息的变动: - 之前当发送重复交易对时,会返回错误信息: "Mandatory parameter symbols was not sent, was empty/null, or malformed." - 现在则返回消息: "Symbol is present multiple times in the list", with a new error code `-1151` - 受影响的接口: - `GET /api/v3/exchangeInfo` - `GET /api/v3/ticker/24hr` - `GET /api/v3/ticker/price` - `GET/api/v3/ticker/bookTicker` - `exchangeInfo` - `ticker.24hr` - `ticker.price` - `ticker.book` - 修复一个bug,当查询没有被存档的订单时候,可能返回错误消息称已经被存档。 Rest API - `GET /api/v3/account` 变动: - 返回数据中添加新字段 `preventSor`。 - 返回数据中添加用户ID的新字段 `uid`。 - `GET /api/v3/historicalTrades` 变动: - 鉴权类型从 `MARKET_DATA` 变更为 `NONE`。 - 不需要设置 `X-MBX-APIKEY` 到请求的header中。 Websocket API - `account.status` 变动: - 返回数据中添加新字段 `preventSor`。 - 返回数据中添加用户ID的新字段 `uid`。 - `trades.historical` 变动: - 鉴权类型从 `MARKET_DATA` 变更为 `NONE`。 - 请求中不需要设置 `apiKey`。 - 修改了几个bugs: 当下单时设置 `type=MARKET` 和 `quoteOrderQty`, 也被称为"反向市价单": - 当处于极端市场情况下, 订单不会返回部分成交,或者成交的数量为0甚至是负数。 - 当这种反向市价单的成交数量超过交易对的 `maxQty`, 订单会因为违反`MARKET_LOT_SIZE` 过滤器而被拒绝。 - 修复一个OCO订单的bug: 当使用 `trailingDelta` 时候, 当任何leg被触发时, `trailingTime` 值可能不正确。 - 这些接口的返回数据中添加新字段 `transactTime` : - `DELETE /api/v3/order` - `POST /api/v3/order/cancelReplace` - `DELETE /api/v3/openOrders` - `DELETE /api/v3/orderList` - `order.cancel` - `order.cancelReplace` - `openOrders.cancelAll` - `orderList.cancel` --- ### 2023-06-06 - 为了提供系统的冗余能力,新加一个API接入网址: **https://api-gcp.binance.com/** - 此网址利用了 GCP (Google Cloud Platform) 的CDN,可能在性能上比`api1`-`api4`要慢。 --- ### 2023-05-26 **注意:** 所有更改都将逐步推出到我们的所有服务器,并可能需要一周时间才能完成。 - 以下基本接口可能会提供比 **https://api.binance.com** 更好的性能但其稳定性略为逊色: - **https://api1.binance.com** - **https://api2.binance.com** - **https://api3.binance.com** - **https://api4.binance.com** --- ### 2023-05-24 - **以前的市场数据 URL 已不建议使用。请立即更新您的代码,以防止来自我们的服务被中断** - 来自 `data.binance.com` 的 API 市场数据现在可以从 `data-api.binance.vision` 访问。 - 来自 `data-stream.binance.com` 的 Websocket 市场数据现在可以从 `data-stream.binance.vision` 访问。 --- ### 2023-03-13 **注意:** 所有更改都将逐步推出到我们的所有服务器,并可能需要一周时间才能完成。 - 某些问题的错误消息已经改进,以便更轻松地进行解决。
情况 之前的错误消息 新错误消息
由于交易权限被禁用,账户无法下订单或取消订单。 This action is disabled on this account. This account may not place or cancel orders.
当配置在交易对上的权限与账户上的权限不匹配时。 This symbol is not permitted for this account.
当账户在其没有权限的交易对上下订单时。 This symbol is restricted for this account.
symbol 不在 TRADING 时下订单。 Unsupported order combination. This order type is not possible in this trading phase.
在不支持 IOCFOK 的交易阶段上使用 timeinForce = IOCFOK 下订单时。 Limit orders require GTC for this phase.
- 更正了查询归档订单的错误消息: - 之前,如果查询了一个归档订单(即状态为 `CANCELED` 或 `EXPIRED`,`executedQty` == 0 而且最后的更新在 90 天以前),错误消息将是: ```json { "code": -2013, "msg": "Order does not exist." } ``` - 现在,错误消息为: ```json { "code": -2026, "msg": "Order was canceled or expired with no executed qty over 90 days ago and has been archived." } ``` - API 请求使用 `startTime` 和 `endTime` 的行为: - 之前,如果 `startTime` == `endTime`,一些请求会失败。 - 现在,所有接受 `startTime` 和 `endTime` 的 API 请求会允许这些参数相等。这适用于以下接口: - Rest API - `GET /api/v3/aggTrades` - `GET /api/v3/klines` - `GET /api/v3/allOrderList` - `GET /api/v3/allOrders` - `GET /api/v3/myTrades` - Websocket API - `trades.aggregate` - `klines` - `allOrderList` - `allOrders` - `myTrades` - 如果用户的IP地址因违反 IP 速率限制(状态码为 `418`)而被禁止,那么连接到 WebSocket API 的用户将被断开连接。 虽然以下更改将在发布日期后 **大约一周内生效**,但是与其相关的文档已经被更改了: - 过滤器评估的更改: - 之前的行为: `LOT_SIZE` 和 `MARKET_LOT_SIZE` 要求 (`quantity` - `minQty`) % `stepSize` == 0。 - 新行为: 现在已更改为 (`quantity` % `stepSize`) == 0。 - 使用 `quoteOrderQty` 的 `MARKET`订单的错误修复: - 之前的行为: 订单的状态将始终为 `FILLED`,即使订单没有完全成交。 - 新行为: 如果订单由于流动性不足而没有完全成交,则订单状态将为 `EXPIRED`,仅当订单完全成交时状态为 `FILLED`。 REST API - `DELETE /api/v3/order` 和 `POST /api/v3/order/cancelReplace` 的更改: - 新的可选参数 `cancelRestrictions`,该参数用于决定是否能成功取消状态为 `NEW` 或 `PARTIALLY_FILLED` 的订单。 - 如果由于 `cancelRestrictions` 而取消订单失败,错误将是: ```json { "code": -2011, "msg": "Order was not canceled due to cancel restrictions." } ``` WEBSOCKET API - `order.cancel` 和 `order.cancelReplace` 的更改: - 新的可选参数 `cancelRestrictions`,该参数用于决定是否能成功取消状态为 `NEW` 或 `PARTIALLY_FILLED` 的订单。 - 如果由于 `cancelRestrictions` 而取消订单失败,错误将是: ```json { "code": -2011, "msg": "Order was not canceled due to cancel restrictions." } ``` --- ### 2023-02-17 **WebSocket频率限制变动** `WS-API` 和 `Websocket Stream` 现在限制每个IP地址、每5分钟可以发送连接请求的上限是300次。 --- ### 2023-01-26 根据此[公告](https://www.binance.com/zh-CN/support/announcement/%E5%B9%A3%E5%AE%89%E7%8F%BE%E8%B2%A8%E6%8E%A8%E5%87%BAapi%E8%87%AA%E6%88%90%E4%BA%A4%E9%A0%90%E9%98%B2-stp-%E5%8A%9F%E8%83%BD-312fd0112fb44635b397c116e56d8f84),Self-Trade Prevention 将在 **2023-01-26 08:00 UTC** 发布。 --- ### 2023-01-23 - 添加了新的 API 集群 https://api4.binance.com --- ### 2023-01-19 实际发布日期待定 **新功能**:Self-Trade Prevention(STP)会添加到系统中。此功能将阻止订单与来自同一账户或者同一 `tradeGroupId` 账户的订单交易。 请使用现货 REST API 的 `GET /api/v3/exchangeInfo` 或 Websocket API 的 `exchangeInfo` 看 STP 的状态。 ```javascript { "defaultSelfTradePreventionMode": "NONE", // selfTradePreventionMode 的默认值 "allowedSelfTradePreventionModes": [ // selfTradePrevention 的可用模式 "NONE", "EXPIRE_TAKER", "EXPIRE_BOTH", "EXPIRE_MAKER" ] } ``` 在[STP 常见问题](/products/spot/faqs/stp_faq) 文档中可以找到更多其它关于 STP 功能的详细信息。 REST API - 新的订单状态:`EXPIRED_IN_MATCH` - 订单由于 STP 触发而过期。 - 新的接口: - `GET /api/v3/myPreventedMatches` - 获取由于 STP 触发而过期的订单。 - 新的可选参数 `selfTradePreventionMode` 已添加到以下的接口: - `POST /api/v3/order` - `POST /api/v3/order/oco` - `POST /api/v3/cancelReplace` - 如果有预防自我交易(Prevented Match),所有下单相关的接口会出现新字段: - `tradeGroupId` - 仅当账户配置为 `tradeGroupId` 时才会出现。 - `preventedQuantity` - 被防止交易的订单数量。 - `preventedMatches` 数组会有以下的字段: - `preventedMatchId` - `makerOrderId` - `price` - `takerPreventedQuantity` - 仅当 `selfTradePreventionMode` 设置为 `EXPIRE_TAKER` 或 `EXPIRE_BOTH` 时才会出现。 - `makerPreventedQuantity` - 仅当 `selfTradePreventionMode` 设置为 `EXPIRE_MAKER` 或 `EXPIRE_BOTH` 时才会出现。 - 如果订单因 STP 触发而过期,以下查询订单接口的响应中可以出现新的字段 `preventedMatchId` 和 `preventedQuantity`: - `GET /api/v3/order` - `GET /api/v3/openOrders` - `GET /api/v3/allOrders` WEBSOCKET API - 新的订单状态:`EXPIRED_IN_MATCH` - 订单由于 STP 触发而过期。 - 新的请求:`myPreventedMatches` - 获取由于 STP 触发而过期的订单。 - 新的可选参数 `selfTradePreventionMode` 已添加到以下的请求: - `order.place` - `orderList.place` - `order.cancelReplace` - 如果有防止自我交易,将为所有下订单的请求会出现的新响应: - `tradeGroupId` - 仅当账户配置为 `tradeGroupId` 时才会出现。 - `preventedQuantity` - 被防止交易的订单数量。 - `preventedMatches` 数组会有以下的字段: - `preventedMatchId` - `makerOrderId` - `price` - `takerPreventedQuantity` - 仅当 `selfTradePreventionMode` 设置为 `EXPIRE_TAKER` 或 `EXPIRE_BOTH` 时才会出现。 - `makerPreventedQuantity` - 仅当 `selfTradePreventionMode` 设置为 `EXPIRE_MAKER` 或 `EXPIRE_BOTH` 时才会出现。 - 如果订单因 STP 触发而过期,以下查询订单接口的响应中可以出现新的字段 `preventedMatchId` 和 `preventedQuantity`: - `order.status` - `openOrders.status` - `allOrders` USER DATA STREAM - 新的执行类型:`TRADE_PREVENTION`。 - `executionReport` 的新字段(这些字段只会在订单因 STP 触发而过期时出现): - `u` - `tradeGroupId` - `v` - `preventedMatchId` - `U` - `counterOrderId` - `A` - `preventedQuantity` - `B` - `lastPreventedQuantity` --- ### 2022-12-28 - 现货 WebSocket API 文档已更新,添加了如何使用 RSA key 签署请求。 --- ### 2022-12-26 - 现货的 Websocket API 发布到生产系统中。 - 现货的 Websocket API 可以通过URL: `wss://ws-api.binance.com/ws-api/v3` 来访问。 --- ### 2022-12-15 - 添加新的RSA签名验证方式 - 文档已更新以显示如何创建 RSA keys。 - 建议在生成 API key 时使用 RSA keys。 - 我们接受`PKCS#8`(BEGIN PUBLIC KEY)。 - 稍后将添加有关如何上传 RSA public key 的更多详细信息。 - 现货 WebSocket API 现在可以在 SPOT 测试网上使用。 - WebSocket API 允许通过 WebSocket 连接下订单、取消订单等。 - WebSocket API 是一个 **独立** 于 WebSocket 市场数据流的服务。 即,下订单和收听市场数据需要两个独立的 WebSocket 连接。 - WebSocket API 与 REST API 相同过滤器和速率限制规则。 - WebSocket API 与 REST API 提供相同的功能,接受相同的参数,返回相同的状态和错误代码。 **WEBSOCKET API 会晚些时候在生产系统中可用。** --- ### 2022-12-13 REST API 错误代码 `-1003` 的一些错误消息已更改 - 之前的错误消息: `Too much request weight used; current limit is %s request weight per %s %s. Please use the websocket for live updates to avoid polling the API.` 改成了: ``` Too much request weight used; current limit is %s request weight per %s. Please use WebSocket Streams for live updates to avoid polling the API. ``` - 之前的错误消息: `Way too much request weight used; IP banned until %s. Please use the websocket for live updates to avoid bans.` 改成了: ``` Way too much request weight used; IP banned until %s Please use WebSocket Streams for live updates to avoid bans. ``` --- ### 2022-12-05 **备注:** 这些更新正在逐步部署到我们所有的服务器,大约需要一周时间才能完成。 WEBSOCKET - `!bookTicker` 在 **2022-12-07** 下线。 请改用按 symbol 的最优挂单信息的数据流(`@bookTicker`)。 - 可以通过一个连接订阅多个 `@bookTicker` 数据流。 (例如`wss://stream.binance.com:9443/stream?streams=btcusdt@bookTicker/bnbbtc@bookTicker`) REST API - 新的错误代码 `-1135` - 如果参数是无效的 JSON 格式,则会出现此错误代码。 - 新的错误代码 `-1108` - 如果发送的参数的值太长,可能会导致溢出,则会发生此错误。 - 此错误代码可能出现在以下接口: - `POST /api/v3/order` - `POST /api/v3/order/cancelReplace` - `POST /api/v3/order/oco` - `GET /api/v3/aggTrades` 更新 - 之前的规则: `startTime` 和 `endTime` 必须结合使用,并且只能相隔一个小时。 - 新的规则: `startTime` 和 `endTime` 可以单独使用,一个小时的限制已被取消。 - 仅使用 startTime 时,如果limit的值为N, 将返回从此时间开始的N条交易。 - 仅使用 endTime 时,如果limit的值为N, 将返回到此时间的N条交易. - 如果不提供 `limit`,无论是组合使用还是单独发送,服务器端都将使用默认的 `limit`。 - `GET /api/v3/myTrades` 更新 - 修复了 `symbol` + `orderId` 组合会返回所有交易,可能会超过`LIMIT`的默认值`500`。 - 之前的行为: API 将根据发送的参数组合发送特定的错误消息。 例如: ```json { "code": -1106, "msg": "Parameter X was sent when not required." } ``` - 新的行为: 如果接口不支持可选参数组合,那么服务器会返回一般性的错误: ```json { "code": -1128, "msg": "Combination of optional parameters invalid." } ``` - 添加一个新的参数组合: `symbol` + `orderId` + `fromId`. - 下面的参数组合不再支持: - `symbol` + `fromId` + `startTime` - `symbol` + `fromId` + `endTime` - `symbol` + `fromId` + `startTime` + `endTime` - 当前支持的所有参数组合: - `symbol` - `symbol` + `orderId` - `symbol` + `startTime` - `symbol` + `endTime` - `symbol` + `fromId` - `symbol` + `startTime` + `endTime` - `symbol`+ `orderId` + `fromId` **备注:** 这些新字段将在发布日期后大约一周出现。 - `GET /api/v3/exchangeInfo` 更新 - 新字段 `defaultSelfTradePreventionMode` 和 `allowedSelfTradePreventionModes` - 下单,查询订单和撤销订单接口的更新: - 响应中会出现新的字段 `selfTradePreventionMode`。 - 以下接口会受到影响: - `POST /api/v3/order` - `POST /api/v3/order/oco` - `POST /api/v3/order/cancelReplace` - `GET /api/v3/order` - `DELETE /api/v3/order` - `DELETE /api/v3/orderList` - `GET /api/v3/account` 更新 - 响应中会出现新的字段 `requireSelfTradePrevention`. - 以下接口的响应中会出现新字段 `workingTime`(指示订单何时添加到了订单簿): - `POST /api/v3/order` - `GET /api/v3/order` - `POST /api/v3/order/cancelReplace` - `POST /api/v3/order/oco` - `GET /api/v3/order` - `GET /api/v3/openOrders` - `GET /api/v3/allOrders` - 如果`trailingDelta`作为参数提供给了`TAKE_PROFIT`,`TAKE_PROFIT_LIMIT`,`STOP_LOSS`或 `STOP_LOSS_LIMIT`的订单,那么下面接口中会出现`trailingTime`, 用来表示追踪单被激活和跟踪价格变化的时间: - `POST /api/v3/order` - `GET /api/v3/order` - `GET /api/v3/openOrders` - `GET /api/v3/allOrders` - `POST /api/v3/order/cancelReplace` - `DELETE /api/v3/order` - 字段 `commissionRates` 会在 `GET /api/v3/acccount` 的响应中出现。 USER DATA STREAM - eventType `executionReport` 有新的字段 - `V` - `selfTradePreventionMode` - `D` - `trailing_time` (追踪单被激活时会出现) - `W` - `workingTime` (如果 `isWorking`=`true` 会出现) --- ### 2022-12-02 - 新增一个用于访问市场信息的RESTful API URL: `https://data.binance.com`. - 新增一个用于访问市场信息的WebSocket URL: `wss://data-stream.binance.com`. --- ### 2022-09-30 `!bookTicker`的WebSocket推送的变更. - 全市场最优挂单信息推送(`!bookTicker`)计划在**2022年11月**下线, 具体下线的时间会在后面通告. - 请使用按Symbol的最优挂单信息推送(`@bookTicker`). - 多个 `@bookTicker` 可以订阅在一个WebSocket连接上. - 比如 `wss://stream.binance.com:9443/stream?streams=btcusdt@bookTicker/bnbbtc@bookTicker` --- ### 2022-09-15 这些变动会是滚动发布,可能需要几天才会部署到所有服务器. - 接口 `GET /api/v3/exchangeInfo` 的变动 - 添加一个新的参数 `permissions` , 用于查询适用于相应权限的所有交易对. - 如果查询时不提供此参数, 则默认值是 `["SPOT","MARGIN","LEVERAGED"]`. - 这表示如果请求 `GET /api/v3/exchangeInfo` 时候没有任何参数, 则会返回拥有权限是 `SPOT`, `MARGIN` , `LEVERAGED` 的交易对. - 如果要查询其他交易权限, 比如`TRD_GRP_004`等, 需要在查询参数里设置(比如`permissions`=`TRD_GRP_004`). - 此参数不可以同时和 `symbol` 或者 `symbols` 使用. --- ### 2022-08-23 此变动会滚动发布, 可能需要一段时间更新到所有服务器上。 - 接口 `GET /api/v3/ticker` 与 `GET /api/v3/ticker/24hr` 变动 - 添加新可选参数 `type` - `type` 可接受的参数值有 `FULL` 与 `MINI` - `FULL` 是默认值, 也是原来接口所返回的响应 - `MINI` 省略了以下字段: `priceChangePercent`, `weightedAvgPrice`, `bidPrice`, `bidQty`, `askPrice`, `askQty` 与 `lastQty` - 添加新错误代码 `-1008` - 每当服务器的请求超载时都会发送此消息 - 此错误代码只会在 SPOT API 里出现 - 接口 `GET /api/v3/account` 添加新参数 `brokered` - 添加新接口: `GET /api/v3/uiKlines` - 添加新k线间隔: `1s` --- ### 2022-08-08 REST API - 接口 `POST /api/v3/order` 与 `POST /api/v3/order/cancelReplace` 变动 - 添加新可选参数 `strategyId` 与 `strategyType` - `strategyId` 是用于将订单标识为某策略的参数。 - `strategyType` 是用于标识在执行的策略。(例如:如果所有订单属于现货网格策略,订单可设置为`strategyType=1000000`) - 接口 `POST /api/v3/order/oco` 变动 - 添加新可选参数 `limitStrategyId`, `limitStrategyType`, `stopStrategyId`, `stopStrategyType` - 这些是OCO订单里两个leg的策略元数据 - `limitStrategyType` 和 `stopStrategyType` 都不能低于 `1000000` - 接口 `GET /api/v3/order`, `GET /api/v3/openOrders` 与 `GET /api/v3/allOrders` 变动 - 新增参数 `strategyId` 与 `strategyType` 必须在下单时填上字段才会在回应JSON里返回 - 接口 `DELETE /api/v3/order` 与 `DELETE /api/v3/openOrders` 变动 - 新增参数 `strategyId` 与 `strategyType` 必须在下单时填上字段才会在回应JSON里返回 USER DATA STREAM - eventType `executionReport` 新增参数 - `j` 代表 `strategyId` - `J` 代表 `strategyType` - 必须在下单时填上字段才会在回应里返回 --- ### 2022-06-20 接口 `GET /api/v3/ticker` 变动 - 权重从每`symbol` 5 降低到 2. - 每次请求最多可以有100个交易对. - 如果`symbols`请求超过100个交易对, 会收到如下错误信息: ```json { "code": -1101, "msg": "Too many values sent for parameter 'symbols', maximum allowed up to 100." } ``` - 单请求的权重上限为100. - 比如,如果请求的交易对超过50个,请求的权重是100. --- ### 2022-06-15 **注意:** 此变动不会立刻可用, 会在后面几天上线。 SPOT API - 添加新接口 `GET /api/v3/ticker` - 基于 `windowSize` 返回最近的价格变动。 - 无需像 `GET /api/v3/ticker/24hr` 提供symbols参数。 - 如果不提供 `windowSize` 参数,默认值是`1d`。 - 响应和 `GET /api/v3/ticker/24hr` 相似,但不包括以下数据:`prevClosePrice`, `lastQty`, `bidPrice`, `bidQty`, `askPrice`, `askQty` - 添加新接口 `POST /api/v3/order/cancelReplace` - 撤消当前的挂单并在同样的交易对上下新订单。 - 过滤器会在**撤单前**做判断。 - 例如,`MAX_NUM_ORDERS` 是 10,如果目前挂单也是10,调用 `POST /api/v3/order/cancelReplace`会失败。撤单与下单的操作都不会被执行。 - 更新将在几天后上线,升级完毕后才会开启此功能。 - `GET /api/v3/exchangeInfo` 在`symbols`列表里返回新数据`cancelReplaceAllowed`。 - 添加新的过滤器 `NOTIONAL` - 基于`minNotional` 与 `maxNotional` 值来限制名义价值 (`price * quantity`) - 添加新的过滤器 `EXCHANGE_MAX_NUM_ICEBERG_ORDERS` - 账号最大冰山挂单数 WEBSOCKETS - 新的symbol ticker流, 可以选择 `1h` 或者 `4h`时间窗口: - 单个交易对: `@ticker_` - 市场所有交易对: `!ticker_@arr` --- ### 2022-05-23 - Order Book 深度的变动 - 之前深度的数量在一些极端情况下会出现负数. - 之后深度数量不会溢出, 而是限制在64位的最大值, 这表示深度的数量达到,或者超过了最大值. 最大值和交易对的`base asset`的精度有关. 比如如果精度是8位小数,最大值则为92,233,720,368.54775807. - 原有的深度价位, 在修复上线后, 需要价位上有变动, 才能体现新的修复. - 哪里有影响? - 现货深度接口 - `GET /api/v3/depth` - Websocket Streams - `@depth` - `@depth@100ms` - `@depth` - `@depth@100ms` - `MAX_POSITION` 的更新 - 如果一个订单的数量(`quantity`) 可能导致持有仓位溢出, 会触发过滤器 `MAX_POSITION`. - `GET api/v3/aggTrades` 更新 - 如果同时提供 `startTime` 和 `endTime`, 旧的记录会返回. - 如果接口 `GET /api/v3/myTrades` 中没有提供参数 `symbol`, 错误消息变为: ```json { "code": -1102, "msg": "Mandatory parameter 'symbol' was not sent, was empty/null, or malformed." } ``` - 下面的接口提供参数 `symbols` 用于查询多个symbol. - `GET /api/v3/ticker/24hr` - `GET /api/v3/ticker/price` - `GET /api/v3/ticker/bookTicker` - 上面接口的权重取决于请求 `symbols` 的数量, 具体请看下面的列表: | 接口 | Symbols的数量 | 权重 | | ------------------------------- | ------------- | ---- | | `GET /api/v3/ticker/price` | Any | 2 | | `GET /api/v3/ticker/bookTicker` | Any | 2 | | `GET /api/v3/ticker/24hr` | 1-20 | 1 | | `GET /api/v3/ticker/24hr` | 21-100 | 20 | | `GET /api/v3/ticker/24hr` | >= 101 | 40 | --- ### 2022-04-13 REST API - 现货交易支持追踪止损(Trailing Stop)订单. - 追踪止损通过一个新的参数`trailingDelta`来设置基于市场价的一个自动触发价格. - 只适用于订单类型: `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, `TAKE_PROFIT_LIMIT`. - 参数`trailingDelta`的单位为基点(BIPS). - 比如一个`STOP_LOSS`卖单设置`trailingDelta`为100, 那么订单会在当前市场价格从下单后的最高点下降1%的时候被触发。(100 / 10,000 => 0.01 => 1%) - 用于OCO订单的时候, 如果市场变动触发了`STOP_LOSS`订单, 那么此止损订单变成追踪止损订单. - 当参数`trailingDelta`和`stopPrice`一起使用时, 一旦`stopPrice`条件被触发,系统会开始追踪当前的价格变动. 从`stopPrice`价格开始,到基于`trailingDelta`值之间变动. - 如果没有提供`stopPrice`, 系统开始追踪价格从最新价到基于`trailingDelta`值之间变动. - `POST /api/v3/order` 变动 - 添加新可选参数 `trailingDelta` - `POST /api/v3/order/test` 变动 - 添加新可选参数 `trailingDelta` - `POST /api/v3/order/oco` 变动 - 添加新可选参数 `trailingDelta` - 添加新的过滤器 `TRAILING_DELTA` - 用于限定 `trailingDelta` 的最大和最小值. USER DATA STREAM - User Data Stream 的`executionReport`添加新参数 - "d" 代表`trailingDelta` --- ### 2022-04-12 **Note:** 下面的变更会在后面几天上线. - `GET api/v3/allOrders` 如果没有提供 `symbol`, 则返回错误信息: ```json { "code": -1102, "msg": "Mandatory parameter 'symbol' was not sent, was empty/null, or malformed." } ``` - 修复一个错误信息中的拼写错误。 如果账号被禁用了相应的权限(比如提款,交易等), 则服务器返回错误: ```json "This action is disabled on this account." ``` - 在市场数据(market data)审计中,发现了一些现货的聚合交易数据(aggTrades)中的问题. - 丢失的记录已经被补回. - 重复的记录被标记成无效,具体的值设置成如下: - p = '0' // price - q = '0' // qty - f = -1 // first_trade_id - l = -1 // last_trade_id --- ### 2022-02-28 - 在接口`GET /api/v3/exchangeInfo`中添加新字段`allowTrailingStop`. --- ### 2022-02-24 - 现货规则`PRICE_FILTER`里面的 `(price-minPrice) % tickSize == 0` 改成 `price % tickSize == 0` - 新添加了一个规则 `PERCENT_PRICE_BY_SIDE`. - 接口 `GET api/v3/depth` 的变动: - `limit` 原先必须是固定值(比如 5, 10, 20, 50, 100, 500, 1000, 5000), 现在可以是在1-5000之间的任意的正整数, 服务器会返回指定的limit数量。(比如如果设置limit=3, 会返回前3个最好的卖价和买价) - 如果`limit`超过5000, 服务器也最多返回5000条记录. - 相应的, 此接口的权重变成: | Limit | Request Weight | | --------- | -------------- | | 1-100 | 1 | | 101-500 | 5 | | 501-1000 | 10 | | 1001-5000 | 50 | - GET `api/v3/aggTrades` 接口的变动: - 当同时提供参数 `startTime` 和 `endTime`, 最旧的订单会优先返回. --- ### 2021-12-29 - 移除交易对类型枚举 - 新增权限枚举 --- ### 2021-11-01 - 新增接口 `GET /api/v3/rateLimit/order` - 回传用户在当前时间区间内的下单总数 - 此接口的权重为20 --- ### 2021-09-14 - 添加一个基于OpenAPI规范的RESTful API接口定义的[YAML文件](https://github.com/binance/binance-api-swagger) --- ### 2021-08-12 - GET `api/v3/myTrades` 添加新的参数 `orderId` --- ### 2021-05-12 - 在文档中添加接口的数据来源说明 - 在每个接口中添加相应的数据源 - GET `api/v3/exchangeInfo` 现在支持单个或者多个交易对查询 --- ### 2021-04-26 从 **April 28, 2021 00:00 UTC** 开始,下面接口的权重有如下变动: - `GET /api/v3/order` 权重改为 2 - `GET /api/v3/openOrders` 权重改为 3 - `GET /api/v3/allOrders` 权重改为 10 - `GET /api/v3/orderList` 权重改为 2 - `GET /api/v3/openOrderList` 权重改为 3 - `GET /api/v3/account` 权重改为 10 - `GET /api/v3/myTrades` 权重改为 10 - `GET /api/v3/exchangeInfo` 权重改为 10 --- ### 2021-01-01 **USER DATA STREAM** - 移除`outboundAccountInfo`事件. --- ### 2020-11-27 为了优化性能,除了当前的`api.binance.com`,新加了一些API的集群。如果访问`api.binance.com`有性能问题,也可以尝试访问: - https://api1.binance.com/api/v3/* - https://api2.binance.com/api/v3/* - https://api3.binance.com/api/v3/* ### 2020-09-09 用户数据 STREAM - `outboundAccountInfo`事件不再推荐使用。 - `outboundAccountInfo`事件以后会被删除(具体时间未定) **请使用 `outboundAccountPosition` 事件.** - `outboundAccountInfo`只推送余额不为0,以及余额刚变成0的资产。 --- ### 2020-05-01 - 从2020-05-01 UTC 00:00开始, 所有交易对都会有最多200个挂单的限制, 体现在过滤器[MAX_NUM_ORDERS](./filters_CN#max_num_orders)上. - 已经存在的挂单不会被移除或者撤销。 - 单交易对(`symbol`)的挂单数量达到或超过200的账号, 无法在此交易对上下新的订单, 除非挂单数量低于200。 - OCO订单在被触发成`LIMIT`订单, 或者被触发成`STOP_LOSS`(或者`STOP_LOSS_LIMIT`)前, 被认为是2个挂单量. 一旦OCO订单被触发, 就只被算作一个挂单。 --- ### 2020-04-23 WEB SOCKET 连接限制 - Websocket服务器每秒最多接受5个消息。消息包括: - PING帧 - PONG帧 - JSON格式的消息, 比如订阅, 断开订阅. - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅 **1024** 个Streams。 --- ### 2020-03-24 - 添加过滤器 `MAX_POSITION`. - 这个过滤器定义账户允许的基于`base asset`的最大仓位。一个用户的仓位可以定义为如下资产的总和: - `base asset`的可用余额 - `base asset`的锁定余额 - 所有处于open的买单的数量总和 - 如果用户的仓位大于最大的允许仓位,买单会被拒绝。 --- ### 2018-11-13 REST API - 账户交易权限被禁时允许进行撤单操作。 - 增加了新的过滤器: `PERCENT_PRICE`, `MARKET_LOT_SIZE`, `MAX_NUM_ICEBERG_ORDERS`。 - 增加了 `RAW_REQUESTS` 频率限制. 该限制仅统计请求次数,不统计请求权重。 - /api/v3/ticker/price 无symbol参数时,权重增加到2。 - /api/v3/ticker/bookTicker 无symbol参数时,权重增加到2。 - DELETE /api/v3/order 现在会返回订单撤销前所处的末次状态。 - `MIN_NOTIONAL` 新增两个参数: `applyToMarket` (是否对市价单生效) and `avgPriceMins` (对市价单生效时,估算金额时使用过去几分钟的平均价格?). - /api/v1/exchangeInfo 中的限制增加了`intervalNum`. `intervalNum`表示该限制针对多少时间间隔进行统计. 例如: `intervalNum`= 5, `interval` = minute, 表示该限制对每5分钟内的行为进行统计。 #### 如何计算过去n分钟平均价格: 1. [对过去n分钟所有订单的数量\*价格求和] / 过去n分钟所有订单的数量 2. 如果过去n分钟没有交易发生,则继续向前追溯,直到找到第一个交易,以此价格作为过去n分钟平均价格。 3. 如果该交易对之前从未发生过交易,则无平均价格,亦即无法在该交易对下市价单,必须至少有一个(双方均未限价单)的交易成交后才可以下市价单。 4. 当前系统使用的平均价格可以通过接口 `https://api.binance.com/api/v3/avgPrice?symbol=`查询例如 https://api.binance.com/api/v3/avgPrice?symbol=BNBUSDT USER DATA STREAM - 成交报告中增加了 `末次成交金额` (`Y`),等于 `末次成交量` _ `末次成交价格` (`L` _ `l`). --- ### 2018-07-18 REST API - 新过滤器: `ICEBERG_PARTS` - `POST api/v3/order` 中 `newOrderRespType` 参数的缺省值更改; `MARKET` `LIMIT` 默认为 `FULL`, 其他默认为 `ACK`. - POST api/v3/order `RESULT` 与 `FULL` 响应中增加 `cummulativeQuoteQty` - GET api/v3/openOrders 无symbol调用权重下降为 40. - GET api/v3/ticker/24hr 无symbol调用权重下降为 40. - GET /api/v1/trades amount最大可取到1000. - GET /api/v1/historicalTrades amount最大可取到1000. - GET /api/v1/aggTrades amount最大可取到1000. - GET /api/v1/klines amount最大可取到1000. - 订单查询结果返回中增加 `updateTime` 字段,代表该订单末次更新(创建、成交、过期、取消、拒绝等等)时间; `time` 仅表示创建时间. - 订单查询结果中增加 `cummulativeQuoteQty`字段. 负值表示尚无任何成交,该字段不可用. - `REQUESTS` 限制更名为 `REQUEST_WEIGHT`. 避免名字造成的误解。 USER DATA STREAM - 订单报告与成交报告中增加`cummulativeQuoteQty` 字段 (`Z`). 表示已经成交的金额, 即已经花费的金额(买入订单)或已经收到的金额(卖出订单),均未计算手续费. 此功能增加之前成交的订单在历史订单接口中查询到的该字段可能小于零. - `cummulativeQuoteQty`/`cummulativeQty` 可以用来计算该订单已经成交部分的平均价格。 - 成交报告中增加了 `O`字段 (订单创建时间) --- ### 2018-01-23 - GET /api/v1/historicalTrades权重降为 5 - GET /api/v1/aggTrades 权重降为 1 - GET /api/v1/klines 权重降为 1 - GET /api/v1/ticker/24hr 不带symbol参数的权重降为 symbols总数 / 2 - GET /api/v3/allOrders 权重降为 5 - GET /api/v3/myTrades 权重降为 5 - GET /api/v3/account 权重降为 5 - GET /api/v1/depth limit=500 权重降为 5 - GET /api/v1/depth limit=1000 权重降为 10 - websocket 用户增加 -1003 error code --- ### 2018-01-20 - GET /api/v1/ticker/24hr 单symbol参数调用权重降为 1 - GET /api/v3/openOrders 不带symbol参数的权重降为 symbols总数 / 2 - GET /api/v3/allOrders 权重降为 15 - GET /api/v3/myTrades 权重降为 15 - GET /api/v3/order 权重降为 1 - 自成交现在会在myTrades结果中有两条记录。 --- ### 2018-01-14 - GET /api/v1/aggTrades 权重改为 2 - GET /api/v1/klines 权重改为 2 - GET /api/v3/order 权重改为 2 - GET /api/v3/allOrders 权重改为 20 - GET /api/v3/account 权重改为 20 - GET /api/v3/myTrades 权重改为 20 - GET /api/v3/historicalTrades 权重改为 20 --- ## Document: /products/simple-earn/quick-start URL: /zh-CN/docs/products/simple-earn/quick-start # 快速开始 ## API Key 权限设置 - 新创建的API的默认权限是 `只读`。 - 如果需要通过API提款, 需要在UI修改权限, 选中 `允许提现`。 ## 账户 ### 现货账户 新注册的币安账号都会有一个现货(`SPOT`)账号。 ### 杠杆账户 为了开设杠杆(`MARGIN`)账户, 可以参考[Binance杠杆交易账户设置指南](https://www.binance.vision/zh/tutorials/binance-margin-trading-guide) ## API 代码库 ### Connectors 以下有一些轻量级的代码库,使不同语言的用户能够直接调用现货的 Binance 公共 API: - Python [https://github.com/binance/binance-connector-python](https://github.com/binance/binance-connector-python) - JavaScript [https://github.com/binance/binance-connector-js](https://github.com/binance/binance-connector-js) - Ruby [https://github.com/binance/binance-connector-ruby](https://github.com/binance/binance-connector-ruby) - DotNET C# [https://github.com/binance/binance-connector-dotnet](https://github.com/binance/binance-connector-dotnet) - Java [https://github.com/binance/binance-connector-java](https://github.com/binance/binance-connector-java) - Rust [https://github.com/binance/binance-spot-connector-rust](https://github.com/binance/binance-spot-connector-rust) - PHP [https://github.com/binance/binance-connector-php](https://github.com/binance/binance-connector-php) - Go [https://github.com/binance/binance-connector-go](https://github.com/binance/binance-connector-go) ### Postman Collections Postman 集合现已推出。推荐给寻求快速和轻松地开始使用 API 的新用户。 [https://github.com/binance/binance-api-postman](https://github.com/binance/binance-api-postman) ### Swagger 以下有提供包含 RESTful API 的 OpenAPI 规范的 YAML 文件,以及可供参考的 Swagger UI 页面。 [https://github.com/binance/binance-api-swagger](https://github.com/binance/binance-api-swagger) --- ## Document: /products/simple-earn/general-info URL: /zh-CN/docs/products/simple-earn/general-info # 基本信息 ## API 基本信息 - 接口可能需要用户的 API Key,如何创建API-KEY请参考[这里](https://www.binance.com/cn/support/articles/360002502072) - 本篇列出接口的 base URL 有: - **https://api.binance.com** - **https://api-gcp.binance.com** - **https://api1.binance.com** - **https://api2.binance.com** - **https://api3.binance.com** - **https://api4.binance.com** - 上述列表的最后4个接口 (`api1`-`api4`) 可能会提供更好的性能,但其稳定性略为逊色。因此,请务必使用最适合您现有配置的那款。 - 所有接口的响应都是 JSON 格式。 - 响应中如有数组,数组元素以时间**升序**排列,越早的数据越提前。 - 所有时间、时间戳均为UNIX时间,单位为**毫秒**。 ### HTTP 返回代码 - HTTP `4XX` 错误码用于指示错误的请求内容、行为、格式。问题在于请求者。 - HTTP `403` 错误码表示违反WAF限制(Web应用程序防火墙)。 - HTTP `409` 错误码表示重新下单(cancelReplace)的请求部分成功。(比如取消订单失败,但是下单成功了) - HTTP `429` 错误码表示警告访问频次超限,即将被封IP。 - HTTP `418` 表示收到429后继续访问,于是被封了。 - HTTP `5XX` 错误码用于指示Binance服务侧的问题。 ### 接口错误代码 - 使用接口 `/api/v3`, 以及 `/sapi/v1/margin`时, 每个接口都有可能抛出异常; > API 与 SAPI 的错误代码返回形式如下: ```javascript { "code": -1121, "msg": "Invalid symbol." } ``` - 具体的错误码及其解释在 [错误代码](./error-code). ### 接口的基本信息 - `GET` 方法的接口, 参数必须在 `query string`中发送。 - `POST`, `PUT`, 和 `DELETE` 方法的接口,参数可以在内容形式为`application/x-www-form-urlencoded`的 `query string` 中发送,也可以在 `request body` 中发送。 如果你喜欢,也可以混合这两种方式发送参数。 - 对参数的顺序不做要求。 - 但如果同一个参数名在query string和request body中都有,query string中的会被优先采用。 --- ## 访问限制 ### 访问限制基本信息 - 以下 是`intervalLetter` 作为头部值: - SECOND => S - MINUTE => M - HOUR => H - DAY => D - 在 `/api/v3/exchangeInfo` `rateLimits` 数组中包含与交易的有关RAW_REQUESTS,REQUEST_WEIGHT和ORDERS速率限制相关的对象。这些在 `限制种类 (rateLimitType)` 下的 `枚举定义` 部分中进一步定义。 - 违反任何一个速率限制时(访问频次限制或下单速率限制),将返回429。 ### IP 访问限制 - 每个请求将包含一个`X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,其中包含当前IP所有请求的已使用权重。 - 每一个接口均有一个相应的权重(weight),有的接口根据参数不同可能拥有不同的权重。越消耗资源的接口权重就会越大。 - 收到429时,您有责任停止发送请求,不得滥用API。 - **收到429后仍然继续违反访问限制,会被封禁IP,并收到418错误码** - 频繁违反限制,封禁时间会逐渐延长,**从最短2分钟到最长3天**。 - `Retry-After`的头会与带有418或429的响应发送,并且会给出**以秒为单位**的等待时长(如果是429)以防止禁令,或者如果是418,直到禁令结束。 - **访问限制是基于IP的,而不是API Key** ###下单频率限制 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - 当下单数超过限制时,会收到带有429但不含`Retry-After`头的响应。请检查 `GET api/v3/exchangeInfo` 的下单频率限制 (rateLimitType = ORDERS) 并等待封禁时间结束。 - 被拒绝或不成功的下单并不保证回报中包含以上头内容。 - **下单频率限制是基于每个账户计数的。** - 用户可以通过接口 `GET api/v3/rateLimit/order` 来查询当前的下单量. ### WEB SOCKET 连接限制 - Websocket服务器每秒最多接受5个消息。消息包括: - PING帧 - PONG帧 - JSON格式的消息, 比如订阅, 断开订阅. - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅 **1024** 个Streams。 - 每IP地址、每5分钟最多可以发送300次连接请求。 ### /api/ 与 /sapi/ 接口限频说明 `/api/*`接口和 `/sapi/*`接口采用两套不同的访问限频规则, 两者互相独立。 - `/api/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以 `/api/*`开头的接口按IP限频,**且所有接口共用每分钟6,000限制**。 - 每个请求将包含一个 `X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,包含当前IP所有请求的已使用权重。 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - `/sapi/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以`/sapi/*`开头的接口采用**单接口限频模式**。按IP统计的权重单接口权重总额为每分钟12000;按照UID统计的单接口权重总额是每分钟180000。 - 每个接口会标明是按照IP或者按照UID统计, 以及相应请求一次的权重值。 - 按照IP统计的接口, 请求返回头里面会包含`X-SAPI-USED-IP-WEIGHT-1M=`或`X-SAPI-USED-IP-WEIGHT-1S=`, 包含当前IP所有请求已使用权重。 - 按照UID统计的接口, 请求返回头里面会包含`X-SAPI-USED-UID-WEIGHT-1M=`或`X-SAPI-USED-UID-WEIGHT-1S=`, 包含当前账户所有已用的UID权重。 --- ## 数据来源 - 因为API系统是异步的, 所以返回的数据有延时很正常, 也在预期之中。 - 在每个接口中,都列出了其数据的来源,可以用于理解数据的时效性。 系统一共有3个数据来源,按照更新速度的先后排序。排在前面的数据最新,在后面就有可能存在延迟。 - **撮合引擎** - 表示数据来源于撮合引擎 - **缓存** - 表示数据来源于内部或者外部的缓存 - **数据库** - 表示数据直接来源于数据库
## 请求鉴权类型 - 每个接口都有一个鉴权类型,指示所需的 API 密钥权限,显示在接口名称旁边(例如,[下新订单 (TRADE)](#place-new-order-trade))。 - 如果未指定,则鉴权类型为 `NONE`。 - 除了为 `NONE` 外,所有具有鉴权类型的接口均视为 `SIGNED` 请求(即包含 `signature`),[listenKey 管理](#user-data-stream-requests) 除外。 - 具有鉴权类型的接口需要提供有效的 API 密钥并验证通过。 - API 密钥可在您的 Binance 账户的 [API 管理](https://www.binance.com/en/support/faq/360002502072) 页面创建。 - **API 密钥和密钥对均为敏感信息,切勿与他人分享。** 如果发现账户有异常活动,请立即撤销所有密钥并联系 Binance 支持。 - API 密钥可配置为仅允许访问某些鉴权接口。 - 例如,您可以拥有具有 `TRADE` 权限的 API 密钥用于交易,同时使用具有 `USER_DATA` 权限的另一个 API 密钥来监控订单状态。 - 默认情况下,API 密钥无法进行 `TRADE`,您需要先在 API 管理中启用交易权限。 | 鉴权类型 | 描述 | | ----------- | ------------------------- | | NONE | 不需要鉴权的接口 | | TRADE | 需要有效的 API-Key 和签名 | | MARGIN | 需要有效的 API-Key 和签名 | | USER_DATA | 需要有效的 API-Key 和签名 | | USER_STREAM | 需要有效的 API-Key | | MARKET_DATA | 需要有效的 API-Key | ### 需要签名的接口 - 调用`SIGNED` 接口时,除了接口本身所需的参数外,还需要在 `query string` 或 `request body` 中传递 `signature`, 即签名参数。 #### 签名是否是大小写敏感的 - **HMAC:** 使用 HMAC 生成的签名**不区分大小写**。这意味着无论字母大小写如何,签名字符串都可以被验证。 - **RSA:** 使用 RSA 生成的签名是**大小写敏感的**。 - **Ed25519:** 使用 Ed25519 生成的签名也是**大小写敏感的**。 请参阅[已签名请求示例 (HMAC)](#hmac-keys)、[已签名请求示例 (RSA)](#rsa-keys) 和[已签名请求示例 (Ed25519)](#ed25519-keys),了解如何根据您使用的 API 密钥类型计算签名。 ### 时间同步安全 - `SIGNED` 请求还需要一个 `timestamp` 参数,该参数应为当前时间戳,单位为毫秒或微秒。(参见 [通用 API 信息](#general-api-information)) - 另一个可选参数 `recvWindow`,用以指定请求的有效期,只能以毫秒为单位。 - `recvWindow` 扩展为三位小数(例如 6000.346),以便可以指定微秒。 - 如果未发送 `recvWindow`,则 **默认值为 5000 毫秒**。 - `recvWindow` 的最大值为 60000 毫秒。 - 请求处理逻辑如下: ```javascript serverTime = getCurrentTime() if (timestamp < (serverTime + 1 second) && (serverTime - timestamp) <= recvWindow) { // 开始处理请求 serverTime = getCurrentTime() if (serverTime - timestamp) <= recvWindow { // 将请求转发到撮合引擎 } else { // 拒绝请求 } // 结束处理请求 } else { // 拒绝请求 } ``` **关于交易时效性** 互联网状况并不100%可靠,不可完全依赖,因此你的程序本地到币安服务器的时延会有抖动. 这是我们设置`recvWindow`的目的所在,如果你从事高频交易,对交易时效性有较高的要求,可以灵活设置`recvWindow`以达到你的要求。 **不推荐使用5秒以上的recvWindow。最大值不能超过60秒!** ### POST /api/v3/order 的签名示例 #### HMAC Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 以下示例分步演示如何使用 `echo`、`openssl` 和 `curl` 从 Linux 命令行发送有效的签名 payload。其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 API 密钥和密钥示例: | Key | Value | | ----------- | ---------------------------------------------------------------- | | `apiKey` | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A | | `secretKey` | NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j | **警告:请勿与任何人分享您的 API 密钥和秘钥。** 此处提供的示例密钥仅用于示范说明目的。 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | LTCBTC | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` **第二步: 计算签名。** 1. 使用 API 密钥中的 `secretKey` 作为 HMAC-SHA-256 算法的签名密钥。 2. 对步骤 1 中构建的签名 payload 进行签名。 3. 将 HMAC-SHA-256 的输出编码为十六进制字符串。 请注意,`secretKey` 和 payload 是**大小写敏感的**,而生成的签名值是不区分大小写的。 **示例命令** 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71 ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n "symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3 ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71" ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3" ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash apiKey="vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" secretKey="NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" payload="symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" # 对请求进行签名 signature=$(echo -n "$payload" | openssl dgst -sha256 -hmac "$secretKey") signature=${signature#*= } # Keep only the part after the "= " # 发送请求 curl -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?$payload&signature=$signature" ``` #### RSA Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 要获取 API 密钥,您需要将 RSA 公钥上传到您的帐户中,系统将为您提供相应的 API 密钥。 仅支持 `PKCS#8` 密钥。 在以下示例中,其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 这些示例假设私钥存储在文件 `./test-prv-key.pem` 中。 | Key | Value | | -------- | ---------------------------------------------------------------- | | `apiKey` | CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ | 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | BTCUSDT | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` **第二步: 计算签名。** 1. 使用 RSASSA-PKCS1-v1_5 算法和 SHA-256 哈希函数对步骤 1 中构建的签名 payload 进行签名。 2. 将输出结果编码为 base64 格式。 请注意,payload 和生成的`签名值`是**大小写敏感的**。 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n 'symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' HZ8HOjiJ1s/igS9JA+n7+7Ti/ihtkRF5BIWcPIEluJP6tlbFM/Bf44LfZka/iemtahZAZzcO9TnI5uaXh3++lrqtNonCwp6/245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH+XxaCmR0WcvlKjNQnp12/eKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang/1WOq+Jaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT/fNnMRxFc7u+j3qI//5yuGuu14KR0MuQKKCSpViieD+fIti46sxPTsjSemoUKp0oXA== ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n 'symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' qJtv66wyp/1mZE+mIFAAMUoTe8xkmLN7/eAZjuC9x1ocxovItHLl/sNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M+JNIMz5UFxfeA53rXjFlvsyH1Sig+OuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C/QMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt/GuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng== ``` 3. 对 base64 格式的字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符): ```console HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D' ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D' ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash function rawurlencode { local string="${1}" local strlen=${#string} local encoded="" local pos c o for (( pos=0 ; pos 错误JSON格式: ```javascript { "code":-1121, "msg":"Invalid symbol." } ``` 错误由两部分组成:错误代码和消息。 代码是通用的,但是消息可能会有所不同。 ## 10xx -常规服务器或网络问题 ### -1000 UNKNOWN - 处理请求时发生未知错误。 - 处理请求时发生未知错误。[%s] ### -1001 DISCONNECTED - 内部错误; 无法处理您的请求。 请再试一次. ### -1002 UNAUTHORIZED - 您无权执行此请求。 ### -1003 TOO_MANY_REQUESTS - 排队的请求过多。 - 请求权重过多; 当前限制是 %s 每 %s 的请求权重。 请使用 Websocket Streams 进行实时更新,以避免轮询API。 - 请求权重过多; IP被禁止,直到%s。 请使用 Websocket Streams 进行实时更新,以免被禁。 ### -1004 SERVER_BUSY - 服务器正忙,请稍候再试。 ### -1006 UNEXPECTED_RESP - 从消息总线收到意外的响应。 执行状态未知。 ### -1007 TIMEOUT - 等待后端服务器响应超时。 发送状态未知; 执行状态未知。 ### -1008 SERVER_BUSY - 现货交易服务器当前因其他请求而过载。 请在几分钟后重试。 ### -1014 UNKNOWN_ORDER_COMPOSITION - 不支持的订单组合。 ### -1015 TOO_MANY_ORDERS - 新订单太多。 - 新订单太多; 当前限制为每%s %s个订单。 ### -1016 SERVICE_SHUTTING_DOWN - 该服务不可用。 ### -1020 UNSUPPORTED_OPERATION - 不支持此操作。 ### -1021 INVALID_TIMESTAMP - 此请求的时间戳在recvWindow之外。 - 此请求的时间戳比服务器时间提前1000毫秒。 ### -1022 INVALID_SIGNATURE - 此请求的签名无效。 ### -1099 Not found, authenticated, or authorized - 替换错误代码-1999 ## 11xx - 2xxx Request issues ### -1100 ILLEGAL_CHARS - 在参数中发现非法字符。 - 在参数中发现非法字符。`%s` - 在参数`%s`中发现非法字符; 合法范围是`%s`。 ### -1101 TOO_MANY_PARAMETERS - 为此端点发送的参数太多。 - 参数太多; 预期为`%s`并收到了`%s`。 - 检测到的参数值重复。 ### -1102 MANDATORY_PARAM_EMPTY_OR_MALFORMED - 未发送强制性参数,该参数为空/空或格式错误。 - 强制参数`%s`未发送,为空/空或格式错误。 - 必须发送参数`%s`或`%s`,但两者均为空! ### -1103 UNKNOWN_PARAM - 发送了未知参数。 ### -1104 UNREAD_PARAMETERS - 并非所有发送的参数都被读取。 - 并非所有发送的参数都被读取; 读取了`%s`参数,但被发送了`%s`。 ### -1105 PARAM_EMPTY - 参数为空。 - 参数`%s`为空。 ### -1106 PARAM_NOT_REQUIRED - 不需要时已发送参数。 - 不需要时发送参数`%s`。 ### -1111 BAD_PRECISION - 精度超过为此资产定义的最大值。 ### -1112 NO_DEPTH - 交易对没有挂单。 ### -1114 TIF_NOT_REQUIRED - 不需要时发送了TimeInForce参数。 ### -1115 INVALID_TIF - 无效 timeInForce. ### -1116 INVALID_ORDER_TYPE - 无效订单类型。 ### -1117 INVALID_SIDE - 无效买卖方向。 ### -1118 EMPTY_NEW_CL_ORD_ID - 新的客户订单ID为空。 ### -1119 EMPTY_ORG_CL_ORD_ID - 客户自定义的订单ID为空。 ### -1120 BAD_INTERVAL - 无效时间间隔。 ### -1121 BAD_SYMBOL - 无效的交易对。 ### -1125 INVALID_LISTEN_KEY - 该listenKey不存在。 ### -1127 MORE_THAN_XX_HOURS - 查询间隔太大。 - 从开始时间到结束时间之间超过%s小时。 ### -1128 OPTIONAL_PARAMS_BAD_COMBO - 可选参数组合无效。 ### -1130 INVALID_PARAMETER - 发送的参数为无效数据。 - 发送参数`%s`的数据无效。 ### -1131 BAD_RECV_WINDOW - `recvWindow` 必须小于 60000 ### -1134 BAD_STRATEGY_TYPE - `strategyType` 必须小于 1000000 #### -1145 INVALID_CANCEL_RESTRICTIONS - `cancelRestrictions` 必须是 `ONLY_NEW` 或者 `ONLY_PARTIALLY_FILLED`。 #### -1151 重复的交易对 - Symbol is present multiple times in the list. ### -2010 NEW_ORDER_REJECTED - 新订单被拒绝 ### -2011 CANCEL_REJECTED - 取消订单被拒绝 ### -2013 NO_SUCH_ORDER - 订单不存在。 ### -2014 BAD_API_KEY_FMT - API-key 格式无效。 ### -2015 REJECTED_MBX_KEY - 无效的API密钥,IP或操作权限。 ### -2016 NO_TRADING_WINDOW - 找不到该交易对的交易窗口。 尝试改为24小时自动报价。 #### -2026 ORDER_ARCHIVED - 订单已被存档因为此订单被取消或过期,无交易数量而最后的更新已超过 90 天前。 ## 3xxx-5xxx SAPI 具体问题 ### -3000 INNER_FAILURE - 内部服务器错误。 ### -3001 NEED_ENABLE_2FA - 请先启用2FA。 ### -3002 ASSET_DEFICIENCY - 此资产不存在。 ### -3003 NO_OPENED_MARGIN_ACCOUNT - 杠杆账户不存在。 ### -3004 TRADE_NOT_ALLOWED - 禁止交易。 ### -3005 TRANSFER_OUT_NOT_ALLOWED - 不允许转账。 ### -3006 EXCEED_MAX_BORROWABLE - 您的已借金额已超过最高可借金额。 ### -3007 HAS_PENDING_TRANSACTION - 您有待处理的交易,请稍后再试。 ### -3008 BORROW_NOT_ALLOWED - 不允许借款。 ### -3009 ASSET_NOT_MORTGAGEABLE - 此资产目前不允许转入杠杆账户。 ### -3010 REPAY_NOT_ALLOWED - 不允许还款。 ### -3011 BAD_DATE_RANGE - 您输入的日期无效。 ### -3012 ASSET_ADMIN_BAN_BORROW - 此资产禁止借款。 ### -3013 LT_MIN_BORROWABLE - 借入金额少于最低借入金额。 ### -3014 ACCOUNT_BAN_BORROW - 此帐户禁止借款。 ### -3015 REPAY_EXCEED_LIABILITY - 还款额超过借款额。 ### -3016 LT_MIN_REPAY - 还款额少于最低还款额。 ### -3017 ASSET_ADMIN_BAN_MORTGAGE - 此资产目前不允许转入保证金账户。 ### -3018 ACCOUNT_BAN_MORTGAGE - 此帐户已禁止转入。 ### -3019 ACCOUNT_BAN_ROLLOUT - 此帐户禁止转出。 ### -3020 EXCEED_MAX_ROLLOUT - 转出金额超过上限。 ### -3021 PAIR_ADMIN_BAN_TRADE - 杠杆账户无法交易此交易对。 ### -3022 ACCOUNT_BAN_TRADE - 账号被禁止交易。 ### -3023 WARNING_MARGIN_LEVEL - 无法在当前杠杆倍数下转出资金或者下单 ### -3024 FEW_LIABILITY_LEFT - 付款之后未付款的债务太小 ### -3025 INVALID_EFFECTIVE_TIME - 输入时间有误。 ### -3026 VALIDATION_FAILED - 输入参数有误。 ### -3027 NOT_VALID_MARGIN_ASSET - 无效的杠杆资产。 ### -3028 NOT_VALID_MARGIN_PAIR - 无效的杠杆交易对。 ### -3029 TRANSFER_FAILED - 转账失败。 ### -3036 ACCOUNT_BAN_REPAY - 此账号无法还款。 ### -3037 PNL_CLEARING - `PNL`正在清帐,请稍等。 ### -3038 LISTEN_KEY_NOT_FOUND - 找不到`Listen key` ### -3041 BALANCE_NOT_CLEARED - 余额不足 ### -3042 PRICE_INDEX_NOT_FOUND - 该杠杆交易对无可用价格指数。 ### -3043 TRANSFER_IN_NOT_ALLOWED - 不允许转入。 ### -3044 SYSTEM_BUSY - 系统繁忙。 ### -3045 SYSTEM - 系统目前没有足够可借的资产。 ### -3999 NOT_WHITELIST_USER - 此功能只面向邀请的用户。 ### -4001 CAPITAL_INVALID - 非法操作 ### -4002 CAPITAL_IG - 非法获取 ### -4003 CAPITAL_IEV - 非法邮箱验证 ### -4004 CAPITAL_UA - 未登录或者认证。 ### -4005 CAPAITAL_TOO_MANY_REQUEST - 请求太频繁。 ### -4006 CAPITAL_ONLY_SUPPORT_PRIMARY_ACCOUNT - 只支持主账号。 ### -4007 CAPITAL_ADDRESS_VERIFICATION_NOT_PASS - 地址的没有通过校验。 ### -4008 CAPITAL_ADDRESS_TAG_VERIFICATION_NOT_PASS - 地址的标记信息(`tag`)没有通过校验。 ### -4010 CAPITAL_WHITELIST_EMAIL_CONFIRM - 确认电子邮件已经列入白名单。 ### -4011 CAPITAL_WHITELIST_EMAIL_EXPIRED - 列入白名单的电子邮件无效。 ### -4012 CAPITAL_WHITELIST_CLOSE - 白名单未打开。 ### -4013 CAPITAL_WITHDRAW_2FA_VERIFY - 2FA未打开。 ### -4014 CAPITAL_WITHDRAW_LOGIN_DELAY - 在登录后的2分钟之内不允许提款。 ### -4015 CAPITAL_WITHDRAW_RESTRICTED_MINUTE - 暂停提款 ### -4016 CAPITAL_WITHDRAW_RESTRICTED_PASSWORD - 在密码修改后的24小时之内不允许提款。 ### -4017 CAPITAL_WITHDRAW_RESTRICTED_UNBIND_2FA - 在2FA发行后的24小时之内不允许提款。 ### -4018 CAPITAL_WITHDRAW_ASSET_NOT_EXIST - 此资产不存在。 ### -4019 CAPITAL_WITHDRAW_ASSET_PROHIBIT - 此资产不允许提款。 ### -4021 CAPITAL_WITHDRAW_AMOUNT_MULTIPLE - 资产的提款数量必须是%s的%s倍。 ### -4022 CAPITAL_WITHDRAW_MIN_AMOUNT - 不须少于最低的提款数量%s。 ### -4023 CAPITAL_WITHDRAW_MAX_AMOUNT - 在24小时之内,不须超过最高的提款数量。 ### -4024 CAPITAL_WITHDRAW_USER_NO_ASSET - 当前用户没有此资产。 ### -4025 CAPITAL_WITHDRAW_USER_ASSET_LESS_THAN_ZERO - 持有资产的数量小于零。 ### -4026 CAPITAL_WITHDRAW_USER_ASSET_NOT_ENOUGH - 此资产余额不足。 ### -4027 CAPITAL_WITHDRAW_GET_TRAN_ID_FAILURE - 无法获取tranId。 ### -4028 CAPITAL_WITHDRAW_MORE_THAN_FEE - 提款金额必须多于佣金额。 ### -4029 CAPITAL_WITHDRAW_NOT_EXIST - 此提款记录不存在。 ### -4030 CAPITAL_WITHDRAW_CONFIRM_SUCCESS - 提款资产成功。 ### -4031 CAPITAL_WITHDRAW_CANCEL_FAILURE - 取消提款失败。 ### -4032 CAPITAL_WITHDRAW_CHECKSUM_VERIFY_FAILURE - 验证提款失败。 ### -4033 CAPITAL_WITHDRAW_ILLEGAL_ADDRESS - 提款地址不合法。 ### -4034 CAPITAL_WITHDRAW_ADDRESS_CHEAT - 当前地址有异常。 ### -4035 CAPITAL_WITHDRAW_NOT_WHITE_ADDRESS - 此地址不在白名单上。请加入然后重试。 ### -4036 CAPITAL_WITHDRAW_NEW_ADDRESS - 新地址在{0}小时后才可以提款。 ### -4037 CAPITAL_WITHDRAW_RESEND_EMAIL_FAIL - 重新发送邮件失败。 ### -4038 CAPITAL_WITHDRAW_RESEND_EMAIL_TIME_OUT - 请5分钟后重试。 ### -4039 CAPITAL_USER_EMPTY - 用户不存在。 ### -4041 CAPITAL_MINUTE_TOO_SMALL - 请一分钟后重试。 ### -4042 CAPITAL_CHARGE_NOT_RESET - 资产无法重新获取存款地址。 ### -4043 CAPITAL_ADDRESS_TOO_MUCH - 在24小时之内充值超过100多个地址。 ### -4044 CAPITAL_BLACKLIST_COUNTRY_GET_ADDRESS - 此国家在黑名单上。 ### -4045 CAPITAL_GET_ASSET_ERROR - 获得资产失败。 ### -4046 CAPITAL_AGREEMENT_NOT_CONFIRMED - 协议未确认。 ### -4047 CAPITAL_DATE_INTERVAL_LIMIT - 时间间隔必须在0-90天之内 ### -4060 CAPITAL_WITHDRAW_USER_ASSET_LOCK_DEPOSIT - 体现仍在区块确认中,暂时锁定部分资产 ### -4106 TAG_NOT_SUPPORTED_FOR_NETWORK - 该网络不支持 memo/tag。请移除 `addressTag` 字段后重试。 ### -5001 ASSET_DRIBBLET_CONVERT_SWITCH_OFF - 不允许转移到微型资产。 ### -5002 ASSET_ASSET_NOT_ENOUGH - 此余额不足。 ### -5003 ASSET_USER_HAVE_NO_ASSET - 此资产不存在。 ### -5004 USER_OUT_OF_TRANSFER_FLOAT - 剩余余额已超过0.001BTC,请重新选择。 - %s的剩余余额已超过0.001BTC,请重新选择。 ### -5005 USER_ASSET_AMOUNT_IS_TOO_LOW - BTC的剩余余额太低,请重新选择。 - %s的剩余余额太低,请重新选择。 ### -5006 USER_CAN_NOT_REQUEST_IN_24_HOURS - 24小时内只能转账一次。 ### -5007 AMOUNT_OVER_ZERO - 数量必须大于零。 ### -5008 ASSET_WITHDRAW_WITHDRAWING_NOT_ENOUGH - 可退回资产的金额不足。 ### -5009 PRODUCT_NOT_EXIST - 产品不存在。 ### -5010 TRANSFER_FAIL - 资产转移失败。 ### -5011 FUTURE_ACCT_NOT_EXIST - 合约帐户不存在。 ### -5012 TRANSFER_PENDING - 资产转移正在进行中。 ### -5021 PARENT_SUB_HAVE_NO_RELATION - 当前的子账户和母账户没有从属关系。 ### -5012 FUTURE_ACCT_OR_SUBRELATION_NOT_EXIST - 合约帐户或子账户关系不存在。 ## 6XXX - 币安宝相关 ### -6001 DAILY_PRODUCT_NOT_EXIST - 理财产品不存在. ### -6003 DAILY_PRODUCT_NOT_ACCESSIBLE - 产品不存在或者没有权限。 ### -6004 DAILY_PRODUCT_NOT_PURCHASABLE - 产品无法购买。 ### -6005 DAILY_LOWER_THAN_MIN_PURCHASE_LIMIT - 低于可以购买的最小限额。 ### -6006 DAILY_REDEEM_AMOUNT_ERROR - 赎回额度有误。 ### -6007 DAILY_REDEEM_TIME_ERROR - 不在赎回的时间内。 ### -6008 DAILY_PRODUCT_NOT_REDEEMABLE - 产品暂时无法赎回。 ### -6009 REQUEST_FREQUENCY_TOO_HIGH - 发送请求太频繁。 ### -6011 EXCEEDED_USER_PURCHASE_LIMIT - 超购每个月用户可以申购的最大次数。 ### -6012 BALANCE_NOT_ENOUGH - 余额不足。 ### -6013 PURCHASING_FAILED - 申购失败。 ### -6014 UPDATE_FAILED - 超过可以申购的最大上限。 ### -6015 EMPTY_REQUEST_BODY - 请求的`body`为空。 ### -6016 PARAMS_ERR - 请求的参数有误。 ### -6017 NOT_IN_WHITELIST - 不在白名单里面。 ### -6018 ASSET_NOT_ENOUGH - 资产不足。 ### -6019 PENDING - 需要进一步确认。 ### -6020 PROJECT_NOT_EXISTS - 此项目不存在。 ## 70xx - 期货 ### -7001 FUTURES_BAD_DATE_RANGE - 此日期范围不支持。 ### -7002 FUTURES_BAD_TYPE - 此数据请求类型不支持。 ## 20xxx - 合约/现货策略交易 ### -20121 Invalid symbol - 无效交易对。 ### -20124 Invalid algo id or it has been completed - 无效的策略订单ID或者它已经被执行。 ### -20130 Invalid data sent for a parameter - 无效数据。 ### -20132 The client algo id is duplicated - 用户自定义策略订单ID重复。 ### -20194 Duration is too short to execute all required quantity - Duration 时间太短不足以执行用户选择的订单数量。 ### -20195 The total size is too small - 下单数量太小。 ### -20196 The total size is too large - 下单数量太大。 ### -20198 Reach the max open orders allowed - 达到了最大挂单上限。 ### -20204 The notional of USD is less or more than the limit - 订单小于最小USD名义价值 ## 过滤器故障 | 报错信息 | 描述 | | ------------------------------------------ | ---------------------------------------------------------------------------------- | | "Filter failure: PRICE_FILTER" | "价格"过高,过低和/或不遵循交易对的最小价格规则。 | | "Filter failure: PERCENT_PRICE" | "价格"比最近Y分钟的平均加权价格高X%或X%太低。 | | "Filter failure: PERCENT_PRICE_BY_SIDE" | `price` 在当前方向上(`BUY`或者`SELL`)比`lastPrice`价格超过X%或者低于Y%。 | | "Filter failure: LOT_SIZE" | "数量"太高,太低和/或不遵循该交易对的步长规则。 | | "Filter failure: MIN_NOTIONAL" | 价格\*数量太低,无法成为该交易对的有效订单。 | | "Filter failure: ICEBERG_PARTS" | `ICEBERG` 订单会分成太多部分; icebergQty太小。 | | "Filter failure: MARKET_LOT_SIZE" | "MARKET"订单的"数量"过高,过低和/或未遵循交易对的步长规则。 | | "Filter failure: MAX_POSITION" | 达到账户的最大仓位限制。这包括了账户的余额总额,以及所有处于open的买单的数量总和。 | | "Filter failure: MAX_NUM_ORDERS" | 客户在交易对上有太多挂单。 | | "Filter failure: MAX_ALGO_ORDERS" | 账户有太多未平仓止损和/或在交易对上执行获利指令。 | | "Filter failure: MAX_NUM_ICEBERG_ORDERS" | 客户在交易对上有太多 iceberg 挂单。 | | "Filter failure: TRAILING_DELTA" | `trailingDelta` 值不在限定的范围内. | | "Filter failure: EXCHANGE_MAX_NUM_ORDERS" | 帐户上的交易所有太多挂单。 | | "Filter failure: EXCHANGE_MAX_ALGO_ORDERS" | 帐户有太多止损挂单和/或在交易所收取获利指令。 | ## 10xxx - 质押借币 ### -10001 SYSTEM_MAINTENANCE - 系统维护中,请稍后再试 ### -10002 INVALID_INPUT - 无效的输入参数 ### -10005 NO_RECORDS - 暂无记录 ### -10007 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10008 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10009 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10010 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10011 INSUFFICIENT_ASSET - 现货资产不足 ### -10012 INVALID_AMOUNT - 无效的还款金额 ### -10013 INSUFFICIENT_AMOUNT - 抵押资产不足 ### -10015 DEDUCTION_FAILED - 抵押资产扣款失败 ### -10016 LOAN_FAILED - 放贷失败 ### -10017 REPAY_EXCEED_DEBT - 还款金额超过负债金额 ### -10018 INVALID_AMOUNT - 无效的还款金额 ### -10019 CONFIG_NOT_EXIST - 配置不存在 ### -10020 UID_NOT_EXIST - 用户ID不存在 ### -10021 ORDER_NOT_EXIST - 订单不存在 ### -10022 INVALID_AMOUNT - 无效的调整金额 ### -10023 ADJUST_LTV_FAILED - 调整质押率失败 ### -10024 ADJUST_LTV_NOT_SUPPORTED - 暂不支持调整质押率 ### -10025 REPAY_FAILED - 还款失败 ### -10026 INVALID_PARAMETER - 无效的参数 ### -10028 INVALID_PARAMETER - 无效的参数 ### -10029 AMOUNT_TOO_SMALL - 借贷金额过小 ### -10030 AMOUNT_TOO_LARGE - 借贷金额过大 ### -10031 QUOTA_REACHED - 已达到个人借贷限额 ### -10032 REPAY_NOT_AVAILABLE - 暂不支持换款 ### -10034 REPAY_NOT_AVAILABLE - 抵押物还款暂时不支持,请尝试用借贷币还款。 ### -10039 AMOUNT_TOO_SMALL - 还款金额过小 ### -10040 AMOUNT_TOO_LARGE - 还款金额过大 ### -10041 INSUFFICIENT_AMOUNT - 由于借贷需求过多,系统剩余可借{0}额度不足。请调整借贷金额或明天再试。 ### -10042 ASSET_NOT_SUPPORTED - 暂不支持%s币种 ### -10043 ASSET_NOT_SUPPORTED - 暂不支持{0} 借贷 ### -10044 QUOTA_REACHED - 抵押物数量已达到限额,请调整抵押金额或使用其他抵押资产。 ### -10045 COLLTERAL_REPAY_NOT_SUPPORTED - 该借贷币种暂不支持抵押物还款,请稍后再试。 ### -10046 EXCEED_MAX_ADJUSTMENT - 调整抵押物超过最大限额,请重试。 ### -10047 REGION_NOT_SUPPORTED - 受当地法规管制,您所在地区暂不支持该币种。 ## 13xxx - 杠杆代币 ### -13000 BLVT_FORBID_REDEEM - 当前该杠杆代币关闭赎回 ### -13001 BLVT_EXCEED_DAILY_LIMIT - 超过该代币个人24小时赎回金额上限 ### -13002 BLVT_EXCEED_TOKEN_DAILY_LIMIT - 超过该代币全局24小时赎回金额上限 ### -13003 BLVT_FORBID_PURCHASE - 当前该杠杆代币关闭申购 ### -13004 BLVT_EXCEED_DAILY_PURCHASE_LIMIT - 超过该代币个人24小时申购金额上限 ### -13005 BLVT_EXCEED_TOKEN_DAILY_PURCHASE_LIMIT - 超过该代币全局24小时申购金额上限 ### -13006 BLVT_PURCHASE_LESS_MIN_AMOUNT - 申购金额低于规定下限 ### -13007 BLVT_PURCHASE_AGREEMENT_NOT_SIGN - 没有签署开通交易协议 ## 12xxx - 流动性挖矿 ### -12014 TOO MANY REQUESTS - 2秒内接收的请求数量多于1条 ## 18xxx - 币安码 ### -18002 - The total amount of codes you created has exceeded the 24-hour limit, please try again after UTC 0 - 24小时内制码总金额已超过限额,请UTC0点后再尝试 ### -18003 - Too many codes created in 24 hours, please try again after UTC 0 - 24小时内制码总次数已超过限额,请UTC0点后再尝试 ### -18004 - Too many invalid redeem attempts in 24 hours, please try again after UTC 0 - 24小时内兑现币安码输错次数已超过限额,请UTC0点后再尝试 ### -18005 - Too many invalid verify attempts, please try later - 参考号输错次数过多,请稍后再试 ### -18006 - The amount is too small, please re-enter - 金额过小,请重新输入 ### -18007 - This token is not currently supported, please re-enter - 尚未支持该币种,请重新输入 ## 21xxx - 統一帳戶 ### -21001 USER_IS_NOT_UNIACCOUNT - 尚未开通统一账户。 ### -21002 UNI_ACCOUNT_CANT_TRANSFER_FUTURE - 统一账户禁用margin向futures转账。 ### -21003 NET_ASSET_MUST_LTE_RATIO - margin资产更新失败。 ### -21004 USER_NO_LIABILITY - 用户不存在统一账户穿仓负债 ### -21005 NO_ENOUGH_ASSET - 用户现货钱包BUSD资产不足以偿还统一账户穿仓负债 ### -21006 HAD_IN_PROCESS_REPAY - 用户存在正在偿还的统一账户穿仓负债 ### -21007 IN_FORCE_LIQUIDATION - 强平进行中,用户偿还统一账户穿仓负债失败 ## 订单拒绝错误 以下错误代码表示撮合引擎返回的订单相关错误: - `-1010 ERROR_MSG_RECEIVED` - `-2010 NEW_ORDER_REJECTED` - `-2011 CANCEL_REJECTED` 结合以下消息将指示特定的错误: | 错误信息 | 描述 | | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | "Unknown order sent." | 找不到订单(通过"orderId","clientOrderId","origClientOrderId") | | "Duplicate order sent." | `clientOrderId`已经被使用 | | "Market is closed." | 该交易对不在交易范围 | | "Account has insufficient balance for requested action." | 没有足够的资金来完成行动 | | "Market orders are not supported for this symbol." | 交易对上未启用"MARKET" | | "Iceberg orders are not supported for this symbol." | 交易对上未启用`icebergQty` | | "Stop loss orders are not supported for this symbol." | 交易对上未启用 `STOP_LOSS` | | "Stop loss limit orders are not supported for this symbol." | 交易对上未启`STOP_LOSS_LIMIT` | | "Take profit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT` | | "Take profit limit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT_LIMIT` | | "Price \* QTY is zero or less." | `price` \* `quantity`太小 | | "IcebergQty exceeds QTY." | `icebergQty` 必须少于订单数量 | | "This action is disabled on this account." | 联系客户支持; 该账户已禁用了某些操作。 | | "This account may not place or cancel orders." | 联系客户支持: 该账户已被禁用了交易操作。 | | "Unsupported order combination" | 不允许组合`orderType`, `timeInForce`, `stopPrice`, 和/或 `icebergQty` 。 | | "Order would trigger immediately." | 与最后交易价格相比,订单的止损价无效。 | | "Cancel order is invalid. Check origClientOrderId and orderId." | 未发送`origClientOrderId` 或`orderId` 。 | | "Order would immediately match and take." | `LIMIT_MAKER` 订单类型将立即匹配并进行交易,而不是纯粹的生成订单。 | | "The relationship of the prices for the orders is not correct." | `OCO`订单中设置的价格不符合报价规则:

The rules are:

`SELL Orders`: Limit Price > Last Price > Stop Price

`BUY Orders`: Limit Price < Last Price < Stop Price | | "OCO orders are not supported for this symbol" | `OCO`订单不支持该交易对 | | "Quote order qty market orders are not support for this symbol." | 这个交易对,市价单不支持参数`quoteOrderQty` | | "Trailing stop orders are not supported for this symbol." | 此symbol不支持 `trailingDelta` | | | "Order cancel-replace is not supported for this symbol." | 此symbol不支持 `POST /api/v3/order/cancelReplace` 或者 `order.cancelReplace` (WebSocket API) | | | "This symbol is not permitted for this account." | 账户和交易对的权限不一致 (比如 `SPOT`, `MARGIN` 等)。| | | "This symbol is restricted for this account." | 账户没有权限在此交易对交易 (比如账户只拥有 `ISOLATED_MARGIN`权限,则无法下`SPOT` 订单)。 | | | "Order was not canceled due to cancel restrictions." | `cancelRestrictions` 设置为 `ONLY_NEW` 但订单状态不是 `NEW`

`cancelRestrictions` 设置为 `ONLY_PARTIALLY_FILLED` 但订单状态不是 `PARTIALLY_FILLED`。 | | ## 关于 POST /api/v3/order/cancelReplace 的错误 ### -2021 Order cancel-replace partially failed 收到该错误码代表撤单**或者**下单失败。 ### -2022 Order cancel-replace failed. 收到该错误码代表撤单**和**下单都失败。 --- ## Document: /products/simple-earn/change-log URL: /zh-CN/docs/products/simple-earn/change-log # 更新日志 ## 2026-05-27 - 新增收益竞技场接口: - `GET /sapi/v1/earn/arena/activities` - 返回该用户当前可参与的理财收益竞技场活动列表(`AIRDROP`、`LEADERBOARD`、`EVENT`)。支持可选请求头 `lang` 用于返回对应语言的 `title` 和 `description`。 ## 2026-03-09 - 更新BFUSD接口: - `GET /sapi/v1/bfusd/quota` - 响应新增 `subscriptionQuota` 对象,包含 `leftQuota` 字段。 ## 2025-12-26 ### 时效性通知 - **以下有关于REST API变更将在 2026-01-15 07:OO UTC 发生:**
调用需要签名的接口时,请在计算签名之前对 payload 进行百分比编码(percent-encode)。不符合此顺序的请求将被拒绝,并返回错误代码 [`-1022 签名不正确`](error-code_zh-CN.md#-1022-invalid_signature)。请检查并相应地更新您代码中的签名逻辑部分。 ### REST API - 更新了 REST API 文档中有关于 [签名请求示例](general-info_zh-CN.md#post-apiv3order-的签名示例) 的部分。 ## 2025-10-27 - 增加BFUSD接口 ## 2025-09-05 - 增加RWUSD接口 ## 2025-09-02 - 更新赚币活期和定期产品的接口文档路径 ## 2025-03-18 - 更新赚币接口: - `GET /sapi/v1/simple-earn/locked/subscriptionPreview` 新增响应字段 `boostRewardAsset`, `estDailyRewardAmt` - `GET /sapi/v1/simple-earn/locked/list` 新增响应字段 `boostRewardAsset`,`boostApr`, `boostEndTime` - `GET /sapi/v1/simple-earn/locked/position` 新增响应字段 `boostRewardAsset`,`boostApr`, `totalBoostRewardAmt` - `GET /sapi/v1/simple-earn/locked/history/rewardsRecord` 新增响应字段 `type` ## 2024-07-04 - 更新赚币接口: - `POST /sapi/v1/simple-earn/locked/subscribe` 新增字段`redeemTo` - `GET /sapi/v1/simple-earn/locked/position` 新增响应字段`redeemTo` - `GET /sapi/v1/simple-earn/flexible/history/subscriptionRecord` 新增响应字段`productId` - `GET /sapi/v1/simple-earn/locked/history/subscriptionRecord` 新增响应字段`projectId` - `GET /sapi/v1/simple-earn/locked/history/redemptionRecord` 新增响应字段`originalAmount`, `lossAmount`, `isComplete`, `rewardAsset`, `rewardAmt`, `extraRewardAsset`, `estExtraRewardAmt` - 新增赚币接口: - `POST /sapi/v1/simple-earn/locked/setRedeemOption` 设置定期产品到期赎回至活期产品或现货钱包 ## 2023-08-26 - 更新赚币接口: - `GET /sapi/v1/simple-earn/flexible/history/subscriptionRecord`: 在响应中增加字段:`sourceAccount`,`amtFromSpot`,`amtFromFunding` - `GET /sapi/v1/simple-earn/locked/history/subscriptionRecord`:在响应中增加字段:`sourceAccount`,`amtFromSpot`,`amtFromFunding` - `GET /sapi/v1/simple-earn/flexible/history/redemptionRecord`:在响应中增加字段:`destAccount` - `POST /sapi/v1/simple-earn/flexible/subscribe`: 新增参数`sourceAccount` - `POST /sapi/v1/simple-earn/locked/subscribe`: 新增参数`sourceAccount` - `POST /sapi/v1/simple-earn/flexible/redeem`: 新增参数`destAccount` --- ## Document: /products/simple-earn/Introduction URL: /zh-CN/docs/products/simple-earn/Introduction 您可以通过申购赚币的活期或定期产品来赚取收益。赚币活期产品支持随时申购或赎回,因此您可以在获得每日收益的同时,保持对资产的灵活性和流动性。赚币定期产品可以在固定期限内提供更高的收益。 --- ## Document: /products/rebate/quick-start URL: /zh-CN/docs/products/rebate/quick-start # 快速开始 ## API Key 权限设置 - 新创建的API的默认权限是 `只读`。 - 如果需要通过API提款, 需要在UI修改权限, 选中 `允许提现`。 ## 账户 ### 现货账户 新注册的币安账号都会有一个现货(`SPOT`)账号。 ### 杠杆账户 为了开设杠杆(`MARGIN`)账户, 可以参考[Binance杠杆交易账户设置指南](https://www.binance.vision/zh/tutorials/binance-margin-trading-guide) ## API 代码库 ### Connectors 以下有一些轻量级的代码库,使不同语言的用户能够直接调用现货的 Binance 公共 API: - Python [https://github.com/binance/binance-connector-python](https://github.com/binance/binance-connector-python) - JavaScript [https://github.com/binance/binance-connector-js](https://github.com/binance/binance-connector-js) - Ruby [https://github.com/binance/binance-connector-ruby](https://github.com/binance/binance-connector-ruby) - DotNET C# [https://github.com/binance/binance-connector-dotnet](https://github.com/binance/binance-connector-dotnet) - Java [https://github.com/binance/binance-connector-java](https://github.com/binance/binance-connector-java) - Rust [https://github.com/binance/binance-spot-connector-rust](https://github.com/binance/binance-spot-connector-rust) - PHP [https://github.com/binance/binance-connector-php](https://github.com/binance/binance-connector-php) - Go [https://github.com/binance/binance-connector-go](https://github.com/binance/binance-connector-go) ### Postman Collections Postman 集合现已推出。推荐给寻求快速和轻松地开始使用 API 的新用户。 [https://github.com/binance/binance-api-postman](https://github.com/binance/binance-api-postman) ### Swagger 以下有提供包含 RESTful API 的 OpenAPI 规范的 YAML 文件,以及可供参考的 Swagger UI 页面。 [https://github.com/binance/binance-api-swagger](https://github.com/binance/binance-api-swagger) --- ## Document: /products/rebate/general-info URL: /zh-CN/docs/products/rebate/general-info # 基本信息 ## API 基本信息 - 接口可能需要用户的 API Key,如何创建API-KEY请参考[这里](https://www.binance.com/cn/support/articles/360002502072) - 本篇列出接口的 base URL 有: - **https://api.binance.com** - **https://api-gcp.binance.com** - **https://api1.binance.com** - **https://api2.binance.com** - **https://api3.binance.com** - **https://api4.binance.com** - 上述列表的最后4个接口 (`api1`-`api4`) 可能会提供更好的性能,但其稳定性略为逊色。因此,请务必使用最适合您现有配置的那款。 - 所有接口的响应都是 JSON 格式。 - 响应中如有数组,数组元素以时间**升序**排列,越早的数据越提前。 - 所有时间、时间戳均为UNIX时间,单位为**毫秒**。 ### HTTP 返回代码 - HTTP `4XX` 错误码用于指示错误的请求内容、行为、格式。问题在于请求者。 - HTTP `403` 错误码表示违反WAF限制(Web应用程序防火墙)。 - HTTP `409` 错误码表示重新下单(cancelReplace)的请求部分成功。(比如取消订单失败,但是下单成功了) - HTTP `429` 错误码表示警告访问频次超限,即将被封IP。 - HTTP `418` 表示收到429后继续访问,于是被封了。 - HTTP `5XX` 错误码用于指示Binance服务侧的问题。 ### 接口错误代码 - 使用接口 `/api/v3`, 以及 `/sapi/v1/margin`时, 每个接口都有可能抛出异常; > API 与 SAPI 的错误代码返回形式如下: ```javascript { "code": -1121, "msg": "Invalid symbol." } ``` - 具体的错误码及其解释在 [错误代码](./error-code). ### 接口的基本信息 - `GET` 方法的接口, 参数必须在 `query string`中发送。 - `POST`, `PUT`, 和 `DELETE` 方法的接口,参数可以在内容形式为`application/x-www-form-urlencoded`的 `query string` 中发送,也可以在 `request body` 中发送。 如果你喜欢,也可以混合这两种方式发送参数。 - 对参数的顺序不做要求。 - 但如果同一个参数名在query string和request body中都有,query string中的会被优先采用。 --- ## 访问限制 ### 访问限制基本信息 - 以下 是`intervalLetter` 作为头部值: - SECOND => S - MINUTE => M - HOUR => H - DAY => D - 在 `/api/v3/exchangeInfo` `rateLimits` 数组中包含与交易的有关RAW_REQUESTS,REQUEST_WEIGHT和ORDERS速率限制相关的对象。这些在 `限制种类 (rateLimitType)` 下的 `枚举定义` 部分中进一步定义。 - 违反任何一个速率限制时(访问频次限制或下单速率限制),将返回429。 ### IP 访问限制 - 每个请求将包含一个`X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,其中包含当前IP所有请求的已使用权重。 - 每一个接口均有一个相应的权重(weight),有的接口根据参数不同可能拥有不同的权重。越消耗资源的接口权重就会越大。 - 收到429时,您有责任停止发送请求,不得滥用API。 - **收到429后仍然继续违反访问限制,会被封禁IP,并收到418错误码** - 频繁违反限制,封禁时间会逐渐延长,**从最短2分钟到最长3天**。 - `Retry-After`的头会与带有418或429的响应发送,并且会给出**以秒为单位**的等待时长(如果是429)以防止禁令,或者如果是418,直到禁令结束。 - **访问限制是基于IP的,而不是API Key** ###下单频率限制 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - 当下单数超过限制时,会收到带有429但不含`Retry-After`头的响应。请检查 `GET api/v3/exchangeInfo` 的下单频率限制 (rateLimitType = ORDERS) 并等待封禁时间结束。 - 被拒绝或不成功的下单并不保证回报中包含以上头内容。 - **下单频率限制是基于每个账户计数的。** - 用户可以通过接口 `GET api/v3/rateLimit/order` 来查询当前的下单量. ### WEB SOCKET 连接限制 - Websocket服务器每秒最多接受5个消息。消息包括: - PING帧 - PONG帧 - JSON格式的消息, 比如订阅, 断开订阅. - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅 **1024** 个Streams。 - 每IP地址、每5分钟最多可以发送300次连接请求。 ### /api/ 与 /sapi/ 接口限频说明 `/api/*`接口和 `/sapi/*`接口采用两套不同的访问限频规则, 两者互相独立。 - `/api/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以 `/api/*`开头的接口按IP限频,**且所有接口共用每分钟6,000限制**。 - 每个请求将包含一个 `X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,包含当前IP所有请求的已使用权重。 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - `/sapi/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以`/sapi/*`开头的接口采用**单接口限频模式**。按IP统计的权重单接口权重总额为每分钟12000;按照UID统计的单接口权重总额是每分钟180000。 - 每个接口会标明是按照IP或者按照UID统计, 以及相应请求一次的权重值。 - 按照IP统计的接口, 请求返回头里面会包含`X-SAPI-USED-IP-WEIGHT-1M=`或`X-SAPI-USED-IP-WEIGHT-1S=`, 包含当前IP所有请求已使用权重。 - 按照UID统计的接口, 请求返回头里面会包含`X-SAPI-USED-UID-WEIGHT-1M=`或`X-SAPI-USED-UID-WEIGHT-1S=`, 包含当前账户所有已用的UID权重。 --- ## 数据来源 - 因为API系统是异步的, 所以返回的数据有延时很正常, 也在预期之中。 - 在每个接口中,都列出了其数据的来源,可以用于理解数据的时效性。 系统一共有3个数据来源,按照更新速度的先后排序。排在前面的数据最新,在后面就有可能存在延迟。 - **撮合引擎** - 表示数据来源于撮合引擎 - **缓存** - 表示数据来源于内部或者外部的缓存 - **数据库** - 表示数据直接来源于数据库 ## 请求鉴权类型 - 每个接口都有一个鉴权类型,指示所需的 API 密钥权限,显示在接口名称旁边(例如,[下新订单 (TRADE)](#place-new-order-trade))。 - 如果未指定,则鉴权类型为 `NONE`。 - 除了为 `NONE` 外,所有具有鉴权类型的接口均视为 `SIGNED` 请求(即包含 `signature`),[listenKey 管理](#user-data-stream-requests) 除外。 - 具有鉴权类型的接口需要提供有效的 API 密钥并验证通过。 - API 密钥可在您的 Binance 账户的 [API 管理](https://www.binance.com/en/support/faq/360002502072) 页面创建。 - **API 密钥和密钥对均为敏感信息,切勿与他人分享。** 如果发现账户有异常活动,请立即撤销所有密钥并联系 Binance 支持。 - API 密钥可配置为仅允许访问某些鉴权接口。 - 例如,您可以拥有具有 `TRADE` 权限的 API 密钥用于交易,同时使用具有 `USER_DATA` 权限的另一个 API 密钥来监控订单状态。 - 默认情况下,API 密钥无法进行 `TRADE`,您需要先在 API 管理中启用交易权限。 | 鉴权类型 | 描述 | | ----------- | ------------------------- | | NONE | 不需要鉴权的接口 | | TRADE | 需要有效的 API-Key 和签名 | | MARGIN | 需要有效的 API-Key 和签名 | | USER_DATA | 需要有效的 API-Key 和签名 | | USER_STREAM | 需要有效的 API-Key | | MARKET_DATA | 需要有效的 API-Key | ### 需要签名的接口 - 调用`SIGNED` 接口时,除了接口本身所需的参数外,还需要在 `query string` 或 `request body` 中传递 `signature`, 即签名参数。 #### 签名是否是大小写敏感的 - **HMAC:** 使用 HMAC 生成的签名**不区分大小写**。这意味着无论字母大小写如何,签名字符串都可以被验证。 - **RSA:** 使用 RSA 生成的签名是**大小写敏感的**。 - **Ed25519:** 使用 Ed25519 生成的签名也是**大小写敏感的**。 请参阅[已签名请求示例 (HMAC)](#hmac-keys)、[已签名请求示例 (RSA)](#rsa-keys) 和[已签名请求示例 (Ed25519)](#ed25519-keys),了解如何根据您使用的 API 密钥类型计算签名。 ### 时间同步安全 - `SIGNED` 请求还需要一个 `timestamp` 参数,该参数应为当前时间戳,单位为毫秒或微秒。(参见 [通用 API 信息](#general-api-information)) - 另一个可选参数 `recvWindow`,用以指定请求的有效期,只能以毫秒为单位。 - `recvWindow` 扩展为三位小数(例如 6000.346),以便可以指定微秒。 - 如果未发送 `recvWindow`,则 **默认值为 5000 毫秒**。 - `recvWindow` 的最大值为 60000 毫秒。 - 请求处理逻辑如下: ```javascript serverTime = getCurrentTime() if (timestamp < (serverTime + 1 second) && (serverTime - timestamp) <= recvWindow) { // 开始处理请求 serverTime = getCurrentTime() if (serverTime - timestamp) <= recvWindow { // 将请求转发到撮合引擎 } else { // 拒绝请求 } // 结束处理请求 } else { // 拒绝请求 } ``` **关于交易时效性** 互联网状况并不100%可靠,不可完全依赖,因此你的程序本地到币安服务器的时延会有抖动. 这是我们设置`recvWindow`的目的所在,如果你从事高频交易,对交易时效性有较高的要求,可以灵活设置`recvWindow`以达到你的要求。 **不推荐使用5秒以上的recvWindow。最大值不能超过60秒!** ### POST /api/v3/order 的签名示例 #### HMAC Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 以下示例分步演示如何使用 `echo`、`openssl` 和 `curl` 从 Linux 命令行发送有效的签名 payload。其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 API 密钥和密钥示例: | Key | Value | | ----------- | ---------------------------------------------------------------- | | `apiKey` | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A | | `secretKey` | NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j | **警告:请勿与任何人分享您的 API 密钥和秘钥。** 此处提供的示例密钥仅用于示范说明目的。 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | LTCBTC | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` **第二步: 计算签名。** 1. 使用 API 密钥中的 `secretKey` 作为 HMAC-SHA-256 算法的签名密钥。 2. 对步骤 1 中构建的签名 payload 进行签名。 3. 将 HMAC-SHA-256 的输出编码为十六进制字符串。 请注意,`secretKey` 和 payload 是**大小写敏感的**,而生成的签名值是不区分大小写的。 **示例命令** 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71 ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n "symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3 ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71" ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3" ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash apiKey="vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" secretKey="NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" payload="symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" # 对请求进行签名 signature=$(echo -n "$payload" | openssl dgst -sha256 -hmac "$secretKey") signature=${signature#*= } # Keep only the part after the "= " # 发送请求 curl -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?$payload&signature=$signature" ``` #### RSA Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 要获取 API 密钥,您需要将 RSA 公钥上传到您的帐户中,系统将为您提供相应的 API 密钥。 仅支持 `PKCS#8` 密钥。 在以下示例中,其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 这些示例假设私钥存储在文件 `./test-prv-key.pem` 中。 | Key | Value | | -------- | ---------------------------------------------------------------- | | `apiKey` | CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ | 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | BTCUSDT | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` **第二步: 计算签名。** 1. 使用 RSASSA-PKCS1-v1_5 算法和 SHA-256 哈希函数对步骤 1 中构建的签名 payload 进行签名。 2. 将输出结果编码为 base64 格式。 请注意,payload 和生成的`签名值`是**大小写敏感的**。 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n 'symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' HZ8HOjiJ1s/igS9JA+n7+7Ti/ihtkRF5BIWcPIEluJP6tlbFM/Bf44LfZka/iemtahZAZzcO9TnI5uaXh3++lrqtNonCwp6/245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH+XxaCmR0WcvlKjNQnp12/eKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang/1WOq+Jaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT/fNnMRxFc7u+j3qI//5yuGuu14KR0MuQKKCSpViieD+fIti46sxPTsjSemoUKp0oXA== ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n 'symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' qJtv66wyp/1mZE+mIFAAMUoTe8xkmLN7/eAZjuC9x1ocxovItHLl/sNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M+JNIMz5UFxfeA53rXjFlvsyH1Sig+OuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C/QMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt/GuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng== ``` 3. 对 base64 格式的字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符): ```console HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D' ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D' ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash function rawurlencode { local string="${1}" local strlen=${#string} local encoded="" local pos c o for (( pos=0 ; pos 错误JSON格式: ```javascript { "code":-1121, "msg":"Invalid symbol." } ``` 错误由两部分组成:错误代码和消息。 代码是通用的,但是消息可能会有所不同。 ## 10xx -常规服务器或网络问题 ### -1000 UNKNOWN - 处理请求时发生未知错误。 - 处理请求时发生未知错误。[%s] ### -1001 DISCONNECTED - 内部错误; 无法处理您的请求。 请再试一次. ### -1002 UNAUTHORIZED - 您无权执行此请求。 ### -1003 TOO_MANY_REQUESTS - 排队的请求过多。 - 请求权重过多; 当前限制是 %s 每 %s 的请求权重。 请使用 Websocket Streams 进行实时更新,以避免轮询API。 - 请求权重过多; IP被禁止,直到%s。 请使用 Websocket Streams 进行实时更新,以免被禁。 ### -1004 SERVER_BUSY - 服务器正忙,请稍候再试。 ### -1006 UNEXPECTED_RESP - 从消息总线收到意外的响应。 执行状态未知。 ### -1007 TIMEOUT - 等待后端服务器响应超时。 发送状态未知; 执行状态未知。 ### -1008 SERVER_BUSY - 现货交易服务器当前因其他请求而过载。 请在几分钟后重试。 ### -1014 UNKNOWN_ORDER_COMPOSITION - 不支持的订单组合。 ### -1015 TOO_MANY_ORDERS - 新订单太多。 - 新订单太多; 当前限制为每%s %s个订单。 ### -1016 SERVICE_SHUTTING_DOWN - 该服务不可用。 ### -1020 UNSUPPORTED_OPERATION - 不支持此操作。 ### -1021 INVALID_TIMESTAMP - 此请求的时间戳在recvWindow之外。 - 此请求的时间戳比服务器时间提前1000毫秒。 ### -1022 INVALID_SIGNATURE - 此请求的签名无效。 ### -1099 Not found, authenticated, or authorized - 替换错误代码-1999 ## 11xx - 2xxx Request issues ### -1100 ILLEGAL_CHARS - 在参数中发现非法字符。 - 在参数中发现非法字符。`%s` - 在参数`%s`中发现非法字符; 合法范围是`%s`。 ### -1101 TOO_MANY_PARAMETERS - 为此端点发送的参数太多。 - 参数太多; 预期为`%s`并收到了`%s`。 - 检测到的参数值重复。 ### -1102 MANDATORY_PARAM_EMPTY_OR_MALFORMED - 未发送强制性参数,该参数为空/空或格式错误。 - 强制参数`%s`未发送,为空/空或格式错误。 - 必须发送参数`%s`或`%s`,但两者均为空! ### -1103 UNKNOWN_PARAM - 发送了未知参数。 ### -1104 UNREAD_PARAMETERS - 并非所有发送的参数都被读取。 - 并非所有发送的参数都被读取; 读取了`%s`参数,但被发送了`%s`。 ### -1105 PARAM_EMPTY - 参数为空。 - 参数`%s`为空。 ### -1106 PARAM_NOT_REQUIRED - 不需要时已发送参数。 - 不需要时发送参数`%s`。 ### -1111 BAD_PRECISION - 精度超过为此资产定义的最大值。 ### -1112 NO_DEPTH - 交易对没有挂单。 ### -1114 TIF_NOT_REQUIRED - 不需要时发送了TimeInForce参数。 ### -1115 INVALID_TIF - 无效 timeInForce. ### -1116 INVALID_ORDER_TYPE - 无效订单类型。 ### -1117 INVALID_SIDE - 无效买卖方向。 ### -1118 EMPTY_NEW_CL_ORD_ID - 新的客户订单ID为空。 ### -1119 EMPTY_ORG_CL_ORD_ID - 客户自定义的订单ID为空。 ### -1120 BAD_INTERVAL - 无效时间间隔。 ### -1121 BAD_SYMBOL - 无效的交易对。 ### -1125 INVALID_LISTEN_KEY - 该listenKey不存在。 ### -1127 MORE_THAN_XX_HOURS - 查询间隔太大。 - 从开始时间到结束时间之间超过%s小时。 ### -1128 OPTIONAL_PARAMS_BAD_COMBO - 可选参数组合无效。 ### -1130 INVALID_PARAMETER - 发送的参数为无效数据。 - 发送参数`%s`的数据无效。 ### -1131 BAD_RECV_WINDOW - `recvWindow` 必须小于 60000 ### -1134 BAD_STRATEGY_TYPE - `strategyType` 必须小于 1000000 #### -1145 INVALID_CANCEL_RESTRICTIONS - `cancelRestrictions` 必须是 `ONLY_NEW` 或者 `ONLY_PARTIALLY_FILLED`。 #### -1151 重复的交易对 - Symbol is present multiple times in the list. ### -2010 NEW_ORDER_REJECTED - 新订单被拒绝 ### -2011 CANCEL_REJECTED - 取消订单被拒绝 ### -2013 NO_SUCH_ORDER - 订单不存在。 ### -2014 BAD_API_KEY_FMT - API-key 格式无效。 ### -2015 REJECTED_MBX_KEY - 无效的API密钥,IP或操作权限。 ### -2016 NO_TRADING_WINDOW - 找不到该交易对的交易窗口。 尝试改为24小时自动报价。 #### -2026 ORDER_ARCHIVED - 订单已被存档因为此订单被取消或过期,无交易数量而最后的更新已超过 90 天前。 ## 3xxx-5xxx SAPI 具体问题 ### -3000 INNER_FAILURE - 内部服务器错误。 ### -3001 NEED_ENABLE_2FA - 请先启用2FA。 ### -3002 ASSET_DEFICIENCY - 此资产不存在。 ### -3003 NO_OPENED_MARGIN_ACCOUNT - 杠杆账户不存在。 ### -3004 TRADE_NOT_ALLOWED - 禁止交易。 ### -3005 TRANSFER_OUT_NOT_ALLOWED - 不允许转账。 ### -3006 EXCEED_MAX_BORROWABLE - 您的已借金额已超过最高可借金额。 ### -3007 HAS_PENDING_TRANSACTION - 您有待处理的交易,请稍后再试。 ### -3008 BORROW_NOT_ALLOWED - 不允许借款。 ### -3009 ASSET_NOT_MORTGAGEABLE - 此资产目前不允许转入杠杆账户。 ### -3010 REPAY_NOT_ALLOWED - 不允许还款。 ### -3011 BAD_DATE_RANGE - 您输入的日期无效。 ### -3012 ASSET_ADMIN_BAN_BORROW - 此资产禁止借款。 ### -3013 LT_MIN_BORROWABLE - 借入金额少于最低借入金额。 ### -3014 ACCOUNT_BAN_BORROW - 此帐户禁止借款。 ### -3015 REPAY_EXCEED_LIABILITY - 还款额超过借款额。 ### -3016 LT_MIN_REPAY - 还款额少于最低还款额。 ### -3017 ASSET_ADMIN_BAN_MORTGAGE - 此资产目前不允许转入保证金账户。 ### -3018 ACCOUNT_BAN_MORTGAGE - 此帐户已禁止转入。 ### -3019 ACCOUNT_BAN_ROLLOUT - 此帐户禁止转出。 ### -3020 EXCEED_MAX_ROLLOUT - 转出金额超过上限。 ### -3021 PAIR_ADMIN_BAN_TRADE - 杠杆账户无法交易此交易对。 ### -3022 ACCOUNT_BAN_TRADE - 账号被禁止交易。 ### -3023 WARNING_MARGIN_LEVEL - 无法在当前杠杆倍数下转出资金或者下单 ### -3024 FEW_LIABILITY_LEFT - 付款之后未付款的债务太小 ### -3025 INVALID_EFFECTIVE_TIME - 输入时间有误。 ### -3026 VALIDATION_FAILED - 输入参数有误。 ### -3027 NOT_VALID_MARGIN_ASSET - 无效的杠杆资产。 ### -3028 NOT_VALID_MARGIN_PAIR - 无效的杠杆交易对。 ### -3029 TRANSFER_FAILED - 转账失败。 ### -3036 ACCOUNT_BAN_REPAY - 此账号无法还款。 ### -3037 PNL_CLEARING - `PNL`正在清帐,请稍等。 ### -3038 LISTEN_KEY_NOT_FOUND - 找不到`Listen key` ### -3041 BALANCE_NOT_CLEARED - 余额不足 ### -3042 PRICE_INDEX_NOT_FOUND - 该杠杆交易对无可用价格指数。 ### -3043 TRANSFER_IN_NOT_ALLOWED - 不允许转入。 ### -3044 SYSTEM_BUSY - 系统繁忙。 ### -3045 SYSTEM - 系统目前没有足够可借的资产。 ### -3999 NOT_WHITELIST_USER - 此功能只面向邀请的用户。 ### -4001 CAPITAL_INVALID - 非法操作 ### -4002 CAPITAL_IG - 非法获取 ### -4003 CAPITAL_IEV - 非法邮箱验证 ### -4004 CAPITAL_UA - 未登录或者认证。 ### -4005 CAPAITAL_TOO_MANY_REQUEST - 请求太频繁。 ### -4006 CAPITAL_ONLY_SUPPORT_PRIMARY_ACCOUNT - 只支持主账号。 ### -4007 CAPITAL_ADDRESS_VERIFICATION_NOT_PASS - 地址的没有通过校验。 ### -4008 CAPITAL_ADDRESS_TAG_VERIFICATION_NOT_PASS - 地址的标记信息(`tag`)没有通过校验。 ### -4010 CAPITAL_WHITELIST_EMAIL_CONFIRM - 确认电子邮件已经列入白名单。 ### -4011 CAPITAL_WHITELIST_EMAIL_EXPIRED - 列入白名单的电子邮件无效。 ### -4012 CAPITAL_WHITELIST_CLOSE - 白名单未打开。 ### -4013 CAPITAL_WITHDRAW_2FA_VERIFY - 2FA未打开。 ### -4014 CAPITAL_WITHDRAW_LOGIN_DELAY - 在登录后的2分钟之内不允许提款。 ### -4015 CAPITAL_WITHDRAW_RESTRICTED_MINUTE - 暂停提款 ### -4016 CAPITAL_WITHDRAW_RESTRICTED_PASSWORD - 在密码修改后的24小时之内不允许提款。 ### -4017 CAPITAL_WITHDRAW_RESTRICTED_UNBIND_2FA - 在2FA发行后的24小时之内不允许提款。 ### -4018 CAPITAL_WITHDRAW_ASSET_NOT_EXIST - 此资产不存在。 ### -4019 CAPITAL_WITHDRAW_ASSET_PROHIBIT - 此资产不允许提款。 ### -4021 CAPITAL_WITHDRAW_AMOUNT_MULTIPLE - 资产的提款数量必须是%s的%s倍。 ### -4022 CAPITAL_WITHDRAW_MIN_AMOUNT - 不须少于最低的提款数量%s。 ### -4023 CAPITAL_WITHDRAW_MAX_AMOUNT - 在24小时之内,不须超过最高的提款数量。 ### -4024 CAPITAL_WITHDRAW_USER_NO_ASSET - 当前用户没有此资产。 ### -4025 CAPITAL_WITHDRAW_USER_ASSET_LESS_THAN_ZERO - 持有资产的数量小于零。 ### -4026 CAPITAL_WITHDRAW_USER_ASSET_NOT_ENOUGH - 此资产余额不足。 ### -4027 CAPITAL_WITHDRAW_GET_TRAN_ID_FAILURE - 无法获取tranId。 ### -4028 CAPITAL_WITHDRAW_MORE_THAN_FEE - 提款金额必须多于佣金额。 ### -4029 CAPITAL_WITHDRAW_NOT_EXIST - 此提款记录不存在。 ### -4030 CAPITAL_WITHDRAW_CONFIRM_SUCCESS - 提款资产成功。 ### -4031 CAPITAL_WITHDRAW_CANCEL_FAILURE - 取消提款失败。 ### -4032 CAPITAL_WITHDRAW_CHECKSUM_VERIFY_FAILURE - 验证提款失败。 ### -4033 CAPITAL_WITHDRAW_ILLEGAL_ADDRESS - 提款地址不合法。 ### -4034 CAPITAL_WITHDRAW_ADDRESS_CHEAT - 当前地址有异常。 ### -4035 CAPITAL_WITHDRAW_NOT_WHITE_ADDRESS - 此地址不在白名单上。请加入然后重试。 ### -4036 CAPITAL_WITHDRAW_NEW_ADDRESS - 新地址在{0}小时后才可以提款。 ### -4037 CAPITAL_WITHDRAW_RESEND_EMAIL_FAIL - 重新发送邮件失败。 ### -4038 CAPITAL_WITHDRAW_RESEND_EMAIL_TIME_OUT - 请5分钟后重试。 ### -4039 CAPITAL_USER_EMPTY - 用户不存在。 ### -4041 CAPITAL_MINUTE_TOO_SMALL - 请一分钟后重试。 ### -4042 CAPITAL_CHARGE_NOT_RESET - 资产无法重新获取存款地址。 ### -4043 CAPITAL_ADDRESS_TOO_MUCH - 在24小时之内充值超过100多个地址。 ### -4044 CAPITAL_BLACKLIST_COUNTRY_GET_ADDRESS - 此国家在黑名单上。 ### -4045 CAPITAL_GET_ASSET_ERROR - 获得资产失败。 ### -4046 CAPITAL_AGREEMENT_NOT_CONFIRMED - 协议未确认。 ### -4047 CAPITAL_DATE_INTERVAL_LIMIT - 时间间隔必须在0-90天之内 ### -4060 CAPITAL_WITHDRAW_USER_ASSET_LOCK_DEPOSIT - 体现仍在区块确认中,暂时锁定部分资产 ### -4106 TAG_NOT_SUPPORTED_FOR_NETWORK - 该网络不支持 memo/tag。请移除 `addressTag` 字段后重试。 ### -5001 ASSET_DRIBBLET_CONVERT_SWITCH_OFF - 不允许转移到微型资产。 ### -5002 ASSET_ASSET_NOT_ENOUGH - 此余额不足。 ### -5003 ASSET_USER_HAVE_NO_ASSET - 此资产不存在。 ### -5004 USER_OUT_OF_TRANSFER_FLOAT - 剩余余额已超过0.001BTC,请重新选择。 - %s的剩余余额已超过0.001BTC,请重新选择。 ### -5005 USER_ASSET_AMOUNT_IS_TOO_LOW - BTC的剩余余额太低,请重新选择。 - %s的剩余余额太低,请重新选择。 ### -5006 USER_CAN_NOT_REQUEST_IN_24_HOURS - 24小时内只能转账一次。 ### -5007 AMOUNT_OVER_ZERO - 数量必须大于零。 ### -5008 ASSET_WITHDRAW_WITHDRAWING_NOT_ENOUGH - 可退回资产的金额不足。 ### -5009 PRODUCT_NOT_EXIST - 产品不存在。 ### -5010 TRANSFER_FAIL - 资产转移失败。 ### -5011 FUTURE_ACCT_NOT_EXIST - 合约帐户不存在。 ### -5012 TRANSFER_PENDING - 资产转移正在进行中。 ### -5021 PARENT_SUB_HAVE_NO_RELATION - 当前的子账户和母账户没有从属关系。 ### -5012 FUTURE_ACCT_OR_SUBRELATION_NOT_EXIST - 合约帐户或子账户关系不存在。 ## 6XXX - 币安宝相关 ### -6001 DAILY_PRODUCT_NOT_EXIST - 理财产品不存在. ### -6003 DAILY_PRODUCT_NOT_ACCESSIBLE - 产品不存在或者没有权限。 ### -6004 DAILY_PRODUCT_NOT_PURCHASABLE - 产品无法购买。 ### -6005 DAILY_LOWER_THAN_MIN_PURCHASE_LIMIT - 低于可以购买的最小限额。 ### -6006 DAILY_REDEEM_AMOUNT_ERROR - 赎回额度有误。 ### -6007 DAILY_REDEEM_TIME_ERROR - 不在赎回的时间内。 ### -6008 DAILY_PRODUCT_NOT_REDEEMABLE - 产品暂时无法赎回。 ### -6009 REQUEST_FREQUENCY_TOO_HIGH - 发送请求太频繁。 ### -6011 EXCEEDED_USER_PURCHASE_LIMIT - 超购每个月用户可以申购的最大次数。 ### -6012 BALANCE_NOT_ENOUGH - 余额不足。 ### -6013 PURCHASING_FAILED - 申购失败。 ### -6014 UPDATE_FAILED - 超过可以申购的最大上限。 ### -6015 EMPTY_REQUEST_BODY - 请求的`body`为空。 ### -6016 PARAMS_ERR - 请求的参数有误。 ### -6017 NOT_IN_WHITELIST - 不在白名单里面。 ### -6018 ASSET_NOT_ENOUGH - 资产不足。 ### -6019 PENDING - 需要进一步确认。 ### -6020 PROJECT_NOT_EXISTS - 此项目不存在。 ## 70xx - 期货 ### -7001 FUTURES_BAD_DATE_RANGE - 此日期范围不支持。 ### -7002 FUTURES_BAD_TYPE - 此数据请求类型不支持。 ## 20xxx - 合约/现货策略交易 ### -20121 Invalid symbol - 无效交易对。 ### -20124 Invalid algo id or it has been completed - 无效的策略订单ID或者它已经被执行。 ### -20130 Invalid data sent for a parameter - 无效数据。 ### -20132 The client algo id is duplicated - 用户自定义策略订单ID重复。 ### -20194 Duration is too short to execute all required quantity - Duration 时间太短不足以执行用户选择的订单数量。 ### -20195 The total size is too small - 下单数量太小。 ### -20196 The total size is too large - 下单数量太大。 ### -20198 Reach the max open orders allowed - 达到了最大挂单上限。 ### -20204 The notional of USD is less or more than the limit - 订单小于最小USD名义价值 ## 过滤器故障 | 报错信息 | 描述 | | ------------------------------------------ | ---------------------------------------------------------------------------------- | | "Filter failure: PRICE_FILTER" | "价格"过高,过低和/或不遵循交易对的最小价格规则。 | | "Filter failure: PERCENT_PRICE" | "价格"比最近Y分钟的平均加权价格高X%或X%太低。 | | "Filter failure: PERCENT_PRICE_BY_SIDE" | `price` 在当前方向上(`BUY`或者`SELL`)比`lastPrice`价格超过X%或者低于Y%。 | | "Filter failure: LOT_SIZE" | "数量"太高,太低和/或不遵循该交易对的步长规则。 | | "Filter failure: MIN_NOTIONAL" | 价格\*数量太低,无法成为该交易对的有效订单。 | | "Filter failure: ICEBERG_PARTS" | `ICEBERG` 订单会分成太多部分; icebergQty太小。 | | "Filter failure: MARKET_LOT_SIZE" | "MARKET"订单的"数量"过高,过低和/或未遵循交易对的步长规则。 | | "Filter failure: MAX_POSITION" | 达到账户的最大仓位限制。这包括了账户的余额总额,以及所有处于open的买单的数量总和。 | | "Filter failure: MAX_NUM_ORDERS" | 客户在交易对上有太多挂单。 | | "Filter failure: MAX_ALGO_ORDERS" | 账户有太多未平仓止损和/或在交易对上执行获利指令。 | | "Filter failure: MAX_NUM_ICEBERG_ORDERS" | 客户在交易对上有太多 iceberg 挂单。 | | "Filter failure: TRAILING_DELTA" | `trailingDelta` 值不在限定的范围内. | | "Filter failure: EXCHANGE_MAX_NUM_ORDERS" | 帐户上的交易所有太多挂单。 | | "Filter failure: EXCHANGE_MAX_ALGO_ORDERS" | 帐户有太多止损挂单和/或在交易所收取获利指令。 | ## 10xxx - 质押借币 ### -10001 SYSTEM_MAINTENANCE - 系统维护中,请稍后再试 ### -10002 INVALID_INPUT - 无效的输入参数 ### -10005 NO_RECORDS - 暂无记录 ### -10007 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10008 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10009 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10010 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10011 INSUFFICIENT_ASSET - 现货资产不足 ### -10012 INVALID_AMOUNT - 无效的还款金额 ### -10013 INSUFFICIENT_AMOUNT - 抵押资产不足 ### -10015 DEDUCTION_FAILED - 抵押资产扣款失败 ### -10016 LOAN_FAILED - 放贷失败 ### -10017 REPAY_EXCEED_DEBT - 还款金额超过负债金额 ### -10018 INVALID_AMOUNT - 无效的还款金额 ### -10019 CONFIG_NOT_EXIST - 配置不存在 ### -10020 UID_NOT_EXIST - 用户ID不存在 ### -10021 ORDER_NOT_EXIST - 订单不存在 ### -10022 INVALID_AMOUNT - 无效的调整金额 ### -10023 ADJUST_LTV_FAILED - 调整质押率失败 ### -10024 ADJUST_LTV_NOT_SUPPORTED - 暂不支持调整质押率 ### -10025 REPAY_FAILED - 还款失败 ### -10026 INVALID_PARAMETER - 无效的参数 ### -10028 INVALID_PARAMETER - 无效的参数 ### -10029 AMOUNT_TOO_SMALL - 借贷金额过小 ### -10030 AMOUNT_TOO_LARGE - 借贷金额过大 ### -10031 QUOTA_REACHED - 已达到个人借贷限额 ### -10032 REPAY_NOT_AVAILABLE - 暂不支持换款 ### -10034 REPAY_NOT_AVAILABLE - 抵押物还款暂时不支持,请尝试用借贷币还款。 ### -10039 AMOUNT_TOO_SMALL - 还款金额过小 ### -10040 AMOUNT_TOO_LARGE - 还款金额过大 ### -10041 INSUFFICIENT_AMOUNT - 由于借贷需求过多,系统剩余可借{0}额度不足。请调整借贷金额或明天再试。 ### -10042 ASSET_NOT_SUPPORTED - 暂不支持%s币种 ### -10043 ASSET_NOT_SUPPORTED - 暂不支持{0} 借贷 ### -10044 QUOTA_REACHED - 抵押物数量已达到限额,请调整抵押金额或使用其他抵押资产。 ### -10045 COLLTERAL_REPAY_NOT_SUPPORTED - 该借贷币种暂不支持抵押物还款,请稍后再试。 ### -10046 EXCEED_MAX_ADJUSTMENT - 调整抵押物超过最大限额,请重试。 ### -10047 REGION_NOT_SUPPORTED - 受当地法规管制,您所在地区暂不支持该币种。 ## 13xxx - 杠杆代币 ### -13000 BLVT_FORBID_REDEEM - 当前该杠杆代币关闭赎回 ### -13001 BLVT_EXCEED_DAILY_LIMIT - 超过该代币个人24小时赎回金额上限 ### -13002 BLVT_EXCEED_TOKEN_DAILY_LIMIT - 超过该代币全局24小时赎回金额上限 ### -13003 BLVT_FORBID_PURCHASE - 当前该杠杆代币关闭申购 ### -13004 BLVT_EXCEED_DAILY_PURCHASE_LIMIT - 超过该代币个人24小时申购金额上限 ### -13005 BLVT_EXCEED_TOKEN_DAILY_PURCHASE_LIMIT - 超过该代币全局24小时申购金额上限 ### -13006 BLVT_PURCHASE_LESS_MIN_AMOUNT - 申购金额低于规定下限 ### -13007 BLVT_PURCHASE_AGREEMENT_NOT_SIGN - 没有签署开通交易协议 ## 12xxx - 流动性挖矿 ### -12014 TOO MANY REQUESTS - 2秒内接收的请求数量多于1条 ## 18xxx - 币安码 ### -18002 - The total amount of codes you created has exceeded the 24-hour limit, please try again after UTC 0 - 24小时内制码总金额已超过限额,请UTC0点后再尝试 ### -18003 - Too many codes created in 24 hours, please try again after UTC 0 - 24小时内制码总次数已超过限额,请UTC0点后再尝试 ### -18004 - Too many invalid redeem attempts in 24 hours, please try again after UTC 0 - 24小时内兑现币安码输错次数已超过限额,请UTC0点后再尝试 ### -18005 - Too many invalid verify attempts, please try later - 参考号输错次数过多,请稍后再试 ### -18006 - The amount is too small, please re-enter - 金额过小,请重新输入 ### -18007 - This token is not currently supported, please re-enter - 尚未支持该币种,请重新输入 ## 21xxx - 統一帳戶 ### -21001 USER_IS_NOT_UNIACCOUNT - 尚未开通统一账户。 ### -21002 UNI_ACCOUNT_CANT_TRANSFER_FUTURE - 统一账户禁用margin向futures转账。 ### -21003 NET_ASSET_MUST_LTE_RATIO - margin资产更新失败。 ### -21004 USER_NO_LIABILITY - 用户不存在统一账户穿仓负债 ### -21005 NO_ENOUGH_ASSET - 用户现货钱包BUSD资产不足以偿还统一账户穿仓负债 ### -21006 HAD_IN_PROCESS_REPAY - 用户存在正在偿还的统一账户穿仓负债 ### -21007 IN_FORCE_LIQUIDATION - 强平进行中,用户偿还统一账户穿仓负债失败 ## 订单拒绝错误 以下错误代码表示撮合引擎返回的订单相关错误: - `-1010 ERROR_MSG_RECEIVED` - `-2010 NEW_ORDER_REJECTED` - `-2011 CANCEL_REJECTED` 结合以下消息将指示特定的错误: | 错误信息 | 描述 | | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | "Unknown order sent." | 找不到订单(通过"orderId","clientOrderId","origClientOrderId") | | "Duplicate order sent." | `clientOrderId`已经被使用 | | "Market is closed." | 该交易对不在交易范围 | | "Account has insufficient balance for requested action." | 没有足够的资金来完成行动 | | "Market orders are not supported for this symbol." | 交易对上未启用"MARKET" | | "Iceberg orders are not supported for this symbol." | 交易对上未启用`icebergQty` | | "Stop loss orders are not supported for this symbol." | 交易对上未启用 `STOP_LOSS` | | "Stop loss limit orders are not supported for this symbol." | 交易对上未启`STOP_LOSS_LIMIT` | | "Take profit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT` | | "Take profit limit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT_LIMIT` | | "Price \* QTY is zero or less." | `price` \* `quantity`太小 | | "IcebergQty exceeds QTY." | `icebergQty` 必须少于订单数量 | | "This action is disabled on this account." | 联系客户支持; 该账户已禁用了某些操作。 | | "This account may not place or cancel orders." | 联系客户支持: 该账户已被禁用了交易操作。 | | "Unsupported order combination" | 不允许组合`orderType`, `timeInForce`, `stopPrice`, 和/或 `icebergQty` 。 | | "Order would trigger immediately." | 与最后交易价格相比,订单的止损价无效。 | | "Cancel order is invalid. Check origClientOrderId and orderId." | 未发送`origClientOrderId` 或`orderId` 。 | | "Order would immediately match and take." | `LIMIT_MAKER` 订单类型将立即匹配并进行交易,而不是纯粹的生成订单。 | | "The relationship of the prices for the orders is not correct." | `OCO`订单中设置的价格不符合报价规则:

The rules are:

`SELL Orders`: Limit Price > Last Price > Stop Price

`BUY Orders`: Limit Price < Last Price < Stop Price | | "OCO orders are not supported for this symbol" | `OCO`订单不支持该交易对 | | "Quote order qty market orders are not support for this symbol." | 这个交易对,市价单不支持参数`quoteOrderQty` | | "Trailing stop orders are not supported for this symbol." | 此symbol不支持 `trailingDelta` | | | "Order cancel-replace is not supported for this symbol." | 此symbol不支持 `POST /api/v3/order/cancelReplace` 或者 `order.cancelReplace` (WebSocket API) | | | "This symbol is not permitted for this account." | 账户和交易对的权限不一致 (比如 `SPOT`, `MARGIN` 等)。| | | "This symbol is restricted for this account." | 账户没有权限在此交易对交易 (比如账户只拥有 `ISOLATED_MARGIN`权限,则无法下`SPOT` 订单)。 | | | "Order was not canceled due to cancel restrictions." | `cancelRestrictions` 设置为 `ONLY_NEW` 但订单状态不是 `NEW`

`cancelRestrictions` 设置为 `ONLY_PARTIALLY_FILLED` 但订单状态不是 `PARTIALLY_FILLED`。 | | ## 关于 POST /api/v3/order/cancelReplace 的错误 ### -2021 Order cancel-replace partially failed 收到该错误码代表撤单**或者**下单失败。 ### -2022 Order cancel-replace failed. 收到该错误码代表撤单**和**下单都失败。 --- ## Document: /products/rebate/change-log URL: /zh-CN/docs/products/rebate/change-log # 更新日志 ## 2025-12-26 ### 时效性通知 - **以下有关于REST API变更将在 2026-01-15 07:OO UTC 发生:**
调用需要签名的接口时,请在计算签名之前对 payload 进行百分比编码(percent-encode)。不符合此顺序的请求将被拒绝,并返回错误代码 [`-1022 签名不正确`](./error-code.md#-1022-invalid_signature)。请检查并相应地更新您代码中的签名逻辑部分。 ### REST API - 更新了 REST API 文档中有关于 [签名请求示例](./general-info.md#post-apiv3order-的签名示例) 的部分。 --- ## 2021-12-03 - 新增反佣接口: - 新增接口 `GET /sapi/v1/rebate/taxQuery` 以支持用户查询现货返佣历史记录 --- ## Document: /products/rebate/Introduction URL: /zh-CN/docs/products/rebate/Introduction 币安现货反佣。 --- ## Document: /products/pay/quick-start URL: /zh-CN/docs/products/pay/quick-start # 快速开始 ## API Key 权限设置 - 新创建的API的默认权限是 `只读`。 - 如果需要通过API提款, 需要在UI修改权限, 选中 `允许提现`。 ## 账户 ### 现货账户 新注册的币安账号都会有一个现货(`SPOT`)账号。 ### 杠杆账户 为了开设杠杆(`MARGIN`)账户, 可以参考[Binance杠杆交易账户设置指南](https://www.binance.vision/zh/tutorials/binance-margin-trading-guide) ## API 代码库 ### Connectors 以下有一些轻量级的代码库,使不同语言的用户能够直接调用现货的 Binance 公共 API: - Python [https://github.com/binance/binance-connector-python](https://github.com/binance/binance-connector-python) - JavaScript [https://github.com/binance/binance-connector-js](https://github.com/binance/binance-connector-js) - Ruby [https://github.com/binance/binance-connector-ruby](https://github.com/binance/binance-connector-ruby) - DotNET C# [https://github.com/binance/binance-connector-dotnet](https://github.com/binance/binance-connector-dotnet) - Java [https://github.com/binance/binance-connector-java](https://github.com/binance/binance-connector-java) - Rust [https://github.com/binance/binance-spot-connector-rust](https://github.com/binance/binance-spot-connector-rust) - PHP [https://github.com/binance/binance-connector-php](https://github.com/binance/binance-connector-php) - Go [https://github.com/binance/binance-connector-go](https://github.com/binance/binance-connector-go) ### Postman Collections Postman 集合现已推出。推荐给寻求快速和轻松地开始使用 API 的新用户。 [https://github.com/binance/binance-api-postman](https://github.com/binance/binance-api-postman) ### Swagger 以下有提供包含 RESTful API 的 OpenAPI 规范的 YAML 文件,以及可供参考的 Swagger UI 页面。 [https://github.com/binance/binance-api-swagger](https://github.com/binance/binance-api-swagger) --- ## Document: /products/pay/general-info URL: /zh-CN/docs/products/pay/general-info # 基本信息 ## API 基本信息 - 接口可能需要用户的 API Key,如何创建API-KEY请参考[这里](https://www.binance.com/cn/support/articles/360002502072) - 本篇列出接口的 base URL 有: - **https://api.binance.com** - **https://api-gcp.binance.com** - **https://api1.binance.com** - **https://api2.binance.com** - **https://api3.binance.com** - **https://api4.binance.com** - 上述列表的最后4个接口 (`api1`-`api4`) 可能会提供更好的性能,但其稳定性略为逊色。因此,请务必使用最适合您现有配置的那款。 - 所有接口的响应都是 JSON 格式。 - 响应中如有数组,数组元素以时间**升序**排列,越早的数据越提前。 - 所有时间、时间戳均为UNIX时间,单位为**毫秒**。 ### HTTP 返回代码 - HTTP `4XX` 错误码用于指示错误的请求内容、行为、格式。问题在于请求者。 - HTTP `403` 错误码表示违反WAF限制(Web应用程序防火墙)。 - HTTP `409` 错误码表示重新下单(cancelReplace)的请求部分成功。(比如取消订单失败,但是下单成功了) - HTTP `429` 错误码表示警告访问频次超限,即将被封IP。 - HTTP `418` 表示收到429后继续访问,于是被封了。 - HTTP `5XX` 错误码用于指示Binance服务侧的问题。 ### 接口错误代码 - 使用接口 `/api/v3`, 以及 `/sapi/v1/margin`时, 每个接口都有可能抛出异常; > API 与 SAPI 的错误代码返回形式如下: ```javascript { "code": -1121, "msg": "Invalid symbol." } ``` - 具体的错误码及其解释在 [错误代码](./error-code). ### 接口的基本信息 - `GET` 方法的接口, 参数必须在 `query string`中发送。 - `POST`, `PUT`, 和 `DELETE` 方法的接口,参数可以在内容形式为`application/x-www-form-urlencoded`的 `query string` 中发送,也可以在 `request body` 中发送。 如果你喜欢,也可以混合这两种方式发送参数。 - 对参数的顺序不做要求。 - 但如果同一个参数名在query string和request body中都有,query string中的会被优先采用。 --- ## 访问限制 ### 访问限制基本信息 - 以下 是`intervalLetter` 作为头部值: - SECOND => S - MINUTE => M - HOUR => H - DAY => D - 在 `/api/v3/exchangeInfo` `rateLimits` 数组中包含与交易的有关RAW_REQUESTS,REQUEST_WEIGHT和ORDERS速率限制相关的对象。这些在 `限制种类 (rateLimitType)` 下的 `枚举定义` 部分中进一步定义。 - 违反任何一个速率限制时(访问频次限制或下单速率限制),将返回429。 ### IP 访问限制 - 每个请求将包含一个`X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,其中包含当前IP所有请求的已使用权重。 - 每一个接口均有一个相应的权重(weight),有的接口根据参数不同可能拥有不同的权重。越消耗资源的接口权重就会越大。 - 收到429时,您有责任停止发送请求,不得滥用API。 - **收到429后仍然继续违反访问限制,会被封禁IP,并收到418错误码** - 频繁违反限制,封禁时间会逐渐延长,**从最短2分钟到最长3天**。 - `Retry-After`的头会与带有418或429的响应发送,并且会给出**以秒为单位**的等待时长(如果是429)以防止禁令,或者如果是418,直到禁令结束。 - **访问限制是基于IP的,而不是API Key** ###下单频率限制 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - 当下单数超过限制时,会收到带有429但不含`Retry-After`头的响应。请检查 `GET api/v3/exchangeInfo` 的下单频率限制 (rateLimitType = ORDERS) 并等待封禁时间结束。 - 被拒绝或不成功的下单并不保证回报中包含以上头内容。 - **下单频率限制是基于每个账户计数的。** - 用户可以通过接口 `GET api/v3/rateLimit/order` 来查询当前的下单量. ### WEB SOCKET 连接限制 - Websocket服务器每秒最多接受5个消息。消息包括: - PING帧 - PONG帧 - JSON格式的消息, 比如订阅, 断开订阅. - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅 **1024** 个Streams。 - 每IP地址、每5分钟最多可以发送300次连接请求。 ### /api/ 与 /sapi/ 接口限频说明 `/api/*`接口和 `/sapi/*`接口采用两套不同的访问限频规则, 两者互相独立。 - `/api/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以 `/api/*`开头的接口按IP限频,**且所有接口共用每分钟6,000限制**。 - 每个请求将包含一个 `X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,包含当前IP所有请求的已使用权重。 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - `/sapi/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以`/sapi/*`开头的接口采用**单接口限频模式**。按IP统计的权重单接口权重总额为每分钟12000;按照UID统计的单接口权重总额是每分钟180000。 - 每个接口会标明是按照IP或者按照UID统计, 以及相应请求一次的权重值。 - 按照IP统计的接口, 请求返回头里面会包含`X-SAPI-USED-IP-WEIGHT-1M=`或`X-SAPI-USED-IP-WEIGHT-1S=`, 包含当前IP所有请求已使用权重。 - 按照UID统计的接口, 请求返回头里面会包含`X-SAPI-USED-UID-WEIGHT-1M=`或`X-SAPI-USED-UID-WEIGHT-1S=`, 包含当前账户所有已用的UID权重。 --- ## 数据来源 - 因为API系统是异步的, 所以返回的数据有延时很正常, 也在预期之中。 - 在每个接口中,都列出了其数据的来源,可以用于理解数据的时效性。 系统一共有3个数据来源,按照更新速度的先后排序。排在前面的数据最新,在后面就有可能存在延迟。 - **撮合引擎** - 表示数据来源于撮合引擎 - **缓存** - 表示数据来源于内部或者外部的缓存 - **数据库** - 表示数据直接来源于数据库 ## 请求鉴权类型 - 每个接口都有一个鉴权类型,指示所需的 API 密钥权限,显示在接口名称旁边(例如,[下新订单 (TRADE)](#place-new-order-trade))。 - 如果未指定,则鉴权类型为 `NONE`。 - 除了为 `NONE` 外,所有具有鉴权类型的接口均视为 `SIGNED` 请求(即包含 `signature`),[listenKey 管理](#user-data-stream-requests) 除外。 - 具有鉴权类型的接口需要提供有效的 API 密钥并验证通过。 - API 密钥可在您的 Binance 账户的 [API 管理](https://www.binance.com/en/support/faq/360002502072) 页面创建。 - **API 密钥和密钥对均为敏感信息,切勿与他人分享。** 如果发现账户有异常活动,请立即撤销所有密钥并联系 Binance 支持。 - API 密钥可配置为仅允许访问某些鉴权接口。 - 例如,您可以拥有具有 `TRADE` 权限的 API 密钥用于交易,同时使用具有 `USER_DATA` 权限的另一个 API 密钥来监控订单状态。 - 默认情况下,API 密钥无法进行 `TRADE`,您需要先在 API 管理中启用交易权限。 | 鉴权类型 | 描述 | | ----------- | ------------------------- | | NONE | 不需要鉴权的接口 | | TRADE | 需要有效的 API-Key 和签名 | | MARGIN | 需要有效的 API-Key 和签名 | | USER_DATA | 需要有效的 API-Key 和签名 | | USER_STREAM | 需要有效的 API-Key | | MARKET_DATA | 需要有效的 API-Key | ### 需要签名的接口 - 调用`SIGNED` 接口时,除了接口本身所需的参数外,还需要在 `query string` 或 `request body` 中传递 `signature`, 即签名参数。 #### 签名是否是大小写敏感的 - **HMAC:** 使用 HMAC 生成的签名**不区分大小写**。这意味着无论字母大小写如何,签名字符串都可以被验证。 - **RSA:** 使用 RSA 生成的签名是**大小写敏感的**。 - **Ed25519:** 使用 Ed25519 生成的签名也是**大小写敏感的**。 请参阅[已签名请求示例 (HMAC)](#hmac-keys)、[已签名请求示例 (RSA)](#rsa-keys) 和[已签名请求示例 (Ed25519)](#ed25519-keys),了解如何根据您使用的 API 密钥类型计算签名。 ### 时间同步安全 - `SIGNED` 请求还需要一个 `timestamp` 参数,该参数应为当前时间戳,单位为毫秒或微秒。(参见 [通用 API 信息](#general-api-information)) - 另一个可选参数 `recvWindow`,用以指定请求的有效期,只能以毫秒为单位。 - `recvWindow` 扩展为三位小数(例如 6000.346),以便可以指定微秒。 - 如果未发送 `recvWindow`,则 **默认值为 5000 毫秒**。 - `recvWindow` 的最大值为 60000 毫秒。 - 请求处理逻辑如下: ```javascript serverTime = getCurrentTime() if (timestamp < (serverTime + 1 second) && (serverTime - timestamp) <= recvWindow) { // 开始处理请求 serverTime = getCurrentTime() if (serverTime - timestamp) <= recvWindow { // 将请求转发到撮合引擎 } else { // 拒绝请求 } // 结束处理请求 } else { // 拒绝请求 } ``` **关于交易时效性** 互联网状况并不100%可靠,不可完全依赖,因此你的程序本地到币安服务器的时延会有抖动. 这是我们设置`recvWindow`的目的所在,如果你从事高频交易,对交易时效性有较高的要求,可以灵活设置`recvWindow`以达到你的要求。 **不推荐使用5秒以上的recvWindow。最大值不能超过60秒!** ### POST /api/v3/order 的签名示例 #### HMAC Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 以下示例分步演示如何使用 `echo`、`openssl` 和 `curl` 从 Linux 命令行发送有效的签名 payload。其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 API 密钥和密钥示例: | Key | Value | | ----------- | ---------------------------------------------------------------- | | `apiKey` | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A | | `secretKey` | NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j | **警告:请勿与任何人分享您的 API 密钥和秘钥。** 此处提供的示例密钥仅用于示范说明目的。 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | LTCBTC | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` **第二步: 计算签名。** 1. 使用 API 密钥中的 `secretKey` 作为 HMAC-SHA-256 算法的签名密钥。 2. 对步骤 1 中构建的签名 payload 进行签名。 3. 将 HMAC-SHA-256 的输出编码为十六进制字符串。 请注意,`secretKey` 和 payload 是**大小写敏感的**,而生成的签名值是不区分大小写的。 **示例命令** 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71 ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n "symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3 ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71" ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3" ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash apiKey="vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" secretKey="NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" payload="symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" # 对请求进行签名 signature=$(echo -n "$payload" | openssl dgst -sha256 -hmac "$secretKey") signature=${signature#*= } # Keep only the part after the "= " # 发送请求 curl -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?$payload&signature=$signature" ``` #### RSA Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 要获取 API 密钥,您需要将 RSA 公钥上传到您的帐户中,系统将为您提供相应的 API 密钥。 仅支持 `PKCS#8` 密钥。 在以下示例中,其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 这些示例假设私钥存储在文件 `./test-prv-key.pem` 中。 | Key | Value | | -------- | ---------------------------------------------------------------- | | `apiKey` | CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ | 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | BTCUSDT | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` **第二步: 计算签名。** 1. 使用 RSASSA-PKCS1-v1_5 算法和 SHA-256 哈希函数对步骤 1 中构建的签名 payload 进行签名。 2. 将输出结果编码为 base64 格式。 请注意,payload 和生成的`签名值`是**大小写敏感的**。 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n 'symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' HZ8HOjiJ1s/igS9JA+n7+7Ti/ihtkRF5BIWcPIEluJP6tlbFM/Bf44LfZka/iemtahZAZzcO9TnI5uaXh3++lrqtNonCwp6/245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH+XxaCmR0WcvlKjNQnp12/eKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang/1WOq+Jaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT/fNnMRxFc7u+j3qI//5yuGuu14KR0MuQKKCSpViieD+fIti46sxPTsjSemoUKp0oXA== ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n 'symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' qJtv66wyp/1mZE+mIFAAMUoTe8xkmLN7/eAZjuC9x1ocxovItHLl/sNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M+JNIMz5UFxfeA53rXjFlvsyH1Sig+OuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C/QMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt/GuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng== ``` 3. 对 base64 格式的字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符): ```console HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D' ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D' ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash function rawurlencode { local string="${1}" local strlen=${#string} local encoded="" local pos c o for (( pos=0 ; pos 错误JSON格式: ```javascript { "code":-1121, "msg":"Invalid symbol." } ``` 错误由两部分组成:错误代码和消息。 代码是通用的,但是消息可能会有所不同。 ## 10xx -常规服务器或网络问题 ### -1000 UNKNOWN - 处理请求时发生未知错误。 - 处理请求时发生未知错误。[%s] ### -1001 DISCONNECTED - 内部错误; 无法处理您的请求。 请再试一次. ### -1002 UNAUTHORIZED - 您无权执行此请求。 ### -1003 TOO_MANY_REQUESTS - 排队的请求过多。 - 请求权重过多; 当前限制是 %s 每 %s 的请求权重。 请使用 Websocket Streams 进行实时更新,以避免轮询API。 - 请求权重过多; IP被禁止,直到%s。 请使用 Websocket Streams 进行实时更新,以免被禁。 ### -1004 SERVER_BUSY - 服务器正忙,请稍候再试。 ### -1006 UNEXPECTED_RESP - 从消息总线收到意外的响应。 执行状态未知。 ### -1007 TIMEOUT - 等待后端服务器响应超时。 发送状态未知; 执行状态未知。 ### -1008 SERVER_BUSY - 现货交易服务器当前因其他请求而过载。 请在几分钟后重试。 ### -1014 UNKNOWN_ORDER_COMPOSITION - 不支持的订单组合。 ### -1015 TOO_MANY_ORDERS - 新订单太多。 - 新订单太多; 当前限制为每%s %s个订单。 ### -1016 SERVICE_SHUTTING_DOWN - 该服务不可用。 ### -1020 UNSUPPORTED_OPERATION - 不支持此操作。 ### -1021 INVALID_TIMESTAMP - 此请求的时间戳在recvWindow之外。 - 此请求的时间戳比服务器时间提前1000毫秒。 ### -1022 INVALID_SIGNATURE - 此请求的签名无效。 ### -1099 Not found, authenticated, or authorized - 替换错误代码-1999 ## 11xx - 2xxx Request issues ### -1100 ILLEGAL_CHARS - 在参数中发现非法字符。 - 在参数中发现非法字符。`%s` - 在参数`%s`中发现非法字符; 合法范围是`%s`。 ### -1101 TOO_MANY_PARAMETERS - 为此端点发送的参数太多。 - 参数太多; 预期为`%s`并收到了`%s`。 - 检测到的参数值重复。 ### -1102 MANDATORY_PARAM_EMPTY_OR_MALFORMED - 未发送强制性参数,该参数为空/空或格式错误。 - 强制参数`%s`未发送,为空/空或格式错误。 - 必须发送参数`%s`或`%s`,但两者均为空! ### -1103 UNKNOWN_PARAM - 发送了未知参数。 ### -1104 UNREAD_PARAMETERS - 并非所有发送的参数都被读取。 - 并非所有发送的参数都被读取; 读取了`%s`参数,但被发送了`%s`。 ### -1105 PARAM_EMPTY - 参数为空。 - 参数`%s`为空。 ### -1106 PARAM_NOT_REQUIRED - 不需要时已发送参数。 - 不需要时发送参数`%s`。 ### -1111 BAD_PRECISION - 精度超过为此资产定义的最大值。 ### -1112 NO_DEPTH - 交易对没有挂单。 ### -1114 TIF_NOT_REQUIRED - 不需要时发送了TimeInForce参数。 ### -1115 INVALID_TIF - 无效 timeInForce. ### -1116 INVALID_ORDER_TYPE - 无效订单类型。 ### -1117 INVALID_SIDE - 无效买卖方向。 ### -1118 EMPTY_NEW_CL_ORD_ID - 新的客户订单ID为空。 ### -1119 EMPTY_ORG_CL_ORD_ID - 客户自定义的订单ID为空。 ### -1120 BAD_INTERVAL - 无效时间间隔。 ### -1121 BAD_SYMBOL - 无效的交易对。 ### -1125 INVALID_LISTEN_KEY - 该listenKey不存在。 ### -1127 MORE_THAN_XX_HOURS - 查询间隔太大。 - 从开始时间到结束时间之间超过%s小时。 ### -1128 OPTIONAL_PARAMS_BAD_COMBO - 可选参数组合无效。 ### -1130 INVALID_PARAMETER - 发送的参数为无效数据。 - 发送参数`%s`的数据无效。 ### -1131 BAD_RECV_WINDOW - `recvWindow` 必须小于 60000 ### -1134 BAD_STRATEGY_TYPE - `strategyType` 必须小于 1000000 #### -1145 INVALID_CANCEL_RESTRICTIONS - `cancelRestrictions` 必须是 `ONLY_NEW` 或者 `ONLY_PARTIALLY_FILLED`。 #### -1151 重复的交易对 - Symbol is present multiple times in the list. ### -2010 NEW_ORDER_REJECTED - 新订单被拒绝 ### -2011 CANCEL_REJECTED - 取消订单被拒绝 ### -2013 NO_SUCH_ORDER - 订单不存在。 ### -2014 BAD_API_KEY_FMT - API-key 格式无效。 ### -2015 REJECTED_MBX_KEY - 无效的API密钥,IP或操作权限。 ### -2016 NO_TRADING_WINDOW - 找不到该交易对的交易窗口。 尝试改为24小时自动报价。 #### -2026 ORDER_ARCHIVED - 订单已被存档因为此订单被取消或过期,无交易数量而最后的更新已超过 90 天前。 ## 3xxx-5xxx SAPI 具体问题 ### -3000 INNER_FAILURE - 内部服务器错误。 ### -3001 NEED_ENABLE_2FA - 请先启用2FA。 ### -3002 ASSET_DEFICIENCY - 此资产不存在。 ### -3003 NO_OPENED_MARGIN_ACCOUNT - 杠杆账户不存在。 ### -3004 TRADE_NOT_ALLOWED - 禁止交易。 ### -3005 TRANSFER_OUT_NOT_ALLOWED - 不允许转账。 ### -3006 EXCEED_MAX_BORROWABLE - 您的已借金额已超过最高可借金额。 ### -3007 HAS_PENDING_TRANSACTION - 您有待处理的交易,请稍后再试。 ### -3008 BORROW_NOT_ALLOWED - 不允许借款。 ### -3009 ASSET_NOT_MORTGAGEABLE - 此资产目前不允许转入杠杆账户。 ### -3010 REPAY_NOT_ALLOWED - 不允许还款。 ### -3011 BAD_DATE_RANGE - 您输入的日期无效。 ### -3012 ASSET_ADMIN_BAN_BORROW - 此资产禁止借款。 ### -3013 LT_MIN_BORROWABLE - 借入金额少于最低借入金额。 ### -3014 ACCOUNT_BAN_BORROW - 此帐户禁止借款。 ### -3015 REPAY_EXCEED_LIABILITY - 还款额超过借款额。 ### -3016 LT_MIN_REPAY - 还款额少于最低还款额。 ### -3017 ASSET_ADMIN_BAN_MORTGAGE - 此资产目前不允许转入保证金账户。 ### -3018 ACCOUNT_BAN_MORTGAGE - 此帐户已禁止转入。 ### -3019 ACCOUNT_BAN_ROLLOUT - 此帐户禁止转出。 ### -3020 EXCEED_MAX_ROLLOUT - 转出金额超过上限。 ### -3021 PAIR_ADMIN_BAN_TRADE - 杠杆账户无法交易此交易对。 ### -3022 ACCOUNT_BAN_TRADE - 账号被禁止交易。 ### -3023 WARNING_MARGIN_LEVEL - 无法在当前杠杆倍数下转出资金或者下单 ### -3024 FEW_LIABILITY_LEFT - 付款之后未付款的债务太小 ### -3025 INVALID_EFFECTIVE_TIME - 输入时间有误。 ### -3026 VALIDATION_FAILED - 输入参数有误。 ### -3027 NOT_VALID_MARGIN_ASSET - 无效的杠杆资产。 ### -3028 NOT_VALID_MARGIN_PAIR - 无效的杠杆交易对。 ### -3029 TRANSFER_FAILED - 转账失败。 ### -3036 ACCOUNT_BAN_REPAY - 此账号无法还款。 ### -3037 PNL_CLEARING - `PNL`正在清帐,请稍等。 ### -3038 LISTEN_KEY_NOT_FOUND - 找不到`Listen key` ### -3041 BALANCE_NOT_CLEARED - 余额不足 ### -3042 PRICE_INDEX_NOT_FOUND - 该杠杆交易对无可用价格指数。 ### -3043 TRANSFER_IN_NOT_ALLOWED - 不允许转入。 ### -3044 SYSTEM_BUSY - 系统繁忙。 ### -3045 SYSTEM - 系统目前没有足够可借的资产。 ### -3999 NOT_WHITELIST_USER - 此功能只面向邀请的用户。 ### -4001 CAPITAL_INVALID - 非法操作 ### -4002 CAPITAL_IG - 非法获取 ### -4003 CAPITAL_IEV - 非法邮箱验证 ### -4004 CAPITAL_UA - 未登录或者认证。 ### -4005 CAPAITAL_TOO_MANY_REQUEST - 请求太频繁。 ### -4006 CAPITAL_ONLY_SUPPORT_PRIMARY_ACCOUNT - 只支持主账号。 ### -4007 CAPITAL_ADDRESS_VERIFICATION_NOT_PASS - 地址的没有通过校验。 ### -4008 CAPITAL_ADDRESS_TAG_VERIFICATION_NOT_PASS - 地址的标记信息(`tag`)没有通过校验。 ### -4010 CAPITAL_WHITELIST_EMAIL_CONFIRM - 确认电子邮件已经列入白名单。 ### -4011 CAPITAL_WHITELIST_EMAIL_EXPIRED - 列入白名单的电子邮件无效。 ### -4012 CAPITAL_WHITELIST_CLOSE - 白名单未打开。 ### -4013 CAPITAL_WITHDRAW_2FA_VERIFY - 2FA未打开。 ### -4014 CAPITAL_WITHDRAW_LOGIN_DELAY - 在登录后的2分钟之内不允许提款。 ### -4015 CAPITAL_WITHDRAW_RESTRICTED_MINUTE - 暂停提款 ### -4016 CAPITAL_WITHDRAW_RESTRICTED_PASSWORD - 在密码修改后的24小时之内不允许提款。 ### -4017 CAPITAL_WITHDRAW_RESTRICTED_UNBIND_2FA - 在2FA发行后的24小时之内不允许提款。 ### -4018 CAPITAL_WITHDRAW_ASSET_NOT_EXIST - 此资产不存在。 ### -4019 CAPITAL_WITHDRAW_ASSET_PROHIBIT - 此资产不允许提款。 ### -4021 CAPITAL_WITHDRAW_AMOUNT_MULTIPLE - 资产的提款数量必须是%s的%s倍。 ### -4022 CAPITAL_WITHDRAW_MIN_AMOUNT - 不须少于最低的提款数量%s。 ### -4023 CAPITAL_WITHDRAW_MAX_AMOUNT - 在24小时之内,不须超过最高的提款数量。 ### -4024 CAPITAL_WITHDRAW_USER_NO_ASSET - 当前用户没有此资产。 ### -4025 CAPITAL_WITHDRAW_USER_ASSET_LESS_THAN_ZERO - 持有资产的数量小于零。 ### -4026 CAPITAL_WITHDRAW_USER_ASSET_NOT_ENOUGH - 此资产余额不足。 ### -4027 CAPITAL_WITHDRAW_GET_TRAN_ID_FAILURE - 无法获取tranId。 ### -4028 CAPITAL_WITHDRAW_MORE_THAN_FEE - 提款金额必须多于佣金额。 ### -4029 CAPITAL_WITHDRAW_NOT_EXIST - 此提款记录不存在。 ### -4030 CAPITAL_WITHDRAW_CONFIRM_SUCCESS - 提款资产成功。 ### -4031 CAPITAL_WITHDRAW_CANCEL_FAILURE - 取消提款失败。 ### -4032 CAPITAL_WITHDRAW_CHECKSUM_VERIFY_FAILURE - 验证提款失败。 ### -4033 CAPITAL_WITHDRAW_ILLEGAL_ADDRESS - 提款地址不合法。 ### -4034 CAPITAL_WITHDRAW_ADDRESS_CHEAT - 当前地址有异常。 ### -4035 CAPITAL_WITHDRAW_NOT_WHITE_ADDRESS - 此地址不在白名单上。请加入然后重试。 ### -4036 CAPITAL_WITHDRAW_NEW_ADDRESS - 新地址在{0}小时后才可以提款。 ### -4037 CAPITAL_WITHDRAW_RESEND_EMAIL_FAIL - 重新发送邮件失败。 ### -4038 CAPITAL_WITHDRAW_RESEND_EMAIL_TIME_OUT - 请5分钟后重试。 ### -4039 CAPITAL_USER_EMPTY - 用户不存在。 ### -4041 CAPITAL_MINUTE_TOO_SMALL - 请一分钟后重试。 ### -4042 CAPITAL_CHARGE_NOT_RESET - 资产无法重新获取存款地址。 ### -4043 CAPITAL_ADDRESS_TOO_MUCH - 在24小时之内充值超过100多个地址。 ### -4044 CAPITAL_BLACKLIST_COUNTRY_GET_ADDRESS - 此国家在黑名单上。 ### -4045 CAPITAL_GET_ASSET_ERROR - 获得资产失败。 ### -4046 CAPITAL_AGREEMENT_NOT_CONFIRMED - 协议未确认。 ### -4047 CAPITAL_DATE_INTERVAL_LIMIT - 时间间隔必须在0-90天之内 ### -4060 CAPITAL_WITHDRAW_USER_ASSET_LOCK_DEPOSIT - 体现仍在区块确认中,暂时锁定部分资产 ### -4106 TAG_NOT_SUPPORTED_FOR_NETWORK - 该网络不支持 memo/tag。请移除 `addressTag` 字段后重试。 ### -5001 ASSET_DRIBBLET_CONVERT_SWITCH_OFF - 不允许转移到微型资产。 ### -5002 ASSET_ASSET_NOT_ENOUGH - 此余额不足。 ### -5003 ASSET_USER_HAVE_NO_ASSET - 此资产不存在。 ### -5004 USER_OUT_OF_TRANSFER_FLOAT - 剩余余额已超过0.001BTC,请重新选择。 - %s的剩余余额已超过0.001BTC,请重新选择。 ### -5005 USER_ASSET_AMOUNT_IS_TOO_LOW - BTC的剩余余额太低,请重新选择。 - %s的剩余余额太低,请重新选择。 ### -5006 USER_CAN_NOT_REQUEST_IN_24_HOURS - 24小时内只能转账一次。 ### -5007 AMOUNT_OVER_ZERO - 数量必须大于零。 ### -5008 ASSET_WITHDRAW_WITHDRAWING_NOT_ENOUGH - 可退回资产的金额不足。 ### -5009 PRODUCT_NOT_EXIST - 产品不存在。 ### -5010 TRANSFER_FAIL - 资产转移失败。 ### -5011 FUTURE_ACCT_NOT_EXIST - 合约帐户不存在。 ### -5012 TRANSFER_PENDING - 资产转移正在进行中。 ### -5021 PARENT_SUB_HAVE_NO_RELATION - 当前的子账户和母账户没有从属关系。 ### -5012 FUTURE_ACCT_OR_SUBRELATION_NOT_EXIST - 合约帐户或子账户关系不存在。 ## 6XXX - 币安宝相关 ### -6001 DAILY_PRODUCT_NOT_EXIST - 理财产品不存在. ### -6003 DAILY_PRODUCT_NOT_ACCESSIBLE - 产品不存在或者没有权限。 ### -6004 DAILY_PRODUCT_NOT_PURCHASABLE - 产品无法购买。 ### -6005 DAILY_LOWER_THAN_MIN_PURCHASE_LIMIT - 低于可以购买的最小限额。 ### -6006 DAILY_REDEEM_AMOUNT_ERROR - 赎回额度有误。 ### -6007 DAILY_REDEEM_TIME_ERROR - 不在赎回的时间内。 ### -6008 DAILY_PRODUCT_NOT_REDEEMABLE - 产品暂时无法赎回。 ### -6009 REQUEST_FREQUENCY_TOO_HIGH - 发送请求太频繁。 ### -6011 EXCEEDED_USER_PURCHASE_LIMIT - 超购每个月用户可以申购的最大次数。 ### -6012 BALANCE_NOT_ENOUGH - 余额不足。 ### -6013 PURCHASING_FAILED - 申购失败。 ### -6014 UPDATE_FAILED - 超过可以申购的最大上限。 ### -6015 EMPTY_REQUEST_BODY - 请求的`body`为空。 ### -6016 PARAMS_ERR - 请求的参数有误。 ### -6017 NOT_IN_WHITELIST - 不在白名单里面。 ### -6018 ASSET_NOT_ENOUGH - 资产不足。 ### -6019 PENDING - 需要进一步确认。 ### -6020 PROJECT_NOT_EXISTS - 此项目不存在。 ## 70xx - 期货 ### -7001 FUTURES_BAD_DATE_RANGE - 此日期范围不支持。 ### -7002 FUTURES_BAD_TYPE - 此数据请求类型不支持。 ## 20xxx - 合约/现货策略交易 ### -20121 Invalid symbol - 无效交易对。 ### -20124 Invalid algo id or it has been completed - 无效的策略订单ID或者它已经被执行。 ### -20130 Invalid data sent for a parameter - 无效数据。 ### -20132 The client algo id is duplicated - 用户自定义策略订单ID重复。 ### -20194 Duration is too short to execute all required quantity - Duration 时间太短不足以执行用户选择的订单数量。 ### -20195 The total size is too small - 下单数量太小。 ### -20196 The total size is too large - 下单数量太大。 ### -20198 Reach the max open orders allowed - 达到了最大挂单上限。 ### -20204 The notional of USD is less or more than the limit - 订单小于最小USD名义价值 ## 过滤器故障 | 报错信息 | 描述 | | ------------------------------------------ | ---------------------------------------------------------------------------------- | | "Filter failure: PRICE_FILTER" | "价格"过高,过低和/或不遵循交易对的最小价格规则。 | | "Filter failure: PERCENT_PRICE" | "价格"比最近Y分钟的平均加权价格高X%或X%太低。 | | "Filter failure: PERCENT_PRICE_BY_SIDE" | `price` 在当前方向上(`BUY`或者`SELL`)比`lastPrice`价格超过X%或者低于Y%。 | | "Filter failure: LOT_SIZE" | "数量"太高,太低和/或不遵循该交易对的步长规则。 | | "Filter failure: MIN_NOTIONAL" | 价格\*数量太低,无法成为该交易对的有效订单。 | | "Filter failure: ICEBERG_PARTS" | `ICEBERG` 订单会分成太多部分; icebergQty太小。 | | "Filter failure: MARKET_LOT_SIZE" | "MARKET"订单的"数量"过高,过低和/或未遵循交易对的步长规则。 | | "Filter failure: MAX_POSITION" | 达到账户的最大仓位限制。这包括了账户的余额总额,以及所有处于open的买单的数量总和。 | | "Filter failure: MAX_NUM_ORDERS" | 客户在交易对上有太多挂单。 | | "Filter failure: MAX_ALGO_ORDERS" | 账户有太多未平仓止损和/或在交易对上执行获利指令。 | | "Filter failure: MAX_NUM_ICEBERG_ORDERS" | 客户在交易对上有太多 iceberg 挂单。 | | "Filter failure: TRAILING_DELTA" | `trailingDelta` 值不在限定的范围内. | | "Filter failure: EXCHANGE_MAX_NUM_ORDERS" | 帐户上的交易所有太多挂单。 | | "Filter failure: EXCHANGE_MAX_ALGO_ORDERS" | 帐户有太多止损挂单和/或在交易所收取获利指令。 | ## 10xxx - 质押借币 ### -10001 SYSTEM_MAINTENANCE - 系统维护中,请稍后再试 ### -10002 INVALID_INPUT - 无效的输入参数 ### -10005 NO_RECORDS - 暂无记录 ### -10007 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10008 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10009 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10010 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10011 INSUFFICIENT_ASSET - 现货资产不足 ### -10012 INVALID_AMOUNT - 无效的还款金额 ### -10013 INSUFFICIENT_AMOUNT - 抵押资产不足 ### -10015 DEDUCTION_FAILED - 抵押资产扣款失败 ### -10016 LOAN_FAILED - 放贷失败 ### -10017 REPAY_EXCEED_DEBT - 还款金额超过负债金额 ### -10018 INVALID_AMOUNT - 无效的还款金额 ### -10019 CONFIG_NOT_EXIST - 配置不存在 ### -10020 UID_NOT_EXIST - 用户ID不存在 ### -10021 ORDER_NOT_EXIST - 订单不存在 ### -10022 INVALID_AMOUNT - 无效的调整金额 ### -10023 ADJUST_LTV_FAILED - 调整质押率失败 ### -10024 ADJUST_LTV_NOT_SUPPORTED - 暂不支持调整质押率 ### -10025 REPAY_FAILED - 还款失败 ### -10026 INVALID_PARAMETER - 无效的参数 ### -10028 INVALID_PARAMETER - 无效的参数 ### -10029 AMOUNT_TOO_SMALL - 借贷金额过小 ### -10030 AMOUNT_TOO_LARGE - 借贷金额过大 ### -10031 QUOTA_REACHED - 已达到个人借贷限额 ### -10032 REPAY_NOT_AVAILABLE - 暂不支持换款 ### -10034 REPAY_NOT_AVAILABLE - 抵押物还款暂时不支持,请尝试用借贷币还款。 ### -10039 AMOUNT_TOO_SMALL - 还款金额过小 ### -10040 AMOUNT_TOO_LARGE - 还款金额过大 ### -10041 INSUFFICIENT_AMOUNT - 由于借贷需求过多,系统剩余可借{0}额度不足。请调整借贷金额或明天再试。 ### -10042 ASSET_NOT_SUPPORTED - 暂不支持%s币种 ### -10043 ASSET_NOT_SUPPORTED - 暂不支持{0} 借贷 ### -10044 QUOTA_REACHED - 抵押物数量已达到限额,请调整抵押金额或使用其他抵押资产。 ### -10045 COLLTERAL_REPAY_NOT_SUPPORTED - 该借贷币种暂不支持抵押物还款,请稍后再试。 ### -10046 EXCEED_MAX_ADJUSTMENT - 调整抵押物超过最大限额,请重试。 ### -10047 REGION_NOT_SUPPORTED - 受当地法规管制,您所在地区暂不支持该币种。 ## 13xxx - 杠杆代币 ### -13000 BLVT_FORBID_REDEEM - 当前该杠杆代币关闭赎回 ### -13001 BLVT_EXCEED_DAILY_LIMIT - 超过该代币个人24小时赎回金额上限 ### -13002 BLVT_EXCEED_TOKEN_DAILY_LIMIT - 超过该代币全局24小时赎回金额上限 ### -13003 BLVT_FORBID_PURCHASE - 当前该杠杆代币关闭申购 ### -13004 BLVT_EXCEED_DAILY_PURCHASE_LIMIT - 超过该代币个人24小时申购金额上限 ### -13005 BLVT_EXCEED_TOKEN_DAILY_PURCHASE_LIMIT - 超过该代币全局24小时申购金额上限 ### -13006 BLVT_PURCHASE_LESS_MIN_AMOUNT - 申购金额低于规定下限 ### -13007 BLVT_PURCHASE_AGREEMENT_NOT_SIGN - 没有签署开通交易协议 ## 12xxx - 流动性挖矿 ### -12014 TOO MANY REQUESTS - 2秒内接收的请求数量多于1条 ## 18xxx - 币安码 ### -18002 - The total amount of codes you created has exceeded the 24-hour limit, please try again after UTC 0 - 24小时内制码总金额已超过限额,请UTC0点后再尝试 ### -18003 - Too many codes created in 24 hours, please try again after UTC 0 - 24小时内制码总次数已超过限额,请UTC0点后再尝试 ### -18004 - Too many invalid redeem attempts in 24 hours, please try again after UTC 0 - 24小时内兑现币安码输错次数已超过限额,请UTC0点后再尝试 ### -18005 - Too many invalid verify attempts, please try later - 参考号输错次数过多,请稍后再试 ### -18006 - The amount is too small, please re-enter - 金额过小,请重新输入 ### -18007 - This token is not currently supported, please re-enter - 尚未支持该币种,请重新输入 ## 21xxx - 統一帳戶 ### -21001 USER_IS_NOT_UNIACCOUNT - 尚未开通统一账户。 ### -21002 UNI_ACCOUNT_CANT_TRANSFER_FUTURE - 统一账户禁用margin向futures转账。 ### -21003 NET_ASSET_MUST_LTE_RATIO - margin资产更新失败。 ### -21004 USER_NO_LIABILITY - 用户不存在统一账户穿仓负债 ### -21005 NO_ENOUGH_ASSET - 用户现货钱包BUSD资产不足以偿还统一账户穿仓负债 ### -21006 HAD_IN_PROCESS_REPAY - 用户存在正在偿还的统一账户穿仓负债 ### -21007 IN_FORCE_LIQUIDATION - 强平进行中,用户偿还统一账户穿仓负债失败 ## 订单拒绝错误 以下错误代码表示撮合引擎返回的订单相关错误: - `-1010 ERROR_MSG_RECEIVED` - `-2010 NEW_ORDER_REJECTED` - `-2011 CANCEL_REJECTED` 结合以下消息将指示特定的错误: | 错误信息 | 描述 | | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | "Unknown order sent." | 找不到订单(通过"orderId","clientOrderId","origClientOrderId") | | "Duplicate order sent." | `clientOrderId`已经被使用 | | "Market is closed." | 该交易对不在交易范围 | | "Account has insufficient balance for requested action." | 没有足够的资金来完成行动 | | "Market orders are not supported for this symbol." | 交易对上未启用"MARKET" | | "Iceberg orders are not supported for this symbol." | 交易对上未启用`icebergQty` | | "Stop loss orders are not supported for this symbol." | 交易对上未启用 `STOP_LOSS` | | "Stop loss limit orders are not supported for this symbol." | 交易对上未启`STOP_LOSS_LIMIT` | | "Take profit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT` | | "Take profit limit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT_LIMIT` | | "Price \* QTY is zero or less." | `price` \* `quantity`太小 | | "IcebergQty exceeds QTY." | `icebergQty` 必须少于订单数量 | | "This action is disabled on this account." | 联系客户支持; 该账户已禁用了某些操作。 | | "This account may not place or cancel orders." | 联系客户支持: 该账户已被禁用了交易操作。 | | "Unsupported order combination" | 不允许组合`orderType`, `timeInForce`, `stopPrice`, 和/或 `icebergQty` 。 | | "Order would trigger immediately." | 与最后交易价格相比,订单的止损价无效。 | | "Cancel order is invalid. Check origClientOrderId and orderId." | 未发送`origClientOrderId` 或`orderId` 。 | | "Order would immediately match and take." | `LIMIT_MAKER` 订单类型将立即匹配并进行交易,而不是纯粹的生成订单。 | | "The relationship of the prices for the orders is not correct." | `OCO`订单中设置的价格不符合报价规则:

The rules are:

`SELL Orders`: Limit Price > Last Price > Stop Price

`BUY Orders`: Limit Price < Last Price < Stop Price | | "OCO orders are not supported for this symbol" | `OCO`订单不支持该交易对 | | "Quote order qty market orders are not support for this symbol." | 这个交易对,市价单不支持参数`quoteOrderQty` | | "Trailing stop orders are not supported for this symbol." | 此symbol不支持 `trailingDelta` | | | "Order cancel-replace is not supported for this symbol." | 此symbol不支持 `POST /api/v3/order/cancelReplace` 或者 `order.cancelReplace` (WebSocket API) | | | "This symbol is not permitted for this account." | 账户和交易对的权限不一致 (比如 `SPOT`, `MARGIN` 等)。| | | "This symbol is restricted for this account." | 账户没有权限在此交易对交易 (比如账户只拥有 `ISOLATED_MARGIN`权限,则无法下`SPOT` 订单)。 | | | "Order was not canceled due to cancel restrictions." | `cancelRestrictions` 设置为 `ONLY_NEW` 但订单状态不是 `NEW`

`cancelRestrictions` 设置为 `ONLY_PARTIALLY_FILLED` 但订单状态不是 `PARTIALLY_FILLED`。 | | ## 关于 POST /api/v3/order/cancelReplace 的错误 ### -2021 Order cancel-replace partially failed 收到该错误码代表撤单**或者**下单失败。 ### -2022 Order cancel-replace failed. 收到该错误码代表撤单**和**下单都失败。 --- ## Document: /products/pay/change-log URL: /zh-CN/docs/products/pay/change-log # 更新日志 ## 2025-12-26 ### 时效性通知 - **以下有关于REST API变更将在 2026-01-15 07:OO UTC 发生:**
调用需要签名的接口时,请在计算签名之前对 payload 进行百分比编码(percent-encode)。不符合此顺序的请求将被拒绝,并返回错误代码 [`-1022 签名不正确`](./error-code.md#-1022-invalid_signature)。请检查并相应地更新您代码中的签名逻辑部分。 ### REST API - 更新了 REST API 文档中有关于 [签名请求示例](./general-info.md#post-apiv3order-的签名示例) 的部分。 --- ## 2021-11-19 - 新增Pay接口: - 新增接口`GET /sapi/v1/pay/transactions`以支持用户查询Pay交易历史记录 --- ## Document: /products/pay/Introduction URL: /zh-CN/docs/products/pay/Introduction 币安支付是币安推出的一种无接触、无国界的加密货币支付技术,安全可靠,值得信赖。通过币安支付,您可以使用加密货币购物或向世界各地的亲朋好友发送加密货币。 --- ## Document: DApp Self-Testing Manual URL: /zh-CN/docs/products/open-platform/self-testing-op # DApp Self-Testing Manual _SDK integration, DApps listing are independent. Well-tested DApps will help to reduce partly campaign workload._ ## Summary For all parties interested in cooperating with Binance Web3 Wallet, this manual contains all relevant information, including [integrating the Binance Web3 Connect SDK](/products/web3-connect/introduction) and **joining the Binance Web3 Wallet Dapp Zone**. **Self-testing** by the project party is essential. The Binance Web3 Wallet team strongly recommends that all projects complete self-testing according to the provided instructions to maximize user experience. Binance reserves the right to reject applications from projects that demonstrate low testing quality. Please read the following information carefully. ## How to test dApp 1. Type your url in the latest Binance Web3 wallet browser. 2. Test all the features in DApps. You could refer to the following test case checklist for guidance. ![browser-entry](/img/web3-dapp/browser-entry.png) ## Frequent Problems ### Error Code : ‘Network not supported for this wallet’ Project website should detect and change to the corresponding chain when users connect. For BEVM, check the `window.ethereum` chainId to change to the correct chain. ### IOS/Android Login Problem Check SDK status and Internet/VPN connection. ### RPC problem When testing on chain actions, projects might find the gas fee abnormally high. In this situation, projects could try the test with Trust Wallet and other Wallets like Metamask. If it only happens in Trust Wallet and Binance Wallet, it would be Binance’s RPC issue. Please contact Jasmine G @P0kEjasmine if this happens. ### Mobile Login Issue Ensure that the Binance App version for both IOS and Android is updated to the **latest version**. ## Test Case Checklist ### SDK | Category | Feature (Web, IOS and Android) | | ---------------- | -------------------------------------------------------------------------------------------------------------------- | | Connect Wallet | Can get wallet address and chainID. | | Send Transaction | The whole transaction process should be successful and can be checked on the chain. | | Sign message | The signature value should be valid | | Logo exposure | E.g.
| ### dApps | Category | Feature (IOS and Android) | | ---------------- | ------------------------------------------------------------------------------------- | | Connect Wallet | Wallet connects successfully and stably. (Without page redirection) | | | Binance Logo Exposure Success (Web & App) | | Send Transaction | All send transaction cases are successful. (e.g. Swap, Approve, etc.) | | | The gas fee is in the normal range. | | User Experience | The font size and icons are displayed appropriately. | | | All the URLs in the dApp can be opened in Binance directly. | | | The project will automatically switch to the user's current chain if it is supported. | | | All cases should be checked in both IOS and Android | --- ## Document: DApp Self-Listing Manual URL: /zh-CN/docs/products/open-platform/self-listing-op # DApp Self-Listing Manual ## Introduction This manual is intended as a guide for any dApp team looking to include their dApp in Binance's Web3 wallet dApp Zone. All project parties who want to cooperate with Binance Web3 wallet must have approval for all the dApps they intend to work with. Therefore, all the teams will need to go through a self-testing process to ensure that the dApps and **Binance Web3 Wallet SDK integration functions** are implemented in both Binance Web3 Wallet on Binance App and PC as scheduled. Only dApps that pass the quality control process will be allowed to enter the review process. ![dApp Zone](/img/web3-dapp/dapp-zone.png) **Please Notice:** 1. All submitted applications are expected to receive review results within 7 business days. 2. Applicants are allowed to check the approval process in [Binance Web3 Wallet Open Platform](https://www.binance.com/en/web3-wallet-open-platform). ## How to apply? 1. Log in Binance Binance Web3 Wallet Open Platform : https://www.binance.com/en/web3-wallet-open-platform 2. Read the Open Platform Vendor Agreement: https://public.bnbstatic.com/static/pdf/open_platform_vendor_terms_180924.pdf 3. Click [dApp],then click [Apply] in the subpage. ![dapp-in-op](/img/web3-dapp/dapp-in-op.png) 4. Fill in the [application form](https://www.binance.com/en/web3-wallet-open-platform/project/dapp/application). ![apply-in-op](/img/web3-dapp/apply-in-op.png) 5. After completing the application form, the status in the Application Management page will change to ‘in Review’. ![review-in-op](/img/web3-dapp/review-in-op.png) 6. Binance will conduct a quality control test using the [self-test checklist](/products/web3-dapp/self-testing#test-case-checklist) within 7 business days of application approval. A full self-test is a prerequisite for self-listing. Binance will only list the DApps that have completed the [Binance Web3 wallet integration](/products/web3-connect/introduction) (including Binance Logo exposure) and pass all items in the [self-test checklist](/products/web3-dapp/self-testing#test-case-checklist). --- ## Document: How to Create an Airdrop Campaign on Binance Web3 Open Platform? URL: /zh-CN/docs/products/open-platform/airdrop-creation # How to Create an Airdrop Campaign on Binance Web3 Open Platform? ## Airdrop Campaign Overview | **Owner** | **Step** | **Description** | | --------- | ---------------------- | ------------------------------------------------ | | Project | Campaign preparation | List your dApp and develop your API | | | Campaign configuration | Set up airdrop campaign | | | Funds deposit | Deposit campaign reward | | | Submit campaign | Submit the campaign to Binance | | Binance | Campaign review | Binance reviews the campaign setting and approve | | | Campaign launch | Binance list campaign on Web3 Wallet | ## Airdrop Campaign Tutorial ### Campaign preparation - Develop API for the on-chain tasks, and register the API on Open Platform > Airdrop Campaign > Task Verification API - API specifications: [Doc](/products/web3-task-verification/apis) - API registration: - Click on the “+ Create New API” button ![create-new-api](/img/web3-dapp/create-new-api.png) - Input the API Name and the API Pre-fix.
API Name: Give your API an arbitrary name. It is an unused variable.
API Pre-Fix: Initial segment of your API URL path. Please contact your dev in charge of the API development to get the API Pre-Fix. ![create-popup](/img/web3-dapp/create-popup.png) ### Campaign configuration - **Start to create a new Airdrop:** - Click on the “+ Create Airdrop” button to create a new airdrop campaign. - Note: All settings can not be changed after you submit the airdrop campaign, so please make sure and re-check after you finish the configuration. ![create-airdrop](/img/web3-dapp/create-airdrop.png) - **Step1: Basic information setting** - Airdrop Name: the title of this airdrop campaign which can be seen by users. E.g.: Binance 1M$ BNB Airdrop! - Airdrop Period(UTC): the airdrop campaign start date and time, and end date and time\ Please set up a test campaign with an immediate start date first for Binance Wallet team to test and sign off for you to set up the official campaign again for the launch. The test campaign should have everything else ready and equal to your formal campaign but the actual launch date and the reward amount. - Airdrop Rules Link: the page links to a page to introduce the campaign rules. - Airdrop Rules Highlight: the highlights of this airdrop campaign mechanism. In the campaign rules link, the project should include the general background of this campaign, the pre-requirement for users to participate, the task design with as precise as possible details for example on which chain for how many tokens etc, and the eligibility criteria for users to receive reward. A tutorial is recommended as the last section of this page to increase the task completion rate. - Campaign chain: the campaign chain, and rewards claim chain. Please note these two chains will have to be the same so that your users can successfully claim the reward later. - Total rewards: the total reward description in the sum of this airdrop campaign. - Campaign rewards type: 2 types supported - Token (Pending TGE): applicable for tokens has not launched now. - Token (Completed TGE): applicable for tokens launched already. ![campaign-form](/img/web3-dapp/campaign-form.png) - Token (Pending TGE) application flow: - This process is only needed when you select the Token (Pending TGE) type of reward. - Click on the “Contact” button and fill in the necessary information. And then wait for Binance’s approval. Alternatively, you can directly reach out and share your Campaign ID with your POC at Binance Wallet to whitelist your Campaign ID and thus you can proceed for the next step. ![campaign-form-2-1](/img/web3-dapp/campaign-form-2-1.png) - **Step2: Eligibility setting** - Anti-Sybil Level setting: - Level 1: 1 wallet address can join the campaign once, and claim rewards once (once the wallet address completes tasks). - Level 2: 1 Binance user (identified by Binance account UID) can join the campaign once, and claim rewards once. - Level 3: 1 real users (identified by Binance account UID, and excluded batch registration user) can join the campaign once, and claim rewards once. - Please make sure to have a consistent description in your rules page regarding campaign participation eligibility. - Restricted Countries / Regions for Participants - Users from the countries/regions you selected will be blocked when they try to join your airdrop campaign. - Please select based on your product’s geo-blocking rules. ![campaign-form-2-2](/img/web3-dapp/campaign-form-2-2.png) - **Step3: Task/Reward setting** - Select templates: - Select an option based on how many dApps will be included in this campaign: - Single dApp: you will only ask users to interact with one dApp to complete the on-chain tasks - Multiple dApps: you will ask users to interact with multiple dApps to complete different on-chain tasks ![campaign-form-3-1](/img/web3-dapp/campaign-form-3-1.png) - Select your Dapp: - Click the “Add dApp” button to select your dApp - _Note: you only can select dApps listed on Binance. If you can not find your dApp, please submit your dApp listing application first._ ![campaign-form-3-2](/img/web3-dapp/campaign-form-3-2.png) - Add task - 2 Task Type:  - On-chain task: requires users to execute some on-chain actions. - Social task: require users to follow X account / Repost X post. * On-chain task:  - Task Title: a summary text for the task. E.g., Stake task - Task Tutorial Link: a page link redirects to the task tutorials. It is highly recommended to add a tutorial for on-chain tasks. - Please input the full URL including “https\://” - dApp URL for the task: the link user can finish the task.  - Please input the full URL including “https\://” - Task description: a detailed description of the task content. Please make sure your task description contains precise details: on which chain, for how many tokens and avoid confusions regarding the token number and values etc. A detailed and precise will greatly help you avoid unnecessary customer support pressure. - A good example: Swap 2 $BNB token on BSC chain. (Assume the current price is $700/BNB) - A bad example: Swap 1400 $BNB. - No instruction on which chain - Confusion about 1400 dollar worth of BNB or 1400 BNB - Token price is often fluctuating. To insure your API can successfully verify the task completion status over the campaign period, we require projects to specify the number of tokens instead of dollar value of tokens. - Task verification: select your API registered and input your task ID.  - If you can not find your API, please go to Open Platform > Airdrop Campaign > Task Verify API to register your API first. - Please ensure the task ID you use is provided and confirmed by your dev. Task ID is a string identifier used to represent a specific task within the `task` parameter of the API. ![new-task](/img/web3-dapp/new-task.png) - Social task - Social Channel: now only X is supported. - Task Content:  - Follow an X account: require users to follow an X account. - Need to input X username. Please don’t include @ in the username. - Repost an X post: require users to repost an X post.  - Need to input the X post link. Please make sure to include https :// in the link. - The repost content is required to be related with Binance Wallet and please do have your POC at Binance Wallet preview and approve the content in advance. - If your project would like to have users to repost about the on-going campaign announcement, please reach out to your POC at Binance Wallet and synchronize the timeline and to-dos in advance so that your link can be updated in time once your post and campaign are live. ![social-task](/img/web3-dapp/social-task.png) - **Reward:** - **3 Reward Type:** - Task Reward: for users who complete the task. - Enable the reward by toggling on the “Enable Task Reward” toggle. ![reward-type](/img/web3-dapp/reward-type.png) - DApp Completion Reward: for users who complete all tasks under a dApp. Only available when the “Multiple DApps” template is selected. - Enable the reward by toggling on the “DApp Completion Reward” toggle. ![reward-toggle](/img/web3-dapp/reward-toggle.png) - Airdrop Completion Reward: for users who complete all tasks under a dApp.  - Enable the reward by toggling on the “Airdrop Completion Reward” toggle. ![completion-reward](/img/web3-dapp/completion-reward.png) - **Reward Setting:**  - All the 3 Reward types share the same setting. The setting is different based on the Rewards Mechanism you selected. | Rewards Mechanism | Description | Settings | | ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | FCFS (First come first serve) | Users who complete the task first to get a share of the reward, which is a fixed amount. | • Rewards Type: Only can select Token (Completed TGE)
• Chain: the same with your Campaign chain
• Number of Winners: the reward share amount
• Token Name:
- If the token is a native token, then select from the dropdown list
- If the token is not a native token, then input the token smart contract address
• Reward per Winner: the amount of tokens for each winner
• Please do not ask all the users to verify their task completion status at once - e.g. verify your holding status on January 1 23:59 UTC - to avoid unnecessary API queries crash from your side | | Shared | Users who completed the task split the reward pool equally, the reward amount is the Total Reward / User who completed the task. | • Rewards Type: Can select both of the 2 token types
• Chain: same with FCFS
• Number of Winners: the maximum number of users who can share the reward pool
• Token Name: same with FCFS
• Total Reward: the total reward amount | | Lucky Draw | Select a certain amount of users from all users who complete the task | • Rewards Type: can select both of the 2 token types
• Chain: same with FCFS
• Number of Winners: the number of users will be selected
• Token Name: same with FCFS
• Reward per Winner: the reward amount for each user | ![edit-dapp-reward](/img/web3-dapp/edit-dapp-reward.png) - After you finish the setting, click on the “Submit” button and notify your campaign POC at Binance Wallet to check your submission and kick off review and testing process. ![submit-campaign](/img/web3-dapp/submit-campaign.png) - **Step4: Deposit the rewards** - For campaigns including Token (Completed TGE), click the “Deposit” button to finish the reward deposit. Please do note that incompletion of deposit will lead to failure of campaign submission and thus potential delays of your campaign launch, so please do align with your finance team in advance. - For campaigns only with Token (Pending TGE), you don’t need to deposit. ![deposit-reward](/img/web3-dapp/deposit-reward.png) - **Step5: Submit airdrop campaign** - Click on the submit button to submit the campaign for Binance review. - Usually, Binance needs 7 working days to finish the campaign review. - If the campaign is approved: you can find the campaign status in Waiting Online/ Online status. After that, your campaign will be listed on Web3 Wallet. - If the campaign is rejected: you’ll see the campaign in rejected status. And you can modify the campaign and resubmit. ![campaign-submit](/img/web3-dapp/campaign-submit.png) --- ## Document: /products/onchainpay-x402/quick-start URL: /zh-CN/docs/products/onchainpay-x402/quick-start # Quick Start Follow these steps to integrate x402 into your application. ### 1. Apply for an Account Register as a partner and obtain your API credentials (`clientId` and `accessToken`). **[Apply here](https://forms.gle/aUQvxUETfGMzyTky5).** See [Apply partner developer account](basics/6.apply-developer-account.md) for the full onboarding process and required materials. ### 2. Understand the Basics Before coding, review these foundation documents: - [Common API request headers](basics/1.common-request-headers.md) - [Common API response](basics/2.common-response.md) - [API request signing](basics/3.request-signing.md) - [Environments and API base URLs](basics/4.base-urls.md) ### 3. Query Supported Configurations Call **POST** `{BASE_URL}/papi/v2/b402/supported` to retrieve the supported payment kinds, networks, tokens, and signer addresses. Cache the response — this data changes infrequently and should be refreshed periodically rather than on every request. See [Get Supported Configurations (V2)](open-apis-v2/1.get-supported-configurations.md). #### Your first signed request Once you have your `clientId`, `accessToken`, and Base64 PKCS#8 private key, the snippet below makes a signed `/supported` call end-to-end. Substitute `{BASE_URL}` with the value provided to you during onboarding (see [basics/4.base-urls.md](basics/4.base-urls.md)). `PRIV_KEY_B64` is the contents of `private_key.base64` produced in [API request signing — Step 1](basics/3.request-signing.md). ```python # Dep: pip install pycryptodome import base64, json, time, urllib.request from Crypto.PublicKey import RSA from Crypto.Signature import pkcs1_15 from Crypto.Hash import SHA256 BASE_URL = "" CLIENT_ID = "" ACCESS_TOKEN = "" PRIV_KEY_B64 = "" body = "{}" timestamp = str(int(time.time() * 1000)) to_sign = (body + timestamp).encode("utf-8") priv = RSA.import_key(base64.b64decode(PRIV_KEY_B64)) signature = base64.b64encode( pkcs1_15.new(priv).sign(SHA256.new(to_sign)) ).decode() req = urllib.request.Request( f"{BASE_URL}/papi/v2/b402/supported", data=body.encode(), method="POST", headers={ "Content-Type": "application/json", "X-Tesla-ClientId": CLIENT_ID, "X-Tesla-SignAccessToken": ACCESS_TOKEN, "X-Tesla-Timestamp": timestamp, "X-Tesla-Signature": signature, }, ) with urllib.request.urlopen(req) as r: print(r.status, json.dumps(json.loads(r.read()), indent=2)) ``` A successful call returns `200` and a JSON body with `kinds`, `extensions`, and `signers` — confirming your signing flow works end-to-end. ### 4. Return HTTP 402 to Buyers When a client requests a paid resource, respond with HTTP **402 Payment Required** and include payment requirements in the response. Use the data from `/supported` to populate the `X-PAYMENT-REQUIREMENTS` header with the accepted token, network, amount, and recipient address. > ⚠️ **Echo the full `extra` object from `/supported` verbatim.** Your 402 response must copy the > entire `kinds[].extra` object into `paymentRequirements.extra` — `name`, `version`, > `assetTransferMethod`, `signerAddress`, and (for `permit2-*`) `spenderAddress`. Buyers do not have > access to `/supported` — they rely entirely on what you send in the 402 response to build the > EIP-712 typed-data domain and a valid Permit2 signature. See > [Forwarding Addresses to Buyers (V2)](open-apis-v2/1.get-supported-configurations.md#forwarding-addresses-to-buyers-merchant-responsibility). ### 5. Verify Payment When a client resubmits the request with a signed payment payload, call **POST** `{BASE_URL}/papi/v2/b402/verify` to validate the buyer's EIP-712 signature off-chain before proceeding to submission. See [Verify Payment (V2)](open-apis-v2/2.verify-payment.md). ### 6. Submit Payment If verification passes, call **POST** `{BASE_URL}/papi/v2/b402/settle` to execute the on-chain token transfer. Gas is sponsored — funds move directly from the buyer's wallet to your wallet. See [Settle Payment (V2)](open-apis-v2/3.settle-payment.md). --- > **Note:** It is recommended to start with the **Sandbox (Testnet)** environment first. Refer to > [Environments and API base URLs](basics/4.base-urls.md) for Sandbox and Production base URLs. --- ## Document: /products/onchainpay-x402/introduction URL: /zh-CN/docs/products/onchainpay-x402/introduction # B402 B402 is Binance's implementation of the [x402 payment protocol](https://github.com/coinbase/x402) on BNB Smart Chain. It enables instant, automatic stablecoin payments directly over HTTP — services charge buyers (human users or autonomous AI agents) per request, settled on-chain in seconds, with gas sponsored by B402. The recommended `/papi/v2/b402/*` API conforms to the [x402 v2 specification](https://github.com/coinbase/x402/blob/main/specs/x402-specification-v2.md); a V1 API (`/papi/v1/b402/*`) is also available for legacy clients. ### Who B402 is for - **Sellers** — API providers, paywall operators, AI tool authors, and microservice owners who want to monetize HTTP endpoints per request without building wallets, billing, or subscription infrastructure. - **Buyers** — AI agents, dApps, and HTTP clients that pay for resources autonomously by signing EIP-712 authorizations. Buyers do not run wallets or hold gas — they sign off-chain and B402 executes the on-chain transfer. ### Use cases - **Per-request API billing** — charge fractions of a cent per call without managing API keys or invoices. - **AI agent payments** — let autonomous agents pay for tools, data, and inference without human-in-the-loop credentials. - **Paywalled content** — gate articles, downloads, or premium endpoints with HTTP 402. - **Microservice metering** — charge internal or external consumers per call against a shared contract. - **Discovery of paid endpoints** — be found by AI agents via [B402 Bazaar](b402-bazaar.md) without manual onboarding. ### How It Works The x402 protocol leverages the HTTP `402 Payment Required` status code to create a standardized payment flow for web resources: 1. A client requests a paid resource from the seller. 2. The seller responds with HTTP **402** and includes payment requirements (token, amount, recipient address, and the addresses needed to construct an EIP-712 signature) in the response body. 3. The buyer signs an EIP-712 authorization off-chain (no on-chain transaction needed from the buyer). 4. The buyer resubmits the request with the signed payment attached. 5. The seller calls B402 to **verify** the signature and then **settle** the payment on-chain. 6. B402 sponsors the gas and executes the token transfer directly from buyer to seller. 7. The seller delivers the paid resource. For the full sequence diagram and step-by-step walkthrough, see [Typical integration flow](basics/8.typical-integration-flow.md). ### Key roles | Role | Description | | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | **Buyer** (AI agent / user) | The payer who signs an EIP-712 authorization off-chain to approve the token transfer. Can be a human user or an autonomous AI agent. | | **Seller** (merchant / developer) | Provides paid APIs or services. Integrates B402 via HTTP. Forwards the buyer's signed payment to the B402 facilitator for verification and execution. | | **Facilitator** (B402) | Verifies signatures off-chain (`/verify`), then sponsors gas and executes the on-chain token transfer (`/settle`). All token transfers occur strictly peer-to-peer on the public blockchain from the buyer's wallet directly to the merchant's wallet. | ### Key features - **Stateless** — no sessions, accounts, or held balances. Each request is its own transaction. - **HTTP-native** — payments flow through standard request/response with the `402` status code. Works with any HTTP server, framework, or client. - **Gas-sponsored** — sellers don't need BNB to operate. B402 pays the gas for every settle. - **Multiple payment methods** — `eip3009` for native EIP-3009 tokens (U, USD1) and `permit2-exact` / `permit2-upto` for any ERC-20 (USDC, USDT, etc.). - **Discoverable** — opt your endpoints into [B402 Bazaar](b402-bazaar.md) for AI-agent discovery simply by attaching metadata on settle. - **CDP wire-shape compatible** — the V2 `PaymentPayload` and Bazaar metadata blob match Coinbase's x402 spec field-for-field, so client libraries built for CDP work against B402 with one URL change. ### Supported payment methods | Token | Contract (BSC Mainnet) | `eip3009` | `permit2-exact` | `permit2-upto` | | -------- | -------------------------------------------- | :-------: | :-------------: | :------------: | | **U** | `0xcE24439F2D9C6a2289F741120FE202248B666666` | ✅ | ✅ | ✅ | | **USD1** | `0x8d0D000Ee44948FC98c9B98A4FA4921476f08B0d` | ✅ | ✅ | ✅ | | **USDT** | `0x55d398326f99059fF775485246999027B3197955` | — | ✅ | ✅ | | **USDC** | `0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d` | — | ✅ | ✅ | | Method | Description | | --------------- | ---------------------------------------------------------------------------------------------------------------- | | `eip3009` | EIP-3009 native `transferWithAuthorization`. Only available for tokens with built-in EIP-3009 support (U, USD1). | | `permit2-exact` | Permit2 exact-amount transfer. Works with any ERC-20 token. | | `permit2-upto` | Permit2 up-to-amount transfer (pay-as-you-go). Works with any ERC-20 token. | ### Current status B402 is **live on BNB Smart Chain (BSC) Testnet** for external partner onboarding. Production (BSC Mainnet) access is granted on request — [apply here](https://forms.gle/aUQvxUETfGMzyTky5) to get your API credentials. See [Environments and API base URLs](basics/4.base-urls.md) for endpoint details. Expansion to other EVM-compatible networks is planned. ### What to read next - [Quick Start](quick-start.md) — step-by-step guide to your first integration. - [Typical integration flow](basics/8.typical-integration-flow.md) — full sequence diagram and per-step explanation of the protocol. - [Integration Guideline](integration-guideline.md) — production prerequisites, rate limits, and security best practices. - [B402 Bazaar](b402-bazaar.md) — make your endpoint discoverable to AI agents. - [Open APIs V2](open-apis-v2/1.get-supported-configurations.md) — detailed API reference for `/supported`, `/verify`, and `/settle` (x402 v2 spec-conformant). - [Permit2 Signing Guide](open-apis-v2/4.permit2-signing.md) — the EIP-712 typed data shape for Permit2 signatures, with viem and ethers.js v6 reference implementations. --- ### Disclaimer This documentation describes Binance x402 (B402), a developer-facing technical service that supports verification of user-signed x402-compatible payment payloads and submission of corresponding on-chain transactions on supported blockchain networks. Binance x402 (B402) is provided as technical infrastructure and software tooling only. It is not intended to constitute, and should not be construed as, any of the following: - a bank account, deposit, stored-value facility, e-money product, or custodial wallet; - a payment account, payment instrument, remittance, money transmission, or funds transfer service; - brokerage, exchange, dealing, clearing, settlement assurance, or other regulated financial service; - investment, legal, tax, accounting, or regulatory advice; - an offer, invitation, solicitation, recommendation, or endorsement to buy, sell, hold, transfer, or use any digital asset, token, or network. B402 does not take possession, custody, or control of user funds or payment tokens as part of the standard flow described in this documentation. In the supported integration model, digital assets move directly on-chain between addresses designated by the user and the merchant or service provider. B402's role is limited to technical functions such as message validation, signature verification, transaction submission, and related API support on supported networks. Use of B402 does not relieve any developer, merchant, integrator, application provider, or other participant of its own responsibility to assess and comply with all applicable laws, rules, regulations, licensing, sanctions, tax, consumer protection, data protection, and disclosure obligations in each relevant jurisdiction. Each integrator remains solely responsible for: - determining whether and how B402 may be used in its product or service; - ensuring that all required notices, disclosures, consents, and terms are provided to end users; - evaluating whether any activity involving digital assets, blockchain-based transfers, or service monetization may be regulated in applicable jurisdictions; - implementing its own compliance, fraud prevention, transaction monitoring, screening, risk management, and customer support processes as required. Blockchain networks, smart contracts, token standards, third-party wallets, signatures, RPC infrastructure, and related software involve operational, technical, and legal risks, including failed transactions, reversibility limitations, network congestion, software bugs, forks, validator or sequencer issues, smart contract vulnerabilities, signature misuse, incorrect addressing, and asset loss. On-chain transactions may be irreversible once confirmed. Binance x402 (B402) does not guarantee transaction success, network availability, confirmation times, compatibility, merchant outcomes, user solvency, or continued support for any blockchain, token, standard, or integration. This documentation is provided for general informational and integration purposes only and may be updated, suspended, or withdrawn at any time. Access to or use of B402 may be subject to separate eligibility requirements, onboarding, contractual terms, technical restrictions, and jurisdictional limitations. Availability may differ by entity, user type, product configuration, and region. To the extent permitted by applicable law, Binance x402 (B402) and its providers disclaim liability for indirect, incidental, consequential, special, exemplary, or punitive damages, and for losses arising from third-party acts or omissions, blockchain events, token issuer actions, smart contract behavior, wallet compromise, configuration errors, unsupported use cases, or user/integrator non-compliance. You should obtain independent legal, regulatory, tax, and technical advice before deploying Binance x402 (B402) in production. --- ## Document: /products/onchainpay-x402/integration-guideline URL: /zh-CN/docs/products/onchainpay-x402/integration-guideline # Integration Guideline This guide covers production-readiness considerations for a B402 integration: security, rate limits, and settlement response timing. For the step-by-step integration flow, see [Quick Start](quick-start.md). ### Prerequisites Before you begin, ensure you have completed the partner onboarding and obtained your API credentials (`clientId` and `accessToken`). See [Apply partner developer account](basics/6.apply-developer-account.md) for the full list of required materials and onboarding steps. ### Security Best Practices - **Forward the full `extra` object to buyers in every 402 response.** When returning HTTP `402 Payment Required`, copy the entire `kinds[].extra` from the cached `/supported` response into `paymentRequirements.extra` — `name`, `version`, `assetTransferMethod`, `signerAddress`, and (for `permit2-*`) `spenderAddress`. Buyers cannot call `/supported` themselves (it requires merchant credentials) and need these to build the EIP-712 typed-data domain and a valid Permit2 signature. Do not hardcode — `/supported` is the single source of truth; missing or stale values cause buyer signatures to be rejected. - **Store your private key securely.** Never expose your RSA private key in client-side code, public repositories, or logs. - **Always verify before settling.** Call `/verify` to validate the buyer's EIP-712 signature before calling `/settle`. Never settle an unverified payment. - **Use IP whitelisting.** Restrict API access to your registered server IPs to prevent unauthorized calls. - **Validate settlement responses.** Check the `success` field and on-chain `transaction` hash in the settlement response to confirm the transfer completed successfully. See [Payment status](basics/7.payment-status.md). - **Guard against duplicate settlements.** Track payment identifiers to prevent settling the same payment more than once. B402 enforces idempotency on `(nonce, network, payer)`, but merchants should guard at their application layer as well. ### Rate Limits | Endpoint | Limit | | ---------------------- | ----------------------------- | | `/papi/v2/b402/verify` | 100 requests/sec per merchant | | `/papi/v2/b402/settle` | 20 requests/sec per merchant | Exceeding the rate limit returns HTTP `429 Too Many Requests`. Implement exponential backoff and retry logic on the client side. ### Settlement Response Times | Transaction Amount | Estimated Response Time | | ------------------ | ----------------------- | | Small amounts | ~10 seconds | | Medium amounts | ~25 seconds | | Large amounts | ~45 seconds | > **Note:** These are estimates. Actual response times depend on network congestion and are adjusted > dynamically. For large transactions, consider an asynchronous callback or polling pattern rather > than blocking on the settlement response. --- ## Document: /products/onchainpay-x402/change-log URL: /zh-CN/docs/products/onchainpay-x402/change-log # Change Log | Date | Description | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 2026-06-24 | Corrected the B402 Bazaar BAPI envelope description on [Environments and API base URLs](basics/4.base-urls.md) — `messageDetail` was missing from the prose summary `{code, message, data, success}`. Live responses always carry `messageDetail` (it's `null` on success, populated on some errors). The full JSON example on [B402 Bazaar — Verifying your listing](b402-bazaar.md#verifying-your-listing) was already correct; this fixes the prose-only mention. No API behavior change. | | 2026-06-23 | Published the public B402 Bazaar discovery base URL (`https://www.binance.com/bapi/ramp/v1/public/ramp/b402`) and corrected the discovery endpoint paths (`/bazaar/{resources, search, merchant}`) on the [B402 Bazaar](b402-bazaar.md) page — previously placeholder-only. Restructured [Environments and API base URLs](basics/4.base-urls.md) into two tables (authenticated `/papi/v2/b402/*` vs. public discovery) so the discovery URL is hardcodable and the auth-gated URLs remain handed-out at onboarding. Documented the BAPI envelope wrapping discovery responses (`{code, message, messageDetail, data, success}`) with the CDP-shape catalog inside `data`, plus the full `/search` filter set (`network` / `asset` / `scheme` / `payTo` / `maxUsdPrice`). Refreshed the [Introduction](introduction.md) to lead with audience, use cases, and a key-features list — same legal disclaimer, no API behavior changes. | | 2026-06-04 | Added [B402 Bazaar](b402-bazaar.md) merchant guide. Documents the opt-in discovery flow: attach `extensions.bazaar = {info, schema, routeTemplate?, description?}` on V2 settle (CDP wire-shape compatible) to make a paid endpoint discoverable to AI agents via the upcoming `/v1/b402/discovery/*` API. Updated the `paymentPayload.extensions` field description on `/papi/v2/b402/verify` to point at the new page. | | 2026-05-29 | Re-introduced `invalidMessage` (verify) and `errorMessage` (settle) debug fields on the V2 wire, gated to structural-error codes only — `invalidMessage` for `invalid_payload` / `invalid_payment_requirements`; `errorMessage` for `invalid_payload`. Spec-strict codes (signature/authorization failures, on-chain reverts, `insufficient_funds`) remain message-free; debug context for those is retained in server logs only. `confirmations` remains dropped. Driven by integrator feedback that an opaque `invalid_payload` on the V2 wire left no path to self-diagnose payload-shape mistakes. Also corrected two prose mentions of `invalid_exact_evm_permit2_payload_spender` to `invalid_payload` — the internal code is collapsed to `invalid_payload` on the wire and the original string is never emitted. | | 2026-05-19 | Corrected `decimals` column in `Supported payment methods`. All four BSC mainnet tokens (U, USD1, USDC, USDT) and BSC testnet USDT were listed as 6 decimals; on-chain `decimals()` returns 18 for each. Merchants who priced API calls assuming 6 decimals (e.g. `amount: "10000"` for $0.01) were charging 1e-14 of a token instead — re-encode amounts against 18 decimals before going to production. Added a note on the page reminding integrators to verify decimals on chain when in doubt. | | 2026-05-14 | Added Permit2 signing guide (`open-apis-v2/4.permit2-signing.md`) covering the EIP-712 typed data shape (`PermitWitnessTransferFrom` + `TokenPermissions` + `Witness`), field semantics, viem and ethers.js v6 TypeScript reference implementations, wire envelope format, common pitfalls, and end-to-end walkthrough. Aimed at merchants integrating `permit2-exact` for assets without EIP-3009 support (e.g. USDT on BSC), where the stock `@x402/evm` client ships no Permit2 signer. Cross-linked from `/verify` page. | | 2026-05-11 | V2-first merchant onboarding pass: restructured `API request signing` into Overview → Step 1 keygen (OpenSSL only, PKCS#8) → Step 2 sign (Python default, Node.js + Java alternates) → Step 3 headers → Postman (optional) → Troubleshooting. Swapped Quick Start and Integration Guideline to V2 endpoints; added runnable signed-`/supported` Python snippet to Quick Start using `{BASE_URL}` placeholder; dropped "Deliver the Resource" step. Promoted "Open APIs V2" above "Open APIs V1" in the nav and added a V2-recommendation note on V1 pages. Updated `Payment status` for the V2 settle response shape (`transaction` always-present string). Fixed factual bug in `Supported payment methods` (`eip3009` supports U and USD1, not USDC). Fixed `GET /supported` → `POST /supported` in typical-integration-flow. | | 2026-05-07 | V2 spec-alignment patch: `paymentPayload.resource` is now a `ResourceInfo` object `{url, description, mimeType}` at the top level of `PaymentPayload` per x402 v2 §5.1. Removed `resource` / `description` / `mimeType` / `outputSchema` from `paymentRequirements`. Settle response now always emits `transaction` and `network` (empty string `""` on pre-broadcast failure) — spec-Required per §5.3.2. New **Deviations from x402 v2 spec** section on the `/verify` page explicitly lists b402 extensions that remain unchanged (`POST /supported`, `upto` scheme, Permit2 methods, `settleAmount`, `extra` fields, `unexpected_*_error` codes). Breaking wire change — coordinate with integrators. V1 endpoints unchanged. | | 2026-05-05 | Added B402 V2 API (`/papi/v2/b402/*`): CAIP-2 signers wildcard namespace, x402 v2 `PaymentPayload` shape with top-level `accepted` + `resource`, split `extra.signerAddress` + `extra.spenderAddress` replacing the overloaded `extra.facilitatorAddress`, `scheme: "upto"` introduced for `permit2-upto`. `invalidMessage` / `confirmations` / `errorMessage` dropped from wire in favour of x402 v2 spec-strict conformance. V1 endpoints remain frozen and unchanged. | | 2026-04-22 | Added U and USD1 token support; restructured Supported Payment Methods into token×method matrix; `eip3009` now limited to U and USD1 (USDC/USDT use permit2 only); expanded `/supported` response example with all 10 kinds; updated `/verify` and `/settle` EIP-3009 examples to use U token; updated token contracts reference table; updated service description and added Disclaimer section | | 2026-04-13 | Initial release of B402 Open API documentation | --- ## Document: /products/onchainpay-x402/b402-bazaar URL: /zh-CN/docs/products/onchainpay-x402/b402-bazaar # B402 Bazaar B402 Bazaar is the discovery layer for B402-registered paid endpoints. AI agents (and any other client) can search the Bazaar to find HTTP APIs and MCP tools that accept x402 payments — without anyone pre-configuring a list. As a merchant, you opt your endpoint in by attaching a metadata blob to your normal V2 settle call. Bazaar indexes you within ~30 seconds of the first confirmed settle carrying that blob. > **Status: opt-in and free.** No separate registration, no contract, no back-office signup. You > declare metadata on your V2 settle, Bazaar picks it up. > **Coinbase CDP wire-shape compatible.** The blob shape matches > [CDP's x402 Bazaar extension spec](https://github.com/coinbase/x402/blob/main/specs/extensions/bazaar.md) > field-for-field. If your code already produces a CDP-compatible bazaar blob (e.g. via > `@coinbase/x402-fetch` or the Python SDK), the same blob works against B402 — just point at our > settle endpoint. ### How It Works ``` Your endpoint ─▶ V2 settle (with bazaar blob) ─▶ B402 ─▶ on-chain confirm │ ▼ Bazaar indexer (30s tick) │ ▼ /bazaar/* (public discovery catalog) ``` 1. A buyer (usually an AI agent) calls your paid endpoint with an x402 V2 payment header. 2. You forward the payment to B402's `/papi/v2/b402/settle` with `paymentPayload.extensions.bazaar` populated. 3. B402 confirms the on-chain settle and stores the blob. 4. Bazaar's indexer picks up the row on its next 30-second tick and upserts your resource into the catalog. 5. Agents searching the Bazaar see your endpoint in the results. **First appearance:** typically within 30–60 seconds of the first confirmed V2 settle. Failed or timed-out settles do not count toward indexing. **Updating metadata:** subsequent settles with a different blob overwrite the stored row's metadata (keyed on `(merchantId, resourceUrl)`). You can update your `description` or `schema` just by shipping an updated blob on your next settle. **Multi-chain:** if you settle the same URL on multiple chains, B402 appends each chain to your resource's `accepts[]` array rather than overwriting. Agents see all your payment options. ### TL;DR — attach `extensions.bazaar` on every V2 settle Minimum HTTP-GET example. The `extensions.bazaar` object goes inside the `paymentPayload` you send to [`/papi/v2/b402/settle`](open-apis-v2/3.settle-payment.md): ```jsonc { "x402Version": 2, "paymentPayload": { "x402Version": 2, "resource": { "url": "https://api.example.com/btc-price", "description": "Real-time BTC spot price aggregated from 20 exchanges.", "mimeType": "application/json", }, "accepted": { /* your PaymentRequirements */ }, "payload": { /* signed authorization */ }, "extensions": { "bazaar": { "info": { "input": { "type": "http", "method": "GET", "queryParams": { "symbol": "BTC" }, }, "output": { "type": "json", "example": { "symbol": "BTC", "price": 67000, "ts": 1700000000 }, }, }, "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "input": { "type": "object", "properties": { "type": { "const": "http" }, "method": { "enum": ["GET"] }, }, "required": ["type", "method"], }, }, "required": ["input"], }, "description": "Real-time BTC spot price aggregated from 20 exchanges.", }, }, }, "paymentRequirements": { /* same as /verify */ }, } ``` That's the whole integration. No other endpoints to call, no API keys to rotate. ### The bazaar blob — field reference | Field | Required | Type | Purpose | | --------------- | -------------------- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | | `info` | **yes** | object | Discovery payload — describes the resource's input / output. Shape depends on variant (see below). | | `schema` | **yes** | JSON Schema (Draft 2020-12) object | Validates the shape of `info`. Must define `input` (required) and optionally `output`. Invalid blobs are skipped by the indexer. | | `routeTemplate` | no | string like `/users/:userId` | For parameterized HTTP routes. Lets B402 collapse `/users/1` and `/users/2` into a single catalog entry. Omit for static routes. | | `description` | no (but recommended) | string | Human-readable resource description. Surfaced on the API's resource-level `description` field. If omitted, B402 derives one from the URL. | ### `info` variants The shape of `info.input` depends on what kind of resource you're listing. The discriminator is `info.input.type` plus, for HTTP, `info.input.method`. #### Variant A — HTTP query method (`GET`, `HEAD`, `DELETE`) ```json { "input": { "type": "http", "method": "GET", "queryParams": { "symbol": "BTC" }, "headers": { "X-Client-Version": "1" } }, "output": { "type": "json", "example": { "price": 67000 } } } ``` | Sub-field | Required | Notes | | ------------------- | ------------------------- | ----------------------------------------------------- | | `input.type` | yes | Always `"http"` | | `input.method` | yes | `"GET"`, `"HEAD"`, or `"DELETE"` | | `input.queryParams` | no | Example query params | | `input.headers` | no | Example headers (agents may use these to shape calls) | | `output.type` | yes (if `output` present) | e.g. `"json"`, `"text"` | | `output.example` | no | An example payload the endpoint returns | #### Variant B — HTTP body method (`POST`, `PUT`, `PATCH`) Same as Variant A, plus `input.bodyType` (`"json"` / `"form-data"` / `"text"`) and `input.body` (example request body — required for body methods). ```json { "input": { "type": "http", "method": "POST", "bodyType": "json", "body": { "ticker": "AAPL", "depth": "full" } }, "output": { "type": "json", "example": { "result": "..." } } } ``` #### Variant C — MCP tool ```json { "input": { "type": "mcp", "tool": "financial_analysis", "description": "Deep-dive financial analysis for a single ticker.", "inputSchema": { "type": "object", "properties": { "ticker": { "type": "string" }, "depth": { "type": "string", "enum": ["summary", "deep"] } }, "required": ["ticker"] }, "example": { "ticker": "AAPL", "depth": "deep" } }, "output": { "type": "json", "example": { "summary": "...", "score": 8.5 } } } ``` For MCP tools the unique resource identifier is the tuple `(resource.url, info.input.tool)` — multiple tools on the same URL produce distinct listings. ### `routeTemplate` — parameterized routes If your endpoint has path parameters like `/users/123` and `/users/456`, set `routeTemplate` so Bazaar collapses them into a single catalog entry: ```jsonc { "info": { "input": { "type": "http", "method": "GET", "pathParams": { "userId": "123" } } }, "schema": { /* ... */ }, "routeTemplate": "/users/:userId", } ``` Rules (per CDP spec): must start with `/`, match `^/[a-zA-Z0-9_/:.\-~%]+$`, no `..`, no `://`. Static routes must omit `routeTemplate`. ### Example: TypeScript ```ts const PRICE_FEED_BLOB = { info: { input: { type: "http" as const, method: "GET" as const, queryParams: { symbol: "BTC" }, }, output: { type: "json" as const, example: { symbol: "BTC", price: 67000 }, }, }, schema: { $schema: "https://json-schema.org/draft/2020-12/schema", type: "object", properties: { input: { type: "object", properties: { type: { const: "http" }, method: { enum: ["GET"] }, }, required: ["type", "method"], }, }, required: ["input"], }, description: "Real-time BTC spot price aggregated from 20 exchanges.", }; // When building the V2 payment payload for /papi/v2/b402/settle: const paymentPayload = { x402Version: 2, resource: { url: "https://api.example.com/btc-price", description: PRICE_FEED_BLOB.description, mimeType: "application/json", }, accepted: paymentRequirements, payload: { signature, authorization }, extensions: { bazaar: PRICE_FEED_BLOB }, }; ``` ### Example: Python ```python PRICE_FEED_BLOB = { "info": { "input": { "type": "http", "method": "GET", "queryParams": {"symbol": "BTC"}, }, "output": {"type": "json", "example": {"symbol": "BTC", "price": 67000}}, }, "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "input": { "type": "object", "properties": { "type": {"const": "http"}, "method": {"enum": ["GET"]}, }, "required": ["type", "method"], } }, "required": ["input"], }, "description": "Real-time BTC spot price aggregated from 20 exchanges.", } payment_payload = { "x402Version": 2, "resource": { "url": "https://api.example.com/btc-price", "description": PRICE_FEED_BLOB["description"], "mimeType": "application/json", }, "accepted": payment_requirements, "payload": {"signature": signature, "authorization": authorization}, "extensions": {"bazaar": PRICE_FEED_BLOB}, } ``` ### Verifying your listing After your first confirmed V2 settle with the blob, hit any of the discovery endpoints. **No authentication required** — discovery is public read-only. Production base URL is `https://www.binance.com/bapi/ramp/v1/public/ramp/b402`; see [Environments and API base URLs](basics/4.base-urls.md) for sandbox. ```bash # Paginated catalog (response data key: items[]) curl https://www.binance.com/bapi/ramp/v1/public/ramp/b402/bazaar/resources # Your listings only (response data key: resources[]) curl "https://www.binance.com/bapi/ramp/v1/public/ramp/b402/bazaar/merchant?payTo=" # Keyword search (response data key: resources[]) curl "https://www.binance.com/bapi/ramp/v1/public/ramp/b402/bazaar/search?query=BTC+price" ``` A response wraps the CDP-shape catalog in Binance's standard BAPI envelope — the discovery payload is in `data`: ```jsonc { "code": "000000", "message": null, "messageDetail": null, "data": { "items": [ { "resource": "https://api.example.com/btc-price", "type": "http", "x402Version": 2, "description": "Real-time BTC spot price aggregated from 20 exchanges.", "accepts": [ { "scheme": "permit2-exact", "network": "eip155:56", "asset": "0x55d398326f99059fF775485246999027B3197955", "maxAmountRequired": "1000", "payTo": "0xabc...", }, ], "lastUpdated": 1780476191702, "quality": { "l30DaysTotalCalls": 1543, "l30DaysUniquePayers": 87, "lastCalledAt": 1780476131000, }, }, ], "pagination": { "limit": 25, "offset": 0, "total": 1 }, "x402Version": 2, }, "success": true, } ``` #### Discovery endpoint reference | Endpoint | Method | Query parameters | Default / max `limit` | `data` array key | | ------------------- | ------ | ---------------------------------------------------------------------- | --------------------- | ---------------- | | `/bazaar/resources` | GET | `limit`, `offset` | 25 / 100 | `items[]` | | `/bazaar/merchant` | GET | **`payTo`** (required, 0x-prefixed EVM address), `limit`, `offset` | 25 / 100 | `resources[]` | | `/bazaar/search` | GET | `query`, `network`, `asset`, `scheme`, `payTo`, `maxUsdPrice`, `limit` | 20 / 20 (no `offset`) | `resources[]` | `/search` filter notes: - `query` — free-text search over resource description and synthesized name; max 400 chars. - `network` / `asset` / `scheme` / `payTo` — narrow to a specific payment option; max 200 chars each. - `maxUsdPrice` — filter to resources whose primary `accepts[]` entry charges at most this many USD per call. Decimal string. - Search has no `offset`/cursor pagination — refine the query with the filters above to surface more results. ### How agents find you AI agents integrate with Bazaar in one of two ways: 1. **REST.** The agent queries `/bazaar/search` directly and picks resources from the result. 2. **MCP.** The agent uses the `search_resources` tool on Bazaar's hosted MCP endpoint. This is the path for agents built on Claude Desktop, OpenAI function-calling frameworks, and similar. Once they've found your resource, they invoke it through their existing x402 client stack. Bazaar doesn't proxy the call — it's pure discovery. ### Ranking & visibility Discovery results are ranked by a composite score combining four signals: - **Text relevance** — your `description` and synthesized internal name are matched against the agent's search query. - **Recent activity** — resources that haven't seen a settle in 30 days sink in the rankings. - **Buyer diversity** — a resource with 1,000 settles from 3 wallets ranks below one with 500 settles from 200 wallets. - **Fail rate** — resources whose recent settles frequently fail are demoted; resources with `fail_rate_24h > 50%` are filtered from results entirely. A minimum-amount threshold (USD $0.01-equivalent per settle) filters out micro-settles from the activity signal, and the diversity cap weights buyers more than raw settle count. Together these mean it's more expensive to fake activity than to build a genuinely-useful endpoint. ### FAQ **Do I have to opt in on every settle, or once is enough?** Every V2 settle. Bazaar treats the blob as "re-advertise my listing with this metadata." It's cheap on your side (it rides on an already-happening request), and lets you update metadata without a side-channel. **What if I have more than one endpoint?** Send a different blob for each endpoint's settles. Each `(payTo, resourceUrl)` pair is a separate listing. **Can I support multiple chains on the same URL?** Yes — settle on each chain separately with the same `resource.url`. B402 merges the `accepts[]` array so agents see all your chains on the same resource. Dedup key is `(scheme, network, asset)` — the latest settle on a given tuple overwrites that entry. **What if the same endpoint has multiple pricing tiers (e.g. basic / pro)?** Bazaar treats them as one listing per `(merchantId, resourceUrl)` — the last settle's `maxAmountRequired` wins for that `(network, asset, scheme)` entry. Multi-tier listings are on the roadmap. **Can I submit a listing without settling?** Not in v0 — listing is strictly opt-in via successful V2 settle. Marketing-only listings are deferred to a future version. **How do I get removed?** Stop including the blob on new settles and your listing's recency signal will decay until it sinks below the visible results. For an active takedown (e.g. leaked API key, compromised endpoint), reach out via the [application form](https://forms.gle/aUQvxUETfGMzyTky5) and we'll hide the listing. ### Next Steps - [Settle Payment (V2)](open-apis-v2/3.settle-payment.md) — the wire shape that carries the bazaar blob. - [Environments and API base URLs](basics/4.base-urls.md) — where to call settle, and the public Bazaar discovery base URL. - [Integration Guideline](integration-guideline.md) — prerequisites, checklist, and best practices for B402 generally. --- ## Document: /products/mining/quick-start URL: /zh-CN/docs/products/mining/quick-start # 快速开始 ## API Key 权限设置 - 新创建的API的默认权限是 `只读`。 - 如果需要通过API提款, 需要在UI修改权限, 选中 `允许提现`。 ## 账户 ### 现货账户 新注册的币安账号都会有一个现货(`SPOT`)账号。 ### 杠杆账户 为了开设杠杆(`MARGIN`)账户, 可以参考[Binance杠杆交易账户设置指南](https://www.binance.vision/zh/tutorials/binance-margin-trading-guide) ## API 代码库 ### Connectors 以下有一些轻量级的代码库,使不同语言的用户能够直接调用现货的 Binance 公共 API: - Python [https://github.com/binance/binance-connector-python](https://github.com/binance/binance-connector-python) - JavaScript [https://github.com/binance/binance-connector-js](https://github.com/binance/binance-connector-js) - Ruby [https://github.com/binance/binance-connector-ruby](https://github.com/binance/binance-connector-ruby) - DotNET C# [https://github.com/binance/binance-connector-dotnet](https://github.com/binance/binance-connector-dotnet) - Java [https://github.com/binance/binance-connector-java](https://github.com/binance/binance-connector-java) - Rust [https://github.com/binance/binance-spot-connector-rust](https://github.com/binance/binance-spot-connector-rust) - PHP [https://github.com/binance/binance-connector-php](https://github.com/binance/binance-connector-php) - Go [https://github.com/binance/binance-connector-go](https://github.com/binance/binance-connector-go) ### Postman Collections Postman 集合现已推出。推荐给寻求快速和轻松地开始使用 API 的新用户。 [https://github.com/binance/binance-api-postman](https://github.com/binance/binance-api-postman) ### Swagger 以下有提供包含 RESTful API 的 OpenAPI 规范的 YAML 文件,以及可供参考的 Swagger UI 页面。 [https://github.com/binance/binance-api-swagger](https://github.com/binance/binance-api-swagger) --- ## Document: /products/mining/general-info URL: /zh-CN/docs/products/mining/general-info # 基本信息 ## API 基本信息 - 接口可能需要用户的 API Key,如何创建API-KEY请参考[这里](https://www.binance.com/cn/support/articles/360002502072) - 本篇列出接口的 base URL 有: - **https://api.binance.com** - **https://api-gcp.binance.com** - **https://api1.binance.com** - **https://api2.binance.com** - **https://api3.binance.com** - **https://api4.binance.com** - 上述列表的最后4个接口 (`api1`-`api4`) 可能会提供更好的性能,但其稳定性略为逊色。因此,请务必使用最适合您现有配置的那款。 - 所有接口的响应都是 JSON 格式。 - 响应中如有数组,数组元素以时间**升序**排列,越早的数据越提前。 - 所有时间、时间戳均为UNIX时间,单位为**毫秒**。 ### HTTP 返回代码 - HTTP `4XX` 错误码用于指示错误的请求内容、行为、格式。问题在于请求者。 - HTTP `403` 错误码表示违反WAF限制(Web应用程序防火墙)。 - HTTP `409` 错误码表示重新下单(cancelReplace)的请求部分成功。(比如取消订单失败,但是下单成功了) - HTTP `429` 错误码表示警告访问频次超限,即将被封IP。 - HTTP `418` 表示收到429后继续访问,于是被封了。 - HTTP `5XX` 错误码用于指示Binance服务侧的问题。 ### 接口错误代码 - 使用接口 `/api/v3`, 以及 `/sapi/v1/margin`时, 每个接口都有可能抛出异常; > API 与 SAPI 的错误代码返回形式如下: ```javascript { "code": -1121, "msg": "Invalid symbol." } ``` - 具体的错误码及其解释在 [错误代码](./error-code). ### 接口的基本信息 - `GET` 方法的接口, 参数必须在 `query string`中发送。 - `POST`, `PUT`, 和 `DELETE` 方法的接口,参数可以在内容形式为`application/x-www-form-urlencoded`的 `query string` 中发送,也可以在 `request body` 中发送。 如果你喜欢,也可以混合这两种方式发送参数。 - 对参数的顺序不做要求。 - 但如果同一个参数名在query string和request body中都有,query string中的会被优先采用。 --- ## 访问限制 ### 访问限制基本信息 - 以下 是`intervalLetter` 作为头部值: - SECOND => S - MINUTE => M - HOUR => H - DAY => D - 在 `/api/v3/exchangeInfo` `rateLimits` 数组中包含与交易的有关RAW_REQUESTS,REQUEST_WEIGHT和ORDERS速率限制相关的对象。这些在 `限制种类 (rateLimitType)` 下的 `枚举定义` 部分中进一步定义。 - 违反任何一个速率限制时(访问频次限制或下单速率限制),将返回429。 ### IP 访问限制 - 每个请求将包含一个`X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,其中包含当前IP所有请求的已使用权重。 - 每一个接口均有一个相应的权重(weight),有的接口根据参数不同可能拥有不同的权重。越消耗资源的接口权重就会越大。 - 收到429时,您有责任停止发送请求,不得滥用API。 - **收到429后仍然继续违反访问限制,会被封禁IP,并收到418错误码** - 频繁违反限制,封禁时间会逐渐延长,**从最短2分钟到最长3天**。 - `Retry-After`的头会与带有418或429的响应发送,并且会给出**以秒为单位**的等待时长(如果是429)以防止禁令,或者如果是418,直到禁令结束。 - **访问限制是基于IP的,而不是API Key** ###下单频率限制 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - 当下单数超过限制时,会收到带有429但不含`Retry-After`头的响应。请检查 `GET api/v3/exchangeInfo` 的下单频率限制 (rateLimitType = ORDERS) 并等待封禁时间结束。 - 被拒绝或不成功的下单并不保证回报中包含以上头内容。 - **下单频率限制是基于每个账户计数的。** - 用户可以通过接口 `GET api/v3/rateLimit/order` 来查询当前的下单量. ### WEB SOCKET 连接限制 - Websocket服务器每秒最多接受5个消息。消息包括: - PING帧 - PONG帧 - JSON格式的消息, 比如订阅, 断开订阅. - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅 **1024** 个Streams。 - 每IP地址、每5分钟最多可以发送300次连接请求。 ### /api/ 与 /sapi/ 接口限频说明 `/api/*`接口和 `/sapi/*`接口采用两套不同的访问限频规则, 两者互相独立。 - `/api/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以 `/api/*`开头的接口按IP限频,**且所有接口共用每分钟6,000限制**。 - 每个请求将包含一个 `X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,包含当前IP所有请求的已使用权重。 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - `/sapi/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以`/sapi/*`开头的接口采用**单接口限频模式**。按IP统计的权重单接口权重总额为每分钟12000;按照UID统计的单接口权重总额是每分钟180000。 - 每个接口会标明是按照IP或者按照UID统计, 以及相应请求一次的权重值。 - 按照IP统计的接口, 请求返回头里面会包含`X-SAPI-USED-IP-WEIGHT-1M=`或`X-SAPI-USED-IP-WEIGHT-1S=`, 包含当前IP所有请求已使用权重。 - 按照UID统计的接口, 请求返回头里面会包含`X-SAPI-USED-UID-WEIGHT-1M=`或`X-SAPI-USED-UID-WEIGHT-1S=`, 包含当前账户所有已用的UID权重。 --- ## 数据来源 - 因为API系统是异步的, 所以返回的数据有延时很正常, 也在预期之中。 - 在每个接口中,都列出了其数据的来源,可以用于理解数据的时效性。 系统一共有3个数据来源,按照更新速度的先后排序。排在前面的数据最新,在后面就有可能存在延迟。 - **撮合引擎** - 表示数据来源于撮合引擎 - **缓存** - 表示数据来源于内部或者外部的缓存 - **数据库** - 表示数据直接来源于数据库 ## 请求鉴权类型 - 每个接口都有一个鉴权类型,指示所需的 API 密钥权限,显示在接口名称旁边(例如,[下新订单 (TRADE)](#place-new-order-trade))。 - 如果未指定,则鉴权类型为 `NONE`。 - 除了为 `NONE` 外,所有具有鉴权类型的接口均视为 `SIGNED` 请求(即包含 `signature`),[listenKey 管理](#user-data-stream-requests) 除外。 - 具有鉴权类型的接口需要提供有效的 API 密钥并验证通过。 - API 密钥可在您的 Binance 账户的 [API 管理](https://www.binance.com/en/support/faq/360002502072) 页面创建。 - **API 密钥和密钥对均为敏感信息,切勿与他人分享。** 如果发现账户有异常活动,请立即撤销所有密钥并联系 Binance 支持。 - API 密钥可配置为仅允许访问某些鉴权接口。 - 例如,您可以拥有具有 `TRADE` 权限的 API 密钥用于交易,同时使用具有 `USER_DATA` 权限的另一个 API 密钥来监控订单状态。 - 默认情况下,API 密钥无法进行 `TRADE`,您需要先在 API 管理中启用交易权限。 | 鉴权类型 | 描述 | | ----------- | ------------------------- | | NONE | 不需要鉴权的接口 | | TRADE | 需要有效的 API-Key 和签名 | | MARGIN | 需要有效的 API-Key 和签名 | | USER_DATA | 需要有效的 API-Key 和签名 | | USER_STREAM | 需要有效的 API-Key | | MARKET_DATA | 需要有效的 API-Key | ### 需要签名的接口 - 调用`SIGNED` 接口时,除了接口本身所需的参数外,还需要在 `query string` 或 `request body` 中传递 `signature`, 即签名参数。 #### 签名是否是大小写敏感的 - **HMAC:** 使用 HMAC 生成的签名**不区分大小写**。这意味着无论字母大小写如何,签名字符串都可以被验证。 - **RSA:** 使用 RSA 生成的签名是**大小写敏感的**。 - **Ed25519:** 使用 Ed25519 生成的签名也是**大小写敏感的**。 请参阅[已签名请求示例 (HMAC)](#hmac-keys)、[已签名请求示例 (RSA)](#rsa-keys) 和[已签名请求示例 (Ed25519)](#ed25519-keys),了解如何根据您使用的 API 密钥类型计算签名。 ### 时间同步安全 - `SIGNED` 请求还需要一个 `timestamp` 参数,该参数应为当前时间戳,单位为毫秒或微秒。(参见 [通用 API 信息](#general-api-information)) - 另一个可选参数 `recvWindow`,用以指定请求的有效期,只能以毫秒为单位。 - `recvWindow` 扩展为三位小数(例如 6000.346),以便可以指定微秒。 - 如果未发送 `recvWindow`,则 **默认值为 5000 毫秒**。 - `recvWindow` 的最大值为 60000 毫秒。 - 请求处理逻辑如下: ```javascript serverTime = getCurrentTime() if (timestamp < (serverTime + 1 second) && (serverTime - timestamp) <= recvWindow) { // 开始处理请求 serverTime = getCurrentTime() if (serverTime - timestamp) <= recvWindow { // 将请求转发到撮合引擎 } else { // 拒绝请求 } // 结束处理请求 } else { // 拒绝请求 } ``` **关于交易时效性** 互联网状况并不100%可靠,不可完全依赖,因此你的程序本地到币安服务器的时延会有抖动. 这是我们设置`recvWindow`的目的所在,如果你从事高频交易,对交易时效性有较高的要求,可以灵活设置`recvWindow`以达到你的要求。 **不推荐使用5秒以上的recvWindow。最大值不能超过60秒!** ### POST /api/v3/order 的签名示例 #### HMAC Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 以下示例分步演示如何使用 `echo`、`openssl` 和 `curl` 从 Linux 命令行发送有效的签名 payload。其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 API 密钥和密钥示例: | Key | Value | | ----------- | ---------------------------------------------------------------- | | `apiKey` | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A | | `secretKey` | NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j | **警告:请勿与任何人分享您的 API 密钥和秘钥。** 此处提供的示例密钥仅用于示范说明目的。 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | LTCBTC | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` **第二步: 计算签名。** 1. 使用 API 密钥中的 `secretKey` 作为 HMAC-SHA-256 算法的签名密钥。 2. 对步骤 1 中构建的签名 payload 进行签名。 3. 将 HMAC-SHA-256 的输出编码为十六进制字符串。 请注意,`secretKey` 和 payload 是**大小写敏感的**,而生成的签名值是不区分大小写的。 **示例命令** 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71 ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n "symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3 ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71" ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3" ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash apiKey="vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" secretKey="NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" payload="symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" # 对请求进行签名 signature=$(echo -n "$payload" | openssl dgst -sha256 -hmac "$secretKey") signature=${signature#*= } # Keep only the part after the "= " # 发送请求 curl -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?$payload&signature=$signature" ``` #### RSA Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 要获取 API 密钥,您需要将 RSA 公钥上传到您的帐户中,系统将为您提供相应的 API 密钥。 仅支持 `PKCS#8` 密钥。 在以下示例中,其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 这些示例假设私钥存储在文件 `./test-prv-key.pem` 中。 | Key | Value | | -------- | ---------------------------------------------------------------- | | `apiKey` | CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ | 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | BTCUSDT | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` **第二步: 计算签名。** 1. 使用 RSASSA-PKCS1-v1_5 算法和 SHA-256 哈希函数对步骤 1 中构建的签名 payload 进行签名。 2. 将输出结果编码为 base64 格式。 请注意,payload 和生成的`签名值`是**大小写敏感的**。 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n 'symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' HZ8HOjiJ1s/igS9JA+n7+7Ti/ihtkRF5BIWcPIEluJP6tlbFM/Bf44LfZka/iemtahZAZzcO9TnI5uaXh3++lrqtNonCwp6/245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH+XxaCmR0WcvlKjNQnp12/eKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang/1WOq+Jaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT/fNnMRxFc7u+j3qI//5yuGuu14KR0MuQKKCSpViieD+fIti46sxPTsjSemoUKp0oXA== ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n 'symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' qJtv66wyp/1mZE+mIFAAMUoTe8xkmLN7/eAZjuC9x1ocxovItHLl/sNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M+JNIMz5UFxfeA53rXjFlvsyH1Sig+OuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C/QMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt/GuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng== ``` 3. 对 base64 格式的字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符): ```console HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D' ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D' ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash function rawurlencode { local string="${1}" local strlen=${#string} local encoded="" local pos c o for (( pos=0 ; pos 错误JSON格式: ```javascript { "code":-1121, "msg":"Invalid symbol." } ``` 错误由两部分组成:错误代码和消息。 代码是通用的,但是消息可能会有所不同。 ## 10xx -常规服务器或网络问题 ### -1000 UNKNOWN - 处理请求时发生未知错误。 - 处理请求时发生未知错误。[%s] ### -1001 DISCONNECTED - 内部错误; 无法处理您的请求。 请再试一次. ### -1002 UNAUTHORIZED - 您无权执行此请求。 ### -1003 TOO_MANY_REQUESTS - 排队的请求过多。 - 请求权重过多; 当前限制是 %s 每 %s 的请求权重。 请使用 Websocket Streams 进行实时更新,以避免轮询API。 - 请求权重过多; IP被禁止,直到%s。 请使用 Websocket Streams 进行实时更新,以免被禁。 ### -1004 SERVER_BUSY - 服务器正忙,请稍候再试。 ### -1006 UNEXPECTED_RESP - 从消息总线收到意外的响应。 执行状态未知。 ### -1007 TIMEOUT - 等待后端服务器响应超时。 发送状态未知; 执行状态未知。 ### -1008 SERVER_BUSY - 现货交易服务器当前因其他请求而过载。 请在几分钟后重试。 ### -1014 UNKNOWN_ORDER_COMPOSITION - 不支持的订单组合。 ### -1015 TOO_MANY_ORDERS - 新订单太多。 - 新订单太多; 当前限制为每%s %s个订单。 ### -1016 SERVICE_SHUTTING_DOWN - 该服务不可用。 ### -1020 UNSUPPORTED_OPERATION - 不支持此操作。 ### -1021 INVALID_TIMESTAMP - 此请求的时间戳在recvWindow之外。 - 此请求的时间戳比服务器时间提前1000毫秒。 ### -1022 INVALID_SIGNATURE - 此请求的签名无效。 ### -1099 Not found, authenticated, or authorized - 替换错误代码-1999 ## 11xx - 2xxx Request issues ### -1100 ILLEGAL_CHARS - 在参数中发现非法字符。 - 在参数中发现非法字符。`%s` - 在参数`%s`中发现非法字符; 合法范围是`%s`。 ### -1101 TOO_MANY_PARAMETERS - 为此端点发送的参数太多。 - 参数太多; 预期为`%s`并收到了`%s`。 - 检测到的参数值重复。 ### -1102 MANDATORY_PARAM_EMPTY_OR_MALFORMED - 未发送强制性参数,该参数为空/空或格式错误。 - 强制参数`%s`未发送,为空/空或格式错误。 - 必须发送参数`%s`或`%s`,但两者均为空! ### -1103 UNKNOWN_PARAM - 发送了未知参数。 ### -1104 UNREAD_PARAMETERS - 并非所有发送的参数都被读取。 - 并非所有发送的参数都被读取; 读取了`%s`参数,但被发送了`%s`。 ### -1105 PARAM_EMPTY - 参数为空。 - 参数`%s`为空。 ### -1106 PARAM_NOT_REQUIRED - 不需要时已发送参数。 - 不需要时发送参数`%s`。 ### -1111 BAD_PRECISION - 精度超过为此资产定义的最大值。 ### -1112 NO_DEPTH - 交易对没有挂单。 ### -1114 TIF_NOT_REQUIRED - 不需要时发送了TimeInForce参数。 ### -1115 INVALID_TIF - 无效 timeInForce. ### -1116 INVALID_ORDER_TYPE - 无效订单类型。 ### -1117 INVALID_SIDE - 无效买卖方向。 ### -1118 EMPTY_NEW_CL_ORD_ID - 新的客户订单ID为空。 ### -1119 EMPTY_ORG_CL_ORD_ID - 客户自定义的订单ID为空。 ### -1120 BAD_INTERVAL - 无效时间间隔。 ### -1121 BAD_SYMBOL - 无效的交易对。 ### -1125 INVALID_LISTEN_KEY - 该listenKey不存在。 ### -1127 MORE_THAN_XX_HOURS - 查询间隔太大。 - 从开始时间到结束时间之间超过%s小时。 ### -1128 OPTIONAL_PARAMS_BAD_COMBO - 可选参数组合无效。 ### -1130 INVALID_PARAMETER - 发送的参数为无效数据。 - 发送参数`%s`的数据无效。 ### -1131 BAD_RECV_WINDOW - `recvWindow` 必须小于 60000 ### -1134 BAD_STRATEGY_TYPE - `strategyType` 必须小于 1000000 #### -1145 INVALID_CANCEL_RESTRICTIONS - `cancelRestrictions` 必须是 `ONLY_NEW` 或者 `ONLY_PARTIALLY_FILLED`。 #### -1151 重复的交易对 - Symbol is present multiple times in the list. ### -2010 NEW_ORDER_REJECTED - 新订单被拒绝 ### -2011 CANCEL_REJECTED - 取消订单被拒绝 ### -2013 NO_SUCH_ORDER - 订单不存在。 ### -2014 BAD_API_KEY_FMT - API-key 格式无效。 ### -2015 REJECTED_MBX_KEY - 无效的API密钥,IP或操作权限。 ### -2016 NO_TRADING_WINDOW - 找不到该交易对的交易窗口。 尝试改为24小时自动报价。 #### -2026 ORDER_ARCHIVED - 订单已被存档因为此订单被取消或过期,无交易数量而最后的更新已超过 90 天前。 ## 3xxx-5xxx SAPI 具体问题 ### -3000 INNER_FAILURE - 内部服务器错误。 ### -3001 NEED_ENABLE_2FA - 请先启用2FA。 ### -3002 ASSET_DEFICIENCY - 此资产不存在。 ### -3003 NO_OPENED_MARGIN_ACCOUNT - 杠杆账户不存在。 ### -3004 TRADE_NOT_ALLOWED - 禁止交易。 ### -3005 TRANSFER_OUT_NOT_ALLOWED - 不允许转账。 ### -3006 EXCEED_MAX_BORROWABLE - 您的已借金额已超过最高可借金额。 ### -3007 HAS_PENDING_TRANSACTION - 您有待处理的交易,请稍后再试。 ### -3008 BORROW_NOT_ALLOWED - 不允许借款。 ### -3009 ASSET_NOT_MORTGAGEABLE - 此资产目前不允许转入杠杆账户。 ### -3010 REPAY_NOT_ALLOWED - 不允许还款。 ### -3011 BAD_DATE_RANGE - 您输入的日期无效。 ### -3012 ASSET_ADMIN_BAN_BORROW - 此资产禁止借款。 ### -3013 LT_MIN_BORROWABLE - 借入金额少于最低借入金额。 ### -3014 ACCOUNT_BAN_BORROW - 此帐户禁止借款。 ### -3015 REPAY_EXCEED_LIABILITY - 还款额超过借款额。 ### -3016 LT_MIN_REPAY - 还款额少于最低还款额。 ### -3017 ASSET_ADMIN_BAN_MORTGAGE - 此资产目前不允许转入保证金账户。 ### -3018 ACCOUNT_BAN_MORTGAGE - 此帐户已禁止转入。 ### -3019 ACCOUNT_BAN_ROLLOUT - 此帐户禁止转出。 ### -3020 EXCEED_MAX_ROLLOUT - 转出金额超过上限。 ### -3021 PAIR_ADMIN_BAN_TRADE - 杠杆账户无法交易此交易对。 ### -3022 ACCOUNT_BAN_TRADE - 账号被禁止交易。 ### -3023 WARNING_MARGIN_LEVEL - 无法在当前杠杆倍数下转出资金或者下单 ### -3024 FEW_LIABILITY_LEFT - 付款之后未付款的债务太小 ### -3025 INVALID_EFFECTIVE_TIME - 输入时间有误。 ### -3026 VALIDATION_FAILED - 输入参数有误。 ### -3027 NOT_VALID_MARGIN_ASSET - 无效的杠杆资产。 ### -3028 NOT_VALID_MARGIN_PAIR - 无效的杠杆交易对。 ### -3029 TRANSFER_FAILED - 转账失败。 ### -3036 ACCOUNT_BAN_REPAY - 此账号无法还款。 ### -3037 PNL_CLEARING - `PNL`正在清帐,请稍等。 ### -3038 LISTEN_KEY_NOT_FOUND - 找不到`Listen key` ### -3041 BALANCE_NOT_CLEARED - 余额不足 ### -3042 PRICE_INDEX_NOT_FOUND - 该杠杆交易对无可用价格指数。 ### -3043 TRANSFER_IN_NOT_ALLOWED - 不允许转入。 ### -3044 SYSTEM_BUSY - 系统繁忙。 ### -3045 SYSTEM - 系统目前没有足够可借的资产。 ### -3999 NOT_WHITELIST_USER - 此功能只面向邀请的用户。 ### -4001 CAPITAL_INVALID - 非法操作 ### -4002 CAPITAL_IG - 非法获取 ### -4003 CAPITAL_IEV - 非法邮箱验证 ### -4004 CAPITAL_UA - 未登录或者认证。 ### -4005 CAPAITAL_TOO_MANY_REQUEST - 请求太频繁。 ### -4006 CAPITAL_ONLY_SUPPORT_PRIMARY_ACCOUNT - 只支持主账号。 ### -4007 CAPITAL_ADDRESS_VERIFICATION_NOT_PASS - 地址的没有通过校验。 ### -4008 CAPITAL_ADDRESS_TAG_VERIFICATION_NOT_PASS - 地址的标记信息(`tag`)没有通过校验。 ### -4010 CAPITAL_WHITELIST_EMAIL_CONFIRM - 确认电子邮件已经列入白名单。 ### -4011 CAPITAL_WHITELIST_EMAIL_EXPIRED - 列入白名单的电子邮件无效。 ### -4012 CAPITAL_WHITELIST_CLOSE - 白名单未打开。 ### -4013 CAPITAL_WITHDRAW_2FA_VERIFY - 2FA未打开。 ### -4014 CAPITAL_WITHDRAW_LOGIN_DELAY - 在登录后的2分钟之内不允许提款。 ### -4015 CAPITAL_WITHDRAW_RESTRICTED_MINUTE - 暂停提款 ### -4016 CAPITAL_WITHDRAW_RESTRICTED_PASSWORD - 在密码修改后的24小时之内不允许提款。 ### -4017 CAPITAL_WITHDRAW_RESTRICTED_UNBIND_2FA - 在2FA发行后的24小时之内不允许提款。 ### -4018 CAPITAL_WITHDRAW_ASSET_NOT_EXIST - 此资产不存在。 ### -4019 CAPITAL_WITHDRAW_ASSET_PROHIBIT - 此资产不允许提款。 ### -4021 CAPITAL_WITHDRAW_AMOUNT_MULTIPLE - 资产的提款数量必须是%s的%s倍。 ### -4022 CAPITAL_WITHDRAW_MIN_AMOUNT - 不须少于最低的提款数量%s。 ### -4023 CAPITAL_WITHDRAW_MAX_AMOUNT - 在24小时之内,不须超过最高的提款数量。 ### -4024 CAPITAL_WITHDRAW_USER_NO_ASSET - 当前用户没有此资产。 ### -4025 CAPITAL_WITHDRAW_USER_ASSET_LESS_THAN_ZERO - 持有资产的数量小于零。 ### -4026 CAPITAL_WITHDRAW_USER_ASSET_NOT_ENOUGH - 此资产余额不足。 ### -4027 CAPITAL_WITHDRAW_GET_TRAN_ID_FAILURE - 无法获取tranId。 ### -4028 CAPITAL_WITHDRAW_MORE_THAN_FEE - 提款金额必须多于佣金额。 ### -4029 CAPITAL_WITHDRAW_NOT_EXIST - 此提款记录不存在。 ### -4030 CAPITAL_WITHDRAW_CONFIRM_SUCCESS - 提款资产成功。 ### -4031 CAPITAL_WITHDRAW_CANCEL_FAILURE - 取消提款失败。 ### -4032 CAPITAL_WITHDRAW_CHECKSUM_VERIFY_FAILURE - 验证提款失败。 ### -4033 CAPITAL_WITHDRAW_ILLEGAL_ADDRESS - 提款地址不合法。 ### -4034 CAPITAL_WITHDRAW_ADDRESS_CHEAT - 当前地址有异常。 ### -4035 CAPITAL_WITHDRAW_NOT_WHITE_ADDRESS - 此地址不在白名单上。请加入然后重试。 ### -4036 CAPITAL_WITHDRAW_NEW_ADDRESS - 新地址在{0}小时后才可以提款。 ### -4037 CAPITAL_WITHDRAW_RESEND_EMAIL_FAIL - 重新发送邮件失败。 ### -4038 CAPITAL_WITHDRAW_RESEND_EMAIL_TIME_OUT - 请5分钟后重试。 ### -4039 CAPITAL_USER_EMPTY - 用户不存在。 ### -4041 CAPITAL_MINUTE_TOO_SMALL - 请一分钟后重试。 ### -4042 CAPITAL_CHARGE_NOT_RESET - 资产无法重新获取存款地址。 ### -4043 CAPITAL_ADDRESS_TOO_MUCH - 在24小时之内充值超过100多个地址。 ### -4044 CAPITAL_BLACKLIST_COUNTRY_GET_ADDRESS - 此国家在黑名单上。 ### -4045 CAPITAL_GET_ASSET_ERROR - 获得资产失败。 ### -4046 CAPITAL_AGREEMENT_NOT_CONFIRMED - 协议未确认。 ### -4047 CAPITAL_DATE_INTERVAL_LIMIT - 时间间隔必须在0-90天之内 ### -4060 CAPITAL_WITHDRAW_USER_ASSET_LOCK_DEPOSIT - 体现仍在区块确认中,暂时锁定部分资产 ### -4106 TAG_NOT_SUPPORTED_FOR_NETWORK - 该网络不支持 memo/tag。请移除 `addressTag` 字段后重试。 ### -5001 ASSET_DRIBBLET_CONVERT_SWITCH_OFF - 不允许转移到微型资产。 ### -5002 ASSET_ASSET_NOT_ENOUGH - 此余额不足。 ### -5003 ASSET_USER_HAVE_NO_ASSET - 此资产不存在。 ### -5004 USER_OUT_OF_TRANSFER_FLOAT - 剩余余额已超过0.001BTC,请重新选择。 - %s的剩余余额已超过0.001BTC,请重新选择。 ### -5005 USER_ASSET_AMOUNT_IS_TOO_LOW - BTC的剩余余额太低,请重新选择。 - %s的剩余余额太低,请重新选择。 ### -5006 USER_CAN_NOT_REQUEST_IN_24_HOURS - 24小时内只能转账一次。 ### -5007 AMOUNT_OVER_ZERO - 数量必须大于零。 ### -5008 ASSET_WITHDRAW_WITHDRAWING_NOT_ENOUGH - 可退回资产的金额不足。 ### -5009 PRODUCT_NOT_EXIST - 产品不存在。 ### -5010 TRANSFER_FAIL - 资产转移失败。 ### -5011 FUTURE_ACCT_NOT_EXIST - 合约帐户不存在。 ### -5012 TRANSFER_PENDING - 资产转移正在进行中。 ### -5021 PARENT_SUB_HAVE_NO_RELATION - 当前的子账户和母账户没有从属关系。 ### -5012 FUTURE_ACCT_OR_SUBRELATION_NOT_EXIST - 合约帐户或子账户关系不存在。 ## 6XXX - 币安宝相关 ### -6001 DAILY_PRODUCT_NOT_EXIST - 理财产品不存在. ### -6003 DAILY_PRODUCT_NOT_ACCESSIBLE - 产品不存在或者没有权限。 ### -6004 DAILY_PRODUCT_NOT_PURCHASABLE - 产品无法购买。 ### -6005 DAILY_LOWER_THAN_MIN_PURCHASE_LIMIT - 低于可以购买的最小限额。 ### -6006 DAILY_REDEEM_AMOUNT_ERROR - 赎回额度有误。 ### -6007 DAILY_REDEEM_TIME_ERROR - 不在赎回的时间内。 ### -6008 DAILY_PRODUCT_NOT_REDEEMABLE - 产品暂时无法赎回。 ### -6009 REQUEST_FREQUENCY_TOO_HIGH - 发送请求太频繁。 ### -6011 EXCEEDED_USER_PURCHASE_LIMIT - 超购每个月用户可以申购的最大次数。 ### -6012 BALANCE_NOT_ENOUGH - 余额不足。 ### -6013 PURCHASING_FAILED - 申购失败。 ### -6014 UPDATE_FAILED - 超过可以申购的最大上限。 ### -6015 EMPTY_REQUEST_BODY - 请求的`body`为空。 ### -6016 PARAMS_ERR - 请求的参数有误。 ### -6017 NOT_IN_WHITELIST - 不在白名单里面。 ### -6018 ASSET_NOT_ENOUGH - 资产不足。 ### -6019 PENDING - 需要进一步确认。 ### -6020 PROJECT_NOT_EXISTS - 此项目不存在。 ## 70xx - 期货 ### -7001 FUTURES_BAD_DATE_RANGE - 此日期范围不支持。 ### -7002 FUTURES_BAD_TYPE - 此数据请求类型不支持。 ## 20xxx - 合约/现货策略交易 ### -20121 Invalid symbol - 无效交易对。 ### -20124 Invalid algo id or it has been completed - 无效的策略订单ID或者它已经被执行。 ### -20130 Invalid data sent for a parameter - 无效数据。 ### -20132 The client algo id is duplicated - 用户自定义策略订单ID重复。 ### -20194 Duration is too short to execute all required quantity - Duration 时间太短不足以执行用户选择的订单数量。 ### -20195 The total size is too small - 下单数量太小。 ### -20196 The total size is too large - 下单数量太大。 ### -20198 Reach the max open orders allowed - 达到了最大挂单上限。 ### -20204 The notional of USD is less or more than the limit - 订单小于最小USD名义价值 ## 过滤器故障 | 报错信息 | 描述 | | ------------------------------------------ | ---------------------------------------------------------------------------------- | | "Filter failure: PRICE_FILTER" | "价格"过高,过低和/或不遵循交易对的最小价格规则。 | | "Filter failure: PERCENT_PRICE" | "价格"比最近Y分钟的平均加权价格高X%或X%太低。 | | "Filter failure: PERCENT_PRICE_BY_SIDE" | `price` 在当前方向上(`BUY`或者`SELL`)比`lastPrice`价格超过X%或者低于Y%。 | | "Filter failure: LOT_SIZE" | "数量"太高,太低和/或不遵循该交易对的步长规则。 | | "Filter failure: MIN_NOTIONAL" | 价格\*数量太低,无法成为该交易对的有效订单。 | | "Filter failure: ICEBERG_PARTS" | `ICEBERG` 订单会分成太多部分; icebergQty太小。 | | "Filter failure: MARKET_LOT_SIZE" | "MARKET"订单的"数量"过高,过低和/或未遵循交易对的步长规则。 | | "Filter failure: MAX_POSITION" | 达到账户的最大仓位限制。这包括了账户的余额总额,以及所有处于open的买单的数量总和。 | | "Filter failure: MAX_NUM_ORDERS" | 客户在交易对上有太多挂单。 | | "Filter failure: MAX_ALGO_ORDERS" | 账户有太多未平仓止损和/或在交易对上执行获利指令。 | | "Filter failure: MAX_NUM_ICEBERG_ORDERS" | 客户在交易对上有太多 iceberg 挂单。 | | "Filter failure: TRAILING_DELTA" | `trailingDelta` 值不在限定的范围内. | | "Filter failure: EXCHANGE_MAX_NUM_ORDERS" | 帐户上的交易所有太多挂单。 | | "Filter failure: EXCHANGE_MAX_ALGO_ORDERS" | 帐户有太多止损挂单和/或在交易所收取获利指令。 | ## 10xxx - 质押借币 ### -10001 SYSTEM_MAINTENANCE - 系统维护中,请稍后再试 ### -10002 INVALID_INPUT - 无效的输入参数 ### -10005 NO_RECORDS - 暂无记录 ### -10007 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10008 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10009 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10010 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10011 INSUFFICIENT_ASSET - 现货资产不足 ### -10012 INVALID_AMOUNT - 无效的还款金额 ### -10013 INSUFFICIENT_AMOUNT - 抵押资产不足 ### -10015 DEDUCTION_FAILED - 抵押资产扣款失败 ### -10016 LOAN_FAILED - 放贷失败 ### -10017 REPAY_EXCEED_DEBT - 还款金额超过负债金额 ### -10018 INVALID_AMOUNT - 无效的还款金额 ### -10019 CONFIG_NOT_EXIST - 配置不存在 ### -10020 UID_NOT_EXIST - 用户ID不存在 ### -10021 ORDER_NOT_EXIST - 订单不存在 ### -10022 INVALID_AMOUNT - 无效的调整金额 ### -10023 ADJUST_LTV_FAILED - 调整质押率失败 ### -10024 ADJUST_LTV_NOT_SUPPORTED - 暂不支持调整质押率 ### -10025 REPAY_FAILED - 还款失败 ### -10026 INVALID_PARAMETER - 无效的参数 ### -10028 INVALID_PARAMETER - 无效的参数 ### -10029 AMOUNT_TOO_SMALL - 借贷金额过小 ### -10030 AMOUNT_TOO_LARGE - 借贷金额过大 ### -10031 QUOTA_REACHED - 已达到个人借贷限额 ### -10032 REPAY_NOT_AVAILABLE - 暂不支持换款 ### -10034 REPAY_NOT_AVAILABLE - 抵押物还款暂时不支持,请尝试用借贷币还款。 ### -10039 AMOUNT_TOO_SMALL - 还款金额过小 ### -10040 AMOUNT_TOO_LARGE - 还款金额过大 ### -10041 INSUFFICIENT_AMOUNT - 由于借贷需求过多,系统剩余可借{0}额度不足。请调整借贷金额或明天再试。 ### -10042 ASSET_NOT_SUPPORTED - 暂不支持%s币种 ### -10043 ASSET_NOT_SUPPORTED - 暂不支持{0} 借贷 ### -10044 QUOTA_REACHED - 抵押物数量已达到限额,请调整抵押金额或使用其他抵押资产。 ### -10045 COLLTERAL_REPAY_NOT_SUPPORTED - 该借贷币种暂不支持抵押物还款,请稍后再试。 ### -10046 EXCEED_MAX_ADJUSTMENT - 调整抵押物超过最大限额,请重试。 ### -10047 REGION_NOT_SUPPORTED - 受当地法规管制,您所在地区暂不支持该币种。 ## 13xxx - 杠杆代币 ### -13000 BLVT_FORBID_REDEEM - 当前该杠杆代币关闭赎回 ### -13001 BLVT_EXCEED_DAILY_LIMIT - 超过该代币个人24小时赎回金额上限 ### -13002 BLVT_EXCEED_TOKEN_DAILY_LIMIT - 超过该代币全局24小时赎回金额上限 ### -13003 BLVT_FORBID_PURCHASE - 当前该杠杆代币关闭申购 ### -13004 BLVT_EXCEED_DAILY_PURCHASE_LIMIT - 超过该代币个人24小时申购金额上限 ### -13005 BLVT_EXCEED_TOKEN_DAILY_PURCHASE_LIMIT - 超过该代币全局24小时申购金额上限 ### -13006 BLVT_PURCHASE_LESS_MIN_AMOUNT - 申购金额低于规定下限 ### -13007 BLVT_PURCHASE_AGREEMENT_NOT_SIGN - 没有签署开通交易协议 ## 12xxx - 流动性挖矿 ### -12014 TOO MANY REQUESTS - 2秒内接收的请求数量多于1条 ## 18xxx - 币安码 ### -18002 - The total amount of codes you created has exceeded the 24-hour limit, please try again after UTC 0 - 24小时内制码总金额已超过限额,请UTC0点后再尝试 ### -18003 - Too many codes created in 24 hours, please try again after UTC 0 - 24小时内制码总次数已超过限额,请UTC0点后再尝试 ### -18004 - Too many invalid redeem attempts in 24 hours, please try again after UTC 0 - 24小时内兑现币安码输错次数已超过限额,请UTC0点后再尝试 ### -18005 - Too many invalid verify attempts, please try later - 参考号输错次数过多,请稍后再试 ### -18006 - The amount is too small, please re-enter - 金额过小,请重新输入 ### -18007 - This token is not currently supported, please re-enter - 尚未支持该币种,请重新输入 ## 21xxx - 統一帳戶 ### -21001 USER_IS_NOT_UNIACCOUNT - 尚未开通统一账户。 ### -21002 UNI_ACCOUNT_CANT_TRANSFER_FUTURE - 统一账户禁用margin向futures转账。 ### -21003 NET_ASSET_MUST_LTE_RATIO - margin资产更新失败。 ### -21004 USER_NO_LIABILITY - 用户不存在统一账户穿仓负债 ### -21005 NO_ENOUGH_ASSET - 用户现货钱包BUSD资产不足以偿还统一账户穿仓负债 ### -21006 HAD_IN_PROCESS_REPAY - 用户存在正在偿还的统一账户穿仓负债 ### -21007 IN_FORCE_LIQUIDATION - 强平进行中,用户偿还统一账户穿仓负债失败 ## 订单拒绝错误 以下错误代码表示撮合引擎返回的订单相关错误: - `-1010 ERROR_MSG_RECEIVED` - `-2010 NEW_ORDER_REJECTED` - `-2011 CANCEL_REJECTED` 结合以下消息将指示特定的错误: | 错误信息 | 描述 | | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | "Unknown order sent." | 找不到订单(通过"orderId","clientOrderId","origClientOrderId") | | "Duplicate order sent." | `clientOrderId`已经被使用 | | "Market is closed." | 该交易对不在交易范围 | | "Account has insufficient balance for requested action." | 没有足够的资金来完成行动 | | "Market orders are not supported for this symbol." | 交易对上未启用"MARKET" | | "Iceberg orders are not supported for this symbol." | 交易对上未启用`icebergQty` | | "Stop loss orders are not supported for this symbol." | 交易对上未启用 `STOP_LOSS` | | "Stop loss limit orders are not supported for this symbol." | 交易对上未启`STOP_LOSS_LIMIT` | | "Take profit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT` | | "Take profit limit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT_LIMIT` | | "Price \* QTY is zero or less." | `price` \* `quantity`太小 | | "IcebergQty exceeds QTY." | `icebergQty` 必须少于订单数量 | | "This action is disabled on this account." | 联系客户支持; 该账户已禁用了某些操作。 | | "This account may not place or cancel orders." | 联系客户支持: 该账户已被禁用了交易操作。 | | "Unsupported order combination" | 不允许组合`orderType`, `timeInForce`, `stopPrice`, 和/或 `icebergQty` 。 | | "Order would trigger immediately." | 与最后交易价格相比,订单的止损价无效。 | | "Cancel order is invalid. Check origClientOrderId and orderId." | 未发送`origClientOrderId` 或`orderId` 。 | | "Order would immediately match and take." | `LIMIT_MAKER` 订单类型将立即匹配并进行交易,而不是纯粹的生成订单。 | | "The relationship of the prices for the orders is not correct." | `OCO`订单中设置的价格不符合报价规则:

The rules are:

`SELL Orders`: Limit Price > Last Price > Stop Price

`BUY Orders`: Limit Price < Last Price < Stop Price | | "OCO orders are not supported for this symbol" | `OCO`订单不支持该交易对 | | "Quote order qty market orders are not support for this symbol." | 这个交易对,市价单不支持参数`quoteOrderQty` | | "Trailing stop orders are not supported for this symbol." | 此symbol不支持 `trailingDelta` | | | "Order cancel-replace is not supported for this symbol." | 此symbol不支持 `POST /api/v3/order/cancelReplace` 或者 `order.cancelReplace` (WebSocket API) | | | "This symbol is not permitted for this account." | 账户和交易对的权限不一致 (比如 `SPOT`, `MARGIN` 等)。| | | "This symbol is restricted for this account." | 账户没有权限在此交易对交易 (比如账户只拥有 `ISOLATED_MARGIN`权限,则无法下`SPOT` 订单)。 | | | "Order was not canceled due to cancel restrictions." | `cancelRestrictions` 设置为 `ONLY_NEW` 但订单状态不是 `NEW`

`cancelRestrictions` 设置为 `ONLY_PARTIALLY_FILLED` 但订单状态不是 `PARTIALLY_FILLED`。 | | ## 关于 POST /api/v3/order/cancelReplace 的错误 ### -2021 Order cancel-replace partially failed 收到该错误码代表撤单**或者**下单失败。 ### -2022 Order cancel-replace failed. 收到该错误码代表撤单**和**下单都失败。 --- ## Document: /products/mining/change-log URL: /zh-CN/docs/products/mining/change-log # 更新日志 ## 2022-05-19 - 更新矿池接口參數: - `GET /sapi/v1/mining/pub/algoList` 及 `GET /sapi/v1/mining/pub/coinList`:不需要参数 --- ## 2022-01-04 - 新增矿池接口: - `GET /sapi/v1/mining/payment/uid` 以获取矿池账户收益列表 --- ## 2021-01-10 - 矿池接口 `GET /sapi/v1/mining/payment/list` 新增可选参数 `pageSize` - 矿池接口 `GET /sapi/v1/mining/payment/list` 新增返回字段: - "type" 表示收益类型 - "hashTransfer" 表示已转让算力 - "transferAmount" 表示已转让收益 - 新增矿池接口: - `GET /sapi/v1/mining/payment/other` - `GET /sapi/v1/mining/hash-transfer/config/details` - `GET /sapi/v1/mining/hash-transfer/config/details/list` - `GET /sapi/v1/mining/hash-transfer/profit/details` - `POST /sapi/v1/mining/hash-transfer/config` - `POST /sapi/v1/mining/hash-transfer/config/cancel` --- ## 2020-05-06 - 新增矿池接口: - `GET /sapi/v1/mining/pub/algoList` - `GET /sapi/v1/mining/pub/coinList` - `GET /sapi/v1/mining/worker/detail` - `GET /sapi/v1/mining/worker/list` - `GET /sapi/v1/mining/payment/list` - `GET /sapi/v1/mining/statistics/user/status` - `GET /sapi/v1/mining/statistics/user/list` --- ## Document: /products/mining/Introduction URL: /zh-CN/docs/products/mining/Introduction - 这些接口作用于币安矿池。更多细节, 参考[币安矿池](https://pool.binance.com/cn)页面。 --- ## Document: TypeScript Support URL: /zh-CN/docs/products/mini-program/typescript # TypeScript Support This guide offers a detailed walkthrough on how to proficiently develop MiniPrograms employing TypeScript. ## Inclusion of DevDependencies Embark by installing the necessary devDependencies: ```bash # Optional # Set npm to default to @binance registry # npm config set @binance:registry https://npm.binance.com # Install devDependencies $ npm install @binance/mp-service @binance/mp-components --dev ``` Following the successful installation of devDependencies, proceed to import them as illustrated below: ```ts import mpService from "@binance/mp-service"; import { View, Text, Button } from "@binance/mp-components"; ``` Equipped with these devDependencies and their rightful Import methods, you're now well-prepared to venture further into the realm of MiniProgram development with TypeScript! --- ## Document: Tutorial: Create a weather app by mini program URL: /zh-CN/docs/products/mini-program/tutorial # Tutorial: Create a weather app by mini program # Crafting a Dynamic Weather Mini-Program from Scratch This comprehensive tutorial offers a step-by-step guide to building a dynamic weather mini-program. The aim is to create a multi-page program that leverages the Amap's weather API, displaying weather conditions for a user-selected city. ## Setting the Project Foundation Start by [following the guide to create your mini program](quick-start#generate-your-mini-program). The result? A new project built within the current directory, following this directory structure: ``` 📦demo-app ┣ 📂pages ┃ ┣ 📂index ┃ ┃ ┣ 📜index.bxml ┃ ┃ ┣ 📜index.bxss ┃ ┃ ┣ 📜index.js ┃ ┃ ┗ 📜index.json ┃ ┗ 📂logs ┃ ┃ ┣ 📜logs.bxml ┃ ┃ ┣ 📜logs.bxss ┃ ┃ ┣ 📜logs.js ┃ ┃ ┗ 📜logs.json ┣ 📂utils ┃ ┗ 📜util.js ┣ 📜app.bxss ┣ 📜app.js ┣ 📜app.json ┗ 📜project.config.json ``` ## Building the List Page Next, update the file code as follows: ┣ 📂index ┃ ┣ 📜index.bxml ┃ ┣ 📜index.js ```html Cities List Beijing Shanghai Guangzhou Shenzhen ``` ```js Page({ // Triggered when the page is brought to the foreground. onShow() {}, // Triggered when the page is hidden in the background. onHide() {}, }); ``` In the code above, we are using the view, text, and navigator components to layout our page. The mini program is equipped with a large collection of built-in components you can learn more about from [Components](framework/components). Page components also provide several lifecycle hooks, like `onShow()` and `onHide()`. These two callbacks are triggered when the mini program toggles between the foreground and background of the app. Learn more about lifecycle from [LifeCycle](framework/lifecycle). We are transitioning between pages using the navigator component, which uses a 'url' parameter to route us to the detail page. You can learn about routing and parameter passing from [Router](framework/router). ## Creating the Details Page Start by creating a 'detail' folder within `pages`, and generating the required files: ``` 📦pages ┣ 📂detail ┃ ┣ 📜index.bxml ┃ ┣ 📜index.bxss ┃ ┣ 📜index.js ┃ ┗ 📜index.json ``` Add this new page to `src/app.config.json`: ```json { "entryPage": "pages/index/index", "pages": [ "pages/index/index", "pages/detail/index" // <- Add this line ], "window": { "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#fff", "navigationBarTitleText": "Title", "navigationBarTextStyle": "black" } } ``` Now you can begin drafting the code for the details page. You can do this by making some adjustments to: ┣ 📂detail ┃ ┣ 📜index.bxml ┃ ┣ 📜index.js ## Developing the Details Page Let's get started by setting up the code for the details page. We will need to update the following: ┣ 📂detail ┃ ┣ 📜index.bxml ┃ ┣ 📜index.js ```HTML {{city}} Weather Temperature: {{temperature}}°C Description: {{weatherDescription}} ``` ```js Page({ // Variables defined here are observable and can be used in templates. data: { city: "", temperature: "", weatherDescription: "", }, // Triggered when the page is loaded. onLoad(query) { this.setData({ city: query.city, }); this.updateWeather(); }, async updateWeather() { // Obtain and parse the weather data... const weatherData = await fetchWeatherData(this.data.city); this.setData({ temperature: weatherData.temperature, weatherDescription: weatherData.description, }); }, }); ``` The `onLoad(query)` function in the above code will be triggered when the page loads. `query` contains the parameters passed from the previous page, which we then access to grab the city value. It is also worth noting the `fetchWeatherData(city)` function. This function fetches and parses the weather data. However, the specifics of this action are not detailed here for simplicity. ## Conclusion This tutorial has guided you through the process of creating a simple and dynamic weather mini-program. If you followed along, congratulations on your new program! Not only did you learn the basic development process, but we hope it also inspired you to explore more about mini-program development, such as using APIs and working with real-time data. Happy coding! --- ## Document: Quick Start URL: /zh-CN/docs/products/mini-program/quick-start # Quick Start import Mermaid from "../../../components/Mermaid";

Initiate your thriving business journey with us right here »

Welcome aboard the Binance Mini Program, an avant-garde development framework expressly conceived for Binance. Our dynamic platform equips developers with the capability to rapidly concoct mini program applications harnessing web-based technology. These applications are tailored to function impeccably with the Binance app. Furthermore, our Mini Program unfolds a wide array of APIs and services designed to facilitate developers with swift access to the abundance of Binance's offerings, thereby accelerating the growth of their business ventures. This guide is your swift-start navigator, providing a clear path within the Mini Program. ## Overall Development Process B(Write codes) B --> C(Debug with DevServer) B --> E(Upload to Management) E --> F(Set as Experience Version) E --> G(Submit for review) G -->|Pass review|H(Run on Binance app) F --> H I(Register and login on Management) --> J(Create a new App) J --> E;`} /> ## Download The Binance DevTools Before diving into development, equip yourself with Binance Devtools. Jump to [download](download) to get our streamlined installer. Post installation, you can login the Binance Devtools with your Binance credentials. ## Generate Your Mini Program Post login to the Binance Devtools, select the '+' icon, fill in your innovative mini program's name and project path, and press 'Create'. Voila! Your new mini program is ready for exploration! ![new-mp](/img/mini-program/new-mp.png) ![new-mp-form](/img/mini-program/new-mp-form.png) Zero in on your freshly created mini program, double click to open it. Welcome to the interactive interface of Binance Devtools! ![ide-main-interface](/img/mini-program/ide-main-interface.png) ## Showcasing the App in Merchant Workspace The mini program created by the skilled Binance Devtools comes with a default AppID. You need to register and login to our efficient [Merchant Workspace](management/management) to further your development experience. Here, you can apply for a mini program, obtain the AppID, and fill in the relevant details. We extend the feature of version control in the Merchant Workspace for you to either release the beta version or submit the final edition for our expert review. ## Compile and preview Press 'Compile' on our toolbar to view the real-time rendition of your ambitious mini program on the Binance Devtools simulator. Fancy experiencing the mini program on your personal device? Simply replace the default AppID with the one you've successfully applied for. Click 'Preview' to generate an exclusive QR code, and voila! Use your Binance app to scan the QR code and immerse yourself in the mini program experience. ![ide-update-appid](/img/mini-program/ide-update-appid.png) ## Showcase Your App Upload the mini-program files using [Binance Devtools](../mp-ide-docs/docs/public/download-stable). The minute upload is successful, your current version details will pop up in the backend. ![ide-upload-mp](/img/mini-program/ide-upload-mp.png) ## Bring Your App to the Spotlight Prod your app for meticulous review using the merchant workspace. Once the review is cleared, your visionary app will become searchable on the prestigious Binance app and users across the globe will be able to open and use it directly. --- ## Document: Mini Program Platform Operation Rules URL: /zh-CN/docs/products/mini-program/operation-rules # Mini Program Platform Operation Rules ## 1. Principles and Explanations The Binance mini program platform provides developers with rich technical capabilities and traffic scenarios, and is committed to providing users with the most valuable information and services. We hope to guide developers to discover business opportunities that meet their needs while ensuring the relevance of Binance mini program to content and providing core value to users, and to generate sustainable corporate revenue while continuing to provide value to users. Mini Program developers should carefully read the Mini Programs Design Rules, and [Mini Programs Development Guide](quick-start) before developing a Mini Program. ## 2. Operation Rules ### 2.1 Rules for Registration and Submission 2.1.1 The developer should provide true and valid contact information and entity certification information. It is necessary to ensure that the entity actually providing services through the mini program must be consistent with the entity information, and the entity shall also be consistent with the payment entity. 2.1.2 The mini program submitted by the developer shall be associated with websites, applications, products or services that have complete legal rights or complete authorization. 2.1.3 To ensure the security and stability of the platform that users can access safely, the platform may require that the developer upload appropriate documents or make certain additions or adjustments to the Mini Program when submitting or operating the Mini Program. Be sure to provide such assistance based on our requirements or the submission may be rejected. 2.1.4 The services provided by the Mini Program shall match the category and tags the developer chooses as well as the services that the Mini Program provides. Additionally, they shall not fall outside the scope of the Mini Program platform's category library. Note that once the developer opts for a game as the category of your Mini Program, it will no longer be able to change it. 2.1.5 Bulk registration and repeated submission of numerous similar Mini Programs are prohibited. ### 2.2 Rules for Basic Information The name, logo, and brief description of a Mini Program constitutes its account's basic information, which shall accurately describe its features and content, help users easily understand it, and be consistent with users' expectations of its features and services. 2.2.1 The basic information of Mini Program accounts shall not contain politically sensitive issues, lewd content, gory violence, terror-related, offensive, disgusting, vulgar, inflammatory, defamatory content or in violation of local laws and regulations. 2.2.2 Basic information of Mini Program accounts: The name, logo and brief description of a Mini Program shall be interrelated to avoid user confusion over the range of features or services offered by this Mini Program. 2.2.3 The basic information of Mini Program accounts shall not contain commercial advertising dictions, names of popular Official Accounts or Mini Programs, popular app names, internet slang, piling up popular search terms, words that are not recognizable, or content that is not related to the function or content to counter the search and ranking system. 2.2.4 The basic information of Mini Program accounts shall not make unauthorized use of trademarks or brand logos to which third parties enjoy the legal rights to, or other content, information or special superscripts/subscripts similar to these trademarks or brand logos. Developers shall not infringe upon third parties' intellectual property rights or other legal rights. 2.2.5 The basic information of the Mini Program accounts shall not have attraction click and distribution related content, and shall not contain official website, invitation code, URL, telephone, address, social account and other related contact information of attraction behavior, interfering with the use of users. 2.2.6 The basic information of the Mini Program accounts: The name, logo, description and other specific audit standards refer to the [Mini Program Naming Audit Rules](audit-rules#2-naming-audit-rules), [Mini Program Icon Audit Rules](audit-rules#audit-rules#4-logo-audit-rules), [Mini Program Description Audit Rules](audit-rules#3-description-audit-rules). ### 2.3 Rules for Feature Settings 2.3.1 The services and content provided by a Mini Program shall conform to its brief description and no hidden services or content are allowed. 2.3.2 The core features of Mini Programs must be showcased on their homepages. 2.3.3 The Mini Programs provide users with basic feature guidelines, which shall incorporate descriptions of features or relevant screenshots thereof. 2.3.4 Developers shall not incorporate features identical or similar to those offered by the Binance app. 2.3.5 The access to any Mini Program features shall not be dependent on any other Mini Programs or apps. That is, the access to the features shall not be conditional upon the use of other Mini Programs or apps. Additionally, without the prior consent of or authorization from the platform, a Mini Program interface shall not display or recommend other Mini Programs or Official Accounts. 2.3.6 According to the local laws and regulations, and as required by mobile operating systems, app stores or the market, Mini Programs shall remind users when they access content or services that may not be appropriate for minors or remove the content or services in order to protect minors' physical and mental health as well as to safeguard their legal rights. ### 2.4 Rules for Entities 2.4.1 The development and operation of Mini Programs shall comply with local laws, regulations, and standards. The platform will reject any submission which is reasonably believed to be illegal or non-compliant. 2.4.2 The documents submitted by the developer must be genuine, legal, and valid. The platform will review the release of the Mini Program within the bounds of its authority and the applicable law. 2.4.3 Any Mini Program that can be reasonably believed to involve or assist in unlawful activities will be rejected. ## 3. Contents Rules ## 3.1 Rules for Page Contents 3.1.1 There can be no defamatory, discriminatory or malicious content, including references or comments about religion, race, sexual orientation, gender, nationality, ethnic origin or other target groups. 3.1.2 There can be no realistic depictions of humans or animals being killed, maimed, tortured, abused, or encouraging violence. In the game, "enemies" cannot be singled out against a specific race, culture, real government or corporation, or any other real entity. 3.1.3 There can be no descriptions that encourage the illegal use or irresponsible use of weapons and dangerous goods, or that promote the purchase of arms or ammunition. 3.1.4 There must not be material promoting pornographic or erotic content (i.e. material intended to arouse eroticism, explicit descriptions or displays of sexual organs or acts, and not related to aesthetics), or material suspected of promoting the dissemination of information on obscene or erotic content, including revealing images, provocative content, etc., or contents that facilitate prostitution. 3.1.5 Cannot contain inflammatory religious commentary or make false or misleading references to religious texts 3.1.6 The Mini Program must not have suspected of fraudulent user behavior or false advertising content, including false or impersonation type content 3.1.7 The Mini Program must provide meaningful contents ### 3.2 Rules for User-Generated Content 3.2.1 The service provider of Mini Programs shall not publish content on behalf of the user without the user's permission 3.2.2 The service provider of Mini Programs should set up mechanisms to filter pornographic, violent, offensive, discriminatory and other inappropriate information content, to ensure that user-generated content in line with the provisions of the information content 3.2.3 When there is a complaint about inappropriate content in the Mini Program, the service provider needs to provide a mechanism for timely response 3.2.4 The service provider of Mini Programs is responsible for the safety of the content, to ensure that the external display of content compliance, reliable, for other links that may generate content should also be strictly gate-keeping, to prevent the appearance of the above-mentioned violations. ### 3.3 Disallowed Mini Program Types Please refer to [Disallowed Mini Program Types](audit-rules#1-disallowed-mini-program-types) ### 3.4 Rules for Embedding Web Pages in Mini Programs 3.4.1 The Mini Program can only open the web page through the embedded web-view, and is not allowed to embed the web page directly on the homepage of the Mini Program as its primary content. 3.4.2 The services provided on the web pages embedded in the Mini Program shall match the category and tags you choose as well as the services that the Mini Program provides. 3.4.3 Developers shall not bypass or evade the Mini Program platform rules by use of embedded web pages in Mini Programs. 3.4.4 Developers should not use embedded web-views to provide games to users. 3.4.5 Once a developer is found in violation of this rule, the platform is entitled to restrict the features or disable the account of their Mini Program, and reserves the right to refuse to provide any services to the Mini Program entity. ## 4. Rules for Technology Implementation ### 4.1 Use of APIs 4.1.1 Non-public API programs shall not be used. 4.1.2 The platform reserves the right to reclaim the APIs if the API program is used under internal testing. 4.1.3 The developer may not use APIs for third-party apps in a manner that violates the inter-entity rule. 4.1.4 Mini Program Framework's codes, APIs, or tools shall not be sold, transferred, or licensed to others without Binance’s authorization. 4.1.5 Neither SDK nor its related components shall be modified, translated or reverse engineered, nor shall they be used to make derivative products. ### 4.2 OAuth Login 4.2.1 Users must log in to the Mini Program via Binance OAuth Login when an account system is used within the Mini Program. 4.2.2 If the user chooses to reject authorization, the developer may remind them again when the user shows the intention to grant the authorization. 4.2.3 A functional "Exit" option must be provided at a noticeable position. 4.2.4 After the user has rejected authorization, the developer is obligated to remove and stop using the user's email, phone number and other data. ### 4.3 Binance Pay 4.3.1 If a Mini Program processes payments, clear instructions shall be provided in the introduction of the Mini Program. 4.3.2 The user should receive a clear prompt on the screen before executing the payment action. 4.3.3 Payment via the Mini Program platform shall be made in compliance with applicable local laws and regulations. ### 4.4 Sharing Service Developers shall not abuse the sharing feature in the services offered by their Mini Programs. Examples are forcing users to share, and inducing users to share with incentives, either express or implied. ### 4.5 Message Service ( unreleased ) The Mini Program should not induce users in bad faith to trigger the operation that distributes templates to users, should not send maliciously harass users or distribute templates that may harass users, or distributes promotion templates for malicious marketing purposes. ## 5. Code of Conduct ### 5.1 Bypassing, circumventing or countering platform auditing and regulation The version of the Mini Program submitted for review and approval should be consistent with the version of the Mini Program actually published and operated online. Developers shall not bypass, circumvent or confront the audit and supervision rules of the Mini Program platform through technical or other means, including but not limited to: displaying content under different service categories for different user groups, or falsifying qualifications, or adopting false or imitation complaint portals or flashing and splash screens to intercept user complaints, and other malicious acts to bypass, circumvent or confront the audit and supervision of the platform. Penalties: - Once found, the mini program will be taken down or be blocked depending on the degree of violation. - If there is malicious publication of such content, all Mini Programs under the same developer account will be restricted in their functions until the platform refuses to provide services to the account any more, depending on the degree of violation. ### 5.2 Collection of users' private information 5.2.1 The developer shall acquire the consent of the user before collecting their information, and shall truthfully notify the user of the purpose and scope of use. 5.2.2 The illegal collection or theft of user passwords or other personal data is not permitted. 5.2.3 Access to devices including, but not limited to, the user's geolocation, photo albums, camera, etc. is not permitted without the user's authorisation. 5.2.4 Data related to the user should be removed from the Mini Program upon the user's request. 5.2.5 The developer must immediately delete all user data collected via Mini Programs if he / she stops using Mini Program Platform. 5.2.6 The developers are not authorized to disclose users' information, including their name, mobile number, email address, wallet address to any other Mini Program users or to any other third parties. 5.2.7 The developers are not authorized to use users' information, including their name, mobile number, email address, or wallet address, for any purposes that either they or the platform have not authorized. 5.2.8 The developers are not authorized to reverse lookup, track, link, mine, or obtain any user's name, mobile number, email address,wallet address, or other information to engage in acts unrelated to Mini Programs. 5.2.9 The developers are not authorized to copy, store, use, or transfer any user data without the user's expressed consent and without the truthful disclosure of applicable information such as how such data is used and the scope of its use. 5.2.10 Any data received via Mini Program Platform should be kept up to date and used to improve Mini Program user experience. 5.2.11 The developer may not add any Mini Program data into search engines or web directories, or add a search feature into the Mini Program without approval or authorization from the Binance. 5.2.12 The developer may not use any data received by Mini Programs to make any decisions regarding eligibility, including without limitation whether to approve or reject an application or how much interest to be charged on a loan without approval or authorization from Binance 5.2.13 Any data you have received via Mini Programs must only be used in your Mini Program in the event that the entity operating the Mini Program is acquired or merged by a third party. 5.2.14 Please take care of the developer's personal account, password and secret. 5.2.15 After collecting users' data, the Mini Program shall take necessary, reasonable and effective security protection measures to prevent any form of theft, leakage or disclosure of users' data. 5.2.16 If any form of theft, leakage or disclosure of user data occurs after the Mini Program has collected the user's data, it should immediately take lawful and effective measures to prevent the expansion of the damage results and report to the relevant authorities in accordance with the law. Penalties: - Once found, the Mini Program will be taken down. - If found again, the app will be taken down or be blocked depending on the degree of violation. - If there is malicious publication of such content, all Mini Programs under the same developer account will be restricted in their functions until the platform refuses to provide services to the account any more, depending on the degree of violation. ### 5.3 Malicious disruption of the platform 5.3.1 For personal or other reasons, maliciously posting undesirable information, insulting reviewers or attacking the platform in the context of the review, posting, email, community, etc. 5.3.2 The Mini Program has malicious non-revision and repeated submission of the same problematic content after being rejected for non-compliant content or non-conformity with the specification in audit sessions including but not limited to basic information, version iteration, traffic configuration, etc. Penalties: - Once found, the auditing will be rejected. And the Mini Program will be taken down, or banned. - If there is malicious publication of such content, all Mini Programs under the same developer account will be restricted in their functions until the platform refuses to provide services to the account any more, depending on the degree of violation. ### 5.4 Trading disputes Transaction disputes in the Mini Program should be dealt with promptly. Transaction dispute behaviour includes the inability to give the appropriate service or goods after payment by the user, the inability to apply for returns or other after-sales services, etc. Penalties: - Once found, the Mini Program will be required to complete the rectification within a certain period of time. - If found again, the app will be taken down or be blocked depending on the degree of violation. - If there is malicious publication of such content, all Mini Programs under the same developer account will be restricted in their functions until the platform refuses to provide services to the account any more, depending on the degree of violation. ### 5.5 Reciprocal promotions All the developers shall not recommend, promote, rank, incorporate an inter-program jump feature into, or add platform services to Mini Programs independently or together with any third parties by virtue of Binance’s services, nor help facilitate these actions. Penalties: - Once found, the Mini Program will be taken down. - If found again, the app will be taken down or be blocked depending on the degree of violation. - If there is malicious publication of such content, all Mini Programs under the same developer account will be restricted in their functions until the platform refuses to provide services to the account any more, depending on the degree of violation. ### 5.6 Fraud Fraud includes but is not limited to fake Red Packets, fake promotional campaigns, false advertising, as well as counterfeiting Binane’s or other entities' services. Penalties: - Once found, the Mini Program will be banned. - If there is malicious publication of such content, all Mini Programs under the same developer account will be restricted in their functions until the platform refuses to provide services to the account any more, depending on the degree of violation. ### 5.7 Deceptive Practices When using a Mini Program's information, such as name, icon, introduction, description, and features, that does not match its entity's information, you must avoid causing the following deception, misunderstanding, association, or influence to users. For example: 5.7.1 Deception related to Binance’s official features; 5.7.2 Deceiving users into believing that a Mini Program has been developed or is operated by certain government agencies, public institutions, and social organizations (regardless of whether such organizations exist or not). Penalties: - Once found, the Mini Program will be banned. - If there is malicious publication of such content, all Mini Programs under the same developer account will be restricted in their functions until the platform refuses to provide services to the account any more, depending on the degree of violation. ### 5.8 Abuse of API capability Mini Programs must use the various features, APIs, and capabilities provided by Binance in a lawful, compliant, proper, and good faith manner pursuant to the applicable Mini Program agreements and guidelines so as to protect the rights and interests of Binance users and other third parties. Developers may not help others or independently abuse, inappropriately use, or in bad faith use the above features, APIs, and capabilities, including without limitation, using an API, feature, or capacity to assist a third party in the violation of the applicable Mini Program agreements and guidelines. Penalties - Depending on the severity of the violation, the Mini Program's non-compliant template will be deleted, its API capability will be suspended, or its account will be banned. ### 5.9 No discretionary suspension or termination of operations If the Mini Program developer has to suspend or terminate the operation of the Mini Program under special circumstances, the developer must handle the aftercare work such as transactions in transit and unresolved disputes/complaints, and must not damage the legitimate rights and interests of users; and at the same time, display the suspension or termination announcement prominently on the home page of its Mini Program and notify the Mini Program Platform in advance before suspending or terminating the operation. If the developer arbitrarily suspends or terminates the operation of the Mini Program, resulting in complaints from users or causing losses to users, the corresponding responsibility will not be reduced or exempted due to the suspension or termination of the operation of the Mini Program. The platform will pursue the responsibility of the developer according to the severity of the circumstances. ### 5.10 Malicious traffic/transaction scraping Developers should make reasonable use of self-operating tools for Mini Programs based on their own service advantages, and guide users to continuously and repeatedly use their services or guide them to make objective evaluations through proper means, and should not maliciously brush transaction volume or traffic through improper methods. ### 5.11 Other violations of the platform operation rules The content of the Mini Program must also not contain information that violates the rules of the platform as follows. 5.11.1 Content that is primarily for marketing or advertising purposes (e.g. contains blank advertising space, investment advertisements, etc.), or appears directly as floating advertisements, or appears as false and exaggerated advertising information. 5.11.2 Rumour-based content that is misleading to users, seriously disrupts the user experience and harms the interests of users. 5.11.3 Content that violates any form of service agreement, platform agreement or function agreement signed with Binance. 5.11.4 Any content that violates the management, operation specifications and rules set by Binance for the relevant software, services and functions. 5.11.5 Any other content that involves violation of local laws or violation of relevant rules of the platform. ## 6. Rules for Availability and Completeness 6.1 The Mini Program submitted shall be a finished product, which can be opened and used, and shall not be a test version. 6.2 The Mini Program should not cause the Binance app to crash or the program itself to crash. 6.3 There should be no major bugs (such as inability to add, open, return to the previous pages and exit, and serious stutter) in the Mini Program. 6.4 Developers shall ensure the Mini Programs they release are stable and secure, and run smoothly. If the service provided to users is interrupted due to the Mini Program itself and cannot be restored within the platform’s required reasonable period of time, the platform is entitled to take action to maintain a good user experience, including, but not limited to, temporarily suspending the account. 6.5 If there are related accounts or paid content in the Mini Program, a test account, including account ID and password, shall be provided to Binance to ensure that the internal reviewer can experience all features. ## 7. Rules for Mini Program's UI 7.1 The UI should comply with Mini Program Design Specifications. 7.2 The UI should be in line with the Binance appearance and features, and should not provide a user experience that changes the appearance and features of Binance. 7.3 The ability to close the flyouts and pop-up windows in the Mini Program should be ensured. 7.4 The Mini Program UI shall not contain any elements that imitate system notifications or warnings to induce tapping. ## 8. Roles for User Service 8.1 The developer should establish convenient and effective user service and complaint channels for users, and provide effective dispute handling methods and contact information. User feedback flowing to the developer's platform should be handled in a timely manner, and complaints should be handled within 24 hours. 8.2 If there is too much feedback from users on the same day, some entrances will be dsiabled or taken down depending on the severity of the problem. 8.3 If the developer has formulated a user service agreement or terms and conditions with equivalent legal effect for the Mini Program, the relevant agreement and terms and conditions shall not be contrary to the Mini Program Platform Operation Rules and related documents, rules and specifications, otherwise the relevant agreement and terms and conditions shall be invalid and the platform shall have the right to handle disputes between the developer and the user in accordance with the platform specifications. ## 9. Local Law Compliance The developer shall comply with local laws, and respect local social norms throughout the course of use of Mini Program platform services. The developer shall be held solely liable if any of his / her actions are in violation of laws or social norms. Mini Program developers shall refrain from using this service in a way that would implicate Binance in political or public incidents. Otherwise, Binance is entitled to suspend or terminate your use of such service. ## 10. Disclaimer of Mini Program Platform Operation Rules Mini Program developers clearly understand and agree that Binance does not provide any kind of express or implied warranties or conditions regarding Mini Program services, including without limitation commercial and specific applicability. The use of Mini Programs shall be at the developer’s own risk. ## 11. Documentation Updates This is a document that will be regularly updated. We will revise and update it and set forth new rules based on new problems, applicable laws, or current product operation requirements to ensure Binance users' experience. Please check this document for updates and review it regularly to ensure that you know about the latest updates. --- ## Document: Mini Program Platform Merchant Enrollment URL: /zh-CN/docs/products/mini-program/merchant-enrollment # Mini Program Platform Merchant Enrollment # How to Become a Binance Marketplace Merchant? ## Stage 1 Assessment: Business Case Approval Reach out to the Binance Marketplace team (merchant@binance.com) to initiate the business assessment of your mini program. Please note that this assessment is a mandatory step prior to development. Upon successful assessment, you will need to sign a Binance Mini Program Agreement (contact Binance Marketplace team) and register for a Binance Mini Program [here](https://developers.binance.com/en/mpp/login) (ensure you are logged into your Binance corporate account). ## Stage 2 Assessment: Store Approval (SKUs, UI/UX, etc.) You may kickstart development once all steps above are completed and approved. If you start development before the business review, please be aware that this will be at your own risk and resource allocation. The testing and launch of your mini app are subject to Binance’s review and approval. Please note that Binance reserves the right to decline access to the Binance Marketplace services. ## Stage 3: Launch & Post-Launch Marketing --- ## Document: CLI URL: /zh-CN/docs/products/mini-program/cli # CLI This document is a comprehensive guide on how to utilize the bmp Command Line Interface (CLI). ## CLI Download Let's start by installing the CLI. ```bash # optional # Set the Binance npm registry (if not set already) # npm config set @binance:registry https://npm.binance.com # Install the CLI globally $ npm install -g @binance/mp-cli ``` ## CLI Usage Breeze through the following commands to get used to the bmp CLI: ### Creating a New Project ```bash $ bmp init [project-name] ``` Running the above command will conjure an initialized mini-program project brimming with potential! For instance: ```bash $ bmp init magnificent-mini-program ``` ### Adding Support to an Existing React Project ```bash # Navigate to the project root directory $ cd [path-to-desirable-project-root] # Run bmp bootstrap $ bmp bootstrap ``` The above commands spin off a `.bmp` directory and add essential configurations to the existing `tsconfig.json` file. This ensures support for importing @binance/\*, thereby enabling TypeScript syntax support. ### Kicking Off with devServer ```bash # Navigate to the project root directory $ cd [path-to-project-root] # Run bmp dev $ npx bmp dev ``` Introducing the command that compiles your project and spins up `devServer`, listening on `locahost:3000` by default. As you hop into the project and select the `dist` project, you will be greeted by your running mini-program. With `liveReload` enabled on `devServer`, any changes to your code will trigger an automatic rebuild and refreshes the page. ### Build and Compile ```bash # Navigate to the project root directory $ cd [path-to-project-root] # Run bmp build $ npx bmp build ``` Compiling the project code has never been easier! The above command renders mini-program files in the project directory. With [Binance Devtools](download), developers can smoothly upload these files to the management portal for release or swift online testing. --- ## Document: Mini Programs Audit Rules URL: /zh-CN/docs/products/mini-program/audit-rules # Mini Programs Audit Rules ## 1. Disallowed Mini Program Types - Advertising and promotion - Game aggregation platform - Information aggregation platform - Lending Information Intermediary - Spot/Futures Trading - Services for Enterprise - Services that conflict with the Binance business model ## 2. Naming Audit Rules ### 2.1 Rules for Naming Settings #### 2.1.1. Composition and Word Limit The name of a Mini Program should be between 3 and 30 characters long, and an unicode character is equal to 3 characters. The Mini Program should try its best to set the internationalization of the name. #### 2.1.2. Unique The name of the Mini Program should be unique. The Mini Program of different entities cannot have the same name. #### 2.1.3. Recognizable The name of the Mini Program must be relevant and recognizable to the description and the services provided in the Mini Program, and is not allowed to be duplicated, highly similar or confusing with the name of the Mini Program already online. The recommended name is a brand, trademark or a short word with recognizable characteristics. ### 2.2 Prohibitions and Restrictions #### 2.2.1. Name is too broad The name of the Mini Program shall not be too broad, thus causing confusion to users, and shall not be named directly or in combination with generic words without different attributes such as nouns, industry category words, product names, activity names, function words, local domain names, marketing words, etc. #### 2.2.2. Illegal or Unlawful Content 2.2.2.1 The name shall not involve pornography, violence and other illegal and unlawful content, shall not involve politics, shall not contain politically sensitive, pornographic, violent and bloody, terrorist content, racial discrimination or content contrary to local laws. 2.2.2.2 Shall not involve intellectual property infringement: in the absence of trademark or brand authorization, the name shall not infringe upon the legitimate intellectual property rights of others, and shall not use without authorization the trademarks, brand logos and other content of third parties enjoying legitimate rights and interests or content, information or special corner markings similar to them. 2.2.2.3 Shall not infringe on the legitimate rights and interests of others: shall not infringe on the legitimate rights and interests of others such as privacy, reputation, portrait and name rights. #### 2.2.3. Inconsistent with the Main Business Content If the name points to specific categories/categories and other industry information, the service content in the Mini Program must contain the category/category content corresponding to the name. #### 2.2.4. Deception related to Binance’s official For non-official accounts, it is forbidden to have the same content in the account name as the existing intellectual property content of Binance, and other content that is easily confused with the theme and appearance of the existing Binance product design. ## 3. Description Audit Rules 3.1 The description length of the Mini Program is between 100-300 characters, the Tagline length is within 60 characters, and an unicode character is equal to 3 characters. The Mini Program should try to complete the internationalization setting of the description. 3.2 The core function points of the Mini Program must be introduced accurately, no false introduction, no description with too broad content, ambiguous semantics, or garbled code without actual semantics and no relevance to the Mini Program. 3.3 Avoid the complete repetition or basic repetition of the name of the Mini Program, and introduce the core function points of the Mini Program to users as precisely as possible, so that users can understand it quickly and intuitively. 3.4 There’s no politically sensitive, pornographic, violent and bloody, terrorist content and other illegal content prohibited by local laws and regulations. It is not allowed to violate the privacy, reputation, portrait rights, intellectual property rights, trade secrets and other legal rights of others. 3.5 There’s no content in the description to be identical or similar to the existing intellectual property content of Binance, or confusing with the theme and appearance of existing Binance products. 3.6 There’s no information that leads users to download or to join other platforms (including but not limited to links to induce download of APP, information of other platform accounts, etc.). ## 4. Logo Audit Rules ### 4.1 Rules for the Developer Logo 4.1.1 The developer logo should be clear, with 144\*144 pixels, and the text and graphics inside the logo should be clearly visible and not cropped by the circular container. 4.1.2 The developer logo is not allowed to involve pornography, violence and other illegal and illegal contents, and is not allowed to involve politics. 4.1.3 The developer logo is not allowed to violate the privacy, reputation, portrait rights, intellectual property rights, trade secrets and other legal rights of others. 4.1.4 The developer logo is not allowed to be duplicated or confused with existing accounts (suspected of infringement). 4.1.5 The developer's logo is not allowed to contain advertising information that is not related to the account's operational content. 4.1.6 The developer logo is not allowed to contain QR code of any platform. 4.1.7 The developer logo is not allowed to contain information that leads users to download or join other platforms (including but not limited to links to induce download of APP, information of other platform accounts, etc.). 4.1.8 The developer's logo is not allowed to contain words that are identical or similar to the content of the existing intellectual property rights of Binance, or content that is easily confused with the theme and appearance of the existing Binance product design. ### 4.2 Rules for Mini Program icon 4.2.1 The Mini Program icon should be clear, with 96x96 pixels and the core logo graphic recommended to be around 72x72. The text and graphics inside the logo should be clearly visible and not cropped by the circular container. 4.2.2 Do not use QR code as a Mini Program icon. If you use a portrait as a Mini Program icon, please make sure you have got authorization from the portrait right holder. 4.2.3 The Mini Program icons are not allowed to have prohibited, vulgar or offensive characters and patterns, and cannot have political tendency or political color. 4.2.4 The Mini Program icons cannot use intellectual property rights such as trademarks that have been registered or have legal rights by others. 4.2.5 No red dots, NEW, HOT, or logos imitating the Label of the Mini Program are allowed to appear on the Mini Program icons. 4.2.5 The Mini Program icon is not allowed to contain words that are identical or similar to the content of the existing intellectual property rights of Binance, or content that is easily confused with the theme and appearance of the existing Binance product design. ## 5. Content Audit Rules ### 5.1 Rules for Page Contents 5.1.1 There can be no defamatory, discriminatory or malicious content, including references or comments about religion, race, sexual orientation, gender, nationality, ethnic origin or other target groups. 5.1.2 There can be no realistic depictions of humans or animals being killed, maimed, tortured, abused, or encouraging violence. In the game, "enemies" cannot be singled out against a specific race, culture, real government or corporation, or any other real entity. 5.1.3 There can be no descriptions that encourage the illegal use or irresponsible use of weapons and dangerous goods, or that promote the purchase of arms or ammunition. 5.1.4 There must not be material promoting pornographic or erotic content (i.e. material intended to arouse eroticism, explicit descriptions or displays of sexual organs or acts, and not related to aesthetics), or material suspected of promoting the dissemination of information on obscene or erotic content, including revealing images, provocative content, etc., or contents that facilitate prostitution. 5.1.5 Cannot contain inflammatory religious commentary or make false or misleading references to religious texts 5.1.6 The Mini Program must not have suspected of fraudulent user behavior or false advertising content, including false or impersonation type content 5.1.7 There must not be any content on the page of the Mini Program that misleadingly and incorrectly implies that there is any cooperation, investment or endorsement relationship between Binance and the Mini Program, such as misleadingly and incorrectly implying that Binance is the operator of the Mini Program, or misleadingly and incorrectly implying that Binance endorses its quality, service or cooperation with it in any form when the Mini Program is not in fact operated by Binance. ### 5.2 User Privacy and Data Security 5.2.1 When collecting and using any user data, the user must be clearly informed of the purpose of the data, ensure that it is explicitly agreed and authorized by the user, and should make reasonable use within the scope of the user's agreement and authorization. The relevant data shall be deleted after the user cancels the account. 5.2.2 The Mini Program must obtain the user's explicit consent and authorization before publishing, sending or forwarding any content instead of the user. 5.2.3 The Mini Program should request users to enter Binance username or password on any pages. 5.2.4 The Mini Program should not display users’ related data, such as: avatar, nickname and other information without their authorized consent. 5.2.5 The Mini Program cannot directly pop up the authorization page when users enter the first screen. 5.2.6 The Mini Program is not allowed to force authorization; the service is still available after the user cancels authorization. 5.2.7 The Mini Program should not request for users’ authorization on multiple pages and for the multiple categories. ### 5.3 Sensitive Content Filtering 5.3.1 There’s no irrelevant, or sensitive or offensive content in the dynamic content such as search boxes and search results. 5.3.2 The Mini Program which contains an user-definable input, needs to have a sensitive content filtering mechanism 5.3.3 The Mini Program which contains an user-definable image uploading, needs to have a sensitive image filtering mechanism ## 6. Quality and Audit ### 6.1 Rules for Functional audit #### 6.1.1 Page Display 6.1.1.1 There’s no sensitive and illegal information in the titles, context and images. 6.1.1.2 There’s no abnormal size, distortion or blurring images on the page. 6.1.1.3 When there is no image or loading failure, there must be a default image as the placeholder. 6.1.1.4 There’s no text and links that lead users to download third party apps. 6.1.1.5 There’s no no blank pages. 6.1.1.6 Sensitive information must be desensitized for display (ID, phone, email, etc.). 6.1.1.7 The customer service email must be accessible. 6.1.1.8 The embedded web page must be adapted according to the mobile layout. 6.1.1.9 The title of the page must be relevant to the current operation. #### 6.1.2 Pop-ups 6.1.2.1 The pop-up must have a close button, and the user must not be forced to click on the pop-up to enter the next step. 6.1.2.2 The pop-up cannot be cycled after the user closes it, and the user must be able to continue using the normal service after closing the pop-up with a button. 6.1.2.3 The pop-up cannot overlap/repeat, and the same pop-up cannot be popped up repeatedly on different pages within the Mini Program. 6.1.2.4 The Developer cannot display exaggerated content on the pop-up to coerce users to click. #### 6.1.3 Reliability The Mini Program should give the user a corresponding prompt in case of network abnormality, loading timeout, system error, etc., and no other errors such as crashes. #### 6.1.4 API The Mini Program should ensure that each API call is functionally correct, including Binance Pay, Binance OAuth Login, etc. #### 6.1.5 Categories 6.1.5.1 The Mini Program category is consistent with the content provided on the page. 6.1.5.2 The core content in the Mini Program page must be consistent with the category selected for that Mini Program. 6.1.5.3 The user can use the service category on the page. The service must not hide it or need multiple navigation. 6.1.5.4 The core functions provided by the Mini Program must be displayed on the home page. #### 6.1.6 Accounts 6.1.6.1 If the Mini Program has an account system, it must provide an "logout" option for users. 6.1.6.2 If the main process involves test account login, test environment configuration, the developer needs to provide the test account and test information when submitting the audit, and if there is a test report, please provide the test report at the same time. ### 6.2 Rules for Performance Audit #### 6.2.1 Runtime The Mini Program does not crash, and does not cause Binance APP to crash. There’s no javascript exceptions or business logic errors. #### 6.2.2 Interaction 6.2.2.1 The Mini Program should not spend too long time to load pages, or to respond to user actions. The Mini Program should work properly when both in the weak network ( 2G, 3G ) and good network ( LTE, wifi ). 6.2.2.2 If the page fails to load, a page prompt is required with the ability to let users retry. 6.2.2.3 If the page takes a long time to load, a loading hint is required. #### 6.2.3 Resources 6.2.3.1 The Mini Program should not load too many resources. 6.2.3.2 The Mini Program should not have too many requests when loading the pages. 6.2.3.3 No continuous, heavy CPU-consuming threads. ### 6.3 Compatibility Model Recommendations Android covers 5.x and higher iOS covers 9.x or higher ## 7. Documentation Updates This is a document that will be regularly updated. We will revise and update it and set forth new rules based on new problems, applicable laws, or current product operation requirements to ensure Binance users' experience. Please check this document for updates and review it regularly to ensure that you know about the latest updates. --- ## Document: Announcement URL: /zh-CN/docs/products/mini-program/announcement # Announcement ## Mini Program Crucial Update ### Notice: Termination of Support for JS SDK <4.0 > Announcement Date: November 21, 2022 We hereby announce the cessation of support for JS SDK <4.0. Immediate action necessary: Upgrade your JS SDK to ^4.x or later versions and confirm that your Mini Program functions seamlessly with the most recent version of Native with SDK ^4.x. For any assistance required, our team is readily available. #### End Of Life (EOL) Notice Our Mini Program hereby discontinues its support for the following JS SDK versions marking their End of Life (EOL): | Most Recent Supported Native Version | Correlated JS SDK Version | EOL Status | | ------------------------------------ | ------------------------- | -------------------- | | 2.35 | JS SDK ^1.x | Ended on 2021-09-09 | | 2.46 | JS SDK ^2.x | Ended on 2022-05-19 | | 2.58 | JS SDK ^3.x | Ending on 2022-12-22 | | | JS SDK ^4.x | Continues LTS ⭐️ | #### Key Notes on Breaking Changes ##### Deprecation of Template Tags ` ``` ### 3. Add mapping of pages and skeletons in `config.json` ```json { "pages/index/index": "skeleton/page/index", "pages/list/list": "skeleton/page/index" } ``` ### 4. After page ready, using `this.removeSkeleton()` remove skeleton ```js { onLoad() { // request data getData().then((pageData) => { this.setData({ pageData }, () => { this.removeSkeleton && this.removeSkeleton(); }); }); } } ``` You can find removeSkeleton on page instance too ```js const pages = globalThis.getCurrentPages(); const current = pages[pages.length - 1]; current.removeSkeleton && current.removeSkeleton(); ``` --- ## Document: Scene Value URL: /zh-CN/docs/products/mini-program/framework/scene-value # Scene Value > Beginning with SDK library version 1.2.0 The scene value describes a path in which a user enters a Mini Program. You can refer to the Scene Value List for a detailed definition of the scene value. ## Retrieve the scene value Developers have the ability to obtain the scene value using `onLaunch` and `onShow` in the App or through the `bn.getLaunchOptions` method. ## Scene Value List | Scene Value ID | Description | | -------------- | --------------------------------- | | 1000 | others | | 1001 | second floor | | 1002 | second floor - recent used | | 1003 | main entrance - home | | 1004 | main entrance - more | | 1005 | second floor - search | | 1009 | banner | | 1010 | favirote | | 1011 | qrcode | | 1014 | push notification | | 1027 | second floor - search - used apps | | 1037 | open by mini program app | | 1038 | return from mini program app | | 1054 | search, quick entrance | | 1300 | short link | | 1301 | webview bridge | | 1135 | related apps in the about page | | 1103 | Lite mode home page | --- ## Document: Router URL: /zh-CN/docs/products/mini-program/framework/router # Router ## Routing API In a mini-program, default routing features are presented and don't necessitate any further configuration by the developer. You just need to declare the pages in the configuration of the entrance file, then you can jump to the destination page by utilizing the API provided by the mini-program. For example: ```javascript // Navigate to the destination page and open a new page bn.navigateTo({ url: "/pages/page/path/name", }); ``` ```javascript // Navigate to the destination page and open it on the current page bn.redirectTo({ url: "/pages/page/path/name", }); ``` For a detailed description of the API, please refer to the [API](api) documentation. ## Route Passing You can redirect by appending a query string parameter after all the jumped URLs. For example: ```javascript // Pass in the parameters id=2&type=test bn.navigateTo({ url: "/pages/page/path/name?id=2&type=test", }); ``` In this case, the passed parameters will be available in the lifecycle method of the target page once the jump is successful. This can be accessed through `getCurrentInstance().router.params`. For the above navigation action, in the `onShow()` lifecycle of the target page: ```javascript Page({ onShow() { console.log(getCurrentInstance().router.params); // output { id: 2, type: 'test' } }, }); ``` ## EventChannel When calling `navigateTo`, we can use `EventChannel` to facilitate communication between the opener page and the opened page. For instance: ```javascript // Page A bn.navigateTo({ url: "/pages/page/path/B", events: { // Add listeners to receive data from the opened page acceptDataFromOpenedPage: function (data) { console.log(data); }, someEvent: function (data) { console.log(data); }, }, }).then((res) => { // Send data to the opened page res.eventChannel.emit("acceptDataFromOpenerPage", { data: "I am the opener page" }); }); ``` ```javascript // Page B Page({ onShow() { const eventChannel = getCurrentInstance().page.getOpenerEventChannel(); // Send data to the opener page eventChannel.emit("acceptDataFromOpenedPage", { data: "I am the opened page" }); eventChannel.emit("someEvent", { data: "test" }); // Add listener to receive data from the opener page eventChannel.on("acceptDataFromOpenerPage", function (data) { console.log(data); }); }, }); ``` --- ## Document: Initial Rendering Cache URL: /zh-CN/docs/products/mini-program/framework/rendering-cache # Initial Rendering Cache ### How Initial Rendering Cache Works The initialization of a mini-program page is divided into two parts: 1. Logic layer initialization: Load essential mini-program code, initialize the page `this` object (which includes all `this` objects related to custom components), and then send relevant data to the view layer. 2. View layer initialization: Load essential mini-program code, then wait for the logic layer to be initialized and receive the data sent by the logic layer, and finally render the page. During the startup of the page, especially during the cold startup of the mini-program and when entering the first page, the logic layer initialization time is relatively long. During the page initialization process, users will see the standard loading screen of the mini-program (during the cold start) or may experience slight flashes of white screen (during the page jump process). When the initial rendering cache is enabled, the view layer does not need to wait for the logic layer to be initialized, it can directly display the rendering result of the initial page `data` to the users in advance, which greatly advances the time when the page is visible to the users. Its working principle is as follows: 1. After a mini-program page is opened for the first time, the rendering result of the initial data of the page is recorded and written to a persistent cache area (the cache can be retained for a long time, but it may be cleared due to mini-program updates, basic library updates, storage space recycling, and other reasons). 2. When this page is opened for the second time, check whether there is still the rendering result of the last initial data of this page in the cache. If there is, it will directly display the rendering result. 3. If the rendering result in the cache is displayed, this page cannot temporarily respond to user events, and can only respond to user events after the logic layer is initialized. Using the initial rendering cache, you can: - Quickly display parts of the page that will never change, such as the navigation bar. - Display a skeleton page in advance to enhance the user experience. - Display custom loading tips. - Display advertisements in advance, and so on. ### Static Initial Rendering Cache The easiest way to enable initial rendering cache is to add the configuration item `"initialRenderingCache": "static"` in the page's json file: ```json { "initialRenderingCache": "static" } ``` After adding this configuration item, preview the mini-program homepage on your phone, then kill the mini-program and re-enter it, the homepage will be rendered by the initial rendering cache. Note: In this case, the initial rendering cache records the result of applying `data` to `BXML` on the page and does not include the result of any `setData` (For tarojs, it will records the result of first setData). For example, if you want to display the words "loading" on the page, these words are controlled by the `loading` data field: ```html Loading ``` In this case, `loading` should be specified in `data` as true: ```javascript // Correct way Page({ data: { loading: true, }, }); ``` And not through `setData` to set `loading` as true: ```javascript // Incorrect way! Don't do this! Page({ data: {}, onLoad: function () { this.setData({ loading: true, }); }, }); ``` ### Adding Dynamic Content to the Initial Rendering Cache In some cases, the rendering result of just the page data might be somewhat limited. Sometimes, you may want to display additional variable content, such as some advertisement. In such cases, you can use the "dynamic" initial rendering cache. Firstly, you need to configure `"initialRenderingCache": "dynamic"`: ```json { "initialRenderingCache": "dynamic" } ``` At this point, the initial rendering cache will not be automatically enabled. You still need to call `this.setInitialRenderingCache(dynamicData)` in the page to enable it. Here, `dynamicData` is a set of data, which participates in rendering the page's WXML along with `data`. ```javascript Page({ data: { loading: true }, onReady: function() { this.({ loadingHint: 'Loading' }, function() { this.setInitialRenderingCache() }) } }) ``` ```html {{loadingHint}} ``` In principle, under the approach of dynamically generating initial rendering cache, the page is re-rendered in the background using dynamic data, which can be relatively demanding in terms of resources. Therefore, it's best to avoid frequently calling `this.setInitialRenderingCache`. If you call it multiple times within a single page, only the last call will take effect. Please note: - You should not call `this.setInitialRenderingCache` earlier than the `onReady` lifecycle of Page or the `ready` lifecycle of Component as it may negatively impact performance. - If you want to disable the initial rendering cache, you can call `this.clearInitialRenderingCache()`. --- ## Document: Project Configuration File URL: /zh-CN/docs/products/mini-program/framework/project-configuration # Project Configuration File You can configure your project using the `project.config.json` file found in the project's root directory. ### Configuration Options | Property | Type | Default Value | Required | Description | | --------------- | -------- | ------------- | -------- | --------------------------------------------------------------------- | | miniprogramRoot | `String` | - | Yes | Sets the directory (a relative path) for the Mini Program source code | | packOptions | `Object` | - | No | Sets the packaging configuration options | ### Packaging Options (packOptions) `packOptions` helps manage the settings for project packaging. Packaging is an essential step for previewing and uploading projects. Using `packOptions.ignore` field, you can define filter rules. Files or folders that satisfy these rules will be discarded during project packaging. They will not appear in the preview or the upload outcomes. `packOptions.ignore` is an array of objects, each containing: | Property | Type | Default Value | Required | Description | | -------- | -------- | ------------- | Yes | ------------- | | value | `String` | - | Yes | Path or value | | type | `String` | - | Yes | Type | Possible type values are `folder`, `file`, `suffix`, `prefix`, `regexp`, and `glob`, representing folders, files, suffixes, prefixes, regular expressions, and Glob rules. Value comparison is case-insensitive. > Note: If the value of the value field designates a file or a folder path, the root directory is > the Mini Program directory (`miniprogramRoot`). Here's a sample configuration: ```json // project.config.json { "miniprogramRoot": "./dist", "packOptions": { "ignore": [ { "type": "file", "value": "utils.bxs" }, { "type": "folder", "value": "image" }, { "type": "suffix", "value": ".LICENSE.txt" }, { "type": "suffix", "value": ".css" }, { "type": "prefix", "value": "rich-" }, { "type": "glob", "value": "pages/API/**/*.js" }, { "type": "regexp", "value": "index\\.js$" } ] } // ... } ``` --- ## Document: Overview URL: /zh-CN/docs/products/mini-program/framework/overview # Overview ## File Architecture A mini program consists of two layers: the app and the page. The app layer describes the complete application, whereas the page layer delineates individual pages. Also, there is an optional configuration detailing the entire project. The core of a Mini Program is built on three files, which must be located in the project's root directory: | File | Required | Purpose | | -------- | -------- | --------------------------------------------------- | | app.js | yes | Houses Mini Program logic | | app.json | yes | Contains common Mini Program settings | | app.bxss | no | Serves as a common style sheet for the Mini Program | A page consists of 4 files, all of which must share a filename and be placed in the same folder. | File Type | Required | Purpose | | --------- | -------- | ------------------------ | | js | yes | Defines page logic | | bxml | Yes | Describes page structure | | json | No | Configures the page | | bxss | No | Styles the page | Below is the typical structure of a project's directory: ``` . └── src/ ├─ app.js ├── app.json ├── app.bxss └── pages/ └── detail/ ├── index.js ├── index.bxml ├── index.bxss └── index.json ``` ## Code Architecture The Mini Program framework includes two key components: the Logic Layer (App Service) and the View Layer (View). A Mini Program is equipped with its own view layer languages, BXML and BXSS, and a logic layer framework based on JavaScript. Additionally, there is a system for data transfer and event coordination between the two layers, which allows developers to concentrate on data and logic. ### Reactive Data Binding The reactive data binding system formulates the core of the framework. It offers a remarkably simple means to ensure data and view synchronization. Modifying the data requires a simple alteration on the logic layer, after which it will get updated on the view layer. Here's a simple illustration: Run a Preview with the Developer Tool ```html Hello {{name}}! ``` ```javascript // This is our data. var helloData = { name: "Binance", }; // Registration of a Page. Page({ data: helloData, changeName: function (e) { // Data change sent to the view this.setData({ name: "World", }); }, }); ``` This example demonstrates how developers can use the framework to bind the 'name' in the logic layer data to 'name' in the view layer. This ensures that 'Hello Binance!' appears when the page opens. Upon clicking the button, the view layer sends 'changeName' events to the logic layer, which identifies and executes the corresponding event handler. After triggering the callback function, the logic layer executes setData to change the name in data from 'Binance' to 'World'. As this data is bound to the view layer, 'Hello World!' automatically applies to the view layer. Note: Since the framework does not run in the browser, certain JavaScript capabilities in the web are not available, such as 'document', 'window', etc. ## Style File The style file has additional features and includes a new size unit called 'rpx'. ### Style Size Unit rpx (responsive pixel) is an adaptive size unit that adjusts according to screen width. As per standard, the screen's width is set to 750rpx. For instance, on an iPhone6, the screen's width is 375px with 750 physical pixels, therefore 750rpx = 375px = 750 physical pixels, and 1rpx = 0.5px = 1 physical pixel. | Device | rpx to px (screen's width/750) | px to rpx (750/screen's width) | | ------------ | ------------------------------ | ------------------------------ | | iPhone5 | 1rpx = 0.42px | 1px = 2.34rpx | | iPhone6 | 1rpx = 0.5px | 1px = 2rpx | | iPhone6 Plus | 1rpx = 0.552px | 1px = 1.81rpx | Suggestion: For the development of Binance Mini Programme, iPhone6 specifications could serve as a standard reference for designers. Attention: One should be aware that specific inevitable limitations may arise on exceedingly small screens. As far as possible, please endeavor to avoid such scenarios. ### Style Import By using the @import statement, external stylesheets can be incorporated. Following the @import statement, the relative path of the external stylesheet has to be mentioned and the line must conclude with a semicolon (;). Example code: ```css /** common.bxss **/ .small-p { padding: 5px; } ``` ```css /** app.bxss **/ @import "common.bxss"; .middle-p { padding: 15px; } ``` ## Incorporating Third-party NPM Modules Mini programs support the integration of third-party modules. Install the necessary module by executing the following command in the project's root directory. ```bash $ npm install i18n --save ``` Note: Please bear in mind that the third-party module's browser-related web capabilities, such as DOM operations or window.location, are unavailable. --- ## Document: Lifecycle URL: /zh-CN/docs/products/mini-program/framework/lifecycle # Lifecycle Developing Mini Programs with React comes with a few differences compared to using React on the web. ## The Entry Component You have to register each mini program. You can do this by calling the App method in the file named 'app.js'. This will let the Mini Program use specific functions. These functions include: tracking the lifecycle, listening for any errors, and detecting when a page cannot be found. ```javascript //app.js App({ onLaunch(options) { // Do something initial when launch. }, onShow(options) { // Do something when show. }, onHide() { // Do something when hide. }, onError(msg) { console.log(msg); }, globalData: "I am global data", }); ``` A Mini Program has only one app instance, which is shared to all pages. Developers can obtain the globally unique app instance by using the getApp method, and then obtain data in the app or call a function registered with App by the developers. ```javascript // xxx.js const appInstance = getApp(); console.log(appInstance.globalData); // I am global data ``` ## Entry Configuration We can create a new file called 'app.json' for overall settings. The way we set up this file is based on the mini program's global configuration. ```javascript // app.json { pages: ['pages/index/index'], window: { backgroundTextStyle: 'light', navigationBarBackgroundColor: '#fff', navigationBarTitleText: 'Title', navigationBarTextStyle: 'black', }, } ``` ### onLaunch () It starts when the app launches. ### onShow () It starts when the app launches, or when it goes from the background to the front. ### onHide () It starts when the app goes from the front to the background. ### onError(err) Listens for when the Mini Program has errors. For example, these errors can be from a broken script or a problem with a function call. The 'err' is what the error is. ## Page For every page in a Mini Program, we need to register a page instance. We do this by calling the Page method in the js file that matches the page. This lets us set the page's initial data, life cycle tracking function, and event handling function. ```javascript // index.js Page({ data: { text: "This is page data.", }, onLoad: function (options) { // Do some initialize when page load. }, onReady: function () { // Do something when page ready. }, onShow: function () { // Do something when page show. }, onHide: function () { // Do something when page hide. }, onUnload: function () { // Do something when page close. }, onPullDownRefresh: function () { // Do something when pull down. }, onReachBottom: function () { // Do something when page reach bottom. }, onShareAppMessage: function () { // return custom share data when user share. }, onPageScroll: function () { // Do something when page scroll }, onTabItemTap(item) { console.log(item.index); console.log(item.pagePath); console.log(item.text); }, // Event handler. viewTap: function () { this.setData( { text: "Set some data for updating view.", }, function () { // this is setData callback }, ); }, }); ``` ### onTabItemTap This happens every time a tab item is tapped. #### Parameters ##### Object | Property | Type | Description | | -------- | ------ | ------------------------------------------- | | index | String | the position of the tab item, starting at 0 | | pagePath | String | the location of the tab item | | text | String | the written content of the tab item | ## Page Configuration For every page file (like. /pages/index/index.js), we can make a new . /pages/index/index.json file for configuring the page. ```json // file: pages/index/index.json { "navigationBarTitleText": "Home" } ``` ### onLoad (options) During this lifecycle, page navigation parameters can be obtained by calling `getCurrentInstance().router`. ### onReady () At this point in the lifecycle, the Mini Program has already transferred the DOM nodes to the rendering layer using APIs. ### onShow () This is triggered when the page is displayed or brought to the front. ### onHide () This is triggered when the page is hidden or moved to the background. ### onErr(err) This listens for Mini Program errors such as a script error or API Calls. ### onPageScroll() This listens for the user scrolling the page. **Parameter Object object:** | Property | Type | Description | | --------- | ------ | ------------------------------------------------- | | scrollTop | Number | Scroll distance in the vertical direction (in px) | **Note: Defining this method in a page should only be done when necessary to reduce potential performance impacts. Also, be cautious of repeated executions in onPageScroll, it could increase communication time.** _Example of a child component in a page_ ```js Page({ onPageScroll({ scrollTop }) { console.log("onPageScroll", scrollTop); }, }); ``` ### onReachBottom() This listens for the user scrolling to the bottom of the page. - You can set the trigger distance `onReachBottomDistance` in the `app.json` window option or in the Page Configuration. - This event only triggers once when the page scrolls within the trigger distance. _Example of a child component in a page_ ```js Page({ onReachBottom() { console.log("onPageReachBottom"); }, }); ``` ### onShareAppMessage(Object) Listen to user-initiated share actions, such as clicking on the in-page share button `open-type="share"`, the top-right menu "Share", or executing `bn.showSharePanel`, and customize the shared content. #### Parameters ##### Object | Property | Type | Description | | -------- | ------ | ----------------------------------------------------------------------------------------------------------------------- | | from | String | Share event source: `button`: in-page share button, `menu`: top-right retweet menu, `code`: Execute `bn.showSharePanel` | | target | String | If `from` value is `button`, then `target` is the triggered share `button`, otherwise `undefined` | This event handler requires a return of an Object or Promise to customize the shared content: | field | Type | Description | Default value | | :------- | :------- | :------------------------------------------------------------------------------- | :------------------------ | | title | String | Share title | Current Mini Program name | | desc | String | Description | | | imageUrl | String | Custom image path, should be a network image path. Supports PNG and JPG formats. | Uses default screenshot | | path | Function | Share path. Must be a full path starting with / | Current page path | | success | Function | Callback function when the user forwards on | | ```javascript Page({ onShareAppMessage(...args) { console.log('onShareAppMessage', args) return Promise.resolve({ title: 'my title', desc: 'mydesc', imageUrl: 'https://public.bnbstatic.com/static/images/common/ogImage.jpg', path: 'pages/extended/pages/share/share?p=1', success: res => console.log('shareResult', res.shareResult)), } }) }) ``` --- ## Document: FAQ URL: /zh-CN/docs/products/mini-program/framework/faq # FAQ ## `getCurrentInstance` query is incorrect When you are using `tarojs` to develop your mini program, sometimes query is incorrect with the api `getCurrentInstance`. Make sure the getCurrentInstance is inside the useDidShow hook ```ts useDidShow(() => { const query = getCurrentInstance().router.params; }); ``` --- ## Document: Extended URL: /zh-CN/docs/products/mini-program/framework/extended # Extended ## Navigators ### Navigation Navigation is the navigator component on top of the Mini Program. Using `navigationStyle: custom`, you can replace the default navigation with a custom component. ```json // page.json { "navigationStyle": "custom" } ``` With this configuration, the default navigation bar on the current page will be removed. You will need to implement a component on your own page to replace it. #### Custom Navigation Bar Example ```json //custom-navigation-bar.json { "navigationStyle": "custom" } ``` ```html {title} ``` ```javascript Page({ data: { title: "Hello world", }, }); ``` ```scss // custom-navigation-bar.bxss .cnb-container { position: relative; padding: 0 10px; height: var(--mp-navigator-height); display: flex; align-items: center; justify-content: space-between; background-color: #000000; color: white; } .custom-nav-bar { position: absolute; left: 95px; right: 95px; height: 100%; display: flex; align-items: center; justify-content: center; top: 0; display: flex; align-items: center; box-sizing: border-box; } ``` ### Tabbar - Bxml Configure `tabBar.custom: true` in `app.json` ```ts "tabBar": { "custom": true } ``` Add `custom-tab-bar` in root directory ```bash custom-tab-bar ├── index.bxml ├── index.bxss ├── index.js └── index.json ``` You will need to implement a `custom tab bar` yourself ### Disable Bounces Set `disableBounces: true` in your `{page}.json`. This prevents the page from sliding out of the screen area (only IOS) ```js export default { disableBounces: true, }; ``` --- ## Document: Download Stable Version URL: /zh-CN/docs/products/mini-program/framework/download-stable # Download Stable Version ## [5.11.0] 2026-04-02 **Download: [5.11.0(2.76 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.11.0.zip)** ### Bug Fixes - Fix/mp renderjs missing - fix(sdk): add backward compatibility for ViewPager2 in SwiperView - Fix/native cli preview UI layout - Fix/type 0331 - fix(cli): bundle native-cli resources and resolve adb - fix: showErrorPage for 600402 page_not_found error - fix(sdk): mcp bin - fix(lib): fix ide cli toolbar sync api - fix(cli): ide cli node version match ### Features - feat(sdk): add QJS bytecode compilation for renderer-service-hummer - feat(sdk): support virtual appid for widget - feat(sdk): add useNewWindow parameter to previewImage API - feat(cli): native-cli & ide-cli-mcp-server recover capabilities improve - Feat/ios orba - feat(cli): mcp tool stability improve - feat(sdk): screen cast - feat(cli): ide cli mcp server sync - feat(cli): add mobile screen viewer and simulator host capture ## [5.10.0] 2026-03-12 **Download: [5.10.0(2.21 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.10.0.zip)** ### Bug Fixes - fix(sdk): fix video props type - fix(native-cli): prevent host hang on Ctrl+C ### Features - feat(cli): native cli mcp adjust - feat(native-cli): add sync mp status mcp tool - feat(sdk): support root portal to specific element - Feat/hummer lcp - feat(cli): sub mode default render path - feat(cli): native cli UI bridge - feat(cli): orba desktop mp side work - feat(cli): make get_log_files as example - feat(cli): native cli UI dev env - feat(cli): init native-cli project ## [5.9.1] 2026-02-27 **Download: [5.9.1(2.21 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.9.1.zip)** ### Bug Fixes - fix(sdk): renderer may never ready when route quickly ## [5.9.0] 2026-02-19 **Download: [5.9.0(2.21 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.9.0.zip)** ### Bug Fixes - fix(sdk): swiper autoheight child item ### Features - Feat/hummer swiper - Feat/hummer event - feat(cli): use custom ios runtime version - feat(cli): ios simulator support - feat(bundler): show error page when load module error ### Misc - Revert " fix(sdk): sortable items when height changes " (#2522) (#2541) ## [5.8.5] 2026-02-09 **Download: [5.8.5(2.21 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.8.5.zip)** ### Bug Fixes - fix(sdk): dom update lead layout size abnormal ## [5.8.4] 2026-02-09 **Download: [5.8.4(2.21 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.8.4.zip)** ### Bug Fixes - fix(sdk): routeChange type=switchTab and page isTabbarPage stack always be the rootTab ## [5.8.3] 2026-02-04 **Download: [5.8.3(2.21 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.8.3.zip)** ## [5.8.2] 2026-02-04 **Download: [5.8.2(2.21 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.8.2.zip)** ### Misc - Revert " fix(sdk): sortable items when height changes " (#2522) ## [5.8.1] 2026-01-30 **Download: [5.8.1(2.21 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.8.1.zip)** ### Bug Fixes - fix(sdk): navigate routeChanging defer ref issues ## [3.8.1] 2026-01-30 **Download: [3.8.1(2.21 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.8.1.zip)** ### Bug Fixes - fix(sdk): navigate routeChanging defer ref issues - fix(sdk): cherry pick 5.7.1 - fix(sdk): sortable items when height changes - fix(sdkl): wallet prerender failed - fix(sdk): rm geature event listener binding - fix(sdk): fix prerender inject data path - fix(sdk,bundler): init nativeScrollNegotiation/enableBackToTop config - fix(sdk): reuse page issue on ios platform - fix(sdk): text dont filter nest components - fix(sdk): chain routechange handler when receviced multiple routechange - fix(lib): add missing code back to protect web import - fix(sdk): add ut - fix(lib): add comma to avoid MFA build error - fix(sdk): cp view based sdk 5.0 issue - fix(sdk): cp tab area scroll - fix(sdk): render data and prerender data independent to resolve flutter blink - fix(sdk): ignore preload font on flutter - fix(bundler): compatibility for old android - fix(cli): version sort - fix(sdk): fix prerender measure - fix(sdk): sdk5.2 cherry pick bn.removeWidgetSkeleton - fix(sdk): inst id not exist - fix(sdk): sdk5.2 cherry pick usePageScroll - fix(sdk): sdk5.x hummer log & nezha debug flag - fix(sdk): hotfix scrollview - fix(sdk): avoid XSS attack - fix(sdk): mounted to ensure nativeComponents context ready and dom instanceId for native widget map - fix(mpp-service): ai meta info upload without widgets - fix(sdk): remove unused log - fix(sdk): fix swiper loop mode & scroll view style - fix(sdk): fix intersection observer relative info not work - fix(sdk): relaunch deeplink issue - fix(sdk): fix swiper autoplay - Fix/swiper 0708 - fix(sdk): deeplink with data loader issue - fix(sdk): exports utils - fix(sdk): export bmp component utils - fix(sdk): scroll X in scroll Y - fix(sdk): expose the error before app init - fix(sdk): hide home button api - fix(server-side-bundle): add bundler as dep - fix(sdk): set scroll top not work / request support enableCache - fix(sdk): `show-scrollbar` doesn't work - fix(sdk): flutter getAttribute polyfill - fix(sdk): fix input textarea type adjustPosition - fix(cli): missing build start callback in bundleWatch - fix(sdk): add LCP report target - fix(sdk): drawer component visible when mounted - fix(mpp-service): fix qjs build for Andriod - fix(demo): pika no longer support `independent` - fix(sdk): page frame await syntax error - fix op_line_number size increased and get_label_pos not changed on node-qjsc - fix(mp-service): fix track line and column numbers for expressions on… - fix(bundler): loadScriptSync issue on android - fix(sdk): svg data url regexp missing text wrap - fix(sdk): fix cursor flashing on devices - fix(sdk): handle non-enumerable CustomEvent properties type and detail - fix(sdk): cherry-pick virtual list hotfix - fix(sdk): clear unreachable rpc promise - fix(sdk): remove skyline sync ui command (#2058) - fix(sdk): mitigate the risk of memory leak - fix(host): loadScriptSync issue - fix(cli): change @shoelace-style/shoelace version to 2 - fix(bmp): remove requestFullscreen param - fix(sdk): flutter-video context issue - fix(sdk): adjust unload timming - fix(sdk): native input with number type issue - fix(cli): ide-cli pnpm dep package.json resolve failed - fix(sdk): widget load timeline - fix(sdk): flutter deprecated-textarea autoheight style error - fix(sdk): trigger renderEffect before componentinit to fix patch issues - fix(sdk): fix page stack update timing - fix(sdk): run setdata callback after vue nexttick - fix(bmp): update type `BnInputProps&BnTextareaProps` - fix(sdk): change handlePaste defaultValue - fix(sdk): remove native component background color - fix(sdk): flutter-image remove eventListener - fix(sdk): support inlineLayout for skyline - fix(sdk): flutter scroll refresher background color - fix(sdk): android quickjs unsupport Unicode Property Escapes - fix(sdk): cherry pick webview message issue - fix(sdk): re-publish @mp/runtime-plugin-enable-sheet-gesture - fix(sdk): fix cursor issue - fix(runtime): premature return issue in ide enviroment's show-modal api - fix(sdk): editor pos nodeBefore return real textContent if node is nonTextNode - fix(sdk): `deprecated-textarea` support force update - fix(sdk): deprecated input does not update when is composing - fix(sdk): jarvis input does not update correctly - fix(sdk): fix webview message action not work - fix(sdk): native list view conflict with sliver style - fix(automator): add timeout when run automator - fix(sdk): fix catchmove not work - fix(sdk):add textarea placeholder class prop - fix(sdk): fix component patch error messsage - fix(sdk): fix drawer error and support accelaration - fix(lib): fix event channel type - fix(bundler): bundle watch mode should copy ignore files - fix(sdk): scroll y on scrollView is not works - fix(sdk): fix textarea props and type - fix(sdk): vnode patch issues - fix(sdk): navigate to type - fix(sdk): delay page set to make sure buforeRouteChange done - fix(bundler): disable sourcemap to reduce memory - fix: add worker plugin - fix(lib): fix bmp component types - fix(bundler): fix expression bundler - fix(sdk): native component webview message - fix(sdk): native event in worker - fix(sdk): fix webview component - fix(sdk): intersectionObserver margin - fix(sdk): eventhandler of chart component - fix(extended-lib): ethers Event identifier duplicated and getGlobal function error - fix(sdk): webview sdk only send invoke message - fix(sdk): image to figure will insert a new paragraph before the figure - fix(sdk): cursor is wired when editor tap keyboard enter - fix: update render cache doc id - fix(extended-lib): resolve path not a module - fix(sdk): image should not add appid for bn protocal src in widget - fix(sdk): page query not ready when onload - fix(extended-lib): postpublish script throw error - fix(host): support webassembly on host - fix(sdk): hover class not disappear - fix(sdk): create webview support widget - fix(host): widget ref not works and webview size not correct - fix(sdk): chart component need delay to setOptions - fix(extended-lib): add missing deps - fix(sdk): fix createwebview node-bridge issu - fix(sdk): fix bmp-component type - fix(sdk): revert readfile issue on ios - fix(sdk): hotfix ios doesn't use native fs - fix(sdk): when user delete all content web input may act unexpected - fix(sdk): remote-debug env update - fix(sdk): remote debugger resend ready to IDE - fix(demo): icon size demo - fix(sdk): label trigger itemClick event for radio and checkbox - fix(sdk): flutter gradient issue - fix(bundler): using prettier as formatter - fix(bundler): fix IDE can not reload - fix(sdk): fix webview sdk to compatible with node bridget - fix(cli): fix scroll-speed-limit default value - fix(cli): fix scroll-speed-limit default value - fix(sdk): support input focus and blur action by developers - fix(sdk): END_FIRSTPAGE_APPLAUNCH send pid - fix(sdk): clone data avoid reuse data object when reopen page - fix(sdk): cherry pick 4.16.2 + try catch instance update - fix(sdk): using show-scrollbar disable scrollbar - fix(sdk): iOS cursor always at the edge of the word, selection update event not trigger - fix(sdk): revert swiper located to wrong child when children updated - fix(demo): component-demo use built-in chart - fix(sdk): decode extra data without appid - fix(sdk): swiper located to wrong child when children updated - fix(bundler): fix expression not work on tag in `bn:for` - fix(demo): independent package config - fix(demo): private-close-app require shouldClose payload - fix(bundler): decompress replace unzipper - fix(bundler): bundler watch has 60s cache - fix(sdk): enbale flutter qjs - fix(sdk): swiper may throw error when disable indicatorDots - fix(sdk): widget props can get in worker - fix(sdk): cursor always jump to the first position when value change from an empty string - fix(sdk): check demo page ci - fix(bundler): source-map issue of swc-loader - fix(sdk): reset transform when refresher unmount - fix(sdk): create webview api in mp cannot message - fix(sdk): customize component data not update when return a data getter - fix(cli): webview component onmessage event - fix(sdk): cherry-pick fix web input seqId - fix(sdk): cherry-pick editor remove link and style recover (#1515) - fix(sdk): cherry-pick editor split figure bugs - fix(sdk): object spread syntax error - fix(cli): add webview component, webpack chain error - fix(bundler): lock unzipper version cause new version may lost file - fix(host): block TextEncoder prop - fix(demo): intersection observer usage - fix(sdk): bundler remove touchmove prevent modifer - fix(demo): editor toolbar bottom 0 when platform is not iOS - fix(sdk): iOS native component created failed when container is not visible - fix: cherry-pick from 4.12.1 - fix(sdk): cancel load-script when redirect - fix(lib): add type of removeSkeleton - fix(sdk): font-family should go with system font-family - fix(sdk): domtoimage svg base64 not have datatype - fix(sdk): add export type - fix(demo): fix canvas toTempFilePath - fix(server-side-bundle): remove subpackage prefix of sourceURL - fix(server-side-bundle): sourceURL issue of qjs - fix(sdk): domtoImage local image support for android - fix(demo): fix share demo - fix(sdk): video fullscreenchange on IOS - fix(cli): hack taro catch event - fix(demo): update prefetch image path - fix(mpp-service): newVersionFromServer might be null issue - fix(demo): reset zoom ref when toggle camera position - fix(sdk): dom to image support private static server images - fix(sdk): editorContext insertCoin not works - fix(mpp-service): min versoin should not replace the input version - fix(mpp-service): set min upload version as 0.0.1 - fix(automator): read route of undefined issue - fix(mpp-service): disable contentType when getUploadFileKey - fix(demo): websocket url not work - fix(mpp-service): set maxBodyLength & maxContentLength as Infinity wh… - fix(sdk): canIUseCustom support string params - fix(cli): support catch touchend - fix(sdk): fix ths issue about get appConfig & getPage - fix(sdk): callbackify error no stack - fix(sdk): load page frame after load base.bxml success - fix(mpp-service): add contentType filed when upload for security - fix(host): download support put - fix(demo): add private send transaction demo - fix(cli): webview injected not work - fix(demo): webview page not found - fix(sdk): figure scrollIntoView should focus on the figure caption - fix(demo): production convertToMPUrl usage - fix(sdk): editor caption selection and image keyboard handler - fix(host): definitions for bn.env - fix(sdk): unhandleRejection support polyfilled promise - fix(sdk): fix edtior editing image error - fix(sdk): init performance observer after worker ready - fix(sdk): editor delete image event stopropagation - fix(sdk): fix load page.js error to report 603505 when webview is des… - fix(demo): fix event-channel demo - fix(demo): on/off pairs - fix(sdk): editor image selection and focus - fix(mpp-service): print the old and new version - fix(demo): bug in navigation demo - fix(sdk): editor image cursor position and delete use touchend event - fix(sdk): update report data object & cancel startupTimeout when load resources - fix(sdk): editor image support update and deletable, hashtag keyboard key unexpected issue - fix(sdk): update load-script payload to ensure the cache is loaded - fix(sdk): update event channel if page init before eventChannel - fix(sdk): fix native input color issues on ios13 - fix(demo): update pika to fix input issue - fix(sdk): update dom to image scale impl and fix image / font issues - fix(sdk): rename getUserOpenId & doc-api - getUserOpenId/getUserKycStatus - fix(host): get-image-info is broken on IDE - fix(host): bn.request support arraybuffer body - fix(demo): radio page issue - fix(sdk): add native-send-appLuanch timer - fix(bundler): css variables rpx to rem align with wechat - fix(sdk): mini game view port size - fix(sdk): getChildrenNode util function - fix(sdk): rendererId zero issue in native ui - fix(bundler): catchmove value should be an exp - fix(sdk): swiper Item blank - fix(demo):fix custom demo textarea maxlength - fix(lib): remove optional chaining from bmp-react - fix(sdk): fix requestBinanceCardInfo error response & cicd - fix(bundler): compile optional chaining when using latest caniuse-lite - fix(sdk): android css transition native component - fix(sdk): fit audio platform api getters/setters on Andriod - fix(sdk): add RootPortal type - fix(sdk): mpc method - fix(lib): update types of bmp-react - fix(sdk): types of bn.call & add RootPortal to bmp-components - fix(demo): caret-color - fix(lib): virtual-list use new bmp packages - fix(sdk): update canIuse info - fix(sdk): cherry pick fix picker view component - fix(lib): @binance/mp-components don't import @tarojs/components - fix(sdk): image reload after src changes - fix(sdk): mini game keyboard event - fix(demo): fix demo navigation bar page - fix(bundler): fix babel env target - fix(demo): api navigation bar input element - fix(sdk): cherry-pick from release/3.14 - fix(runtime): network service setupServices multiple times - fix(automator): update @binance/mp-web for fix some issue and add `sdkPath` option - fix(bundler): launch MP with page of independent subpackage - fix(sdk): Image widthfix/heightFix mode can update size automatically - fix(demo): fix universal-share css - fix(bundler): reorder files in pkg - renderer files first - fix(sdk): fix web canvas width and height - fix(automator): replace parcel with http server to fix the installation issue from BIDS - fix(sdk): selectorQuery return empty when error - fix(runtime): remove BXML spaces - fix(bundler): remove setImmediate polyfill to fix pika MP white screen on iOS - fix(automator): fix some bugs & add `.waitFor` - fix(sdk): native component css - fix(sdk): (cherry-pick) reduce the blank page - fix(runtime): no need to add webview when open new page - fix(demo): input style of storage pages & update privatePrefetchRules - fix(sdk): cherry pick - load-script-progress event when mp background event to lead blank screen - fix(sdk): cherry pick fix location plugin - fix(cli): skip generation of unmatched tags - fix(demo): request pages issue of component-demo - fix(sdk): load \_\_app.js after $ready - fix(sdk): remove generating worker-service-game.qjs - fix(runtime): vibrate shifting bug - fix(demo): show isPrefetch in request pages - fix(cli): mpService should support both function api and object api - fix(mp-web): support absolute path - fix(changelog): changelog bug: 3.14.5-dev.1 & 4.0.2-dev.1 - fix(sdk): add readme for deprecated usage - fix(sdk): cherry pick - await load appJs - fix(sdk): fix image style not work - fix(cli): remove .npmrc and add npm token - fix(cli): duplicate resolve issue of ConditionNamesPlugin - fix(sdk): network service - fix(sdk): ready replace uirenderserviceready - fix(host): create webview files issue - fix(host): support private-request command - fix(runtime): download-file not work - fix(sdk): env undefined - fix(sdk): revoke native buffer issue - fix(mp-web): fix sw.js ready timeline issue - fix(sdk): native-image onload and image bug - fix(runtime): width of scroll-bar should be zero - fix(automator): support download-package rpc - fix(cli): update web host cli - fix(demo): update webgl demo with rgba - fix(demo): payment request use success callback instead - fix(sdk): useNativeImage - fix(mpp-service): copy source-code ignore node_module & hidden files - fix(sdk): fix image and keep **MP_WARN_DEPRECATED** - fix(sdk): gcanvas toDataURL and audio time update event - fix(server-side-bundle): upload bytecode pkg issue - fix(sdk): getUserProfile mini game doesn't need check tap event - fix(demo): native input width zero in android when container is a flex box - fix(sdk): reuqest text no response - fix(bundler): update dependencies to fix pkg-cli - fix(bundler): support error stack link jump of dev mode page.worker.js - fix(demo): fix benchmark - fix(sdk, demo): check promise polyfill by using \_\_\_mp_polyfill - fix(demo): public demo read file - fix(sdk): native-cover-view not work when using taro - fix(demo): two-fa demo scene data is undefined - fix(demo): pull down refresh not works - fix(sdk): cache promise online with polyfill - fix(sdk): mini game audio adapter - fix: disable ed and add @deprecated flag - fix(sdk): changelog issue - fix(sdk): callbackId could be zero - fix(sdk): input scrollbar css issue on android - fix(sdk): isCache undefined issue - fix(mpp-service): fix status api empty fail message - fix(sdk): add properties on webgl context - fix(sdk): fix timeOrigin 0 issues on IOS14 - fix(runtime): cannot resolve the font with url "bnshare://" - fix(sdk): fix getperformance firstRender - fix: cherry-pick cachePromise of getSystemInfo - fix(sdk): use promise polyfill fix promise task order in ios12 - ios14 - fix(sdk): error code detection of remote debug - fix(sdk): requestAnimationFrame NaN - fix(automator): web cli core apis - fix: add dependency to pass build job - fix(sdk): performance init appLaunch payload - fix: getPerformance first-render - fix(sdk): delete useless report - fix(sdk): loading when expect route-change type - fix(sdk): remove cachePromise to fix ios 13 eventloop issue - fix(sdk): fix: fix to signature error when include specific data struct issue - fix(sdk): remove type check in wallet-connect plugin - fix(sdk): gcanvas texImage2D flushnative - fix(sdk): fix taskify cache fail - fix(sdk): remove canvas service code - fix(sdk): fix applaunch-getPerformance - fix(sdk): fix webview sdk - fix(mpp-service): publish issue - fix(sdk): fix mg api host register - fix(sdk): navigateBackMiniProgram extra data should transform to string - fix(sdk): fix blank screen issue when relaunch because of taskify - fix(demo): public demo - fix(sdk): getCurrentPages error handler - fix(demo): textarea confirm-type - fix(sdk): fetch remote tags with force arg when tag conflict - fix(demo): textarea maxlength caused display issue - fix(sdk): access methods defined within methods property - fix(sdk): fix this problem for '\_setDataMaxSize' of undefined - fix(cli & runtime): useExtendedLib issue - fix(demo): public-demo textarea bug - fix(bundler): if directive not work as non-first attribute - fix(sdk): revert removing of setTimeout hack because of useDidShow issues on IOS - fix(server-side-bundle): set default value of versionSetting - fix(runtime): plainText body not supported - fix(demo): fix crash caused by private request demo - fix(sdk): bug in OnOffManager and add test - fix(sdk): revert changes of performance entry name - fix(demo): callback should not inside function component - fix(bundler): nested component with directive "for" - fix(runtime): set different left for title on different lefticon - fix(mpp-service): remove request body of getApplicationVersions - fix(sdk): request-timeout - fix: webstudio qa test - fix(sdk): tmpl_0_undefined bug lead to a blank page - fix(sdk): remove 120ms timeout of page show, make sure onShow is before onReady - fix(sdk): use logger to enable warn log visible - fix(bundler): disable autoloading postcss config of MP project - fix(sdk): tmpl_0_undefined issue - fix(demo): component-demo-public head component click fix - fix(demo): get appid from systemInfo - fix(runtime): set title when route-changed - fix(sdk): add missing @mp/runtime-plugin-sensor-orientation depenedncies - fix(sdk): page instance option property update - fix(sdk): from render to worker UIRendererServiceReady - fix(sdk): use log.error instead of filter text nest component - fix(demo): route query parameter different handler with encode64 - fix(runtime): load extended lib of specific version - fix(bundler): require relative path for cocos game - fix(sdk): reject the previous defer when reLaunch too early - fix(sdk): adjust MPRunTimeLogger - fix(sdk): routing api should wait app launched - fix(automator): api is undefined during first lauch of e2e(#NEZ-5634) - fix(sdk): share-panel not working (#542) - fix(bundler): copy non-existent files issue - fix(demo): how to use custom tabbar - fix(cli): resolve path of react - fix(sdk): rename package - fix(runtime): add getBridgeCode to files array - fix(runtime): remove dependency cycle - fix(runtime): align fail behaviour of request plugin with wechat - fix(sdk): cherry pick - timeline check app & hotfix 3.8.2 - fix(bundler): common.bxss is imported twice & release factory after jsModule is required - fix(sdk): empty subpackages force download action - fix(runtime): add service.d.ts to npm pack - fix(cli): update vendors to support node 16 - fix: catch downloadFile fail and remove --unhandled-rejections=warn - fix(sdk): mg add devicePixelRatio into getSystemInfo api - fix(sdk): mp canvastouche event payload - fix(bundler): add globalThis polyfill to page-frame - fix(sdk): setData in onLoad not working - fix(cli): fix tarojs version can not found in yarn global action ### Features - feat(sdk): hummer gcanvas - feat(sdk): load appjs when reload worker - feat(sdk): enhance native event channel for CustomNativeComponent - feat(cli): miniprogram mcp server - feat(cli): more function in devtool - feat(sdk): hummer button functions - feat(sdk): support createContext with customNativeComponent widget rendererId - feat(sdk): add internal doc site - feat(cli): auto perf - feat(sdk): add extra type - feat(sdk): support debug prefetch configuration - feat(sdk): lottie comp support animationData props - feat(bundler): update terser avoid bugs of old ver - feat(sdk): support closest AnchorElement tap - feat(sdk): add private api getVisibilityState - feat(sdk): input support force-decimal-dot - feat(sdk): fliter standalone chunk js for bytecode pkg - feat(sdk): support webview markdown list style - feat(cli): release 1.0.0 stable version - feat(cli): dx improve - feat(sdk): page timeline add check point - feat(sdk): editor chart UI revamp - feat(sdk,bundler): customize renderer components - feat(sdk): add debug - feat(sdk): b8 widget custom lifecycle - feat(extendedLib): extended lib ci and checksum - feat(sdk): update value for input - feat(script): add dev tag for publish-dev - feat(sdk): add scrollOffset for pageScrollTo - feat(sdk): support access node in SelectQuery - feat(sdk): flutterToImage and nativeComponent for iOS webview renderer - feat(sdk): remove root style 100% - feat(mpp-service): use label as rev - feat(sdk): call all api - feat(sdk): preload font - feat(mpp-service): add widget qrcode request logic - feat(bundler): update widgetConfigs - feat(cli): dynamic bundle version support - feat(sdk): video class name - feat(cli): clean code & fix no-qjs flag & fix fs-extra copy failed - feat: add preload-worker - feat(cli): use libversion - feat(bundler): support bundler version - feat(sdk): support share v2 api - feat(sdk): add formatter attribute - feat(sdk): menuBts for flutter markdown - feat(sdk): video poster - feat(sdk): support locked config for sortableitem - feat(cli): support home page widget preview - feat(mpp-service): update ai router payload - feat(mpp-service): ai router solution - feat(sdk): revert autoheight default value to false - feat(sdk): swiper autoHeight - feat(sdk): mp plugin support AbortSignal - feat(sdk): add require error log - feat(cli): bundle watch process not exiting correctly - feat(cli): add error handler for ios debug target query - feat(cli): support inspect webview/webf with native devtool protocol message - feat(sdk): support nested scroll view - feat(sdk): blank detector - feat(sdk): support typewriter effect for flutter markdown - feat(sdk): support playsinline for video - feat(sdk): use \_\_mp_runtime_config.screenWidth for set rem - feat(mpp-service): add report file size functions - feat(extended-lib): mpp runtime vendor - feat(sdk): new api bn.addPhoneCalendar & bn.addPhoneRepeatCalendar - feat(cli): add meta info indicator and every day tip - feat(sdk): add new svg component demo - feat(sdk): not set dataurl on style change - feat(sdk): w3w timeline monitor - feat(sdk): flutter svg class support - feat(sdk): add ios timeline log fit regexp - feat(sdk): virtualList support size by function - feat(sdk): remove set rem in flutter - feat(sdk): add createEventSource support for IDE - feat(sdk): add `max-lines` for text-span - feat(sdk): support page preload - feat(sdk): negotiation scroll with native on Android - feat(extended-lib): use dynamicExtendedLib for all the libs and remove upload builtIn lib - feat(sdk): suspend & resume lifecycle - feat(sdk): support keyboard accessory item - feat(sdk): remove sync api - feat(sdk): domtoimage can ignore error when image not exist or load error - feat(sdk): scrollview support enableBackToTop - feat(sdk): showErrorPage support auto detect rendererId - feat(sdk): flutter scrollView add events - feat(cli): achieve pkg stability & log process stability optimization - feat(host): support five themes - feat(cli): support mcp refresh - feat(sdk): remove hack worker patch - feat(sdk): add dark_midnight support - feat(bundler): support polyfill self and XMLHttpRequest - feat(bundler): dynamic path by env. BUNDLER_PATCH - feat(extended-lib): support extended lib uikit flow - feat(host): support midnight - feat(sdk): alpha chart for editor - feat(sdk): new component flutter markdown - feat(sdk): add `` & `` components - feat(sdk): support get prefetch data synchronous - feat: update process-md-paths - feat(cli): log process status indicator - feat: update md jobs - feat: add job to convert md path - feat(cli): filter standalone-chunks while addEntry - feat(sdk): input support max-digits-length - feat(cli): use release version devtool - feat(sdk): add runtime-plugin-create-event-source - feat(cli): chrome devtools Integration - console - feat: update llms.txt title and filter docs - feat: add upload-docs-md job - feat(cli): rebundle while refresh - feat(cli): improve achieve stability - feat(cli): adjust glob params - feat(cli): manual update qjsc version - feat(cli): add syncPackInclude flag - feat(bmp): add direction type for sortable - feat(runtime): add api `fs.removeSavedFile` - feat(demo): add more chose file or media demo - feat(sdk): add image info type - feat(sdk): init rem to avoid style issue in flutter renderer - feat(sdk): widget support selectorQuery & intersectionObserver - feat(sdk): implement lite-timeline sdk part - feat(sdk): improve virtual scrollview - feat(sdk): remove webf sync command during the initialization - feat(sdk): support disableCleanStack and cleanOtherStack - feat(sdk): increase priority of framework level message - feat(runtime): add plugin `addEventListenerToBody` - feat(server-side-bundle): add new qjs compilation - feat(sdk): add disable-ios-embed props for ios native input - feat(sdk): get static template theme from body - feat(sdk): support remove skeleton after static templete rendered - feat(sdk): drawer support teleportTo - feat(demo): add fixed page input demo - feat(sdk): flutter svg support - feat(sdk): input component can highlight the inputed content - feat(sdk): flutter deprecated textarea add `cursor-spacing` - feat(sdk): support auto zip sdk in watch mode - feat(cli): add socket status indicator - feat(bundler): support standalone-chunks - feat(sdk): add showDiagnosticPage API - feat(sdk): native-input cursor issue - feat(sdk): add flutter-chart component - feat(sdk): catch setTimeout callback error & Handle redundant `Uncaught` errors - feat(cli): support debug mode flag - feat(sdk): `MP.onError` message format & `MP.lifecycle` throw error - feat(sdk): add params in chooseFile - feat(sdk): scrollview support flex height virtual list - feat(sdk): svg inline tag performence improve - feat(bmp): `` support events - feat(sdk): `` support switching animation - feat(sdk): add `flutter-video` component - feat(sdk): throw bmp app `onError` - feat(sdk): add `` component - feat(extended-lib): update react/react-dom 18.3.1 - feat(sdk): echarts tooltip formatter support function - feat(cli): ide cli build failed not catch - feat(bmp): `PickerView` add options `maskClass|maskStyle|indicatorClass|indicatorStyle` - feat(cli): fix hot reload & change package name to ide-cli - feat(sdk): sortable support dark mode - feat: sortable component - feat(sdk): flutter-scrollview add `refresher` props - feat:(sdk): builtin svg component - feat(sdk): deprecated textarea autoHeight support - feat(ide-cli): preview functions for binance devtool - feat(sdk): create chart context support options params - feat(sdk): DeprecatedTextarea add `autocorrect` & `autocapitalize` - feat(sdk): add scrollstart scrollend to scrollview - feat(sdk): add `flutter-container` - feat(sdk): add `option.url` in applyUpdate - feat(sdk): add switch tab options in api - feat(sdk): add timeformat api - feat(sdk): add showBackButton api - feat(sdk): `native-textarea` add onPaste - feat(sdk): `native-textarea` add `alwaysEmbed` - feat(sdk): add the value of input type `decimals` - feat(sdk): flutter-deprecated-textarea add `autoFocus` - feat(sdk): new api page.updateRouteOptions - feat(sdk): `DeprecatedTextarea` support `cursor/autoFocus/selection-start/selection-end` - feat(demo): add error handler bot modal demo - feat(sdk): use tap for skyline - feat(sdk): add tab-switched api - feat(sdk): update caniuse api - feat(sdk): support multi pages in tabbar - feat(sdk): webview clearScrollStatus, invoke api - feat(sdk): add sticky-header & stick-section - feat(sdk): add `` - feat(sdk): setup markdown on flutter - feat(sdk): new api enable enableSheetGesture - feat(extended-lib): expose buildIn libs for server side bundle - feat(host): align response with native - feat(sdk): flutter text component - feat(sdk): update markdown & pika version update - feat(sdk): support readme feature - feat(sdk): add 2 components `ContextMenu` & `ContextMenuItem` - feat(sdk): add `` component & lottie-context - feat(bundler): emit handlePageBundled when skeleton build finish - feat(bundler): upgrade webpack to support Node >=18 - feat(demo): error handler demo - feat(sdk): add deeplink target type - feat(sdk): hack textarea with **BN_IGNORE_IS_COMPOSING** id - feat(extended-lib): update react qjs - feat(sdk): add component `flutter-image` - feat(demo): add style inject demo page - feat(sdk): add component flutter-scroll-view - feat(sdk): add plugin `runtime-plugin-update-page-query` - feat(sdk): add type `injected` for bmp-component - feat(sdk): add plugin `runtime-plugin-control-button` - feat(sdk): drawer component - feat(bundler): support static script, do not bundle into \_app.js and \_common.js - feat(bundler): mark build is done before send pageBundled - feat(bundler): add entry must trigger a rebuild - feat(sdk): scroll view support extra data prop - feat(sdk): performance babel plugin log format with timeline - feat(sdk): flutter scroll-view - feat(bundler): update watch page utils - feat(bundler): support ignore qjs options - feat(bundler): skeleton create style tags by script to avoid webf issues - feat(sdk): remove game script in sdk - feat(sdk): flutter scroll view - feat(sdk): add props for input - feat(bundler): update bundler for host - feat(doc): update doc - feat(demo): add input unfocuse issue - feat(sdk): lcp element timeline metrics - feat(sdk): choose image support compression threshold - feat(sdk): webview scrollChange event - feat(sdk): add logger for timeline log analyze - feat(sdk): scrollView skyline type list property support - feat(sdk): input prop disablePaste - feat(bundler): support bns in base.bxml and pika compile mode - feat(sdk): editor chart ui revamp - feat(sdk): support create worker - feat(lib): add type of Script to bmp-components - feat(sdk): webview component event api in queryselector - feat(sdk): support navigate api with animated - feat(sdk): bn.onCopy Api on Android - feat(host): export workerEnvCode for host - feat(extended-lib): upload bitcoinjs-lib & solana/web3.js - feat(extended-lib): upload ethers-5.5.4.js - feat(sdk): new api for webview component - feat(sdk): api show setting - feat(sdk): support fontFamily for native-input and native-textarea - feat(extended-lib): upload react-dom 18.2.0 - feat(sdk): remove load skeleton - feat(sdk): add onCopy event for text component - feat: mini program performance babel plugin - feat(sdk):add ut coverage 98% - feat(demo): add log for skyline debug & extended-lib should keep the built-in libs for cicd & ide - feat(extended-lib): remove built-in upload and fix getUrl data not send - feat(extended-lib): support web3 libs - feat(sdk): richtext support a href - feat(sdk): add page name to performance point - feat(sdk): widget props support functions in deeper obj - feat(sdk): webview status and invoke api - feat(sdk): add ut and increase coverage to 96.88% - feat(sdk): support dynamic rendering cache - feat(sdk): defer for taro useReady - feat(sdk): editor chart insert should focus next line - feat(sdk): api getrandomvalues - feat(sdk): widgetslot props can use functions start with 'on' - feat(plugin): sdk support w3w evm configurable - feat(sdk): add flutter input comp - feat(lib): add getWidgetId and try get ctx from current.widget - feat(sdk): widget can load base.bxml in target app - feat(sdk): api hide back button - feat(sdk): editor echart card - feat(sdk): cross app rpc support sync action - feat(sdk): bump - feat(host): support big int - feat(demo):host shell app add basebxml & preload - feat(server-side-bundle): add bytecode full - feat(sdk): api open document - feat(sdk): cross app rpc api - feat(demo): native component demo update - feat(bundler): support widget extended lib - feat(sdk): bns can work on exp - feat(sdk): cherry-pick: delay onReady for tarojs & add more error message info for appjs load - feat(cli): webf lint add new rules - feat(lib): check media query in webf - feat(sdk): taro page await app loaded - feat(extended-lib): release to prod - feat(sdk): custom native component - feat(sdk): improve doc 0325 - feat(sdk): add new prop webPreferences - feat(bundler): add solution for dynamic lib - feat(sdk): render earlier for pages with static template configuration - feat(sdk): flutter can report lcp - feat(host): support widget api - feat(sdk): add error code for widget when renderer destroy during init - feat(sdk): widget can get props without properties define - feat(sdk): webf lint adjustment - feat(sdk): add api setPageScrollable - feat(sdk): limit data point max length - feat(sdk): closeWidget can close native opend widget - feat(sdk): editor support \n inside paste content - feat(sdk): editor link paste with strick whitelist validator - feat(bundler): increase SOURCEMAP_SIZE_LIMIT to 10MB - feat(sdk): cherry-pick: add preloadflutterwebview api - feat(sdk): add error code to show error page - feat(sdk): add renderer Type in getCurrentPages api - feat(sdk): createSelectorQuery select support rootPortal options - feat(sdk): add latest version to update event - feat(sdk): editor enter event - feat(sdk): enableCursor for developers to use native cursor - feat(sdk): hold atom selection - feat(sdk): web input support inputmode and pattern - feat(bundler): merge widgetconfig to appconfig - feat(sdk): support atom selection - feat(sdk): add scrollSpeedLimit to avoid blank frame of virtual list - feat(sdk): editor support mention and hardBreak - feat(bundler): use js-beautify replace prettier as formater of qjs - feat(bundler): qjs compared from a formatted js code - feat(lib): bmp-api openWidget add support for convention path - feat(sdk): report error during renderer launching process - feat(sdk): scroll view support scrollWithAnimation and scrollIntoViewAlignment - feat(sdk): support swiper rtl props - feat(sdk): widget support open dialog - feat(tools):webf style linter - feat(sdk): report LCP only after user interacts - feat(sdk): set tab bar list api - feat(lib): refactor WidgetSlot as react component - feat(lib): bmp-react & bmp-component add support for widget - feat(sdk): echarts tooltip support basic dom - feat(sdk): widget in widgetslot support lifecycles - feat(sdk): editor internal plugin link support - feat(sdk): add more info to showErrorPage and add widget error report - feat(sdk): export standard error to developers - feat(sdk): bump version - feat(sdk): dynamic widget support props and add openWidget API - feat(sdk): sdk ut to 95% - feat(bundler): build qjs for renderer in flutter - feat(demo): enable flutter - feat(bundler): server side bundle add more files into qjs - feat(sdk): editor transform pasted content - feat(demo): pika extendedlib - feat(sdk): scroll-view supports scroll-anchor - feat(sdk): api bn.preloadWebContent to preload webview content advance - Feat/metadata - feat(sdk): editor paste event props - feat(sdk): echart component - feat(sdk): editor selectImage api - feat(mpp-service) add released pr - feat(sdk): support walletkit and init func - feat(demo): add manual to web input public demo - feat(lib): add API removeSkeleton to bmp-react - feat(sdk): control input - feat(server-side-bundle): add sentry project name and releaseid - feat(sdk): split figure into fig-caption and image - feat(server-side-bundle): use file path as sourceURL of qjs - feat(sdk): support udpsocket api - feat(sdk): 🎸 [plugin] add universal web3 provider - feat(sdk): dom to image support native canvas - feat(sdk): editor extension link - feat(sdk,bundler,demo): support skeleton - feat(sdk,bundler,demo): add camera component & createCameraContext API - feat(demo): add prefetchRules - feat(sdk): getUserOpenId return token - feat(sdk): editor coin - feat(sdk): editor image scrollIntoView - feat(sdk): editor image default spinner - feat(sdk): Mini Game touch event optimization - feat(bundler): support bxs - feat(host): set custom http headers for fetch requests - feat(sdk): ut from plugin-location to plugin-request-subscribe-message - feat(sdk): file method support put method - feat(demo): add beforeRouteChange usage to component-demo - feat(sdk,bundler): add show confirm bar for input - feat(sdk): srcollview pulldown refresher - feat(sdk): bids use monitorupload - feat(demo): editor component demo - feat(sdk): remove settimeout for page.show - feat(sdk): page-not-found - feat(sdk): add page-frame-html in sdk - feat(sdk): chooseMedia & chooseFile API - feat(sdk): editor focus and mark - feat(sdk): add startupTimeout & restore time compensation - feat(sdk): editor extension update and docs - feat(sdk): loading progress animation - feat(host): createBufferUrl support svg - feat(demo): add dom to image demo - feat(sdk): method domToImage - feat(sdk): exitMiniProgram support force close - feat(sdk): new api - getuseropenid getuserkycstatus - feat(sdk): editor component & editorContext api - feat(sdk):load resource fail or slowly - feat(demo): control picker view demo - feat(sdk): detect page timeline - feat(host): support pageReadyCallback - feat(sdk): add binance-card-info api - feat(demo): migrate to pika - feat(sdk): jssdk dashboard rename & calculate - feat(sdk): wallet connector use new wallet provider - feat(lib): add WebViewComponent to @binance/bmp-components - feat(demo): add English desc to image mode demo - feat(sdk): remove window info cache for view-base mode - feat(lib): add getCurrentInstance & getTabBar to @binance/bmp-react - feat(sdk): webview component supports message - feat(sdk): add runtime-plugin-mpc - feat(automator): impove `setupProxyMethod` & add test - feat(sdk): create buffer url supports extension option - feat(demo): add audio and write file benchemark - feat(sdk): swiper support previousMargin/nextMargin/snapToEdge - feat(automator): add mock api for automator - feat(lib): bmp-api & bmp-components & bmp-react - feat(sdk): add error log for 603114 - feat(sdk): View support prop: catchMove - feat(demo): images add mode & readFile add length & position config - feat(lib): generate types for @binance/mp-service - feat(sdk): root-portal - feat: integrate automator on CI - feat(sdk): loadFontFace - feat(sdk): file system api use platform api - feat(sdk): expose navigateBackMiniProgram, add mpModalType prop to navigateToMiniProgram - feat(sdk): webview bounce and loading bar - feat(lib): fork implement from @tarojs/components to @binance/mp-components - feat(sdk): create buffer url use platformAPI - feat(sdk): createInnerAudioContext use platform api - feat(demo): fix create buffer url demo - feat(sdk): gcanvas optimazation - feat(demo): add a rendererId 0 issue test case - feat(sdk): demo update & delete appTimeline - feat(sdk): native webview component - feat(demo): runtime benchmark add getAppBaseInfo apis - feat(sdk): (cherry-pick)support caretColor for Input and TextArea components - feat(automator): automator added headless option & refactor `.launch` & demo page - feat(demo): move sync-api-demo to component-demo & update prefetchRules - feat(sdk): api on add to favorites - feat(bundler): generate fileTree for analyzeSource - feat(sdk): first render new fields - feat(runtime): support selecting sdk - feat(sdk): web canvas component - feat(demo): mini game system info demo - feat(sdk): load gcanvas on demand - feat(sdk): add page-frame-resource points - feat(automator): refactor mp-web & inject mp-web to automator - feat(sdk): gcanvas createJSBuffer, less cpu cost - feat(automator): support plugins service to fix service undefined issue - feat(bundler): add **REPORT_POINTS** for renderer - feat(sdk): nezhaRenderPageJs point - feat(automator): allow reloading the mini-program - feat(cli): update publish yml file - feat(sdk): truncate long rpc logs limit length - feat(sdk): shareAppMessage support fallback url - feat(sdk): add debounce to navigator - feat(cli): support conditional exports bmp - feat(sdk): renderer to native page ready - feat(sdk): add param usePrefetchCache to bn.request - feat(demo): release component-demo PROD - feat(sdk): getPerformance support entryType: loadPackage downloadPackage - feat(sdk): scroll-view support showScrollbar - feat(sdk): mg keyboard api - feat(demo): taro version runtime benchmark - feat(demo): virtual list - feat(runtime): support bn.env.USER_DATA_PATH - feat(sdk): remove monitor because native didn't support the commands - feat(sdk): loadScriptSync rpc - feat(sdk): support multiple intersectionObserver - feat(sdk): navigateTo add target external - feat(sdk): update canIUse for new api - feat(runtime): downloa-package add two fields - feat(bundler): add monitor NEZHA_RENDER_PAGE_JS & update sorter of pkg - feat(host): remove canvas useless dep - feat(sdk): remove deprecated items for sdk4.0 - feat(sdk): getSystemInfo cache - feat(server-side-bundle): compile & upload worker code into bytecode when enableBytecode - feat(sdk): bump versions - feat(sdk): bump version for ide deps - feat(sdk): validate current page is tabBar page when call tabBar apis - feat(demo): update prod demo - feat(sdk): plugin createIntersectionObserver and fix selectorQuery setTimeout issue - feat(sdk): detect darkmode for appBaseInfo - feat(sdk): load app js advance after worker send $Ready - feat(sdk): generate bytecode for worker-service - feat(sdk): gcanvas buffer data optimize - feat: native image - feat(bundler): add new package node-qjsc - feat(sdk): getAppBaseInfo & getWindowInfo & getDeviceInfo - feat(runtime): expose updateBackground of create webview service for ide - feat(sdk): $renderer-ready action - feat(sdk): loadScriptSync method - feat(sdk): chainId should be number when pass to native - feat(demo): add promise polyfill demo for QA regression - feat: web host cli - feat(demo): release demo on QA env - feat(cli): cover-view support hover-class - feat(demo): improve twoFa demo - feat(demo): remove webauthn demo - feat(bundler): add statistics mode to pkg-cli & feat(mpp-service): support config msv - feat(sdk,demo): add private fps api and benchmark for render fps - feat(sdk): cache promise reject handler - feat(sdk): getperformance-evaluateScript - feat(lib): add promise polyfill source code and descreption - feat(sdk): gcanvas async method - feat(server-side-bundle): use X-Mp-Open-Api-Token to authorize - feat(sdk): add warn deprecated info for sdk 4.0 - feat(sdk): support injected prop in webview component - feat(sdk): add experimental on walletconnector - feat(bundler): support include options in project.config.json - feat(sdk): error with stack - feat(sdk): new render point NEZHA_INJECT_RENDERER_JS_END & update timeline point info - feat(lib): use body class to control theme rather than prefers-color-scheme - feat(lib): remote-debug route-change-done notify to render - feat(cli): add props to webview - feat(sdk): mpRuntimeLogger rename & add error code - feat(sdk): webgl finish api - feat(mpp-service): output version info to MPP_SERVICE_OUTPUT.json - feat(sdk): time app check after app-launch - feat(bundler): impl util-function analyzeSource & remove AddEntryAppJsPlugin - feat(mpp-service): output hostQrcode to a file - feat(sdk): sdk-loading - feat(lib): remote-debug new action & ignore native side delay error - feat(sdk): create webview sdk & demo - feat(runtime): disable click when loading display - feat(sdk): gcanvas supports cocos - feat(bundler): use zlib to compress pkg - feat(sdk): setInterval 0 with warning - feat(sdk): add api requestSubscribeMessage - feat(sdk): make-phone-call - feat(runtime): @mp/host catch error and send to parent window - feat(sdk): canvas to temp file path api and demo - feat(sdk): add FP/FCP/LCP entry for performance API - feat(demo): add readfile api to benchmark - feat(sdk): add route-change-done event to fix route entry negative duration - feat(demo): add apiBenchmark at globalThis to run customize api benchmark - feat(demo): add extended-libs page - feat(demo): demo for webgl - feat(cli): quick publish for dev & qa [NEZ-7388] - feat(sdk): add mt_start when monitorupload setdata - feat(extended-lib): integrate distribution API (test on dev env) - feat(cli): support plugins - feat(sdk): improve web3 api - feat(demo): Standard Benchmark DSL Mini Program for runtimes - feat(demo): migrate component-demo api to component-demo-public - feat(sdk): cache promise api until it resolved - feat(bundler): add file hash to pkg - feat(sdk): filesystem api - copyfile, unzip - feat(demo): update radio example code as wechat example - feat(runtime): assign path to render iframe name - feat(demo): form view media public demo components - feat(demo): release demos in QA env - feat(demo): release demos in QA env - feat(demo): release demos in QA env - feat(cli): support taro prerender - feat(mpp-service): intergate server-side-bundle - feat(sdk): open-type getEmailAddress / getPhoneNumber - feat(demo): share app demo - feat(sdk): universal link - feat(extended-lib): export libs info - feat(bundler): add analyse mode to pkg-cli - feat(extended-lib): add new package @mp/extended-lib - feat(bundler): add pkg-cli - feat(sdk): monitorupload NEZHA_RENDER_PAGE_JS with data-eb - feat(sdk): setData payload size & remove cocos - feat(sdk): check TIME_APP by heartbeat scheme - feat(lib): preload styles bug fix - feat(demo): migrate theme-context - feat(bundler): bundler-cli add disabledSubpackages - feat(mpp-service): upload pkg of mini-program - feat(sdk): refactor framework-load-script - feat(demo): update custome event demo - feat(sdk): ide clipboard plugin migrate - feat(demo): add getEmailAddress getPhoneNumber demo - feat(server-side-bundle): upload source-map & source-code - feat(lib): preload html core - feat(mpp-service): support auto increase version code & improve error… - feat(runtime): simulator navigator title left align - feat(sdk): custom event on/off - feat(sdk): open-type button support getPhoneNumber, getEmail - feat(demo): expose base64_encode method example for developers - feat(sdk): native send event to worker with time - feat(sdk): renderer send RendererReady to Native - feat(demo): standalone webview demo - feat(sdk): add create offscreen canvas api - feat(sdk): warn if developer call sync api in app & page lifecycle - feat(runtime,sdk): handle page-not-found and fix onPageNotFound not working - feat(server-side-bundle): add new package @mp/server-side-bundle - feat(demo): implement 5 api to component-demo - feat(demo): component-demo for dsl - feat(sdk): route query parameters updates - feat(demo): migrate e2e test - feat(mpp-service): submit the MiniProgram in audit step - feat(demo): enterkeyhint of search - feat(sdk): remote debug support sync rpc - feat(sdk): remove cocos runtime script from sdk package - feat(automator): replace puppeteer wiht playwright - feat(sdk): wallet-connector issue fix - feat(sdk): text component support decode and space - feat(sdk): add new rpc action RendererServiceReady - feat(sdk): add fullyDownloaded to FrameworkDownloadPackage - feat(demo): webview custom nav demo - feat(lib): host getImageInfo plugin - feat(sdk): getImageInfo support relative path - feat(sdk): add wallet-connector plugin - feat(bundler) : bxml support relative path - feat(cli): update deprecated input props - feat(demo): public demo component migrate - feat(demo): update wallet connector demo - feat(demo): include get-image-info demo image files - feat(demo): component demo public - feat(runtime): deprecated input support confirm event - feat(demo): update wallet connector demo - feat(demo): getImageInfo support absolute path and short path - feat(demo): add more cases in wallet-connector demo - feat(cli,doc): modify bundler info for useExtendedLib and update doc troubleshooting - feat(bundler & runtime): support useExtendedLib - feat(demo): update the unsupported domain test - feat: e2e-test - feat(sdk): hotfix 3.8.1 cherry pick master & restore yml - feat(sdk): redesign timeline - feat(sdk): startlocationupdate type - feat(sdk): image-info plugin - feat(demo): get-image-info demo - feat(sdk): add plugin user-info & migrate getUserProfile to action get-user-info-profile - feat(cli): support externals lib - feat(playground): add wallet-connector context api - feat(cli): upgrade tarojs to 3.4.4 - feat(sdk): expose esmoudle of plugin submodule with .mjs - feat(bundler): empty app.js for drop compatibility & fix independent … ### Performance Improvements - perf: enhance scroll performance by reduce binding getter from event target - perf: add filesystem cache - perf: app-rpc msg encoder - perf: pre-create worker - perf(sdk): use local js-sha3 ### Misc - Revert "fix(sdk): export bmp component utils" - Revert "chore: @mp/bundler dev" - Revert "fix(sdk): vnode patch issues " (#1786) (#1796) - Revert "fix(sdk): iOS native component created failed when container is not visible " - Revert "fix(sdk): env undefined" - Revert "Revert "refactor(sdk): remove locationReadyManager " (#888)" (#929) - Revert "refactor(sdk): remove locationReadyManager " (#888) - Revert "fix: cherry-pick cachePromise of getSystemInfo " (#867) - revert(sdk): revert getPhoneNumber/getEmailAddress feature because IOS not ready yet - revert(sdk): rollback to use the old get-user-profile action ## [5.8.0] 2026-01-30 **Download: [5.8.0(2.21 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.8.0.zip)** ### Bug Fixes - fix(sdk): cherry pick 5.7.1 - fix(sdk): sortable items when height changes - fix(sdkl): wallet prerender failed ### Features - feat(sdk): hummer gcanvas - feat(sdk): load appjs when reload worker - feat(sdk): enhance native event channel for CustomNativeComponent - feat(cli): miniprogram mcp server - feat(cli): more function in devtool ## [5.7.4] 2026-01-26 **Download: [5.7.4(2.21 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.7.4.zip)** ### Misc - revert: revert v5.7.2 and v5.7.3 which fix by native ## [5.7.3] 2026-01-16 **Download: [5.7.3(1.87 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.7.3.zip)** ### Bug Fixes - fix(sdk): showErrorPage when setData unordered ## [5.7.2] 2026-01-15 **Download: [5.7.2(1.87 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.7.2.zip)** ### Features - feat(sdk): showError page when node tree not matched ## [5.7.1] 2026-01-14 **Download: [5.7.1(1.87 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.7.1.zip)** ### Bug Fixes - fix(sdk): fix route pending when page.js fails ## [5.6.1] 2026-01-14 **Download: [5.6.1(1.87 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.6.1.zip)** ### Bug Fixes - fix(sdk): fix route pending when page.js fails ## [5.7.0] 2026-01-08 **Download: [5.7.0(1.87 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.7.0.zip)** ### Bug Fixes - fix(sdk): rm geature event listener binding ### Features - feat(sdk): hummer button functions - feat(sdk): support createContext with customNativeComponent widget rendererId - feat(sdk): add internal doc site - feat(cli): auto perf ## [5.5.3] 2025-12-29 **Download: [5.5.3(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.5.3.zip)** ## [5.4.2] 2025-12-29 **Download: [5.4.2(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.4.2.zip)** ## [5.2.10] 2025-12-29 **Download: [5.2.10(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.2.10.zip)** ## [5.6.0] 2025-12-19 **Download: [5.6.0(1.87 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.6.0.zip)** ### Bug Fixes - fix(sdk): fix prerender inject data path - fix(sdk,bundler): init nativeScrollNegotiation/enableBackToTop config - fix(sdk): reuse page issue on ios platform - fix(sdk): text dont filter nest components - fix(sdk): chain routechange handler when receviced multiple routechange - fix(lib): add missing code back to protect web import ### Features - feat(sdk): add extra type - feat(sdk): support debug prefetch configuration - feat(sdk): lottie comp support animationData props - feat(bundler): update terser avoid bugs of old ver ## [5.5.2] 2025-12-17 **Download: [5.5.2(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.5.2.zip)** ### Bug Fixes - fix(sdk): add ut - fix(lib): add comma to avoid MFA build error - fix(sdk): cp view based sdk 5.0 issue - fix(sdk): cp tab area scroll - fix(sdk): render data and prerender data independent to resolve flutter blink - fix(sdk): ignore preload font on flutter - fix(bundler): compatibility for old android - fix(cli): version sort - fix(sdk): fix prerender measure - fix(sdk): sdk5.2 cherry pick bn.removeWidgetSkeleton - fix(sdk): inst id not exist - fix(sdk): sdk5.2 cherry pick usePageScroll - fix(sdk): sdk5.x hummer log & nezha debug flag - fix(sdk): hotfix scrollview - fix(sdk): avoid XSS attack - fix(sdk): mounted to ensure nativeComponents context ready and dom instanceId for native widget map - fix(mpp-service): ai meta info upload without widgets - fix(sdk): remove unused log ### Features - feat(sdk): support closest AnchorElement tap - feat(sdk): add private api getVisibilityState - feat(sdk): input support force-decimal-dot - feat(sdk): fliter standalone chunk js for bytecode pkg - feat(sdk): support webview markdown list style - feat(cli): release 1.0.0 stable version - feat(cli): dx improve - feat(sdk): page timeline add check point - feat(sdk): editor chart UI revamp - feat(sdk,bundler): customize renderer components - feat(sdk): add debug - feat(sdk): b8 widget custom lifecycle - feat(extendedLib): extended lib ci and checksum - feat(sdk): update value for input - feat(script): add dev tag for publish-dev - feat(sdk): add scrollOffset for pageScrollTo - feat(sdk): support access node in SelectQuery - feat(sdk): flutterToImage and nativeComponent for iOS webview renderer - feat(sdk): remove root style 100% - feat(mpp-service): use label as rev - feat(sdk): call all api - feat(sdk): preload font - feat(mpp-service): add widget qrcode request logic - feat(bundler): update widgetConfigs - feat(cli): dynamic bundle version support - feat(sdk): video class name - feat(cli): clean code & fix no-qjs flag & fix fs-extra copy failed - feat: add preload-worker - feat(cli): use libversion ## [5.5.1] 2025-12-17 **Download: [5.5.1(1.81 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.5.1.zip)** ### Bug Fixes - fix(libs); bmp-components imported unexpectedly by web project - fix(sdk): usePageScroll hooks not work - fix(bmp): pika ci error - fix(sdk): fix resolve native comp & input update timestamp - fix(sdk): render child node directly when component need children vnode - fix(sdk): host mini app events and setData damaged by widget flow - fix: revert comment - fix(sdk): @binance/bmp-xx deps - fix(sdk): scrollViewUpdate rendererId undefined - fix(lib): define EMPTY_OBJ - fix(sdk): fix build script - fix(sdk): dep missing - fix(sdk): plugins types issue - fix(sdk): fake childnode - fix(sdk): fix no text in child text - fix(sdk): nested text node - fix(sdk): remove capture event handler - fix(cli): bundler function params missing - fix(sdk): typo error - fix(sdk): fix alias to avoid multiple event emit ### Features - feat(bundler): fix bundler config - feat(lib): support legacy dynamic widget slot - feat(lib): release prod bmp-components and bmp-react - feat(bundler): remove prerender data after build in - feat(lib): update bmp component for ts - feat(lib): support legacy widget-slot - feat(sdk): update systemInfo cache when shellapp not restart - feat(sdk): prerender remove skeleton auto - feat(sdk): prerender support combined data - feat(lib): update typo and EMPTY_OBJ - feat(sdk): update taro-bn-components - feat(lib): remove useTheme - feat(lib): use one reactMeta for context - feat(sdk): update hummer webpack with production mode - feat(sdk): update typo - feat(lib): update useEffect - feat(sdk): use pika **APPID** - feat(lib): move context to bmp-react - feat(lib): add context - feat(cli): update bundler version - feat(sdk): update widget - feat(sdk): add log - feat(sdk): add widget hummer - feat(sdk): no cache for widget open event - feat(sdk): remove global RuntimeMonitor - feat(sdk): hummer send to worker pageready - feat(sdk): track campatibility for app inst - feat(sdk): support widget slot - feat(sdk): widget plugin - feat(sdk): support event & update - feat(sdk): update widget - feat(sdk): hummer event, context, widget update - feat(sdk): add component render plugin - feat(sdk): widget slot plugin - feat(sdk): add page ready - feat(sdk): export widget component - feat(sdk): fix typo - feat(sdk): add widgetOpen handler - feat(sdk): widget plugin - feat(sdk): remove app timeline check & loadApp directly - feat(sdk): remove mg - feat(sdk): draft widget - feat(sdk): avoid event error of widget - feat(sdk): mp lite support prerender - feat(sdk): update 5.0 widget - feat(sdk): remove app instance - feat(bundler): init widget bundler - feat(sdk): export methods for widget - feat(sdk): worker not wait renderer ready - feat(sdk): use vue render - feat(sdk): add components alias - feat(sdk): remove bxml render in worker - feat(sdk): clean worker timeline - feat(sdk): clean worker timeline - feat(sdk): 5.0 add script to build renderer-service-hummer.js - feat(sdk): remove vnode and patch on worker ### Misc - Revert "Merge master" - revert: root condition in setData ## [5.4.1] 2025-12-17 **Download: [5.4.1(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.4.1.zip)** ### Features - feat(cli): release 1.0.0 stable version - feat(cli): dx improve ## [5.3.5] 2025-12-17 **Download: [5.3.5(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.3.5.zip)** ## [5.2.9] 2025-12-15 **Download: [5.2.9(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.2.9.zip)** ### Bug Fixes - fix(sdk): text dont filter nest components ## [5.5.0] 2025-11-27 **Download: [5.5.0(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.5.0.zip)** ### Features - feat(sdk): support closest AnchorElement tap - feat(sdk): add private api getVisibilityState - feat(sdk): input support force-decimal-dot - feat(sdk): fliter standalone chunk js for bytecode pkg - feat(sdk): support webview markdown list style - feat(cli): release 1.0.0 stable version - feat(cli): dx improve ## [5.4.0] 2025-11-07 **Download: [5.4.0(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.4.0.zip)** ### Bug Fixes - fix(sdk): cp view based sdk 5.0 issue - fix(sdk): cp tab area scroll - fix(sdk): render data and prerender data independent to resolve flutter blink - fix(sdk): ignore preload font on flutter - fix(bundler): compatibility for old android ### Features - feat(sdk): page timeline add check point - feat(sdk): editor chart UI revamp - feat(sdk,bundler): customize renderer components - feat(sdk): add debug - feat(sdk): b8 widget custom lifecycle - feat(extendedLib): extended lib ci and checksum ## [5.2.8] 2025-11-04 **Download: [5.2.8(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.2.8.zip)** ### Bug Fixes - fix(sdk): capacibility of document body - fix(sdk): cp tab area scroll ## [5.3.4] 2025-11-04 **Download: [5.3.4(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.3.4.zip)** ### Bug Fixes - fix(sdk): capacibility of document body - fix(sdk): cp tab area scroll ## [5.3.4] 2025-11-04 **Download: [5.3.4(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.3.4.zip)** ### Bug Fixes - fix(sdk): cp tab area scroll ## [5.2.8] 2025-11-04 **Download: [5.2.8(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.2.8.zip)** ### Bug Fixes - fix(sdk): cp tab area scroll ## [4.51.4] 2025-11-03 **Download: [4.51.4(1.85 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.51.4.zip)** ### Bug Fixes - Fix/tab move ## [5.3.3] 2025-11-02 **Download: [5.3.3(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.3.3.zip)** ### Bug Fixes - fix(sdk): render data and prerender data independent to resolve flutter blink ## [5.2.7] 2025-11-02 **Download: [5.2.7(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.2.7.zip)** ### Bug Fixes - fix(sdk): render data and prerender data independent to resolve flutter blink ## [4.51.3] 2025-10-30 **Download: [4.51.3(1.85 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.51.3.zip)** ### Features - feat(sdk): editor chart UI revamp ## [5.3.2] 2025-10-30 **Download: [5.3.2(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.3.2.zip)** ### Bug Fixes - fix(sdk): capacibility for prerender text ## [5.2.6] 2025-10-30 **Download: [5.2.6(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.2.6.zip)** ### Bug Fixes - fix(sdk): capacibility for prerender text ## [4.51.2] 2025-10-29 **Download: [4.51.2(1.85 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.51.2.zip)** ### Features - feat(sdk): support custom native component in iOS ## [5.2.5] 2025-10-28 **Download: [5.2.5(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.2.5.zip)** ## [5.2.4] 2025-10-28 **Download: [5.2.4(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.2.4.zip)** ### Bug Fixes - fix(sdk): viewbased mp issue ## [5.3.1] 2025-10-28 **Download: [5.3.1(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.3.1.zip)** ### Bug Fixes - fix(sdk): viewbased mp issue ## [5.2.4] 2025-10-28 **Download: [5.2.4(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.2.4.zip)** ### Bug Fixes - fix(sdk): viewbased mp issue ## [5.3.0] 2025-10-17 **Download: [5.3.0(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.3.0.zip)** ### Features - feat(sdk): update value for input - feat(script): add dev tag for publish-dev - feat(sdk): add scrollOffset for pageScrollTo - feat(sdk): support access node in SelectQuery - feat(sdk): flutterToImage and nativeComponent for iOS webview renderer - feat(sdk): remove root style 100% - feat(mpp-service): use label as rev ## [5.2.3] 2025-10-15 **Download: [5.2.3(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.2.3.zip)** ### Bug Fixes - fix(sdk): nested text render ### Features - feat(sdk): remove skeleton earlier to improve FCP ## [4.51.2] 2025-10-14 **Download: [4.51.2(1.85 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.51.2.zip)** ### Features - feat(sdk): support custom native component in iOS ## [4.51.1] 2025-10-13 **Download: [4.51.1(1.85 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.51.1.zip)** ### Features - feat(sdk): flutter domToImage - feat(mpp-service): update to junior ## [5.2.1] 2025-10-11 **Download: [5.2.1(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.2.1.zip)** ### Bug Fixes - fix(sdk): render full attrs & buildin alias - fix(cli): version sort ## [5.2.0] 2025-09-26 **Download: [5.2.0(1.81 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.2.0.zip)** ### Bug Fixes - fix(sdk): fix prerender measure - fix(sdk): sdk5.2 cherry pick bn.removeWidgetSkeleton - fix(sdk): inst id not exist - fix(sdk): sdk5.2 cherry pick usePageScroll - fix(sdk): sdk5.x hummer log & nezha debug flag - fix(sdk): hotfix scrollview - fix(sdk): avoid XSS attack - fix(sdk): mounted to ensure nativeComponents context ready and dom instanceId for native widget map - fix(mpp-service): ai meta info upload without widgets - fix(sdk): remove unused log ### Features - feat(sdk): call all api - feat(sdk): preload font - feat(mpp-service): add widget qrcode request logic - feat(bundler): update widgetConfigs - feat(cli): dynamic bundle version support - feat(sdk): video class name - feat(cli): clean code & fix no-qjs flag & fix fs-extra copy failed - feat: add preload-worker - feat(cli): use libversion ## [4.51.0] 2025-09-26 **Download: [4.51.0(1.85 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.51.0.zip)** ### Features - Feat call all - feat(sdk): sdk4.x support support formatter for all echart options ## [5.1.4] 2025-09-24 **Download: [5.1.4(1.81 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.1.4.zip)** ### Bug Fixes - fix(sdk): usePageScroll hooks not work - fix(sdk): hummer renderer support update single child ### Features - feat(sdk): bn.removeWidgetSkeleton ## [5.1.3] 2025-09-17 **Download: [5.1.3(1.81 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.1.3.zip)** ### Bug Fixes - fix(sdk): hummer render support update dom - fix(sdk): fix hummer event not work because eventId not exist - fix(sdk): comment log & debug log flag - fix(sdk): remove duplicate worker module while hot-reload - fix(sdk): fix render native webview ## [5.1.2] 2025-09-12 **Download: [5.1.2(1.81 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.1.2.zip)** ### Features - feat(sdk): renderer mount do not wait worker rpc response ## [5.1.1] 2025-09-12 **Download: [5.1.1(1.81 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.1.1.zip)** ### Bug Fixes - fix(sdk): fix widget FCP & LCP report - fix(sdk): hotfix scrollview ### Features - feat(sdk): sdk5.1 support formatter for all echart options ## [4.50.1] 2025-09-12 **Download: [4.50.1(1.85 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.50.1.zip)** ### Bug Fixes - fix(sdk): hotfix scrollview ## [4.50.0] 2025-09-04 **Download: [4.50.0(1.85 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.50.0.zip)** ### Bug Fixes - fix(sdk): mounted to ensure nativeComponents context ready and dom instanceId for native widget map - fix(mpp-service): ai meta info upload without widgets - fix(sdk): remove unused log ### Features - feat(sdk): video class name - feat(cli): clean code & fix no-qjs flag & fix fs-extra copy failed - feat: add preload-worker - feat(cli): use libversion - feat(bundler): support bundler version ## [5.1.0] 2025-09-04 **Download: [5.1.0(1.81 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.1.0.zip)** ### Bug Fixes - fix(bmp): pika ci error - fix(sdk): fix resolve native comp & input update timestamp - fix(sdk): render child node directly when component need children vnode - fix(sdk): host mini app events and setData damaged by widget flow - fix: revert comment - fix(sdk): @binance/bmp-xx deps - fix(sdk): scrollViewUpdate rendererId undefined - fix(lib): define EMPTY_OBJ ### Features - feat(lib): support legacy dynamic widget slot - feat(lib): release prod bmp-components and bmp-react - feat(bundler): remove prerender data after build in - feat(lib): update bmp component for ts - feat(lib): support legacy widget-slot - feat(sdk): update systemInfo cache when shellapp not restart - feat(sdk): prerender remove skeleton auto - feat(sdk): prerender support combined data - feat(lib): update typo and EMPTY_OBJ - feat(sdk): update taro-bn-components - feat(lib): remove useTheme - feat(bundler): support bundler version ### Misc - Revert "Merge master" - revert: root condition in setData ## [4.49.1] 2025-08-22 **Download: [4.49.1(1.85 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.49.1.zip)** ### Bug Fixes - fix(sdk): nested scroll not work - fix(sdk): menuBts props ## [5.0.0] 2025-08-15 **Download: [5.0.0(1.90 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-5.0.0.zip)** ### Bug Fixes - fix(sdk): fix build script - fix(sdk): dep missing - fix(sdk): plugins types issue - fix(sdk): fake childnode - fix(sdk): fix no text in child text - fix(sdk): nested text node - fix(sdk): fix swiper loop mode & scroll view style - fix(sdk): fix intersection observer relative info not work - fix(sdk): remove capture event handler - fix(cli): bundler function params missing - fix(sdk): typo error - fix(sdk): relaunch deeplink issue - fix(sdk): fix swiper autoplay - fix(sdk): fix alias to avoid multiple event emit - Fix/swiper 0708 - fix(sdk): deeplink with data loader issue - fix(sdk): exports utils - fix(sdk): export bmp component utils - fix(sdk): scroll X in scroll Y - fix(sdk): expose the error before app init - fix(sdk): hide home button api - fix(server-side-bundle): add bundler as dep ### Features - feat(lib): use one reactMeta for context - feat(sdk): update hummer webpack with production mode - feat(sdk): update typo - feat(lib): update useEffect - feat(sdk): use pika **APPID** - feat(lib): move context to bmp-react - feat(lib): add context - feat(cli): update bundler version - feat(sdk): support share v2 api - feat(sdk): update widget - feat(sdk): add formatter attribute - feat(sdk): menuBts for flutter markdown - feat(sdk): video poster - feat(sdk): support locked config for sortableitem - feat(sdk): add log - feat(sdk): add widget hummer - feat(sdk): no cache for widget open event - feat(sdk): remove global RuntimeMonitor - feat(sdk): hummer send to worker pageready - feat(sdk): track campatibility for app inst - feat(sdk): support widget slot - feat(sdk): widget plugin - feat(sdk): support event & update - feat(sdk): update widget - feat(sdk): hummer event, context, widget update - feat(cli): support home page widget preview - feat(sdk): add component render plugin - feat(sdk): widget slot plugin - feat(sdk): add page ready - feat(sdk): export widget component - feat(sdk): fix typo - feat(sdk): add widgetOpen handler - feat(sdk): widget plugin - feat(sdk): remove app timeline check & loadApp directly - feat(mpp-service): update ai router payload - feat(sdk): remove mg - feat(sdk): draft widget - feat(mpp-service): ai router solution - feat(sdk): revert autoheight default value to false - feat(sdk): swiper autoHeight - feat(sdk): mp plugin support AbortSignal - feat(sdk): add require error log - feat(sdk): avoid event error of widget - feat(cli): bundle watch process not exiting correctly - feat(sdk): mp lite support prerender - feat(sdk): update 5.0 widget - feat(sdk): remove app instance - feat(bundler): init widget bundler - feat(sdk): export methods for widget - feat(cli): add error handler for ios debug target query - feat(cli): support inspect webview/webf with native devtool protocol message - feat(sdk): worker not wait renderer ready - feat(sdk): use vue render - feat(sdk): add components alias - feat(sdk): remove bxml render in worker - feat(sdk): clean worker timeline - feat(sdk): clean worker timeline - feat(sdk): 5.0 add script to build renderer-service-hummer.js - feat(sdk): remove vnode and patch on worker - feat(sdk): support nested scroll view - feat(sdk): blank detector - feat(sdk): support typewriter effect for flutter markdown - feat(sdk): support playsinline for video - feat(sdk): use \_\_mp_runtime_config.screenWidth for set rem - feat(mpp-service): add report file size functions - feat(extended-lib): mpp runtime vendor - feat(sdk): new api bn.addPhoneCalendar & bn.addPhoneRepeatCalendar - feat(cli): add meta info indicator and every day tip - feat(sdk): add new svg component demo - feat(sdk): not set dataurl on style change - feat(sdk): w3w timeline monitor - feat(sdk): flutter svg class support - feat(sdk): add ios timeline log fit regexp - feat(sdk): virtualList support size by function - feat(sdk): remove set rem in flutter - feat(sdk): add createEventSource support for IDE - feat(sdk): add `max-lines` for text-span - feat(sdk): support page preload - feat(sdk): negotiation scroll with native on Android - feat(extended-lib): use dynamicExtendedLib for all the libs and remove upload builtIn lib - feat(sdk): suspend & resume lifecycle ### Misc - Revert "fix(sdk): export bmp component utils" ## [4.49.0] 2025-08-14 **Download: [4.49.0(1.85 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.49.0.zip)** ### Bug Fixes - fix(sdk): fix swiper loop mode & scroll view style - fix(sdk): fix intersection observer relative info not work ### Features - feat(sdk): support share v2 api - feat(sdk): add formatter attribute - feat(sdk): menuBts for flutter markdown - feat(sdk): video poster - feat(sdk): support locked config for sortableitem - feat(cli): support home page widget preview - feat(mpp-service): update ai router payload - feat(mpp-service): ai router solution ## [4.48.1] 2025-08-04 **Download: [4.48.1(1.85 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.48.1.zip)** ### Bug Fixes - fix(sdk): fix swiper loop mode & scroll view style ## [4.48.0] 2025-07-25 **Download: [4.48.0(1.85 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.48.0.zip)** ### Bug Fixes - fix(sdk): relaunch deeplink issue - fix(sdk): fix swiper autoplay - Fix/swiper 0708 - fix(sdk): deeplink with data loader issue - fix(sdk): exports utils - fix(sdk): export bmp component utils - fix(sdk): scroll X in scroll Y ### Features - feat(sdk): revert autoheight default value to false - feat(sdk): swiper autoHeight - feat(sdk): mp plugin support AbortSignal - feat(sdk): add require error log - feat(cli): bundle watch process not exiting correctly - feat(cli): add error handler for ios debug target query - feat(cli): support inspect webview/webf with native devtool protocol message ### Misc - Revert "fix(sdk): export bmp component utils" ## [4.47.1] 2025-07-21 **Download: [4.47.1(1.84 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.47.1.zip)** ### Bug Fixes - fix(sdk): scroll X in scroll Y (#2251) ## [4.47.0] 2025-07-07 **Download: [4.47.0(1.84 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.47.0.zip)** ### Bug Fixes - fix(sdk): expose the error before app init ### Features - feat(sdk): support nested scroll view - feat(sdk): blank detector - feat(sdk): support typewriter effect for flutter markdown - feat(sdk): support playsinline for video - feat(sdk): use \_\_mp_runtime_config.screenWidth for set rem - feat(mpp-service): add report file size functions - feat(extended-lib): mpp runtime vendor - feat(sdk): new api bn.addPhoneCalendar & bn.addPhoneRepeatCalendar - feat(cli): add meta info indicator and every day tip - feat(sdk): add new svg component demo ## [4.46.0] 2025-06-13 **Download: [4.46.0(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.46.0.zip)** ### Bug Fixes - fix(sdk): hide home button api - fix(server-side-bundle): add bundler as dep ### Features - feat(sdk): not set dataurl on style change - feat(sdk): w3w timeline monitor - feat(sdk): flutter svg class support - feat(sdk): add ios timeline log fit regexp - feat(sdk): virtualList support size by function - feat(sdk): remove set rem in flutter - feat(sdk): add createEventSource support for IDE - feat(sdk): add `max-lines` for text-span - feat(sdk): support page preload - feat(sdk): negotiation scroll with native on Android - feat(extended-lib): use dynamicExtendedLib for all the libs and remove upload builtIn lib ## [4.45.5] 2025-06-12 **Download: [4.45.5(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.45.5.zip)** ### Misc - Revert "feat(sdk): remove set rem in flutter" ## [4.45.4] 2025-05-26 **Download: [4.45.4(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.45.4.zip)** ### Bug Fixes - fix(sdk): add svg style filter - fix(sdk): fix page-frame ### Features - feat(sdk): remove set rem in flutter ## [4.45.3] 2025-05-23 **Download: [4.45.3(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.45.3.zip)** ### Bug Fixes - fix(server-side-bundle): add bundler as dep ### Features - feat(sdk): support page preload - feat(sdk): negotiation scroll with native on Android - feat(extended-lib): use dynamicExtendedLib for all the libs and remove upload builtIn lib ## [4.45.3] 2025-05-23 **Download: [4.45.3(1.80 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.45.3.zip)** ### Features - feat(sdk): remove set rem in flutter ## [4.45.2] 2025-05-21 **Download: [4.45.2(1.73 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.45.2.zip)** ### Bug Fixes - fix(sdk): add svg style filter ## [4.45.1] 2025-05-19 **Download: [4.45.1(1.73 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.45.1.zip)** ### Bug Fixes - fix(sdk): fix page-frame ## [4.44.4] 2025-05-19 **Download: [4.44.4(1.73 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.44.4.zip)** ### Bug Fixes - fix(sdk): fix page-frame ## [4.45.1] 2025-05-19 **Download: [4.45.1(1.73 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.45.1.zip)** ### Bug Fixes - fix(sdk): fix page-frame ## [4.44.3] 2025-05-16 **Download: [4.44.3(1.73 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.44.3.zip)** ## [4.45.0] 2025-05-15 **Download: [4.45.0(1.73 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.45.0.zip)** ### Features - feat(sdk): suspend & resume lifecycle ## [4.1043.1] 2025-05-12 **Download: [4.1043.1(1.73 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.1043.1.zip)** ### Bug Fixes - fix(sdk): support multiple chart instances with same chart id when work with swiper - fix(sdk): observer doesn't work - fix(sdk): set scroll top not work / request support enableCache - fix(sdk): `show-scrollbar` doesn't work ### Features - feat(sdk): support keyboard accessory item - feat(sdk): remove sync api - feat(sdk): domtoimage can ignore error when image not exist or load error - feat(sdk): scrollview support enableBackToTop - feat(sdk): showErrorPage support auto detect rendererId - feat(sdk): flutter scrollView add events - feat(cli): achieve pkg stability & log process stability optimization - feat(host): support five themes - feat(cli): support mcp refresh - feat(sdk): remove hack worker patch - feat(sdk): add dark_midnight support - feat(bundler): support polyfill self and XMLHttpRequest - feat(bundler): dynamic path by env. BUNDLER_PATCH - feat(extended-lib): support extended lib uikit flow - feat(host): support midnight ## [4.44.2] 2025-05-12 **Download: [4.44.2(1.73 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.44.2.zip)** ### Bug Fixes - fix(sdk): support multiple chart instances with same chart id when work with swiper ## [4.44.1] 2025-05-07 **Download: [4.44.1(1.73 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.44.1.zip)** ### Bug Fixes - fix(sdk): observer doesn't work ## [4.44.0] 2025-05-02 **Download: [4.44.0(1.73 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.44.0.zip)** ### Bug Fixes - fix(sdk): set scroll top not work / request support enableCache - fix(sdk): `show-scrollbar` doesn't work ### Features - feat(sdk): support keyboard accessory item - feat(sdk): remove sync api - feat(sdk): domtoimage can ignore error when image not exist or load error - feat(sdk): scrollview support enableBackToTop - feat(sdk): showErrorPage support auto detect rendererId - feat(sdk): flutter scrollView add events - feat(cli): achieve pkg stability & log process stability optimization - feat(host): support five themes - feat(cli): support mcp refresh - feat(sdk): remove hack worker patch - feat(sdk): add dark_midnight support - feat(bundler): support polyfill self and XMLHttpRequest - feat(bundler): dynamic path by env. BUNDLER_PATCH - feat(extended-lib): support extended lib uikit flow - feat(host): support midnight ## [4.1043.0] 2025-04-18 **Download: [4.1043.0(1.72 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.1043.0.zip)** ## [4.43.1] 2025-04-16 **Download: [4.43.1(1.72 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.43.1.zip)** ### Bug Fixes - fix(sdk): domtoimage image url corner cases ### Features - feat(sdk): add dark_midnight support for prerender ## [4.43.0] 2025-04-10 **Download: [4.43.0(1.72 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.43.0.zip)** ### Bug Fixes - fix(sdk): flutter getAttribute polyfill - fix(sdk): fix input textarea type adjustPosition ### Features - feat(sdk): alpha chart for editor - feat(sdk): new component flutter markdown - feat(sdk): add `` & `` components - feat(sdk): support get prefetch data synchronous - feat: update process-md-paths - feat(cli): log process status indicator - feat: update md jobs - feat: add job to convert md path - feat(cli): filter standalone-chunks while addEntry - feat(sdk): input support max-digits-length - feat(cli): use release version devtool - feat(sdk): add runtime-plugin-create-event-source - feat(cli): chrome devtools Integration - console - feat: update llms.txt title and filter docs - feat: add upload-docs-md job ## [4.42.2] 2025-04-02 **Download: [4.42.2(1.72 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.42.2.zip)** ## [4.42.1] 2025-03-25 **Download: [4.42.1(1.72 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.42.1.zip)** ### Bug Fixes - fix(sdk): flutter getAttribute polyfill ## [4.42.0] 2025-03-21 **Download: [4.42.0(1.72 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.42.0.zip)** ### Bug Fixes - fix(cli): missing build start callback in bundleWatch - fix(sdk): add LCP report target - fix(sdk): drawer component visible when mounted - fix(mpp-service): fix qjs build for Andriod - fix(demo): pika no longer support `independent` ### Features - feat(cli): rebundle while refresh - feat(cli): improve achieve stability - feat(cli): adjust glob params - feat(cli): manual update qjsc version - feat(cli): add syncPackInclude flag - feat(bmp): add direction type for sortable - feat(runtime): add api `fs.removeSavedFile` - feat(demo): add more chose file or media demo ## [4.41.7] 2025-03-20 **Download: [4.41.7(1.71 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.41.7.zip)** ### Bug Fixes - fix(sdk): duplicated route change ## [4.41.6] 2025-03-19 **Download: [4.41.6(1.71 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.41.6.zip)** ### Bug Fixes - fix(sdk): fix modal navigate on android 2.97(no cherry pick to master) ## [4.41.5] 2025-03-17 **Download: [4.41.5(1.71 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.41.5.zip)** ## [4.41.4] 2025-03-14 **Download: [4.41.4(1.71 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.41.4.zip)** ### Features - feat(sdk): improve drag & sort behaviour ## [4.41.3] 2025-03-10 **Download: [4.41.3(1.71 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.41.3.zip)** ### Performance Improvements - perf: optimize performance by remove rpc log - perf: remove logger to fast lcp metric ## [4.41.3] 2025-03-10 **Download: [4.41.3(1.72 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.41.3.zip)** ### Performance Improvements - perf: remove logger to fast lcp metric ## [4.41.2] 2025-03-07 **Download: [4.41.2(1.72 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.41.2.zip)** ### Bug Fixes - fix(sdk): intersection Observer component undefined issue ## [4.41.1] 2025-03-06 **Download: [4.41.1(1.72 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.41.1.zip)** ### Bug Fixes - fix(sdk): free mode sortable and highlight input rtl issue ## [4.41.0] 2025-03-03 **Download: [4.41.0(1.72 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.41.0.zip)** ### Bug Fixes - fix(sdk): page frame await syntax error - fix op_line_number size increased and get_label_pos not changed on node-qjsc - fix(mp-service): fix track line and column numbers for expressions on… ### Features - feat(sdk): add image info type - feat(sdk): init rem to avoid style issue in flutter renderer - feat(sdk): widget support selectorQuery & intersectionObserver - feat(sdk): implement lite-timeline sdk part - feat(sdk): improve virtual scrollview - feat(sdk): remove webf sync command during the initialization - feat(sdk): support disableCleanStack and cleanOtherStack - feat(sdk): increase priority of framework level message - feat(runtime): add plugin `addEventListenerToBody` - feat(server-side-bundle): add new qjs compilation ## [4.41.0] 2025-02-28 **Download: [4.41.0(1.72 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.41.0.zip)** ### Bug Fixes - fix op_line_number size increased and get_label_pos not changed on node-qjsc - fix(mp-service): fix track line and column numbers for expressions on… ### Features - feat(sdk): add image info type - feat(sdk): init rem to avoid style issue in flutter renderer - feat(sdk): widget support selectorQuery & intersectionObserver - feat(sdk): implement lite-timeline sdk part - feat(sdk): improve virtual scrollview - feat(sdk): remove webf sync command during the initialization - feat(sdk): support disableCleanStack and cleanOtherStack - feat(sdk): increase priority of framework level message - feat(runtime): add plugin `addEventListenerToBody` - feat(server-side-bundle): add new qjs compilation ## [4.40.2] 2025-02-21 **Download: [4.40.2(2.48 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.40.2.zip)** ### Bug Fixes - fix(sdk): domToImage only disabled in flutter ## [4.40.1] 2025-02-19 **Download: [4.40.1(2.48 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.40.1.zip)** ### Bug Fixes - fix(sdk): flutterTarget can not be converted directly ## [4.40.0] 2025-02-10 **Download: [4.40.0(2.48 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.40.0.zip)** ### Bug Fixes - fix(bundler): loadScriptSync issue on android - fix(sdk): svg data url regexp missing text wrap - fix(sdk): fix cursor flashing on devices - fix(sdk): handle non-enumerable CustomEvent properties type and detail - fix(sdk): cherry-pick virtual list hotfix - fix(sdk): clear unreachable rpc promise - fix(sdk): remove skyline sync ui command (#2058) - fix(sdk): mitigate the risk of memory leak - fix(host): loadScriptSync issue - fix(cli): change @shoelace-style/shoelace version to 2 ### Features - feat(sdk): add disable-ios-embed props for ios native input - feat(sdk): get static template theme from body - feat(sdk): support remove skeleton after static templete rendered - feat(sdk): drawer support teleportTo - feat(demo): add fixed page input demo - feat(sdk): flutter svg support - feat(sdk): input component can highlight the inputed content - feat(sdk): flutter deprecated textarea add `cursor-spacing` - feat(sdk): support auto zip sdk in watch mode - feat(cli): add socket status indicator - feat(bundler): support standalone-chunks ## [4.39.8] 2025-01-29 **Download: [4.39.8(2.57 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.39.8.zip)** ### Bug Fixes - fix(sdk): changelog script ## [4.39.7] 2025-01-27 **Download: [4.39.7(2.47 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.39.7.zip)** ### Bug Fixes - fix(sdk): remove skyline sync ui command ## [4.38.7] 2025-01-24 **Download: [4.38.7(2.57 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.38.7.zip)** ### Bug Fixes - fix(sdk): disable scrolling when scroll into view ## [4.37.11] 2025-01-24 **Download: [4.37.11(2.56 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.37.11.zip)** ### Bug Fixes - fix(sdk): disable scrolling when scroll into view ## [4.39.6] 2025-01-24 **Download: [4.39.6(2.57 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.39.6.zip)** ### Features - feat(sdk): disable scrolling when scroll into viewe ## [4.38.6] 2025-01-23 **Download: [4.38.6(2.57 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.38.6.zip)** ### Bug Fixes - fix(sdk): clear unreachable rpc promise ### Features - feat(sdk): native-input cursor issue ## [4.37.10] 2025-01-23 **Download: [4.37.10(2.56 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.37.10.zip)** ### Bug Fixes - fix(sdk): clear unreachable rpc promise ### Features - feat(sdk): native-input cursor issue ## [4.37.10] 2025-01-23 **Download: [4.37.10(2.56 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.37.10.zip)** ### Bug Fixes - fix(sdk): clear unreachable rpc promise ## [4.38.6] 2025-01-23 **Download: [4.38.6(2.57 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.38.6.zip)** ### Bug Fixes - fix(sdk): clear unreachable rpc promise ## [4.39.5] 2025-01-23 **Download: [4.39.5(2.57 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.39.5.zip)** ### Bug Fixes - fix(sdk): clear unreachable rpc promise ## [4.39.4] 2025-01-21 **Download: [4.39.4(2.57 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.39.4.zip)** ### Bug Fixes - fix(sdk): mitigate the risk of memory leak ## [4.38.5] 2025-01-21 **Download: [4.38.5(2.57 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.38.5.zip)** ### Bug Fixes - fix(sdk): mitigate the risk of memory leak ## [4.37.9] 2025-01-21 **Download: [4.37.9(2.56 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.37.9.zip)** ### Bug Fixes - fix(sdk): mitigate the risk of memory leak ## [4.38.4] 2025-01-21 **Download: [4.38.4(2.57 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.38.4.zip)** ### Bug Fixes - fix(sdk): 438 virtual list hotfix 0120 ## [4.37.8] 2025-01-21 **Download: [4.37.8(2.56 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.37.8.zip)** ### Bug Fixes - fix(sdk): virtual list hotfix 0120 ## [4.39.3] 2025-01-20 **Download: [4.39.3(2.57 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.39.3.zip)** ### Bug Fixes - fix(sdk): 439 virtual list hotfix 0120 ## [4.38.4] 2025-01-20 **Download: [4.38.4(2.57 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.38.4.zip)** ### Bug Fixes - fix(sdk): 438 virtual list hotfix 0120 ## [4.37.8] 2025-01-20 **Download: [4.37.8(2.56 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.37.8.zip)** ### Bug Fixes - fix(sdk): virtual list hotfix 0120 ## [4.39.2] 2025-01-17 **Download: [4.39.2(2.50 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.39.2.zip)** ### Features - feat(sdk): view component add events `onAppear&onIntersectionChange&o… ## [4.39.1] 2025-01-17 **Download: [4.39.1(2.50 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.39.1.zip)** ### Bug Fixes - fix(sdk): 4.39 virtual list hotfix ## [4.38.3] 2025-01-17 **Download: [4.38.3(2.50 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.38.3.zip)** ## [4.37.7] 2025-01-17 **Download: [4.37.7(2.49 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.37.7.zip)** ## [4.39.0] 2025-01-16 **Download: [4.39.0(2.50 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.39.0.zip)** ### Bug Fixes - fix(bmp): remove requestFullscreen param - fix(sdk): flutter-video context issue ### Features - feat(sdk): add showDiagnosticPage API - feat(sdk): native-input cursor issue - feat(sdk): add flutter-chart component - feat(sdk): catch setTimeout callback error & Handle redundant `Uncaught` errors - feat(cli): support debug mode flag ## [4.38.2] 2025-01-09 **Download: [4.38.2(2.50 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.38.2.zip)** ### Bug Fixes - fix(sdk): flutter-video context issue - fix(sdk): chart should be destroy after unmounted - fix(sdk): enable placeholder for flutter ## [4.38.1] 2025-01-03 **Download: [4.38.1(2.50 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.38.1.zip)** ### Bug Fixes - fix(sdk): chartActionQueue cache with id and monitor LCPElement payload ### Performance Improvements - perf: remove getBoundingClientRect in flutter widget and nativeComp ## [4.38.0] 2024-12-26 **Download: [4.38.0(2.50 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.38.0.zip)** ### Bug Fixes - fix(sdk): adjust unload timming - fix(sdk): native input with number type issue - fix(cli): ide-cli pnpm dep package.json resolve failed ### Features - feat(sdk): `MP.onError` message format & `MP.lifecycle` throw error - feat(sdk): add params in chooseFile - feat(sdk): scrollview support flex height virtual list - feat(sdk): svg inline tag performence improve - feat(bmp): `` support events - feat(sdk): `` support switching animation - feat(sdk): add `flutter-video` component - feat(sdk): throw bmp app `onError` - feat(sdk): add `` component - feat(extended-lib): update react/react-dom 18.3.1 - feat(sdk): echarts tooltip formatter support function - feat(cli): ide cli build failed not catch - feat(bmp): `PickerView` add options `maskClass|maskStyle|indicatorClass|indicatorStyle` - feat(cli): fix hot reload & change package name to ide-cli ## [4.37.6] 2024-12-19 **Download: [4.37.6(2.48 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.37.6.zip)** ## [4.37.5] 2024-12-19 **Download: [4.37.5(2.48 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.37.5.zip)** ### Bug Fixes - fix(sdk): svg object.hasown not found ## [4.37.4] 2024-12-17 **Download: [4.37.4(2.48 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.37.4.zip)** ### Features - feat(sdk): svg improve inline tag support ## [4.37.3] 2024-12-12 **Download: [4.37.3(2.48 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.37.3.zip)** ### Bug Fixes - fix(sdk): remove repeat effect when worker data update ## [4.36.3] 2024-12-12 **Download: [4.36.3(2.43 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.36.3.zip)** ### Features - feat(sdk): add skeleton remove point ## [4.36.3] 2024-12-11 **Download: [4.36.3(2.48 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.36.3.zip)** ### Bug Fixes - fix(sdk): trigger renderEffect before componentinit to fix patch issues - fix(sdk): fix page stack update timing - fix(sdk): run setdata callback after vue nexttick - fix(bmp): update type `BnInputProps&BnTextareaProps` ### Features - feat(sdk): add remove skeleton point - feat: sortable component - feat(sdk): flutter-scrollview add `refresher` props - feat:(sdk): builtin svg component - feat(sdk): deprecated textarea autoHeight support - feat(ide-cli): preview functions for binance devtool - feat(sdk): create chart context support options params - feat(sdk): DeprecatedTextarea add `autocorrect` & `autocapitalize` - feat(sdk): add scrollstart scrollend to scrollview - feat(sdk): add `flutter-container` - feat(sdk): add `option.url` in applyUpdate ### Performance Improvements - perf: enhance scroll performance by reduce binding getter from event target ### Misc - Revert "chore: @mp/bundler dev" ## [4.37.2] 2024-12-10 **Download: [4.37.2(2.48 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.37.2.zip)** ### Bug Fixes - fix(sdk): hotfix 4.37.2 ## [4.37.1] 2024-12-09 **Download: [4.37.1(2.48 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.37.1.zip)** ### Bug Fixes - fix(sdk): refresher event detail not provide the flutterTarget as expect ## [4.37.0] 2024-12-05 **Download: [4.37.0(2.48 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.37.0.zip)** ### Bug Fixes - fix(sdk): widget load timeline - fix(sdk): flutter deprecated-textarea autoheight style error - fix(sdk): trigger renderEffect before componentinit to fix patch issues - fix(sdk): fix page stack update timing - fix(sdk): run setdata callback after vue nexttick - fix(bmp): update type `BnInputProps&BnTextareaProps` ### Features - feat(sdk): sortable support dark mode - feat: sortable component - feat(sdk): flutter-scrollview add `refresher` props - feat:(sdk): builtin svg component - feat(sdk): deprecated textarea autoHeight support - feat(ide-cli): preview functions for binance devtool - feat(sdk): create chart context support options params - feat(sdk): DeprecatedTextarea add `autocorrect` & `autocapitalize` - feat(sdk): add scrollstart scrollend to scrollview - feat(sdk): add `flutter-container` - feat(sdk): add `option.url` in applyUpdate ### Performance Improvements - perf: enhance scroll performance by reduce binding getter from event target ### Misc - Revert "chore: @mp/bundler dev" ## [4.36.2] 2024-11-27 **Download: [4.36.2(2.43 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.36.2.zip)** ### Bug Fixes - fix(sdk): resolve IntersectionObserver is undefined issue ### Features - feat(sdk): expose response for native component ## [4.36.1] 2024-11-20 **Download: [4.36.1(2.43 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.36.1.zip)** ### Bug Fixes - fix(sdk): webview instance id should not repeat ## [4.36.0] 2024-11-15 **Download: [4.36.0(2.43 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.36.0.zip)** ### Bug Fixes - fix(sdk): change handlePaste defaultValue - fix(sdk): remove native component background color - fix(sdk): flutter-image remove eventListener ### Features - feat(sdk): add switch tab options in api - feat(sdk): add timeformat api - feat(sdk): add showBackButton api - feat(sdk): `native-textarea` add onPaste - feat(sdk): `native-textarea` add `alwaysEmbed` - feat(sdk): add the value of input type `decimals` - feat(sdk): flutter-deprecated-textarea add `autoFocus` ## [4.35.2] 2024-11-08 **Download: [4.35.2(2.43 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.35.2.zip)** ### Bug Fixes - fix(sdk): check whether to use patch - fix(sdk): release flutter image load - fix(sdk): wrap inline element with bn-span for bn-markdown ### Misc - Revert "chore: revert ui command" ## [4.35.1] 2024-10-31 **Download: [4.35.1(2.43 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.35.1.zip)** ### Bug Fixes - fix(sdk): markdown paragraph use bn-view, strong/em use bn-text ## [4.35.0] 2024-10-25 **Download: [4.35.0(2.43 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.35.0.zip)** ### Bug Fixes - fix(sdk): support inlineLayout for skyline - fix(sdk): flutter scroll refresher background color - fix(sdk): android quickjs unsupport Unicode Property Escapes - fix(sdk): cherry pick webview message issue - fix(sdk): re-publish @mp/runtime-plugin-enable-sheet-gesture - fix(sdk): fix cursor issue - fix(runtime): premature return issue in ide enviroment's show-modal api - fix(sdk): editor pos nodeBefore return real textContent if node is nonTextNode - fix(sdk): `deprecated-textarea` support force update - fix(sdk): deprecated input does not update when is composing - fix(sdk): jarvis input does not update correctly ### Features - feat(sdk): new api page.updateRouteOptions - feat(sdk): `DeprecatedTextarea` support `cursor/autoFocus/selection-start/selection-end` - feat(demo): add error handler bot modal demo - feat(sdk): use tap for skyline - feat(sdk): add tab-switched api - feat(sdk): update caniuse api - feat(sdk): support multi pages in tabbar - feat(sdk): webview clearScrollStatus, invoke api - feat(sdk): add sticky-header & stick-section - feat(sdk): add `` - feat(sdk): setup markdown on flutter - feat(sdk): new api enable enableSheetGesture - feat(extended-lib): expose buildIn libs for server side bundle ## [4.34.7] 2024-10-25 **Download: [4.34.7(2.42 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.34.7.zip)** ### Bug Fixes - fix(sdk): support tap and inlineLayout for skyline ## [4.34.6] 2024-10-22 **Download: [4.34.6(2.42 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.34.6.zip)** ### Bug Fixes - fix(sdk): android 7 quickjs not support Unicode Property Escapes ## [4.34.5] 2024-10-15 **Download: [4.34.5(2.42 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.34.5.zip)** ### Bug Fixes - fix(sdk): `deprecated-textarea` support force update ## [4.34.4] 2024-10-11 **Download: [4.34.4(2.42 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.34.4.zip)** ### Features - feat(sdk): web-view-post-message event handler ## [4.34.3] 2024-10-10 **Download: [4.34.3(2.42 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.34.3.zip)** ### Features - feat(sdk): setup markdown on flutter ## [4.34.2] 2024-10-09 **Download: [4.34.2(2.38 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.34.2.zip)** ### Bug Fixes - fix(sdk): message for createwebview api instance ## [4.33.3] 2024-10-09 **Download: [4.33.3(2.20 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.33.3.zip)** ### Bug Fixes - fix(sdk): hotfix 4.33.3 deprecated textarea ## [4.34.1] 2024-10-09 **Download: [4.34.1(2.38 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.34.1.zip)** ### Bug Fixes - fix(sdk): flutter deprecated textarea when composing - fix(sdk): flutter deprecated textarea ## [4.34.0] 2024-10-07 **Download: [4.34.0(2.38 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.34.0.zip)** ### Bug Fixes - fix(sdk): fix webview message action not work - fix(sdk): native list view conflict with sliver style - fix(automator): add timeout when run automator ### Features - feat(host): align response with native - feat(sdk): flutter text component - feat(sdk): update markdown & pika version update - feat(sdk): support readme feature - feat(sdk): add 2 components `ContextMenu` & `ContextMenuItem` - feat(sdk): add `` component & lottie-context - feat(bundler): emit handlePageBundled when skeleton build finish - feat(bundler): upgrade webpack to support Node >=18 ## [4.33.2] 2024-09-19 **Download: [4.33.2(2.20 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.33.2.zip)** ### Bug Fixes - fix: add FlutterImage switch and remove FlutterSrollView type=list props ## [4.33.2] 2024-09-19 **Download: [4.33.2(2.38 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.33.2.zip)** ### Bug Fixes - fix(sdk): native list view conflict with sliver style - fix(automator): add timeout when run automator ### Features - feat(sdk): add `` component & lottie-context - feat(bundler): emit handlePageBundled when skeleton build finish - feat(bundler): upgrade webpack to support Node >=18 ## [4.33.1] 2024-09-17 **Download: [4.33.1(2.20 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.33.1.zip)** ## [4.33.0] 2024-09-13 **Download: [4.33.0(2.20 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.33.0.zip)** ### Bug Fixes - fix(sdk): fix catchmove not work - fix(sdk):add textarea placeholder class prop - fix(sdk): fix component patch error messsage - fix(sdk): fix drawer error and support accelaration - fix(lib): fix event channel type - fix(bundler): bundle watch mode should copy ignore files - fix(sdk): scroll y on scrollView is not works - fix(sdk): fix textarea props and type ### Features - feat(demo): error handler demo - feat(sdk): add deeplink target type - feat(sdk): hack textarea with **BN_IGNORE_IS_COMPOSING** id - feat(extended-lib): update react qjs - feat(sdk): add component `flutter-image` - feat(demo): add style inject demo page - feat(sdk): add component flutter-scroll-view - feat(sdk): add plugin `runtime-plugin-update-page-query` - feat(sdk): add type `injected` for bmp-component - feat(sdk): add plugin `runtime-plugin-control-button` ### Misc - Revert "fix(sdk): vnode patch issues " (#1786) (#1796) ## [4.32.1] 2024-08-30 **Download: [4.32.1(2.20 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.32.1.zip)** ### Misc - Revert "fix(sdk): vnode patch issues " (#1786) ## [4.32.0] 2024-08-23 **Download: [4.32.0(2.20 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.32.0.zip)** ### Bug Fixes - fix(sdk): vnode patch issues - fix(sdk): navigate to type - fix(sdk): delay page set to make sure buforeRouteChange done - fix(bundler): disable sourcemap to reduce memory ### Features - feat(sdk): drawer component - feat(bundler): support static script, do not bundle into \_app.js and \_common.js - feat(bundler): mark build is done before send pageBundled - feat(bundler): add entry must trigger a rebuild - feat(sdk): scroll view support extra data prop - feat(sdk): performance babel plugin log format with timeline - feat(sdk): flutter scroll-view - feat(bundler): update watch page utils - feat(bundler): support ignore qjs options - feat(bundler): skeleton create style tags by script to avoid webf issues - feat(sdk): remove game script in sdk - feat(sdk): flutter scroll view - feat(sdk): add props for input - feat(bundler): update bundler for host - feat(doc): update doc - feat(demo): add input unfocuse issue - feat(sdk): lcp element timeline metrics ## [4.31.1] 2024-08-02 **Download: [4.31.1(2.42 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.31.1.zip)** ### Bug Fixes - fix: add worker plugin ## [4.31.0] 2024-08-02 **Download: [4.31.0(2.42 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.31.0.zip)** ### Bug Fixes - fix(lib): fix bmp component types - fix(bundler): fix expression bundler ### Features - feat(sdk): choose image support compression threshold - feat(sdk): webview scrollChange event - feat(sdk): add logger for timeline log analyze - feat(sdk): scrollView skyline type list property support - feat(sdk): input prop disablePaste - feat(bundler): support bns in base.bxml and pika compile mode - feat(sdk): editor chart ui revamp - feat(sdk): support create worker - feat(lib): add type of Script to bmp-components ## [4.30.0] 2024-07-12 **Download: [4.30.0(2.42 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.30.0.zip)** ### Bug Fixes - fix(sdk): native component webview message - fix(sdk): native event in worker - fix(sdk): fix webview component - fix(sdk): intersectionObserver margin - fix(sdk): eventhandler of chart component - fix(extended-lib): ethers Event identifier duplicated and getGlobal function error ### Features - feat(sdk): webview component event api in queryselector - feat(sdk): support navigate api with animated - feat(sdk): bn.onCopy Api on Android - feat(host): export workerEnvCode for host - feat(extended-lib): upload bitcoinjs-lib & solana/web3.js - feat(extended-lib): upload ethers-5.5.4.js ## [4.29.0] 2024-06-24 **Download: [4.29.0(2.42 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.29.0.zip)** ### Bug Fixes - fix(sdk): webview sdk only send invoke message - fix(sdk): image to figure will insert a new paragraph before the figure - fix(sdk): cursor is wired when editor tap keyboard enter ### Features - feat(sdk): new api for webview component - feat(sdk): api show setting - feat(sdk): support fontFamily for native-input and native-textarea - feat(extended-lib): upload react-dom 18.2.0 - feat(sdk): remove load skeleton - feat(sdk): add onCopy event for text component - feat: mini program performance babel plugin - feat(sdk):add ut coverage 98% ## [4.28.0] 2024-05-31 **Download: [4.28.0(2.42 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.28.0.zip)** ### Bug Fixes - fix: update render cache doc id - fix(extended-lib): resolve path not a module ### Features - feat(demo): add log for skyline debug & extended-lib should keep the built-in libs for cicd & ide - feat(extended-lib): remove built-in upload and fix getUrl data not send - feat(extended-lib): support web3 libs - feat(sdk): richtext support a href - feat(sdk): add page name to performance point - feat(sdk): widget props support functions in deeper obj - feat(sdk): webview status and invoke api - feat(sdk): add ut and increase coverage to 96.88% - feat(sdk): support dynamic rendering cache - feat(sdk): defer for taro useReady - feat(sdk): editor chart insert should focus next line ## [4.27.0] 2024-05-10 **Download: [4.27.0(2.42 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.27.0.zip)** ### Bug Fixes - fix(sdk): image should not add appid for bn protocal src in widget - fix(sdk): page query not ready when onload - fix(extended-lib): postpublish script throw error ### Features - feat(sdk): api getrandomvalues - feat(sdk): widgetslot props can use functions start with 'on' - feat(plugin): sdk support w3w evm configurable - feat(sdk): add flutter input comp - feat(lib): add getWidgetId and try get ctx from current.widget - feat(sdk): widget can load base.bxml in target app - feat(sdk): api hide back button - feat(sdk): editor echart card - feat(sdk): cross app rpc support sync action - feat(sdk): bump - feat(host): support big int ## [4.26.2] 2024-04-23 **Download: [4.26.2(2.41 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.26.2.zip)** ### Bug Fixes - fix(sdk): wsw call id ## [4.26.1] 2024-04-22 **Download: [4.26.1(2.41 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.26.1.zip)** ### Features - feat(sdk): web3 plugin use shell app (#1687) ## [4.26.0] 2024-04-19 **Download: [4.26.0(2.41 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.26.0.zip)** ### Bug Fixes - fix(host): support webassembly on host - fix(sdk): hover class not disappear - fix(sdk): create webview support widget - fix(host): widget ref not works and webview size not correct - fix(sdk): chart component need delay to setOptions ### Features - feat(demo):host shell app add basebxml & preload - feat(server-side-bundle): add bytecode full - feat(sdk): api open document - feat(sdk): cross app rpc api - feat(demo): native component demo update - feat(bundler): support widget extended lib - feat(sdk): bns can work on exp - feat(sdk): cherry-pick: delay onReady for tarojs & add more error message info for appjs load - feat(cli): webf lint add new rules - feat(lib): check media query in webf - feat(sdk): taro page await app loaded ## [4.25.1] 2024-04-10 **Download: [4.25.1(2.40 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.25.1.zip)** ### Bug Fixes - fix(sdk): echart no need delay - fix(sdk): delay onReady for tarojs ### Features - feat(sdk): add more error message info for appjs load ## [4.25.0] 2024-03-29 **Download: [4.25.0(2.40 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.25.0.zip)** ### Bug Fixes - fix(extended-lib): add missing deps - fix(sdk): fix createwebview node-bridge issu - fix(sdk): fix bmp-component type ### Features - feat(extended-lib): release to prod - feat(sdk): custom native component - feat(sdk): improve doc 0325 - feat(sdk): add new prop webPreferences - feat(bundler): add solution for dynamic lib - feat(sdk): render earlier for pages with static template configuration ## [4.23.1] 2024-02-21 **Download: [4.23.1(2.40 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.23.1.zip)** ### Bug Fixes - fix(sdk): cherry-pick for hotfix ## [4.23.0] 2024-02-19 **Download: [4.23.0(2.40 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.23.0.zip)** ### Bug Fixes - fix(sdk): when user delete all content web input may act unexpected - fix(sdk): remote-debug env update - fix(sdk): remote debugger resend ready to IDE ### Features - feat(sdk): add error code for widget when renderer destroy during init - feat(sdk): widget can get props without properties define ## [4.22.0] 2024-01-26 **Download: [4.22.0(2.39 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.22.0.zip)** ### Bug Fixes - fix(demo): icon size demo - fix(sdk): label trigger itemClick event for radio and checkbox ### Features - feat(sdk): webf lint adjustment - feat(sdk): add api setPageScrollable - feat(sdk): limit data point max length - feat(sdk): closeWidget can close native opend widget - feat(sdk): editor support \n inside paste content ## [4.21.0] 2024-01-09 **Download: [4.21.0(2.39 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.21.0.zip)** ### Features - feat(sdk): editor link paste with strick whitelist validator - feat(bundler): increase SOURCEMAP_SIZE_LIMIT to 10MB ## [4.20.0] 2023-12-15 **Download: [4.20.0(2.39 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.20.0.zip)** ### Bug Fixes - fix(sdk): flutter gradient issue - fix(bundler): using prettier as formatter ## [4.19.0] 2023-11-24 **Download: [4.19.0(2.39 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.19.0.zip)** ### Bug Fixes - fix(bundler): fix IDE can not reload ### Features - feat(sdk): cherry-pick: add preloadflutterwebview api - feat(sdk): add error code to show error page - feat(sdk): add renderer Type in getCurrentPages api - feat(sdk): createSelectorQuery select support rootPortal options - feat(sdk): add latest version to update event - feat(sdk): editor enter event - feat(sdk): enableCursor for developers to use native cursor ## [4.18.1] 2023-11-22 **Download: [4.18.1(2.39 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.18.1.zip)** ### Features - feat(sdk): add preloadflutterwebview api ## [4.18.0] 2023-11-03 **Download: [4.18.0(2.39 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.18.0.zip)** ### Bug Fixes - fix(sdk): fix webview sdk to compatible with node bridget - fix(cli): fix scroll-speed-limit default value - fix(cli): fix scroll-speed-limit default value - fix(sdk): support input focus and blur action by developers ### Features - feat(sdk): hold atom selection - feat(sdk): web input support inputmode and pattern - feat(bundler): merge widgetconfig to appconfig - feat(sdk): support atom selection - feat(sdk): add scrollSpeedLimit to avoid blank frame of virtual list - feat(sdk): editor support mention and hardBreak ## [4.17.2] 2023-10-23 **Download: [4.17.2(2.39 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.17.2.zip)** ### Bug Fixes - fix(sdk): support input focus and blur action by developers ## [4.17.1] 2023-10-18 **Download: [4.17.1(2.39 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.17.1.zip)** ### Bug Fixes - fix(sdk): END_FIRSTPAGE_APPLAUNCH send pid ### Features - feat(bundler): use js-beautify replace prettier as formater of qjs ## [4.16.3] 2023-10-13 **Download: [4.16.3(2.39 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.16.3.zip)** ### Bug Fixes - fix(sdk): clone data avoid reuse data object when reopen page ## [4.17.0] 2023-10-13 **Download: [4.17.0(2.39 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.17.0.zip)** ### Bug Fixes - fix(sdk): clone data avoid reuse data object when reopen page - fix(sdk): cherry pick 4.16.2 + try catch instance update - fix(sdk): using show-scrollbar disable scrollbar - fix(sdk): iOS cursor always at the edge of the word, selection update event not trigger ### Features - feat(bundler): qjs compared from a formatted js code - feat(lib): bmp-api openWidget add support for convention path - feat(sdk): report error during renderer launching process - feat(sdk): scroll view support scrollWithAnimation and scrollIntoViewAlignment - feat(sdk): support swiper rtl props - feat(sdk): widget support open dialog - feat(tools):webf style linter - feat(sdk): report LCP only after user interacts - feat(sdk): set tab bar list api - feat(lib): refactor WidgetSlot as react component - feat(lib): bmp-react & bmp-component add support for widget ## [4.16.3] 2023-10-13 **Download: [4.16.3(2.39 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.16.3.zip)** ### Bug Fixes - fix(sdk): clone data avoid reuse data object when reopen page ## [4.16.2] 2023-09-27 **Download: [4.16.2(2.38 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.16.2.zip)** ### Bug Fixes - fix(sdk): avoid crash when worker receive invalid tags ## [4.16.1] 2023-09-25 **Download: [4.16.1(2.38 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.16.1.zip)** ### Bug Fixes - fix(sdk): editor link node ## [4.16.0] 2023-09-22 **Download: [4.16.0(2.38 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.16.0.zip)** ### Bug Fixes - fix(sdk): revert swiper located to wrong child when children updated - fix(demo): component-demo use built-in chart - fix(sdk): decode extra data without appid - fix(sdk): swiper located to wrong child when children updated - fix(bundler): fix expression not work on tag in `bn:for` - fix(demo): independent package config - fix(demo): private-close-app require shouldClose payload - fix(bundler): decompress replace unzipper - fix(bundler): bundler watch has 60s cache ### Features - feat(sdk): echarts tooltip support basic dom - feat(sdk): widget in widgetslot support lifecycles - feat(sdk): editor internal plugin link support ## [4.15.1] 2023-09-07 **Download: [4.15.1(2.34 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.15.1.zip)** ### Bug Fixes - fix(sdk): fix call plugin error code ## [4.15.0] 2023-08-31 **Download: [4.15.0(2.34 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.15.0.zip)** ### Bug Fixes - fix(sdk): enbale flutter qjs - fix(sdk): swiper may throw error when disable indicatorDots - fix(sdk): widget props can get in worker - fix(sdk): cursor always jump to the first position when value change from an empty string - fix(sdk): check demo page ci - fix(bundler): source-map issue of swc-loader - fix(sdk): reset transform when refresher unmount ### Features - feat(sdk): add more info to showErrorPage and add widget error report - feat(sdk): export standard error to developers - feat(sdk): bump version - feat(sdk): dynamic widget support props and add openWidget API - feat(sdk): sdk ut to 95% - feat(bundler): build qjs for renderer in flutter - feat(demo): enable flutter - feat(bundler): server side bundle add more files into qjs ## [4.14.0] 2023-08-11 **Download: [4.14.0(1.45 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.14.0.zip)** ### Bug Fixes - fix(sdk): create webview api in mp cannot message - fix(sdk): customize component data not update when return a data getter - fix(cli): webview component onmessage event - fix(sdk): cherry-pick fix web input seqId - fix(sdk): cherry-pick editor remove link and style recover (#1515) - fix(sdk): cherry-pick editor split figure bugs - fix(sdk): object spread syntax error - fix(cli): add webview component, webpack chain error - fix(bundler): lock unzipper version cause new version may lost file - fix(host): block TextEncoder prop ### Features - feat(sdk): editor transform pasted content - feat(demo): pika extendedlib - feat(sdk): scroll-view supports scroll-anchor - feat(sdk): api bn.preloadWebContent to preload webview content advance - Feat/metadata - feat(sdk): editor paste event props - feat(sdk): echart component ## [4.13.1] 2023-07-28 **Download: [4.13.1(1.13 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.13.1.zip)** ### Bug Fixes - fix(sdk): unicode regex issue - fix(sdk): editor remove link and style recover - fix(sdk): object spread syntax error - fix(sdk): editor split figure bugs - fix(sdk): object spread sytax error - fix(sdk): add seqId to web input event ## [4.13.0] 2023-07-26 **Download: [4.13.0(1.14 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.13.0.zip)** ### Bug Fixes - fix(demo): intersection observer usage - fix(sdk): bundler remove touchmove prevent modifer - fix(demo): editor toolbar bottom 0 when platform is not iOS - fix(sdk): iOS native component created failed when container is not visible - fix: cherry-pick from 4.12.1 - fix(sdk): cancel load-script when redirect - fix(lib): add type of removeSkeleton ### Features - feat(sdk): editor selectImage api - feat(mpp-service) add released pr - feat(sdk): support walletkit and init func - feat(demo): add manual to web input public demo ### Misc - Revert "fix(sdk): iOS native component created failed when container is not visible " ## [4.12.1] 2023-07-07 **Download: [4.12.1(1.13 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.12.1.zip)** ### Features - feat: add mamual prop to web input ## [4.12.0] 2023-06-30 **Download: [4.12.0(1.13 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.12.0.zip)** ### Bug Fixes - fix(sdk): font-family should go with system font-family - fix(sdk): domtoimage svg base64 not have datatype - fix(sdk): add export type - fix(demo): fix canvas toTempFilePath - fix(server-side-bundle): remove subpackage prefix of sourceURL - fix(server-side-bundle): sourceURL issue of qjs ### Features - feat(lib): add API removeSkeleton to bmp-react - feat(sdk): control input - feat(server-side-bundle): add sentry project name and releaseid - feat(sdk): split figure into fig-caption and image ### Performance Improvements - perf: add filesystem cache ## [4.11.1] 2023-06-27 **Download: [4.11.1(1.13 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.11.1.zip)** ### Bug Fixes - fix(sdk): domtoimage svg base64 not have datatype (4.11) ## [4.11.0] 2023-06-16 **Download: [4.11.0(1.13 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.11.0.zip)** ### Bug Fixes - fix(sdk): domtoImage local image support for android - fix(demo): fix share demo - fix(sdk): video fullscreenchange on IOS - fix(cli): hack taro catch event - fix(demo): update prefetch image path - fix(mpp-service): newVersionFromServer might be null issue - fix(demo): reset zoom ref when toggle camera position - fix(sdk): dom to image support private static server images - fix(sdk): editorContext insertCoin not works - fix(mpp-service): min versoin should not replace the input version - fix(mpp-service): set min upload version as 0.0.1 - fix(automator): read route of undefined issue - fix(mpp-service): disable contentType when getUploadFileKey - fix(demo): websocket url not work ### Features - feat(server-side-bundle): use file path as sourceURL of qjs - feat(sdk): support udpsocket api - feat(sdk): 🎸 [plugin] add universal web3 provider - feat(sdk): dom to image support native canvas - feat(sdk): editor extension link - feat(sdk,bundler,demo): support skeleton - feat(sdk,bundler,demo): add camera component & createCameraContext API ## [4.10.2] 2023-06-08 **Download: [4.10.2(1.14 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.10.2.zip)** ### Bug Fixes - fix(sdk): fix startCheckPageTimeline error ## [4.10.1] 2023-05-25 **Download: [4.10.1(1.14 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.10.1.zip)** ### Bug Fixes - fix(sdk): renderer service compatitable with es5 ## [4.10.0] 2023-05-23 **Download: [4.10.0(1.10 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.10.0.zip)** ### Bug Fixes - fix(mpp-service): set maxBodyLength & maxContentLength as Infinity wh… - fix(sdk): canIUseCustom support string params - fix(cli): support catch touchend - fix(sdk): fix ths issue about get appConfig & getPage - fix(sdk): callbackify error no stack - fix(sdk): load page frame after load base.bxml success - fix(mpp-service): add contentType filed when upload for security - fix(host): download support put - fix(demo): add private send transaction demo - fix(cli): webview injected not work - fix(demo): webview page not found ### Features - feat(demo): add prefetchRules - feat(sdk): getUserOpenId return token - feat(sdk): editor coin - feat(sdk): editor image scrollIntoView - feat(sdk): editor image default spinner - feat(sdk): Mini Game touch event optimization - feat(bundler): support bxs ## [4.9.2] 2023-05-19 **Download: [4.9.2(1.09 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.9.2.zip)** ### Bug Fixes - fix(sdk): canIUseCustom support string params ## [4.9.1] 2023-05-17 **Download: [4.9.1(1.09 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.9.1.zip)** ### Bug Fixes - fix(sdk): update load script error code ### Features - feat(sdk): use appConfig after init appConfig & add appConfig detection & syncGetPage or asyncGetPage - feat(host): set custom http headers for fetch requests ## [4.9.0] 2023-04-28 **Download: [4.9.0(1.09 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.9.0.zip)** ### Bug Fixes - fix(sdk): figure scrollIntoView should focus on the figure caption - fix(demo): production convertToMPUrl usage - fix(sdk): editor caption selection and image keyboard handler - fix(host): definitions for bn.env - fix(sdk): unhandleRejection support polyfilled promise - fix(sdk): fix edtior editing image error - fix(sdk): init performance observer after worker ready - fix(sdk): editor delete image event stopropagation - fix(sdk): fix load page.js error to report 603505 when webview is des… - fix(demo): fix event-channel demo - fix(demo): on/off pairs - fix(sdk): editor image selection and focus - fix(mpp-service): print the old and new version - fix(demo): bug in navigation demo - fix(sdk): editor image cursor position and delete use touchend event - fix(sdk): update report data object & cancel startupTimeout when load resources - fix(sdk): editor image support update and deletable, hashtag keyboard key unexpected issue - fix(sdk): update load-script payload to ensure the cache is loaded - fix(sdk): update event channel if page init before eventChannel - fix(sdk): fix native input color issues on ios13 - fix(demo): update pika to fix input issue - fix(sdk): update dom to image scale impl and fix image / font issues - fix(sdk): rename getUserOpenId & doc-api - getUserOpenId/getUserKycStatus - fix(host): get-image-info is broken on IDE - fix(host): bn.request support arraybuffer body - fix(demo): radio page issue - fix(sdk): add native-send-appLuanch timer - fix(bundler): css variables rpx to rem align with wechat - fix(sdk): mini game view port size - fix(sdk): getChildrenNode util function - fix(sdk): rendererId zero issue in native ui - fix(bundler): catchmove value should be an exp - fix(sdk): swiper Item blank - fix(demo):fix custom demo textarea maxlength - fix(lib): remove optional chaining from bmp-react - fix(sdk): fix requestBinanceCardInfo error response & cicd - fix(bundler): compile optional chaining when using latest caniuse-lite - fix(sdk): android css transition native component - fix(sdk): fit audio platform api getters/setters on Andriod - fix(sdk): add RootPortal type - fix(sdk): mpc method - fix(lib): update types of bmp-react - fix(sdk): types of bn.call & add RootPortal to bmp-components - fix(demo): caret-color - fix(lib): virtual-list use new bmp packages - fix(sdk): update canIuse info - fix(sdk): cherry pick fix picker view component - fix(lib): @binance/mp-components don't import @tarojs/components - fix(sdk): image reload after src changes - fix(sdk): mini game keyboard event - fix(demo): fix demo navigation bar page - fix(bundler): fix babel env target - fix(demo): api navigation bar input element - fix(sdk): cherry-pick from release/3.14 - fix(runtime): network service setupServices multiple times - fix(automator): update @binance/mp-web for fix some issue and add `sdkPath` option - fix(bundler): launch MP with page of independent subpackage - fix(sdk): Image widthfix/heightFix mode can update size automatically - fix(demo): fix universal-share css - fix(bundler): reorder files in pkg - renderer files first - fix(sdk): fix web canvas width and height - fix(automator): replace parcel with http server to fix the installation issue from BIDS - fix(sdk): selectorQuery return empty when error - fix(runtime): remove BXML spaces - fix(bundler): remove setImmediate polyfill to fix pika MP white screen on iOS - fix(automator): fix some bugs & add `.waitFor` - fix(sdk): native component css - fix(sdk): (cherry-pick) reduce the blank page - fix(runtime): no need to add webview when open new page - fix(demo): input style of storage pages & update privatePrefetchRules - fix(sdk): cherry pick - load-script-progress event when mp background event to lead blank screen - fix(sdk): cherry pick fix location plugin - fix(cli): skip generation of unmatched tags - fix(demo): request pages issue of component-demo - fix(sdk): load \_\_app.js after $ready - fix(sdk): remove generating worker-service-game.qjs - fix(runtime): vibrate shifting bug - fix(demo): show isPrefetch in request pages - fix(cli): mpService should support both function api and object api - fix(mp-web): support absolute path - fix(changelog): changelog bug: 3.14.5-dev.1 & 4.0.2-dev.1 - fix(sdk): add readme for deprecated usage - fix(sdk): cherry pick - await load appJs - fix(sdk): fix image style not work - fix(cli): remove .npmrc and add npm token - fix(cli): duplicate resolve issue of ConditionNamesPlugin - fix(sdk): network service - fix(sdk): ready replace uirenderserviceready - fix(host): create webview files issue - fix(host): support private-request command - fix(runtime): download-file not work - fix(sdk): env undefined - fix(sdk): revoke native buffer issue - fix(mp-web): fix sw.js ready timeline issue - fix(sdk): native-image onload and image bug - fix(runtime): width of scroll-bar should be zero - fix(automator): support download-package rpc - fix(cli): update web host cli - fix(demo): update webgl demo with rgba - fix(demo): payment request use success callback instead - fix(sdk): useNativeImage - fix(mpp-service): copy source-code ignore node_module & hidden files - fix(sdk): fix image and keep **MP_WARN_DEPRECATED** - fix(sdk): gcanvas toDataURL and audio time update event - fix(server-side-bundle): upload bytecode pkg issue - fix(sdk): getUserProfile mini game doesn't need check tap event - fix(demo): native input width zero in android when container is a flex box - fix(sdk): reuqest text no response - fix(bundler): update dependencies to fix pkg-cli - fix(bundler): support error stack link jump of dev mode page.worker.js ### Features - feat(sdk): ut from plugin-location to plugin-request-subscribe-message - feat(sdk): file method support put method - feat(demo): add beforeRouteChange usage to component-demo - feat(sdk,bundler): add show confirm bar for input - feat(sdk): srcollview pulldown refresher - feat(sdk): bids use monitorupload - feat(demo): editor component demo - feat(sdk): remove settimeout for page.show - feat(sdk): page-not-found - feat(sdk): add page-frame-html in sdk - feat(sdk): chooseMedia & chooseFile API - feat(sdk): editor focus and mark - feat(sdk): add startupTimeout & restore time compensation - feat(sdk): editor extension update and docs - feat(sdk): loading progress animation - feat(host): createBufferUrl support svg - feat(demo): add dom to image demo - feat(sdk): method domToImage - feat(sdk): exitMiniProgram support force close - feat(sdk): new api - getuseropenid getuserkycstatus - feat(sdk): editor component & editorContext api - feat(sdk):load resource fail or slowly - feat(demo): control picker view demo - feat(sdk): detect page timeline - feat(host): support pageReadyCallback - feat(sdk): add binance-card-info api - feat(demo): migrate to pika - feat(sdk): jssdk dashboard rename & calculate - feat(sdk): wallet connector use new wallet provider - feat(lib): add WebViewComponent to @binance/bmp-components - feat(demo): add English desc to image mode demo - feat(sdk): remove window info cache for view-base mode - feat(lib): add getCurrentInstance & getTabBar to @binance/bmp-react - feat(sdk): webview component supports message - feat(sdk): add runtime-plugin-mpc - feat(automator): impove `setupProxyMethod` & add test - feat(sdk): create buffer url supports extension option - feat(demo): add audio and write file benchemark - feat(sdk): swiper support previousMargin/nextMargin/snapToEdge - feat(automator): add mock api for automator - feat(lib): bmp-api & bmp-components & bmp-react - feat(sdk): add error log for 603114 - feat(sdk): View support prop: catchMove - feat(demo): images add mode & readFile add length & position config - feat(lib): generate types for @binance/mp-service - feat(sdk): root-portal - feat: integrate automator on CI - feat(sdk): loadFontFace - feat(sdk): file system api use platform api - feat(sdk): expose navigateBackMiniProgram, add mpModalType prop to navigateToMiniProgram - feat(sdk): webview bounce and loading bar - feat(lib): fork implement from @tarojs/components to @binance/mp-components - feat(sdk): create buffer url use platformAPI - feat(sdk): createInnerAudioContext use platform api - feat(demo): fix create buffer url demo - feat(sdk): gcanvas optimazation - feat(demo): add a rendererId 0 issue test case - feat(sdk): demo update & delete appTimeline - feat(sdk): native webview component - feat(demo): runtime benchmark add getAppBaseInfo apis - feat(sdk): (cherry-pick)support caretColor for Input and TextArea components - feat(automator): automator added headless option & refactor `.launch` & demo page - feat(demo): move sync-api-demo to component-demo & update prefetchRules - feat(sdk): api on add to favorites - feat(bundler): generate fileTree for analyzeSource - feat(sdk): first render new fields - feat(runtime): support selecting sdk - feat(sdk): web canvas component - feat(demo): mini game system info demo - feat(sdk): load gcanvas on demand - feat(sdk): add page-frame-resource points - feat(automator): refactor mp-web & inject mp-web to automator - feat(sdk): gcanvas createJSBuffer, less cpu cost - feat(automator): support plugins service to fix service undefined issue - feat(bundler): add **REPORT_POINTS** for renderer - feat(sdk): nezhaRenderPageJs point - feat(automator): allow reloading the mini-program - feat(cli): update publish yml file - feat(sdk): truncate long rpc logs limit length - feat(sdk): shareAppMessage support fallback url - feat(sdk): add debounce to navigator - feat(cli): support conditional exports bmp - feat(sdk): renderer to native page ready - feat(sdk): add param usePrefetchCache to bn.request - feat(demo): release component-demo PROD - feat(sdk): getPerformance support entryType: loadPackage downloadPackage - feat(sdk): scroll-view support showScrollbar - feat(sdk): mg keyboard api - feat(demo): taro version runtime benchmark - feat(demo): virtual list - feat(runtime): support bn.env.USER_DATA_PATH - feat(sdk): remove monitor because native didn't support the commands - feat(sdk): loadScriptSync rpc - feat(sdk): support multiple intersectionObserver - feat(sdk): navigateTo add target external - feat(sdk): update canIUse for new api - feat(runtime): downloa-package add two fields - feat(bundler): add monitor NEZHA_RENDER_PAGE_JS & update sorter of pkg - feat(host): remove canvas useless dep - feat(sdk): remove deprecated items for sdk4.0 - feat(sdk): getSystemInfo cache - feat(server-side-bundle): compile & upload worker code into bytecode when enableBytecode - feat(sdk): bump versions - feat(sdk): bump version for ide deps - feat(sdk): validate current page is tabBar page when call tabBar apis - feat(demo): update prod demo - feat(sdk): plugin createIntersectionObserver and fix selectorQuery setTimeout issue - feat(sdk): detect darkmode for appBaseInfo - feat(sdk): load app js advance after worker send $Ready - feat(sdk): generate bytecode for worker-service - feat(sdk): gcanvas buffer data optimize - feat: native image - feat(bundler): add new package node-qjsc - feat(sdk): getAppBaseInfo & getWindowInfo & getDeviceInfo - feat(runtime): expose updateBackground of create webview service for ide - feat(sdk): $renderer-ready action - feat(sdk): loadScriptSync method ### Misc - Revert "fix(sdk): env undefined" - Revert "Revert "refactor(sdk): remove locationReadyManager " (#888)" (#929) ## [4.8.1] 2023-04-13 **Download: [4.8.1(1.09 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.8.1.zip)** ### Bug Fixes - fix(sdk): fix load page.js error to report 603505 when webview is destroyed ## [4.8.0] 2023-04-07 **Download: [4.8.0(1.09 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.8.0.zip)** ### Bug Fixes - fix(sdk): editor image selection and focus - fix(mpp-service): print the old and new version ### Features - feat(sdk): bids use monitorupload - feat(demo): editor component demo - feat(sdk): remove settimeout for page.show - feat(sdk): page-not-found - feat(sdk): add page-frame-html in sdk - feat(sdk): chooseMedia & chooseFile API ## [4.7.1] 2023-03-23 **Download: [4.7.1(NaN MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.7.1.zip)** ### Bug Fixes - fix(sdk): startuptimeout & try catch getpage & add get page info - fix(demo): bug in navigation demo ### Features - feat(sdk): catch html - feat(sdk): figure ## [4.7.0] 2023-03-17 **Download: [4.7.0(1.1 MB)](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.7.0.zip)** ### Bug Fixes - fix(sdk): editor image cursor position and delete use touchend event - fix(sdk): update report data object & cancel startupTimeout when load resources - fix(sdk): editor image support update and deletable, hashtag keyboard key unexpected issue - fix(sdk): update load-script payload to ensure the cache is loaded - fix(sdk): update event channel if page init before eventChannel - fix(sdk): fix native input color issues on ios13 - fix(demo): update pika to fix input issue - fix(sdk): update dom to image scale impl and fix image / font issues - fix(sdk): rename getUserOpenId & doc-api - getUserOpenId/getUserKycStatus - fix(host): get-image-info is broken on IDE - fix(host): bn.request support arraybuffer body - fix(demo): radio page issue ### Features - feat(sdk): editor focus and mark - feat(sdk): add startupTimeout & restore time compensation - feat(sdk): editor extension update and docs - feat(sdk): loading progress animation - feat(host): createBufferUrl support svg - feat(demo): add dom to image demo - feat(sdk): method domToImage - feat(sdk): exitMiniProgram support force close - feat(sdk): new api - getuseropenid getuserkycstatus - feat(sdk): editor component & editorContext api - feat(sdk):load resource fail or slowly ## [3.14.16] 2023-02-24 **Download: [SDK-3.14.16](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.16.zip)** ### Bug Fixes - fix(sdk): cherry-pick - picker view control mode ([d9a10d59](https://git.toolsfdg.net/fe/mini-program/commit/d9a10d599fb2ab6d7c222c2204917dcd7511a888)) by lawrence.w@binance.com ## [4.6.0] 2023-02-24 **Download: [SDK-4.6.0](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.6.0.zip)** ### Bug Fixes - fix(sdk): add native-send-appLuanch timer ([532dde2e](https://git.toolsfdg.net/fe/mini-program/commit/532dde2e37e8c3ff48cbf655238b88a9a1ff0dcd)) by finley.x@binance.com - fix(bundler): css variables rpx to rem align with wechat ([5fcfd131](https://git.toolsfdg.net/fe/mini-program/commit/5fcfd1319437e3fd52389083be12f459cb53d243)) by dylan.z@binance.com - fix(sdk): mini game view port size ([fc6048f0](https://git.toolsfdg.net/fe/mini-program/commit/fc6048f03ed5b9cb7357654e8a5699124fa38898)) by henry.w@binance.com - fix(sdk): getChildrenNode util function ([7c5764b6](https://git.toolsfdg.net/fe/mini-program/commit/7c5764b60831fa1c194490a907a1ad10e7ded92b)) by henry.w@binance.com - fix(sdk): rendererId zero issue in native ui ([c3d9020b](https://git.toolsfdg.net/fe/mini-program/commit/c3d9020b10630ac6c12f71595fb3c80cd3e7d2cf)) by dylan.z@binance.com - fix(bundler): catchmove value should be an exp ([dc53e87f](https://git.toolsfdg.net/fe/mini-program/commit/dc53e87f6ccb59b859b0eb13171f5038c98910da)) by lawrence.w@binance.com - fix(sdk): swiper Item blank ([7981ff89](https://git.toolsfdg.net/fe/mini-program/commit/7981ff894557f9145b619a68c823252654826014)) by finley.x@binance.com - fix(demo):fix custom demo textarea maxlength ([c28c58aa](https://git.toolsfdg.net/fe/mini-program/commit/c28c58aa2556d9e8eb21ef3b46269461bcf308c4)) by henry.w@binance.com - fix(sdk): controlled picker view ([661aa89a](https://git.toolsfdg.net/fe/mini-program/commit/661aa89ad9c3289ce614f2b77995d4ebf6d08bfa)) by lawrence.w@binance.com ### Features - feat(demo): control picker view demo ([b80c088c](https://git.toolsfdg.net/fe/mini-program/commit/b80c088cd6307f659af3fba713787becc824479c)) by lawrence.w@binance.com - feat(sdk): detect page timeline ([0b1381a4](https://git.toolsfdg.net/fe/mini-program/commit/0b1381a4406d0767f736836a8418aede38ccd44f)) by finley.x@binance.com - feat(host): support pageReadyCallback ([1339544e](https://git.toolsfdg.net/fe/mini-program/commit/1339544ec010a520efab2e822bfe15d4249fdc66)) by dylan.z@binance.com ### Refactor - refactor: remove any type in AppCommandMap ([9b2411bd](https://git.toolsfdg.net/fe/mini-program/commit/9b2411bde6250820403082572e38070d9c9fc443)) by lucifer.l@binance.com ### Internal - chore: bump commit after write files ([9378fed1](https://git.toolsfdg.net/fe/mini-program/commit/9378fed122a9613f50aac333ff8543d12893bbbc)) by dylan.z@binance.com - docs: add api comment for documentation ([7993a741](https://git.toolsfdg.net/fe/mini-program/commit/7993a741307a4049768fcfe771cfbb3ad6231723)) by dylan.z@binance.com - chore: update bump with git auto push ([e25b674f](https://git.toolsfdg.net/fe/mini-program/commit/e25b674f8ed8fd0638bc25122a9d8c6efb223d6d)) by dylan.z@binance.com - chore: change UT coverage scope and threshold ([50820980](https://git.toolsfdg.net/fe/mini-program/commit/50820980c6a0d517e0a19df8d2ed740965c36f40)) by lucifer.l@binance.com - docs: format issue ([05c3cc6e](https://git.toolsfdg.net/fe/mini-program/commit/05c3cc6e632ea84fc316a8db27fa7c9337d2ca24)) by dylan.z@binance.com - docs: update config ([aaae5561](https://git.toolsfdg.net/fe/mini-program/commit/aaae556164f3bd260fbed971c490f090b6327a25)) by dylan.z@binance.com - docs: excited features of the JSCore team 202302 ([1b38cbfe](https://git.toolsfdg.net/fe/mini-program/commit/1b38cbfe6c2344120f532eed76bda7a6990a7fc8)) by dylan.z@binance.com - mpp service support binance us host app ([fb8edeb8](https://git.toolsfdg.net/fe/mini-program/commit/fb8edeb8c6840cc84ef840c6ca84dcfc3a51fd72)) by leo.cc@binance.com ## [4.5.0] 2023-02-03 **Download: [SDK-4.5.0](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.5.0.zip)** ### Bug Fixes - fix(lib): remove optional chaining from bmp-react - fix(sdk): fix requestBinanceCardInfo error response & cicd - fix(bundler): compile optional chaining when using latest caniuse-lite - fix(sdk): android css transition native component ### Features - feat(sdk): add binance-card-info api - feat(demo): migrate to pika - feat(sdk): jssdk dashboard rename & calculate - feat(sdk): wallet connector use new wallet provider - feat(lib): add WebViewComponent to @binance/bmp-components - feat(demo): add English desc to image mode demo - feat(sdk): remove window info cache for view-base mode - feat(lib): add getCurrentInstance & getTabBar to @binance/bmp-react ### Refactor - refactor: throw error for the non-supported apis in IDE ### Internal - chore: update component demo - docs: remove the app.config.json issue since pika will support it - docs: getCurrentInstance query incorrect ## [4.4.0] 2023-01-13 **Download: [SDK-4.4.0](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.4.0.zip)** ### Bug Fixes - fix(sdk): fit audio platform api getters/setters on Andriod - fix(sdk): add RootPortal type - fix(sdk): mpc method - fix(lib): update types of bmp-react - fix(sdk): types of bn.call & add RootPortal to bmp-components - fix(demo): caret-color - fix(lib): virtual-list use new bmp packages - fix(sdk): update canIuse info - fix(sdk): cherry pick fix picker view component - fix(lib): @binance/mp-components don't import @tarojs/components - fix(sdk): image reload after src changes ### Features - feat(sdk): webview component supports message - feat(sdk): add runtime-plugin-mpc - feat(automator): impove `setupProxyMethod` & add test - feat(sdk): create buffer url supports extension option - feat(demo): add audio and write file benchemark - feat(sdk): swiper support previousMargin/nextMargin/snapToEdge - feat(automator): add mock api for automator - feat(lib): bmp-api & bmp-components & bmp-react - feat(sdk): add error log for 603114 - feat(sdk): View support prop: catchMove - feat(demo): images add mode & readFile add length & position config - feat(lib): generate types for @binance/mp-service - feat(sdk): root-portal ### Internal - chore: update config for FAQ - docs: faq about app.config.json - docs(sdk): darkmode - chore(sdk): cherry pick update sdk loading - test: add more unit tests for host ## [3.14.15] 2023-01-10 **Download: [SDK-3.14.15](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.15.zip)** ### Bug Fixes - fix(sdk): cherry pick from native component css ### Internal - cherry-pick(sdk): swiper ## [3.14.14] 2023-01-04 **Download: [SDK-3.14.14](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.14.zip)** ### Bug Fixes - fix(sdk): picker view component ### Features - feat(sdk): add applaunch pid & new point from pageJsEnd to pageReady - feat(sdk): cherry-pick - add error log for 603114 ## [3.14.13] 2022-12-29 **Download: [SDK-3.14.13](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.13.zip)** ### Bug Fixes - fix(sdk): image style not work when set mode to aspectFill ## [3.14.12] 2022-12-26 **Download: [SDK-3.14.12](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.12.zip)** ### Bug Fixes - fix(sdk): update sdk loading ## [4.3.0] 2022-12-22 **Download: [SDK-4.3.0](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.3.0.zip)** ### Bug Fixes - fix(sdk): mini game keyboard event - fix(demo): fix demo navigation bar page - fix(bundler): fix babel env target - fix(demo): api navigation bar input element - fix(sdk): cherry-pick from release/3.14 - fix(runtime): network service setupServices multiple times - fix(automator): update @binance/mp-web for fix some issue and add `sdkPath` option - fix(bundler): launch MP with page of independent subpackage - fix(sdk): Image widthfix/heightFix mode can update size automatically - fix(demo): fix universal-share css ### Features - feat: integrate automator on CI - feat(sdk): loadFontFace - feat(sdk): file system api use platform api - feat(sdk): expose navigateBackMiniProgram, add mpModalType prop to navigateToMiniProgram - feat(sdk): webview bounce and loading bar - feat(lib): fork implement from @tarojs/components to @binance/mp-components - feat(sdk): create buffer url use platformAPI - feat(sdk): createInnerAudioContext use platform api - feat(demo): fix create buffer url demo ### Refactor - refactor: rename host-mp-ide to host-ide ### Internal - chore: remove `yarn playwright install --with-deps` - docs(sdk): integrate with doc-system - chore(package.json): fix installing sqllite3 in macos - chore(package.json): add packageManager field - chore: replace resolve with join - chore(sdk): cherry-pick from 4.2.1 - chore: update version remote and pwd alias - chore: bump local - chore: update prefetch rule of component demo - docs: demos readme ## [3.14.11] 2022-12-19 **Download: [SDK-3.14.11](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.11.zip)** ### Bug Fixes - fix(sdk): appConfig bug in ios while open worker pool ## [4.2.1] 2022-12-15 **Download: [SDK-4.2.1](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.2.1.zip)** ### Features - feat(sdk): add mg page-ready ## [3.14.10] 2022-12-07 **Download: [SDK-3.14.10](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.10.zip)** ### Bug Fixes - fix(sdk): fix renderer-defer lead to blank screen ## [4.2.0] 2022-12-02 **Download: [SDK-4.2.0](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.2.0.zip)** ### Bug Fixes - fix(bundler): reorder files in pkg - renderer files first - fix(sdk): fix web canvas width and height - fix(automator): replace parcel with http server to fix the installation issue from BIDS - fix(sdk): selectorQuery return empty when error - fix(runtime): remove BXML spaces - fix(bundler): remove setImmediate polyfill to fix pika MP white screen on iOS - fix(automator): fix some bugs & add `.waitFor` - fix(sdk): native component css - fix(sdk): (cherry-pick) reduce the blank page - fix(runtime): no need to add webview when open new page - fix(demo): input style of storage pages & update privatePrefetchRules - fix(sdk): cherry pick - load-script-progress event when mp background event to lead blank screen - fix(sdk): cherry pick fix location plugin - fix(cli): skip generation of unmatched tags - fix(demo): request pages issue of component-demo - fix(sdk): load \_\_app.js after $ready - fix(sdk): remove generating worker-service-game.qjs - fix(runtime): vibrate shifting bug - fix(demo): show isPrefetch in request pages ### Features - feat(sdk): gcanvas optimazation - feat(demo): add a rendererId 0 issue test case - feat(sdk): demo update & delete appTimeline - feat(sdk): native webview component - feat(demo): runtime benchmark add getAppBaseInfo apis - feat(sdk): (cherry-pick)support caretColor for Input and TextArea components - feat(automator): automator added headless option & refactor `.launch` & demo page - feat(demo): move sync-api-demo to component-demo & update prefetchRules - feat(sdk): api on add to favorites - feat(bundler): generate fileTree for analyzeSource - feat(sdk): first render new fields - feat(runtime): support selecting sdk ### Refactor - refactor(sdk): plugins including show-leaderboard, storage and tab-bar - refactor(sdk): native ui plugin - refactor(sdk): replace enum with union type - refactor(host): plugin user-info - refactor(host): plugin & remove twoFA demo ### Internal - chore: remove useless message in changelog.md by 'bot' - chore: redirect blank page issue - ci: fix git push tag one by one - chore: add caretColor demo - chore: gen-sdk local ## [3.14.9] 2022-12-01 **Download: [SDK-3.14.9](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.9.zip)** ### Features - feat(sdk): support navigateTo an external link - cherry pick ## [3.14.8] 2022-11-22 **Download: [SDK-3.14.8](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.8.zip)** ### Bug Fixes - fix(sdk): fix native delay app-launch after background and load \_\_app.js fail to lead blank screen ### Features - feat(sdk): nezha render js point ## [4.0.3] 2022-11-18 **Download: [SDK-4.0.3](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.0.3.zip)** ### Bug Fixes - fix(sdk): rendererId start with zero - fix(sdk): cherry pick - fix image style not work - fix(sdk): await load appJs - fix(sdk): env undefined - fix(demo): update webgl demo with rgba - fix(demo): payment request use success callback instead - fix(sdk): useNativeImage - fix(mpp-service): copy source-code ignore node_module & hidden files - fix(sdk): fix image and keep **MP_WARN_DEPRECATED** - fix(sdk): gcanvas toDataURL and audio time update event - fix(server-side-bundle): upload bytecode pkg issue - fix(sdk): getUserProfile mini game doesn't need check tap event - fix(demo): native input width zero in android when container is a flex box - fix(sdk): reuqest text no response - fix(bundler): update dependencies to fix pkg-cli - fix(bundler): support error stack link jump of dev mode page.worker.js ### Features - feat(sdk): support multiple intersectionObserver - feat(sdk): navigateTo add target external - feat(sdk): update canIUse for new api - feat(runtime): downloa-package add two fields - feat(bundler): add monitor NEZHA_RENDER_PAGE_JS & update sorter of pkg - feat(host): remove canvas useless dep - feat(sdk): remove deprecated items for sdk4.0 - feat(sdk): getSystemInfo cache - feat(server-side-bundle): compile & upload worker code into bytecode when enableBytecode - feat(sdk): bump versions - feat(sdk): bump version for ide deps - feat(sdk): validate current page is tabBar page when call tabBar apis - feat(demo): update prod demo - feat(sdk): plugin createIntersectionObserver and fix selectorQuery setTimeout issue - feat(sdk): detect darkmode for appBaseInfo - feat(sdk): load app js advance after worker send $Ready - feat(sdk): generate bytecode for worker-service - feat(sdk): gcanvas buffer data optimize - feat: native image - feat(bundler): add new package node-qjsc - feat(sdk): getAppBaseInfo & getWindowInfo & getDeviceInfo - feat(runtime): expose updateBackground of create webview service for ide - feat(sdk): $renderer-ready action - feat(sdk): loadScriptSync method ### Misc - Revert "Revert "refactor(sdk): remove locationReadyManager " (#888)" (#929) ### Internal - chore(cicd): yaml files - chore(changelog): update changelog for version v3.14.3 - chore(changelog): update changelog for version v4.0.0-dev.3 - chore(runtime): add currentSize filed - chore: update public demo - chore(sdk): automator package rename - chore(changelog): update changelog for version v4.0.0-dev.2 - chore(changelog): update changelog for version v3.14.2 - chore: update public demo - chore: component-demo - chore: bump npm versions - chore(changelog): update changelog for version v4.0.0-dev.1 - chore(changelog): update changelog for version v3.14.1 ## [3.14.7] 2022-11-17 **Download: [SDK-3.14.7](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.7.zip)** ### Features - feat(sdk): add support caretColor style for Input and TextArea components ## [3.14.6] 2022-11-16 **Download: [SDK-3.14.6](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.6.zip)** ### Bug Fixes - fix(sdk): load-script-progress event when mp background event to lead blank screen - fix(sdk): remove generating worker-service-game.qjs ### Internal - chore: add checker for 3.14 - chore: gen-sdk script - chore: update changelog.js ## [4.1.0] 2022-11-16 **Download: [SDK-4.1.0](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.1.0.zip)** ### Bug Fixes - fix(cli): skip generation of unmatched tags - fix(sdk): read-file demo, location api - fix(cli): mpService should support both function api and object api - fix(mp-web): support absolute path - fix(changelog): changelog bug: 3.14.5-dev.1 & 4.0.2-dev.1 - fix(sdk): add readme for deprecated usage - fix(sdk): cherry pick - await load appJs - fix(sdk): fix image style not work - fix(cli): remove .npmrc and add npm token - fix(cli): duplicate resolve issue of ConditionNamesPlugin - fix(sdk): network service - fix(sdk): ready replace uirenderserviceready - fix(host): create webview files issue - fix(host): support private-request command - fix(runtime): download-file not work - fix(sdk): env undefined - fix(sdk): revoke native buffer issue - fix(mp-web): fix sw.js ready timeline issue - fix(sdk): native-image onload and image bug - fix(runtime): width of scroll-bar should be zero - fix(automator): support download-package rpc - fix(cli): update web host cli ### Features - feat(sdk): web canvas component - feat(demo): mini game system info demo - feat(sdk): load gcanvas on demand - feat(sdk): add page-frame-resource points - feat(automator): refactor mp-web & inject mp-web to automator - feat(sdk): gcanvas createJSBuffer, less cpu cost - feat(automator): support plugins service to fix service undefined issue - feat(bundler): add **REPORT_POINTS** for renderer - feat(sdk): nezhaRenderPageJs point - feat(automator): allow reloading the mini-program - feat(cli): update publish yml file - feat(sdk): truncate long rpc logs limit length - feat(sdk): shareAppMessage support fallback url - feat(sdk): add debounce to navigator - feat(cli): support conditional exports bmp - feat(sdk): renderer to native page ready - feat(sdk): add param usePrefetchCache to bn.request - feat(demo): release component-demo PROD - feat(sdk): getPerformance support entryType: loadPackage downloadPackage - feat(sdk): scroll-view support showScrollbar - feat(sdk): mg keyboard api - feat(demo): taro version runtime benchmark - feat(demo): virtual list - feat(runtime): support bn.env.USER_DATA_PATH - feat(sdk): remove monitor because native didn't support the commands - feat(sdk): loadScriptSync rpc ### Refactor - refactor(sdk): migrate wallet-connector plugin - refactor(host): share-menu(sdk & host)and network - refactor(sdk): migrate toast plugin - refactor(host): update manager and webview plugin - refactor(sdk): migrate web3 plugin ### Misc - Revert "fix(sdk): env undefined" ### Internal - chore: 4.1 pr checker - chore(changelog): @binance/mp-cli@2.4.26 - chore(changelog): @binance/mp-automator@1.0.7 - chore(changelog): @binance/mp-web@0.0.21 - chore(mp-web): update start script - chore(changelog): update changelog for version v3.14.5 - chore(changelog): @binance/mp-cli@2.4.25 - chore: fix changelog.md - chore(changelog): update changelog for version v4.1.0-dev.2 - chore(changelog): @binance/mp-cli@2.4.24 - chore(demo): update prefetchRules of component-demo - chore(changelog): @binance/mp-cli@2.4.23 - ci: fix bump exclude checked cache files - chore(changelog): @mp/gen-sdk@1.0.12 - ci: fix wrong git tag versions for manifest and changelog - chore(changelog): update changelog for version v3.14.5 - ci: pass the job if there is nothing to be validated - chore(changelog): @binance/mp-web@0.0.18 - chore(changelog): @binance/mp-web@0.0.17 - docs: update how to fixed log when version validate failed - chore(changelog): update changelog for version v3.14.5-dev.1 - docs(sdk): add docs about yarn bump - chore(changelog): update changelog for version v4.0.2-dev.1 - chore: fix submodule error by removing temp file - chore(changelog): @binance/mp-cli@2.4.22 - chore: bump version issue cause by cicd - chore: local auto bump support - chore(changelog): @binance/mp-cli@2.4.21 - chore: update ci - chore(changelog): update changelog for version v4.0.1 - chore: version validate - chore: rename pipeline name - chore: update npm-publish job - ci: fix release job for git fetch failed on CI - chore: test new job success - chore(changelog): update changelog for version v3.14.4 - chore: bump host deps chain - chore(changelog): update changelog for version v4.0.1-dev.1 - ci: setup ci changelog & release automatically - chore(sdk): bump plugins version - chore(sdk): plugin bump version - chore(sdk): bump versions - chore(sdk): add mg adapter file - chore(changelog): update changelog for version v4.1.0-dev.1 - chore(cicd): migrate prowjobs - chore(changelog): update changelog for version v4.0.0 - chore: noopify commands ## [4.1.0] 2022-11-16 **Download: [SDK-4.1.0](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.1.0.zip)** ### Bug Fixes - fix(sdk): read-file demo, location api - fix(cli): mpService should support both function api and object api - fix(mp-web): support absolute path - fix(changelog): changelog bug: 3.14.5-dev.1 & 4.0.2-dev.1 - fix(sdk): add readme for deprecated usage - fix(sdk): cherry pick - await load appJs - fix(sdk): fix image style not work - fix(cli): remove .npmrc and add npm token - fix(cli): duplicate resolve issue of ConditionNamesPlugin - fix(sdk): network service - fix(sdk): ready replace uirenderserviceready - fix(host): create webview files issue - fix(host): support private-request command - fix(runtime): download-file not work - fix(sdk): env undefined - fix(sdk): revoke native buffer issue - fix(mp-web): fix sw.js ready timeline issue - fix(sdk): native-image onload and image bug - fix(runtime): width of scroll-bar should be zero - fix(automator): support download-package rpc - fix(cli): update web host cli ### Features - feat(sdk): web canvas component - feat(demo): mini game system info demo - feat(sdk): load gcanvas on demand - feat(sdk): add page-frame-resource points - feat(automator): refactor mp-web & inject mp-web to automator - feat(sdk): gcanvas createJSBuffer, less cpu cost - feat(automator): support plugins service to fix service undefined issue - feat(bundler): add **REPORT_POINTS** for renderer - feat(sdk): nezhaRenderPageJs point - feat(automator): allow reloading the mini-program - feat(cli): update publish yml file - feat(sdk): truncate long rpc logs limit length - feat(sdk): shareAppMessage support fallback url - feat(sdk): add debounce to navigator - feat(cli): support conditional exports bmp - feat(sdk): renderer to native page ready - feat(sdk): add param usePrefetchCache to bn.request - feat(demo): release component-demo PROD - feat(sdk): getPerformance support entryType: loadPackage downloadPackage - feat(sdk): scroll-view support showScrollbar - feat(sdk): mg keyboard api - feat(demo): taro version runtime benchmark - feat(demo): virtual list - feat(runtime): support bn.env.USER_DATA_PATH - feat(sdk): remove monitor because native didn't support the commands - feat(sdk): loadScriptSync rpc ### Refactor - refactor(sdk): migrate wallet-connector plugin - refactor(host): share-menu(sdk & host)and network - refactor(sdk): migrate toast plugin - refactor(host): update manager and webview plugin - refactor(sdk): migrate web3 plugin ### Misc - Revert "fix(sdk): env undefined" ### Internal - chore: 4.1 pr checker - chore(changelog): @binance/mp-cli@2.4.26 - chore(changelog): @binance/mp-automator@1.0.7 - chore(changelog): @binance/mp-web@0.0.21 - chore(mp-web): update start script - chore(changelog): update changelog for version v3.14.5 - chore(changelog): @binance/mp-cli@2.4.25 - chore: fix changelog.md - chore(changelog): update changelog for version v4.1.0-dev.2 - chore(changelog): @binance/mp-cli@2.4.24 - chore(demo): update prefetchRules of component-demo - chore(changelog): @binance/mp-cli@2.4.23 - ci: fix bump exclude checked cache files - chore(changelog): @mp/gen-sdk@1.0.12 - ci: fix wrong git tag versions for manifest and changelog - chore(changelog): update changelog for version v3.14.5 - ci: pass the job if there is nothing to be validated - chore(changelog): @binance/mp-web@0.0.18 - chore(changelog): @binance/mp-web@0.0.17 - docs: update how to fixed log when version validate failed - chore(changelog): update changelog for version v3.14.5-dev.1 - docs(sdk): add docs about yarn bump - chore(changelog): update changelog for version v4.0.2-dev.1 - chore: fix submodule error by removing temp file - chore(changelog): @binance/mp-cli@2.4.22 - chore: bump version issue cause by cicd - chore: local auto bump support - chore(changelog): @binance/mp-cli@2.4.21 - chore: update ci - chore(changelog): update changelog for version v4.0.1 - chore: version validate - chore: rename pipeline name - chore: update npm-publish job - ci: fix release job for git fetch failed on CI - chore: test new job success - chore(changelog): update changelog for version v3.14.4 - chore: bump host deps chain - chore(changelog): update changelog for version v4.0.1-dev.1 - ci: setup ci changelog & release automatically - chore(sdk): bump plugins version - chore(sdk): plugin bump version - chore(sdk): bump versions - chore(sdk): add mg adapter file - chore(changelog): update changelog for version v4.1.0-dev.1 - chore(cicd): migrate prowjobs - chore(changelog): update changelog for version v4.0.0 - chore: noopify commands ## [4.0.2] 2022-11-14) **Download: [SDK-4.0.2](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.0.2.zip)** ### Bug Fixes - fix(sdk): cherry pick - fix image style not work - fix(sdk): await load appJs - fix(sdk): env undefined - fix(demo): update webgl demo with rgba - fix(demo): payment request use success callback instead - fix(sdk): useNativeImage - fix(mpp-service): copy source-code ignore node_module & hidden files - fix(sdk): fix image and keep **MP_WARN_DEPRECATED** - fix(sdk): gcanvas toDataURL and audio time update event - fix(server-side-bundle): upload bytecode pkg issue - fix(sdk): getUserProfile mini game doesn't need check tap event - fix(demo): native input width zero in android when container is a flex box - fix(sdk): reuqest text no response - fix(bundler): update dependencies to fix pkg-cli - fix(bundler): support error stack link jump of dev mode page.worker.js - fix(demo): fix benchmark - fix(sdk, demo): check promise polyfill by using \_\_\_mp_polyfill - fix(demo): public demo read file - fix(sdk): native-cover-view not work when using taro - fix(demo): two-fa demo scene data is undefined - fix(demo): pull down refresh not works - fix(sdk): cache promise online with polyfill - fix(sdk): mini game audio adapter - fix: disable ed and add @deprecated flag - fix(sdk): changelog issue - fix(sdk): callbackId could be zero - fix(sdk): input scrollbar css issue on android - fix(sdk): isCache undefined issue - fix(mpp-service): fix status api empty fail message - fix(sdk): add properties on webgl context - fix(sdk): fix timeOrigin 0 issues on IOS14 - fix(runtime): cannot resolve the font with url "bnshare://" - fix(sdk): fix getperformance firstRender - fix: cherry-pick cachePromise of getSystemInfo - fix(sdk): use promise polyfill fix promise task order in ios12 - ios14 - fix(sdk): error code detection of remote debug - fix(sdk): requestAnimationFrame NaN - fix(automator): web cli core apis - fix: add dependency to pass build job - fix(sdk): performance init appLaunch payload - fix: getPerformance first-render - fix(sdk): delete useless report - fix(sdk): loading when expect route-change type - fix(sdk): remove cachePromise to fix ios 13 eventloop issue - fix(sdk): fix: fix to signature error when include specific data struct issue - fix(sdk): remove type check in wallet-connect plugin - fix(sdk): gcanvas texImage2D flushnative - fix(sdk): fix taskify cache fail - fix(sdk): remove canvas service code - fix(sdk): fix applaunch-getPerformance - fix(sdk): fix webview sdk - fix(mpp-service): publish issue - fix(sdk): fix mg api host register - fix(sdk): navigateBackMiniProgram extra data should transform to string - fix(sdk): fix blank screen issue when relaunch because of taskify - fix(demo): public demo - fix(sdk): getCurrentPages error handler - fix(demo): textarea confirm-type - fix(sdk): fetch remote tags with force arg when tag conflict - fix(demo): textarea maxlength caused display issue - fix(sdk): access methods defined within methods property - fix(sdk): fix this problem for '\_setDataMaxSize' of undefined - fix(cli & runtime): useExtendedLib issue - fix(demo): public-demo textarea bug - fix(bundler): if directive not work as non-first attribute - fix(sdk): revert removing of setTimeout hack because of useDidShow issues on IOS - fix(server-side-bundle): set default value of versionSetting - fix(runtime): plainText body not supported - fix(demo): fix crash caused by private request demo - fix(sdk): bug in OnOffManager and add test - fix(sdk): revert changes of performance entry name - fix(demo): callback should not inside function component - fix(bundler): nested component with directive "for" - fix(runtime): set different left for title on different lefticon - fix(mpp-service): remove request body of getApplicationVersions - fix(sdk): request-timeout - fix: webstudio qa test - fix(sdk): tmpl_0_undefined bug lead to a blank page - fix(sdk): remove 120ms timeout of page show, make sure onShow is before onReady - fix(sdk): use logger to enable warn log visible - fix(bundler): disable autoloading postcss config of MP project - fix(sdk): tmpl_0_undefined issue - fix(demo): component-demo-public head component click fix - fix(demo): get appid from systemInfo - fix(runtime): set title when route-changed - fix(sdk): add missing @mp/runtime-plugin-sensor-orientation depenedncies - fix(sdk): page instance option property update - fix(sdk): from render to worker UIRendererServiceReady - fix(sdk): use log.error instead of filter text nest component - fix(demo): route query parameter different handler with encode64 - fix(runtime): load extended lib of specific version - fix(bundler): require relative path for cocos game - fix(sdk): reject the previous defer when reLaunch too early - fix(sdk): adjust MPRunTimeLogger - fix(sdk): routing api should wait app launched - fix(automator): api is undefined during first lauch of e2e - fix(sdk): share-panel not working - fix(bundler): copy non-existent files issue - fix(demo): how to use custom tabbar - fix(cli): resolve path of react - fix(sdk): rename package - fix(runtime): add getBridgeCode to files array - fix(runtime): remove dependency cycle - fix(runtime): align fail behaviour of request plugin with wechat - fix(sdk): cherry pick - timeline check app & hotfix 3.8.2 - fix(bundler): common.bxss is imported twice & release factory after jsModule is required - fix(sdk): empty subpackages force download action - fix(runtime): add service.d.ts to npm pack - fix(cli): update vendors to support node 16 - fix: catch downloadFile fail and remove --unhandled-rejections=warn - fix(sdk): mg add devicePixelRatio into getSystemInfo api - fix(sdk): mp canvastouche event payload - fix(bundler): add globalThis polyfill to page-frame - fix(sdk): setData in onLoad not working - fix(cli): fix tarojs version can not found in yarn global action - fix(sdk): fix timeline order error - fix(sdk): remove global wx, fix getOpenDataContext placeholder - fix(sdk): timeline appJs error - fix(sdk): timeline-update - fix(cli): debugReact with react-reconciler not works - fix(sdk): increase gas limit when estiamte gas failed - fix(runtime): postMessage should wait for ready - fix(cli): resolve taro presets from installation dir of bmp - fix(cli): support node 15 - fix(sdk): can-i-use types & injectPrivateApi - fix(rumtime): support tmp/store/usr http request - fix(bundler): source-map OOM & repeated refresh in watch mode issues - fix(sdk): fix onOffManager memory leak for task-style apis - fix(demo): fix demo for fileSystemManager - fix(runtime): add Math.ceil when populate gas - fix(sdk): canvas plugin - fix(bundler): adjust the order of loading script in page-frame - fix(bundler): load base.bxml.js earlier than renderer-service.js - fix(sdk): plugin write file - fix(sdk): blank page when relaunch in old ios device - fix(sdk): support cocos - fix(sdk): app-rpc-logger judge from or to & delete extra log - fix(sdk): monitor d change to dt & update RuntimeLogger monitor-upload - fix(sdk): webview not working for the webview using node-bridge - fix(bundler): load base.bxml.js in head element of page-frame - fix(sdk): plugin-private-request command - fix(sdk): add dataset to MPEventTarget - fix(runtime): onNativeApiRequest able to listen all actions - fix(sdk): radio and checkbox components - fix(sdk): ios not support bigint 64 - fix(sdk): sentry + vconsole cause oom - fix(sdk): fix Android need to tap input twice to focus - fix(sdk): fix the issue that slider wrap with position: relative container - fix(mp): fix request cookie setting - fix(sdk): fix reportEvent with keyword to error - fix(sdk): timeline startup del loadAppJs - fix(sdk): DeprecatedInput auto-fill not emit input event - fix(sdk): fix native input color with autoFocus props - fix(runtime): storage plugin api not work - fix(sdk): fix Image style width:100% - fix(sdk): remove header filed with null value - fix: add defer for webview context in the node-bridge demo - fix: create a empty webview if src not provied - fix(mp): fix tab bar css, red dot api error message - fix(sdk): fix Image style being overridden and comments using English - fix(sdk): image can not use width/height:auto with div-bgImg - fix(sdk): onAppShow not working - fix(sdk): remove the error of webivew-sdk Unknown Action $ready - fix(sdk): update image component from img to div with background-image - fix: framework-load-script has been registed - fix(sdk): fix View component touchstart twice (#295) - fix(lib,sdk): fix deprecated-input onInput not working - fix(runtime): show & hide ToastContainer - fix(sdk): plugin create native buffer - fix(sdk): Image and IDECoverImage onload & onerror - fix(sdk): timelogger error add time - fix(sdk): debounce update state for native input - fix(sdk): fix re-launch page not found issue - fix(runtime): fix storage plugin - fix(sdk): disable the JS timer for blank page detection - fix(lib): make bundler generate component code that not override comp… - fix(runtime): prevent app.js load twice - fix(sdk): polyfill IntersectionObserver for iOS 12.1 (#237) - fix:add commit hash to branch name - Fix: release script - fix: unexport subscribeLocationChange - fix: sdk build - fix the problem that bundler still work when in h5 mode - fix some dependencies of project template - fix: use path.resolve - fix: make form component soft controlled & add missing component map - fix: use -o - fix the problem after last commit which make bundle script not work - fix: normalize page url - fix: 🐛 overwrite template files - fix for debugger - fix: 🐛 add http-proxy-middleware@0.19 in runtime-render - Fix/fix the request with correct parameters and all other things for mvp2 - fix: send body only for post and put method - fix: prevent user from scaling view - fix: remove useless code - fix(runtime-renderer): fix multiple event binding on same event - fix: get props and data from parent & rename api - fix: typo - fix: use Object.assign - fix: reduce payload size - fix: Resolve events from attrs and separate two rpc events - fix: use eventNames to tell the different if it is a event name or a normal props name - fix: watch $props - fix: rename - fix: watch all props changed - fix: remove bind props interface - fix: remove useless code - fix the problem invoked by packange name changed of taro plugin - fix: prevent capture event trigger twice - fix: 🐛 use e.currentTarget - fix: 🐛 renderTaro and updateData - fix: 🐛 renderTaro - fix: keep compatible with taro - fix: add tapCapture - fix: add capture event - fix: update props naming - fix: remove console.log - fix: Non-function value encountered for default slot. Prefer function slots for better performance. - fix: remove console.log - fix: types - fix: update sdk - fix: response.data typing - fix: 🐛 enableCSSModule - fix: call ready before navigation-push - fix: typo - fix: typo - fix: typo - fix: change data type - fix: 🐛 back to list page - fix: rpc - fix(runner): rpc message format - fix(runner): rpc message format - fix: pass query to page.oLoad - fix: fix ready and push action order - fix: page component created twice - fix: fix page hooks - fix: 🐛 support page-hide and page-show - fix: 🐛 not parse querystring when method is GET or HEAD - fix: 🐛 createAndSavePage params - fix: 🐛 init lifecycle and method - fix: 🐛 only create page when \_\_pageConfig exist - fix: 🐛 create page on worker runtime - fix: build - fix: disable webpack-dev-server host check - fix: improve js compatibility - fix: improve js compatibility - fix: prefix component instance id with page id - fix(rpc): change rpc interface - fix: 🐛 add recordInstanceBoundEffect - fix: 🐛 remove effect - fix: 🐛 computed bind to ctx - fix: change defualt build format to esm-bundler - fix: change defualt build format to esm-bundler - fix(project): fix default format - fix(project): format package.json - fix(project): rm .gitkeep & fix deps - fix: typo - fix: COMPONENT_TYPE_ID is undefined - fix: 🐛 build script ### Features - feat(sdk): support multiple intersectionObserver - feat(sdk): navigateTo add target external - feat(sdk): update canIUse for new api - feat(runtime): downloa-package add two fields - feat(bundler): add monitor NEZHA_RENDER_PAGE_JS & update sorter of pkg - feat(host): remove canvas useless dep - feat(sdk): remove deprecated items for sdk4.0 - feat(sdk): getSystemInfo cache - feat(server-side-bundle): compile & upload worker code into bytecode when enableBytecode - feat(sdk): bump versions - feat(sdk): bump version for ide deps - feat(sdk): validate current page is tabBar page when call tabBar apis - feat(demo): update prod demo - feat(sdk): plugin createIntersectionObserver and fix selectorQuery setTimeout issue - feat(sdk): detect darkmode for appBaseInfo - feat(sdk): load app js advance after worker send $Ready - feat(sdk): generate bytecode for worker-service - feat(sdk): gcanvas buffer data optimize - feat: native image - feat(bundler): add new package node-qjsc - feat(sdk): getAppBaseInfo & getWindowInfo & getDeviceInfo - feat(runtime): expose updateBackground of create webview service for ide - feat(sdk): $renderer-ready action - feat(sdk): loadScriptSync method - feat(sdk): chainId should be number when pass to native - feat(demo): add promise polyfill demo for QA regression - feat: web host cli - feat(demo): release demo on QA env - feat(cli): cover-view support hover-class - feat(demo): improve twoFa demo - feat(demo): remove webauthn demo - feat(bundler): add statistics mode to pkg-cli & feat(mpp-service): support config msv - feat(sdk,demo): add private fps api and benchmark for render fps - feat(sdk): cache promise reject handler - feat(sdk): getperformance-evaluateScript - feat(lib): add promise polyfill source code and descreption - feat(sdk): gcanvas async method - feat(server-side-bundle): use X-Mp-Open-Api-Token to authorize - feat(sdk): add warn deprecated info for sdk 4.0 - feat(sdk): support injected prop in webview component - feat(sdk): add experimental on walletconnector - feat(bundler): support include options in project.config.json - feat(sdk): error with stack - feat(sdk): new render point NEZHA_INJECT_RENDERER_JS_END & update timeline point info - feat(lib): use body class to control theme rather than prefers-color-scheme - feat(lib): remote-debug route-change-done notify to render - feat(cli): add props to webview - feat(sdk): mpRuntimeLogger rename & add error code - feat(sdk): webgl finish api - feat(mpp-service): output version info to MPP_SERVICE_OUTPUT.json - feat(sdk): time app check after app-launch - feat(bundler): impl util-function analyzeSource & remove AddEntryAppJsPlugin - feat(mpp-service): output hostQrcode to a file - feat(sdk): sdk-loading - feat(lib): remote-debug new action & ignore native side delay error - feat(sdk): create webview sdk & demo - feat(runtime): disable click when loading display - feat(sdk): gcanvas supports cocos - feat(bundler): use zlib to compress pkg - feat(sdk): setInterval 0 with warning - feat(sdk): add api requestSubscribeMessage - feat(sdk): make-phone-call - feat(runtime): @mp/host catch error and send to parent window - feat(sdk): canvas to temp file path api and demo - feat(sdk): add FP/FCP/LCP entry for performance API - feat(demo): add readfile api to benchmark - feat(sdk): add route-change-done event to fix route entry negative duration - feat(demo): add apiBenchmark at globalThis to run customize api benchmark - feat(demo): add extended-libs page - feat(demo): demo for webgl - feat(cli): quick publish for dev & qa - feat(sdk): add mt_start when monitorupload setdata - feat(extended-lib): integrate distribution API (test on dev env) - feat(cli): support plugins - feat(sdk): improve web3 api - feat(demo): Standard Benchmark DSL Mini Program for runtimes - feat(demo): migrate component-demo api to component-demo-public - feat(sdk): cache promise api until it resolved - feat(bundler): add file hash to pkg - feat(sdk): filesystem api - copyfile, unzip - feat(demo): update radio example code as wechat example - feat(runtime): assign path to render iframe name - feat(demo): form view media public demo components - feat(demo): release demos in QA env - feat(demo): release demos in QA env - feat(demo): release demos in QA env - feat(cli): support taro prerender - feat(mpp-service): intergate server-side-bundle - feat(sdk): open-type getEmailAddress / getPhoneNumber - feat(demo): share app demo - feat(sdk): universal link - feat(extended-lib): export libs info - feat(bundler): add analyse mode to pkg-cli - feat(extended-lib): add new package @mp/extended-lib - feat(bundler): add pkg-cli - feat(sdk): monitorupload NEZHA_RENDER_PAGE_JS with data-eb - feat(sdk): setData payload size & remove cocos - feat(sdk): check TIME_APP by heartbeat scheme - feat(lib): preload styles bug fix - feat(demo): migrate theme-context - feat(bundler): bundler-cli add disabledSubpackages - feat(mpp-service): upload pkg of mini-program - feat(sdk): refactor framework-load-script - feat(demo): update custome event demo - feat(sdk): ide clipboard plugin migrate - feat(demo): add getEmailAddress getPhoneNumber demo - feat(server-side-bundle): upload source-map & source-code - feat(lib): preload html core - feat(mpp-service): support auto increase version code & improve error… - feat(runtime): simulator navigator title left align - feat(sdk): custom event on/off - feat(sdk): open-type button support getPhoneNumber, getEmail - feat(demo): expose base64_encode method example for developers - feat(sdk): native send event to worker with time - feat(sdk): renderer send RendererReady to Native - feat(demo): standalone webview demo - feat(sdk): add create offscreen canvas api - feat(sdk): warn if developer call sync api in app & page lifecycle - feat(runtime,sdk): handle page-not-found and fix onPageNotFound not working - feat(server-side-bundle): add new package @mp/server-side-bundle - feat(demo): implement 5 api to component-demo - feat(demo): component-demo for dsl - feat(sdk): route query parameters updates - feat(demo): migrate e2e test - feat(mpp-service): submit the MiniProgram in audit step - feat(demo): enterkeyhint of search - feat(sdk): remote debug support sync rpc - feat(sdk): remove cocos runtime script from sdk package - feat(automator): replace puppeteer wiht playwright - feat(sdk): wallet-connector issue fix - feat(sdk): text component support decode and space - feat(sdk): add new rpc action RendererServiceReady - feat(sdk): add fullyDownloaded to FrameworkDownloadPackage - feat(demo): webview custom nav demo - feat(lib): host getImageInfo plugin - feat(sdk): getImageInfo support relative path - feat(sdk): add wallet-connector plugin - feat(bundler) : bxml support relative path - feat(cli): update deprecated input props - feat(demo): public demo component migrate - feat(demo): update wallet connector demo - feat(demo): include get-image-info demo image files - feat(demo): component demo public - feat(runtime): deprecated input support confirm event - feat(demo): update wallet connector demo - feat(demo): getImageInfo support absolute path and short path - feat(demo): add more cases in wallet-connector demo - feat(cli,doc): modify bundler info for useExtendedLib and update doc troubleshooting - feat(bundler & runtime): support useExtendedLib - feat(demo): update the unsupported domain test - feat: e2e-test - feat(sdk): hotfix 3.8.1 cherry pick master & restore yml - feat(sdk): redesign timeline - feat(sdk): startlocationupdate type - feat(sdk): image-info plugin - feat(demo): get-image-info demo - feat(sdk): add plugin user-info & migrate getUserProfile to action get-user-info-profile - feat(cli): support externals lib - feat(playground): add wallet-connector context api - feat(cli): upgrade tarojs to 3.4.4 - feat(sdk): expose esmoudle of plugin submodule with .mjs - feat(bundler): empty app.js for drop compatibility & fix independent … - feat(bundler & mpp-service): add bundler-cli & support output .pkg files - feat(sdk): clear detection when hidden - feat(demo): update runtime-web-host bundleAll params - feat(sdk): hotfix-3.7.6-cherry-pick-to-master timeline update - feat(sdk): hotfix-3.7.6-cherry-pick-to-master timeline update - feat(sdk): add more info about AppLaunch in runtimeloger - feat(sdk): framework-storage plugin - feat(bundler,cli): update bundler log info - feat(mpp-service): add package mpp-service to tools - feat(sdk): hotfix-3.7.3-onerror-monitor-upload - feat(sdk): try catch error in App lifecycle - feat(sdk): add load pageJS info in timeline logger - feat(sdk): add more info about AppLaunch in runtimeloger - feat(bundler): move page logic to page.worker.js - feat(sdk): add startAppLaunch handleAppLaunchCallback in runtimeloger - feat(demo): preloadRule demo app - feat(sdk,runtime): file system manger access api sdk,runtime,demo - feat(cli): add button open-type getUserProfile & getEmailAddress - feat(sdk): canIUse plugin - feat(demo): handle error demo - feat(runtime): remove native-ui - feat(sdk): add Button open-type attribute getUserProfile - feat(sdk): add Button open-type attribute openSetting - feat(sdk): add wallet-connector plugin - feat(lib): add binary-pkg to bundler - feat(sdk): add API isLoggedIn & add custom plugin ensure-logged-in - feat(demo): private-request demo - feat(runtime): filesystem permission - feat(sdk): plugin device-orientation-change - feat: add disableBounces page to demo app - feat(mp,sdk): file system plugins - feat: private-request plugin - feat(sdk): app-rpc logger add event - feat(mp): buffer-url mp plugin - feat(sdk): timeLogger-startup add loadAppJs and appLoad - feat(sdk): native-rpc-logger supprot event - feat(cli): add support autocomplete feature for DeprecatedInput - feat(sdk): support confirm event for web input - feat(sdk,mp): mp,sdk plugin tab bar red dot - feat(cli & bundler): provide source-map in prod mode - feat: update blank-page demo with navigate to a new page - feat: update blank page demo with input - feat(runtime): on-off plugin - feat(sdk): add system log label - feat(sdk): plugins show-leaderboard, cloud-storage - feat(mp): plugin background-fetch - feat(runtime): save image to photos album plugin - feat(bundler): extract base.bxml - feat(sdk): plugin beforeAppClose api and demo - feat: add blank-page demo - feat(sdk): add direction RTL support for native components include native-input - feat(runtime): clipboard plugin - feat(sdk): optimize vconsole, lazy load, split log and system panel - feat(sdk): report plugin - feat(mp-runtime): add webview plugin - feat: sync with mono 3.5.0 - feat: test([32d06ace](https://git.toolsfdg.net/fe/mini-program/commit/32d06aceb8d95036bc2f28bd72ea4f7347db3db2)) by ka - feat: test - feat: trigger - feat: failed trigger and do it one more time - feat: test publish - feat: modify release script - feat(Slider): add mp-slider component - feat: add fallback action handler - feat: add bn.login - feat(cli): archive bundle to zip file - feat(cli): do bundle after taro build - feat: add downloadFile and requestPayment - feat: add base component Radio and RadioGroup & fix wrong onChange target id - feat: add dist -d option - feat: add bn apis - feat(taro-plugin): 🎸 add bn typings for taro - feat(build): add build command in @mp/cli - feat: 🎸 add cli-init react template - feat: implement WorkerService with iframe - feat: add mp-checkbox & mp-checkbox-group - feat: add action defintions - feat: 🎸 add options to dev cli - feat: 🎸 init @mp/cli - feat: support api cors - feat: expose rpcworker on dev - feat: add toast action - feat: 🎸 change page in app.json from object to array - feat: enhance request taro - feat: enhance request taro - feat: enhance request taro - feat: 🎸 add set method - Feature/bundler - feat(runtime-render): connect mp event to taro event - feat: enhance request - feat: add icon - feat: add mp-text & fix input event - feat: 🎸 add entry html and update taro plugin - feat: 🎸 add **cid and **pageConfig to Page function - feature/bundle - feat: 🎸 remove isPage logic and add test cases - feat: 🎸 defineApp and defineComponent - feat: 🎸 _.config.json => _.json - feat: 🎸 add \_\_cid to components - feat: 🎸 add bundleAll method - feat: 🎸 add merge-page-config-plugin - feat: 🎸 return empty style and import pages - feat: 🎸 add bundleApp function - feat: export renderTaro - feat: output sdk manifest - feat: 🎸 add mp-tpl-loader and complete mp-bjs-loader - feat: 🎸 use mp-bjs-loader - feat: add mp-switch - feat: add mp-textarea - feat: add mp-label - feat: runner-web-cli - feat: add onTap - feat: add mp-input - feat: 🎸 add @babel/runtime - feat: 🎸 support css module and scss - feat: 🎸 clean memfs dir before run each test - feat: 🎸 set config.optimization and add test cases - feat: 🎸 extract css files - feat: 🎸 add webpack-chain and support css files - feat: 🎸 bundle single page - feat: 🎸 invoke AppShow before first page loaded - feat: 🎸 runner: support app-hide & app-show - feat: 🎸 bn.api - feat: 🎸 `runner` support navigate-pop and navigate-redirect - feat: add navigator.redirect - feat(public-api): init bn - feat(rpc): add callback error - feat: add app.js - feat: 🎸 add multi pages and remove app-launch / page-load event - feat: 🎸 add page2 and import worker.js on demand - feat: 🎸 set navigation bar title - feat: 🎸 add bn.request function - feat: 🎸 mock native functions - feat: navigator - feat: add App and Page - feat: navigator - feat(runtime-render): add mp- prefix - feat(runtime-render): add comments - feat(runtime-render): update text - feat(runtime-render): add tap event - feat: add load and unload method - feat: 🎸 support tsconfig.json in packages - feat: 🎸 add @vue/compiler - feat: multipage runner - feat: 🎸 compiler init - feat: add cmd typings - feat: add runner-web - feat: queue msg before ready - feat(event): add event support - feat: desctroy component when unmounted - feat: add build watch option and add methods and computed function - feat: 🎸 support methods and computed functionality - feat(compiler): add base compile functions - feat(project): add dev:all script - feat(project): add dev:all script - feat(project): specify format - feat(project): update dev:app scripts - feat(project): add owners - feat: add dev script - feat: use single rpc implementation - feat: counter demo - feat: first commit for runtime-\* - feat: 🎸 add rollup to build runtime bundle - feat: 🎸 minify code - feat: 🎸 add rollup to build runtime bundle - feat(rpc): add webwork rpc & native rpc - feat(rpc): change names - feat(rpc): add nativeBridge - feat(rpc): add nativeBridge - feat(rpc): fix issue - feat(rpc): fix issue - feat(rpc): add createRpcFromWorkerToView - feat(rpc): add result - feat(rpc): add createRpcFromViewToWorkder for dev - feat: define rpc interface ### Refactor - refactor(sdk): remove locationReadyManager - refactor(sdk): delete gcanvas useless code - refactor(demo): move component - refactor: websocket hostplugin and text-line-height - refactor: ide plugin login, location, download-package - refactor: sensor plugin migration - refactor: move plugins to runtime-plugins - refactor(demo): mp-web - refactor: ide plugin migration(error page, preview-image) - refactor(sdk): optimize logger - refactor: ide-host plugin migration - refactor(runtime): redefine definePlugin to support service - refactor(sdk): refactor plugins - refactor: plugins migration - refactor: clean dist of @mp/host - refactor(runtime): re-export by host itself - refactor(demo): component transform page - refactor(sdk): fix plugin migration types errors - refactor: new DSL demo page - tabbar - refactor(demo): new component demo based on bxml - refactor(sdk): migrate choose-image clipboard cloud-storage - refactor(sdk): migrate plugin-canvas - refactor(runtime): migrate plugins - refactor(plugins): plugins -> runtime-plugins - refactor(sdk): rename directories & fix watch mode - refactor: remove @mp/runtime-host - refactor(runtime): migrate plugins from to runtime-plugins - refactor(sdk): plugins -> runtime-plugins - refactor(runtime): code quality - refactor(plugin): migrate internal-plugins - refactor(runtime): add new desgin for plugin service - refactor(sdk,runtime): extract internal plugins & fix types for mp-ide - refactor(sdk,runtime): colocate host plugin & extract @mp/host-core - refactor: restructure folders - refactor: unit test of mp runtime - refactor: rename deviceInfo to viewportInfo - refactor(runtime): re-export @mp/plugins-mp - refactor(sdk): add new runtime-core and move plugins to runtime-plugins - refactor(runtime): rename runtime api - refactor: runtime re-export - refactor(runtime): add watch mode - refactor(runtime): export resolvePublicAsset instead of dirs - refactor(runtime): remove jump plugin effect - refactor(runtime): jump plugin - refactor(runtime): plugin performance-test and fix a bug cause by defaultTargetId is zero - refactor(runtime): mp-runtime dev mode - refactor(sdk,runtime): remove rollup warnings and prevent it - refactor(sdk): use disableBuiltInPlugins options instead of setIsMG - refactor(mp runtime): mp runtime api - refactor(runtime): remove useless service - refactor(runtime): move service plugin to IDE - refactor(runtime): move service plugin to IDE - refactor(runtime): move service plugin to IDE - refactor(sdk): monitor-upload service and plugin - refactor: update-manager - refactor(sdk): performance plugin - refactor: extract fs - refactor(sdk): share-panel plugin for mp & mg - refactor: navigation-bar plugin - refactor: rollup build - refactor: split action and event - refactor: separate action and event - refactor: events -> listeners - refactor: use cache & proxy - refactor: bind props with relation - refactor: rename customevent -> events & emitEvents - refactor: separate component props into normal props and custom events - refactor: using async setup to init instance - refactor: 💡 add webpack utils.ts - refactor: use $emit event - refactor: 💡 addStyleRule - refactor: change action to string from object - refactor: 💡 ViewManager.\_destroyView - refactor: remove render.js suffix - refactor: change page url - refactor: 💡 change name - refactor: pass rendererId by context - refactor: change ready process - refactor: change native bridge interface - refactor: 💡 @compiler -> @mp/compiler - refactor: use single bridge - refactor: rpc init process - refactor: update rpc message struct - refactor: use two bridge to communicate - refactor: change rpc interface - refactor: change rpc interface ### Performance Improvements - perf: app-rpc msg encoder - perf: pre-create worker - perf(sdk): use local js-sha3 ### Misc - Revert "Revert "refactor(sdk): remove locationReadyManager " (#888)" (#929) - Revert "refactor(sdk): remove locationReadyManager " (#888) - Revert "fix: cherry-pick cachePromise of getSystemInfo " (#867) - revert(sdk): revert getPhoneNumber/getEmailAddress feature because IOS not ready yet - revert(sdk): rollback to use the old get-user-profile action - Revert "fix(sdk): update image component from img to div with background-image " (#309) - Revert "feat(mp-runtime): add webview plugin" - Revert "feat: 🎸 change page in app.json from object to array " (#119) - Revert "feat(project): add dev:all script " (#21) ### Internal - chore(cicd): yaml files - chore(changelog): update changelog for version v3.14.3 - chore(changelog): update changelog for version v4.0.0-dev.3 - chore(runtime): add currentSize filed - chore: update public demo - chore(sdk): automator package rename - chore(changelog): update changelog for version v4.0.0-dev.2 - chore(changelog): update changelog for version v3.14.2 - chore: update public demo - chore: component-demo - chore: bump npm versions - chore(changelog): update changelog for version v4.0.0-dev.1 - chore(changelog): update changelog for version v3.14.1 - chore(changelog): update changelog for version v3.14.0 - chore(changelog): update changelog for version v3.14.0-dev.4 - chore(changelog): update changelog for version v3.13.3 - chore(changelog): update changelog for version v3.14.0-dev.3 - chore(changelog): update changelog for version v3.14.0-dev.2 - chore(changelog): update changelog for version v3.14.0-dev.1 - chore(changelog): update changelog for version v3.13.2 - chore(tools): remove cicd - chore: fix dockerfile - chore(changelog): update changelog for version v3.13.1 - docs(demo): update automator readme - update cicd tool - update cicd tool - docs(docs): provide troubleshooting for canvas dependencies installing issue - cicd tools - docs: remove duplicated changelog for 3.13.0 - chore(changelog): update changelog for version v3.13.0 - chore(changelog): update changelog for version v3.13.0 - docs: changelog for hotfix 3.12.2 - chore(changelog): update changelog for version v3.12.3 - chore(changelog): update changelog for version v3.13.0-dev.5 - chore(changelog): update changelog for version v3.13.0-dev.4 - chore(changelog): update changelog for version v3.13.0-dev.3 - chore(changelog): update changelog for version v3.13.0-dev.2 - docs(sdk): components docs - chore: changelog automation - docs(sdk): view & text components docs - chore(sdk): getperformance update - test: taskify-unit-test - chore: deploy extended-lib to prod env - docs: add typedoc doc to generate plugin docs - chore: test publish @mp/extended-lib on QA env - chore(demo): release prod demos - chore: publish @mp/extended-lib - chore(demo): bump component-demo-public prod version - chore(demo): release improve web3 api feature with component-demo app - chore(sdk): debug log - chore(demo): bump qa demo version for radio-issue - style(demo): add style of public - docs(bundler): add how to use pkg-cli - chore: webstudio release public-demo on prod - build: sync webview demo - build: sync-demos - chore: build with bump version from hotfix or local - chore: webstudio release public-demo on prod - chore: webstudio release public demo to prod - chore: rebuild webstudio public-demo - chore: prepare demo app release - chore: webstudio test disabledSubpackage - chore: webstudio test subPackage - chore: bump version - docs: mp-host overview - chore: bump version - chore: webstudio - chore: release component-demo - chore(sdk): delete RendererReady - Chore/webstudio - chore: test-webstudio - chore: add service.ts to files field - chore(sdk): update local gen-sdk mainfest.json version - chore: webstudio - chore: hide migrated pages for testing purpose - chore: webstudio config - chore: webstudio config - chore: webstudio config - chore: bump version - chore(sdk): cherrypick 3.10.1 to master - chore(release): mp-sdk v3.10.0 - chore: bump versions - chore: image url - build: issue template - chore: test webstudio auto submit - chore: studio publish mp-sdk - chore: test webstudio - chore: webstudio demo - chore: webstudio - chore: add 1st version of issue templates - chore(lib): bump versions cause by router query parameter feature - docs: update documents about how to test plugin - chore(sdk): cherry pick - delay 30s check app temporary - chore(sdk): cherry pick 3.9.2 to master - Merge branch 'master' into release/3.9 - docs: format readme - chore(sdk): cherry pick 3.9.2 to master - chore(sdk): cherry pick 3.9.2 to master - chore: add concurrency script - chore(release): mp-sdk v3.9.0 - chore: forgot to add .cjs suffix - chore: fix yarn release script - chore(demo): migrate component-demo to use cli 2.4.9 - chore: bump npm versions - chore: add @tarojs/react to dependencies of babel-preset-bmp - chore(cli): remove useless webpack alias - docs(runtime): added migration plugin - chore: bump version - docs(demo): how to add new feature on new demo app - chore: bump npm versions - chore: bump npm versions - chore: trigger packages republish - chore(sdk): drop compatibility code isLegacyAppJsLoaded - chore(doc): update mp-runtime doc troubleshooting - chore: update automator README & puppeteer package - docs(sdk): add special cases description - docs(runtime): test host plugin - Merge pull request #471 from finley-x/release/3.8 - Merge branch 'master' into release/3.8 - chore: bump npm versions - chore(release): mp-sdk v3.8.0 - docs: plugin integrate with IDE & release - chore: add wallet created action - docs: how to development mp runtime - docs: add plugin docs - chore: set --unhandled-rejections=warn with jest to fix unit-test on node16 - chore: add @mp/mp-runtime-shared-plugins - chore: bump versions - chore: throw typescript check error - chore: bump mp-runtime version - chore: pre commit disallow empty files - Merge pull request #423 from finley-x/release/3.7.4 - chore(cli): re-trigger bump CLI v2.3.3 - chore: organize mono workspaces - chore(sdk): release/3.7.3 -> master - chore(sdk): restore yml - chore(sdk): restore yml - test(sdk): logger test update - chore(release): mp-sdk v3.7.2 - test(runtime): add inner audio unit tests - chore(sdk): canvas plugins - test(lib): improve logger unit tests - ci: commitlint allow multiple scopes - test(lib): add logger unit tests - chore(sdk): fix fs plugin demos - ci: fix commit-lint issue - chore(sdk): demo for fs and orientation plugin - chore: bump version to 1.1.0 - chore(sdk): fix Circular dependencies - chore(cli): downgrade Taro to 3.2.13 - chore(bundler & sdk): move patches to root of workspace - chore(bundler): add compiler-dom.d.ts - chore(bundler): use tsc to build bundler - build: fix cli build & render dev mode - test: remove jest errors - build(lib): update runtime-worker-common build script - test(sdk): fix report test error - test(sdk): fix report test error - chore: use tsc to build cli - chore: logger error caused by navigation-bar - build: fix validate sdk output & add runtime-worker-common as deps of MP_ONLY - chore: merge release/3.6 - chore: integrate v3.5.2 - Merge pull request #168 from kami-c/feature/test-ci-5 - Merge pull request #167 from fe/\_\_release-mp-sdk_prod_1.0.1_c7aa75d45e4516e684e941c544935c32a862b2ca_1646900584973 - release mp-sdk v1.0.1 - Merge pull request #154 from henry-w/mono-sdk-3.4.0 - moved from mono 3.4.0, add prowjob + config - Merge pull request #152 from michael-xu/feature/mp-slider - Merge pull request #151 from myron-li/dev - Merge pull request #150 from myron-li/dev - Merge pull request #148 from chengfan-lin/mp-cli-build-bundle-zip - Merge pull request #149 from myron-li/dev - Merge pull request #147 from myron-li/dev - Merge pull request #146 from michael-xu/feature/radio - update - Merge pull request #145 from myron-li/refactor-build - Merge pull request #144 from myron-li/fix-build - Merge pull request #143 from james-l/feat/patches - unit the style of module import - use cross-spwan instead of child_process - add livereload for dev server - clean up package.json of cli - added a link cmd to make it easy to install cli added cli related document - Merge pull request #142 from michael-xu/fix/origin-bundler-with-path - do patches before build - Merge pull request #139 from myron-li/work - chore: 🤖 update yarn.lock - Merge pull request #136 from myron-li/html-worker-container - Merge pull request #135 from luffy-wang/fix-for-debugger - Merge pull request #131 from myron-li/add-actions - Merge pull request #126 from myron-li/refactor-rpc - Merge pull request #125 from myron-li/MYRON-1 - Merge pull request #124 from myron-li/dev - Merge pull request #97 from michael-xu/feature/custom-event - Merge pull request #120 from james-l/Feature/watch-mode-bundler - added exception catching in bundle script of watch mode - test: 💍 add cid equal test case - complete w -> watch as watch mode argument - chore: upgrade vue - Merge pull request #121 from myron-li/toast - added the bundler usage to README.md - add watching mode for bundler - Merge pull request #117 from myron-li/action - Merge pull request #109 from luffy-wang/enhance-request - chore: 🤖 update service assets - Merge branch 'master' of https://git.toolsfdg.net/fe/mini-program into enhance-request - Merge pull request #115 from chengfan-lin/api-taro - Merge branch 'master' into feature/custom-event - Merge pull request #114 from bowen-zhu/feature/bundler - Merge branch 'master' of https://git.toolsfdg.net/fe/mini-program into enhance-request - Merge pull request #113 from myron-li/MYRON-1 - chore: fix typo - Merge pull request #111 from chengfan-lin/api-taro - Merge pull request #112 from james-l/simplify-taro-plugin - make bxss generate correct sourcemap when is in development - simplify taro plugin and make it work as an npm package - Merge pull request #108 from luffy-wang/add-icon - Merge pull request #107 from james-l/fix/yarn-command-of-build-taro-plugin - Merge pull request #106 from myron-li/batch-updated - optimize: batch setData call - Merge pull request #105 from michael-xu/feature/components - Merge pull request #104 from myron-li/optimize - chore: optimize build - Merge pull request #103 from bowen-zhu/fix/bunlder - Merge pull request #102 from james-l/fix/sourcemap-of-css - dont let bxss generate sourcemap - Merge pull request #101 from james-l/change-output-of-taro-plugin - Merge branch 'master' into change-output-of-taro-plugin - added components definitions of uikit requirements - test: 💍 add test cases - use tsc instead of rollup as the packer - Merge pull request #95 from myron-li/refactor - add sourcemap to bjs files - use a modified app loader instead of origin one - let page's code export via umd - make output of the page scripts ends with .bjs - Merge pull request #87 from bowen-zhu/feature/app-bundler - chore: 🤖 remove bundled files - chore: 🤖 add todos - chore: 🤖 rename .tpl -> .bxml - chore: 🤖 update package.json - test: 💍 update test cases - test: 💍 update test cases - Merge pull request #90 from james-l/Feature/taro-integration - add components - Merge pull request #91 from myron-li/custom-event - chore: custom component - add code to support lifecycle callback of taro for Page object - added REDME to taro plugin package - add taro platform plugin into repository - Merge pull request #89 from myron-li/bundle-demo - chore: add example - Merge pull request #88 from myron-li/rename - chore: rename - Merge pull request #84 from myron-li/taro - chore: 🤖 build bundler by tsc - Merge pull request #79 from michael-xu/feature/mp-components - chore: 🤖 split bundler - Merge pull request #77 from bowen-zhu/feature/bundler - test: 💍 remove useless test fixtures - test: 💍 add basic fixtures - Merge pull request #78 from myron-li/runner - chore: 🤖 remove unused example - Merge pull request #74 from bowen-zhu/feature/loader - test: 💍 add runInDom test function - chore: 🤖 rename and remove useless code - Merge branch 'master' of https://git.toolsfdg.net/fe/mini-program - chore: 🤖 setup bundler - chore: 🤖 add compiler example - merge upstream master - chore: update example - Merge branch 'master' of https://git.toolsfdg.net/fe/mini-program - add weather app demo - Merge pull request #71 from myron-li/fix-page-hooks - chore: 🤖 rename types - Merge pull request #69 from bowen-zhu/feature/runner - chore: 🤖 types - chore: 🤖 navigate in worker - chore: renemae variable - chore: update example - chore: rename variables - Merge pull request #68 from myron-li/navigator-redirect - Merge pull request #66 from bowen-zhu/fix/runner - Merge pull request #65 from myron-li/page-url - Merge pull request #64 from myron-li/app-js - Merge pull request #60 from bowen-zhu/feature/runner-navigation - chore: 🤖 remove redundant code - chore: 🤖 rename function names - chore: 🤖 add response interface - chore: 🤖 update types and ui - Merge pull request #63 from myron-li/integrate-app-and-page - Merge pull request #57 from myron-li/navigator - Merge pull request #54 from luffy-wang/add-app - enhance - create once only - Merge pull request #52 from sora-liu/master - typos - add createApp and interfaces - chore: rename pageid to rendererid - chore: 🤖 update compiler fixture - Merge pull request #51 from myron-li/init-process - chore: 🤖 build prod version - Merge pull request #48 from bowen-zhu/feature/compiler - chore: 🤖 compiler dir structure - Merge pull request #46 from myron-li/single-bridge - Merge pull request #45 from myron-li/multi-page - refacotr: change rpc message definition - Merge pull request #44 from myron-li/test - test: add component test - Merge pull request #43 from myron-li/setup-test - chore: setup jest - Merge pull request #40 from myron-li/fix-compatibility - Merge pull request #39 from myron-li/format - Merge pull request #38 from myron-li/compiler-helper - Merge pull request #37 from myron-li/worker-render-protocol - Merge pull request #36 from myron-li/update-rpc - change rpc - Merge pull request #34 from myron-li/mock-service - Merge pull request #32 from myron-li/bridge-ready - Merge pull request #31 from myron-li/multi-bridge - Merge pull request #30 from luffy-wang/change-rpc - Merge pull request #27 from myron-li/build-sdk - chore: add command to generate sdk - Merge pull request #26 from myron-li/cleanup - Merge pull request #25 from shenxiang-feng/master - Merge pull request #23 from luffy-wang/add-compile-functions - Merge pull request #19 from myron-li/patch - chore: update readme - chore: update readme - Merge pull request #10 from myron-li/dev-script - chore: 🤖 add todo - chore: rename packages - chore: 🤖 project setup - chore: 🤖 add @types/node - chore: 🤖 add eslint and prettier - chore: 🤖 build ts files - chore: 🤖 add lerna - init - wip - init ## [3.14.5] 2022-11-10 **Download: [SDK-3.14.5](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.5.zip)** ### Bug Fixes - fix(demo): fix benchmark - fix(sdk, demo): check promise polyfill by using \_\_\_mp_polyfill - fix(demo): public demo read file - fix(sdk): native-cover-view not work when using taro - fix(demo): two-fa demo scene data is undefined - fix(demo): pull down refresh not works - fix(sdk): cache promise online with polyfill - fix(sdk): mini game audio adapter - fix: disable ed and add @deprecated flag - fix(sdk): changelog issue - fix(sdk): callbackId could be zero - fix(sdk): input scrollbar css issue on android - fix(sdk): isCache undefined issue - fix(mpp-service): fix status api empty fail message - fix(sdk): add properties on webgl context - fix(sdk): fix timeOrigin 0 issues on IOS14 - fix(runtime): cannot resolve the font with url "bnshare://" - fix(sdk): fix getperformance firstRender - fix: cherry-pick cachePromise of getSystemInfo - fix(sdk): use promise polyfill fix promise task order in ios12 - ios14 - fix(sdk): error code detection of remote debug - fix(sdk): requestAnimationFrame NaN - fix(automator): web cli core apis - fix: add dependency to pass build job - fix(sdk): performance init appLaunch payload - fix: getPerformance first-render - fix(sdk): delete useless report - fix(sdk): loading when expect route-change type - fix(sdk): remove cachePromise to fix ios 13 eventloop issue - fix(sdk): fix: fix to signature error when include specific data struct issue - fix(sdk): remove type check in wallet-connect plugin - fix(sdk): gcanvas texImage2D flushnative - fix(sdk): fix taskify cache fail - fix(sdk): remove canvas service code - fix(sdk): fix applaunch-getPerformance - fix(sdk): fix webview sdk - fix(mpp-service): publish issue - fix(sdk): fix mg api host register - fix(sdk): navigateBackMiniProgram extra data should transform to string - fix(sdk): fix blank screen issue when relaunch because of taskify - fix(demo): public demo - fix(sdk): getCurrentPages error handler - fix(demo): textarea confirm-type - fix(sdk): fetch remote tags with force arg when tag conflict - fix(demo): textarea maxlength caused display issue - fix(sdk): access methods defined within methods property - fix(sdk): fix this problem for '\_setDataMaxSize' of undefined - fix(cli & runtime): useExtendedLib issue - fix(demo): public-demo textarea bug - fix(bundler): if directive not work as non-first attribute - fix(sdk): revert removing of setTimeout hack because of useDidShow issues on IOS - fix(server-side-bundle): set default value of versionSetting - fix(runtime): plainText body not supported - fix(demo): fix crash caused by private request demo - fix(sdk): bug in OnOffManager and add test - fix(sdk): revert changes of performance entry name - fix(demo): callback should not inside function component - fix(bundler): nested component with directive "for" - fix(runtime): set different left for title on different lefticon - fix(mpp-service): remove request body of getApplicationVersions - fix(sdk): request-timeout - fix: webstudio qa test - fix(sdk): tmpl_0_undefined bug lead to a blank page - fix(sdk): remove 120ms timeout of page show, make sure onShow is before onReady - fix(sdk): use logger to enable warn log visible - fix(bundler): disable autoloading postcss config of MP project - fix(sdk): tmpl_0_undefined issue - fix(demo): component-demo-public head component click fix - fix(demo): get appid from systemInfo - fix(runtime): set title when route-changed - fix(sdk): add missing @mp/runtime-plugin-sensor-orientation depenedncies - fix(sdk): page instance option property update - fix(sdk): from render to worker UIRendererServiceReady - fix(sdk): use log.error instead of filter text nest component - fix(demo): route query parameter different handler with encode64 - fix(runtime): load extended lib of specific version - fix(bundler): require relative path for cocos game - fix(sdk): reject the previous defer when reLaunch too early - fix(sdk): adjust MPRunTimeLogger - fix(sdk): routing api should wait app launched - fix(automator): api is undefined during first lauch of e2e - fix(sdk): share-panel not working (#542) - fix(bundler): copy non-existent files issue - fix(demo): how to use custom tabbar - fix(cli): resolve path of react - fix(sdk): rename package - fix(runtime): add getBridgeCode to files array - fix(runtime): remove dependency cycle - fix(runtime): align fail behaviour of request plugin with wechat - fix(sdk): cherry pick - timeline check app & hotfix 3.8.2 - fix(bundler): common.bxss is imported twice & release factory after jsModule is required - fix(sdk): empty subpackages force download action - fix(runtime): add service.d.ts to npm pack - fix(cli): update vendors to support node 16 - fix: catch downloadFile fail and remove --unhandled-rejections=warn - fix(sdk): mg add devicePixelRatio into getSystemInfo api - fix(sdk): mp canvastouche event payload - fix(bundler): add globalThis polyfill to page-frame - fix(sdk): setData in onLoad not working - fix(cli): fix tarojs version can not found in yarn global action - fix(sdk): fix timeline order error - fix(sdk): remove global wx, fix getOpenDataContext placeholder - fix(sdk): timeline appJs error - fix(sdk): timeline-update - fix(cli): debugReact with react-reconciler not works - fix(sdk): increase gas limit when estiamte gas failed - fix(runtime): postMessage should wait for ready - fix(cli): resolve taro presets from installation dir of bmp - fix(cli): support node 15 - fix(sdk): can-i-use types & injectPrivateApi - fix(rumtime): support tmp/store/usr http request - fix(bundler): source-map OOM & repeated refresh in watch mode issues - fix(sdk): fix onOffManager memory leak for task-style apis - fix(demo): fix demo for fileSystemManager - fix(runtime): add Math.ceil when populate gas - fix(sdk): canvas plugin - fix(bundler): adjust the order of loading script in page-frame - fix(bundler): load base.bxml.js earlier than renderer-service.js - fix(sdk): plugin write file - fix(sdk): blank page when relaunch in old ios device - fix(sdk): support cocos - fix(sdk): app-rpc-logger judge from or to & delete extra log - fix(sdk): monitor d change to dt & update RuntimeLogger monitor-upload - fix(sdk): webview not working for the webview using node-bridge - fix(bundler): load base.bxml.js in head element of page-frame - fix(sdk): plugin-private-request command - fix(sdk): add dataset to MPEventTarget - fix(runtime): onNativeApiRequest able to listen all actions - fix(sdk): radio and checkbox components - fix(sdk): ios not support bigint 64 - fix(sdk): sentry + vconsole cause oom - fix(sdk): fix Android need to tap input twice to focus - fix(sdk): fix the issue that slider wrap with position: relative container - fix(mp): fix request cookie setting - fix(sdk): fix reportEvent with keyword to error - fix(sdk): timeline startup del loadAppJs - fix(sdk): DeprecatedInput auto-fill not emit input event - fix(sdk): fix native input color with autoFocus props - fix(runtime): storage plugin api not work - fix(sdk): fix Image style width:100% - fix(sdk): remove header filed with null value - fix: add defer for webview context in the node-bridge demo - fix: create a empty webview if src not provied - fix(mp): fix tab bar css, red dot api error message - fix(sdk): fix Image style being overridden and comments using English - fix(sdk): image can not use width/height:auto with div-bgImg - fix(sdk): onAppShow not working - fix(sdk): remove the error of webivew-sdk Unknown Action $ready - fix(sdk): update image component from img to div with background-image - fix: framework-load-script has been registed - fix(sdk): fix View component touchstart twice (#295) - fix(lib,sdk): fix deprecated-input onInput not working - fix(runtime): show & hide ToastContainer - fix(sdk): plugin create native buffer - fix(sdk): Image and IDECoverImage onload & onerror - fix(sdk): timelogger error add time - fix(sdk): debounce update state for native input - fix(sdk): fix re-launch page not found issue - fix(runtime): fix storage plugin - fix(sdk): disable the JS timer for blank page detection - fix(lib): make bundler generate component code that not override comp… - fix(runtime): prevent app.js load twice - fix(sdk): polyfill IntersectionObserver for iOS 12.1 (#237) - fix:add commit hash to branch name - Fix: release script - fix: unexport subscribeLocationChange - fix: sdk build - fix the problem that bundler still work when in h5 mode - fix some dependencies of project template - fix: use path.resolve - fix: make form component soft controlled & add missing component map - fix: use -o - fix the problem after last commit which make bundle script not work - fix: normalize page url - fix: 🐛 overwrite template files - fix for debugger - fix: 🐛 add http-proxy-middleware@0.19 in runtime-render - Fix/fix the request with correct parameters and all other things for mvp2 - fix: send body only for post and put method - fix: prevent user from scaling view - fix: remove useless code - fix(runtime-renderer): fix multiple event binding on same event - fix: get props and data from parent & rename api - fix: typo - fix: use Object.assign - fix: reduce payload size - fix: Resolve events from attrs and separate two rpc events - fix: use eventNames to tell the different if it is a event name or a normal props name - fix: watch $props - fix: rename - fix: watch all props changed - fix: remove bind props interface - fix: remove useless code - fix the problem invoked by packange name changed of taro plugin - fix: prevent capture event trigger twice - fix: 🐛 use e.currentTarget - fix: 🐛 renderTaro and updateData - fix: 🐛 renderTaro - fix: keep compatible with taro - fix: add tapCapture - fix: add capture event - fix: update props naming - fix: remove console.log - fix: Non-function value encountered for default slot. Prefer function slots for better performance. - fix: remove console.log - fix: types - fix: update sdk - fix: response.data typing - fix: 🐛 enableCSSModule - fix: call ready before navigation-push - fix: typo - fix: typo - fix: typo - fix: change data type - fix: 🐛 back to list page - fix: rpc - fix(runner): rpc message format - fix(runner): rpc message format - fix: pass query to page.oLoad - fix: fix ready and push action order - fix: page component created twice - fix: fix page hooks - fix: 🐛 support page-hide and page-show - fix: 🐛 not parse querystring when method is GET or HEAD - fix: 🐛 createAndSavePage params - fix: 🐛 init lifecycle and method - fix: 🐛 only create page when \_\_pageConfig exist - fix: 🐛 create page on worker runtime - fix: build - fix: disable webpack-dev-server host check - fix: improve js compatibility - fix: improve js compatibility - fix: prefix component instance id with page id - fix(rpc): change rpc interface - fix: 🐛 add recordInstanceBoundEffect - fix: 🐛 remove effect - fix: 🐛 computed bind to ctx - fix: change defualt build format to esm-bundler - fix: change defualt build format to esm-bundler - fix(project): fix default format - fix(project): format package.json - fix(project): rm .gitkeep & fix deps - fix: typo - fix: COMPONENT_TYPE_ID is undefined - fix: 🐛 build script ### Features - feat(sdk): add page-frame-resource points - feat(sdk): shareAppMessage support fallback url - feat(sdk): generate bytecode for worker-service - feat(sdk): toDataURL and getuserprofile - feat(sdk): chainId should be number when pass to native - feat(demo): add promise polyfill demo for QA regression - feat: web host cli - feat(demo): release demo on QA env - feat(cli): cover-view support hover-class - feat(demo): improve twoFa demo - feat(demo): remove webauthn demo - feat(bundler): add statistics mode to pkg-cli & feat(mpp-service): support config msv - feat(sdk,demo): add private fps api and benchmark for render fps - feat(sdk): cache promise reject handler - feat(sdk): getperformance-evaluateScript - feat(lib): add promise polyfill source code and descreption - feat(sdk): gcanvas async method - feat(server-side-bundle): use X-Mp-Open-Api-Token to authorize - feat(sdk): add warn deprecated info for sdk 4.0 - feat(sdk): support injected prop in webview component - feat(sdk): add experimental on walletconnector - feat(bundler): support include options in project.config.json - feat(sdk): error with stack - feat(sdk): new render point NEZHA_INJECT_RENDERER_JS_END & update timeline point info - feat(lib): use body class to control theme rather than prefers-color-scheme - feat(lib): remote-debug route-change-done notify to render - feat(cli): add props to webview - feat(sdk): mpRuntimeLogger rename & add error code - feat(sdk): webgl finish api - feat(mpp-service): output version info to MPP_SERVICE_OUTPUT.json - feat(sdk): time app check after app-launch - feat(bundler): impl util-function analyzeSource & remove AddEntryAppJsPlugin - feat(mpp-service): output hostQrcode to a file - feat(sdk): sdk-loading - feat(lib): remote-debug new action & ignore native side delay error - feat(sdk): create webview sdk & demo - feat(runtime): disable click when loading display - feat(sdk): gcanvas supports cocos - feat(bundler): use zlib to compress pkg - feat(sdk): setInterval 0 with warning - feat(sdk): add api requestSubscribeMessage - feat(sdk): make-phone-call - feat(runtime): @mp/host catch error and send to parent window - feat(sdk): canvas to temp file path api and demo - feat(sdk): add FP/FCP/LCP entry for performance API - feat(demo): add readfile api to benchmark - feat(sdk): add route-change-done event to fix route entry negative duration - feat(demo): add apiBenchmark at globalThis to run customize api benchmark - feat(demo): add extended-libs page - feat(demo): demo for webgl - feat(cli): quick publish for dev & qa - feat(sdk): add mt_start when monitorupload setdata - feat(extended-lib): integrate distribution API (test on dev env) - feat(cli): support plugins - feat(sdk): improve web3 api - feat(demo): Standard Benchmark DSL Mini Program for runtimes - feat(demo): migrate component-demo api to component-demo-public - feat(sdk): cache promise api until it resolved - feat(bundler): add file hash to pkg - feat(sdk): filesystem api - copyfile, unzip - feat(demo): update radio example code as wechat example - feat(runtime): assign path to render iframe name - feat(demo): form view media public demo components - feat(demo): release demos in QA env - feat(demo): release demos in QA env - feat(demo): release demos in QA env - feat(cli): support taro prerender - feat(mpp-service): intergate server-side-bundle - feat(sdk): open-type getEmailAddress / getPhoneNumber - feat(demo): share app demo - feat(sdk): universal link - feat(extended-lib): export libs info - feat(bundler): add analyse mode to pkg-cli - feat(extended-lib): add new package @mp/extended-lib - feat(bundler): add pkg-cli - feat(sdk): monitorupload NEZHA_RENDER_PAGE_JS with data-eb - feat(sdk): setData payload size & remove cocos - feat(sdk): check TIME_APP by heartbeat scheme - feat(lib): preload styles bug fix - feat(demo): migrate theme-context - feat(bundler): bundler-cli add disabledSubpackages - feat(mpp-service): upload pkg of mini-program - feat(sdk): refactor framework-load-script - feat(demo): update custome event demo - feat(sdk): ide clipboard plugin migrate - feat(demo): add getEmailAddress getPhoneNumber demo - feat(server-side-bundle): upload source-map & source-code - feat(lib): preload html core - feat(mpp-service): support auto increase version code & improve error… - feat(runtime): simulator navigator title left align - feat(sdk): custom event on/off - feat(sdk): open-type button support getPhoneNumber, getEmail - feat(demo): expose base64_encode method example for developers - feat(sdk): native send event to worker with time - feat(sdk): renderer send RendererReady to Native - feat(demo): standalone webview demo - feat(sdk): add create offscreen canvas api - feat(sdk): warn if developer call sync api in app & page lifecycle - feat(runtime,sdk): handle page-not-found and fix onPageNotFound not working - feat(server-side-bundle): add new package @mp/server-side-bundle - feat(demo): implement 5 api to component-demo - feat(demo): component-demo for dsl - feat(sdk): route query parameters updates - feat(demo): migrate e2e test - feat(mpp-service): submit the MiniProgram in audit step - feat(demo): enterkeyhint of search - feat(sdk): remote debug support sync rpc - feat(sdk): remove cocos runtime script from sdk package - feat(automator): replace puppeteer wiht playwright - feat(sdk): wallet-connector issue fix - feat(sdk): text component support decode and space - feat(sdk): add new rpc action RendererServiceReady - feat(sdk): add fullyDownloaded to FrameworkDownloadPackage - feat(demo): webview custom nav demo - feat(lib): host getImageInfo plugin - feat(sdk): getImageInfo support relative path - feat(sdk): add wallet-connector plugin - feat(bundler) : bxml support relative path - feat(cli): update deprecated input props - feat(demo): public demo component migrate - feat(demo): update wallet connector demo - feat(demo): include get-image-info demo image files - feat(demo): component demo public - feat(runtime): deprecated input support confirm event - feat(demo): update wallet connector demo - feat(demo): getImageInfo support absolute path and short path - feat(demo): add more cases in wallet-connector demo - feat(cli,doc): modify bundler info for useExtendedLib and update doc troubleshooting - feat(bundler & runtime): support useExtendedLib - feat(demo): update the unsupported domain test - feat: e2e-test - feat(sdk): hotfix 3.8.1 cherry pick master & restore yml - feat(sdk): redesign timeline - feat(sdk): startlocationupdate type - feat(sdk): image-info plugin - feat(demo): get-image-info demo - feat(sdk): add plugin user-info & migrate getUserProfile to action get-user-info-profile - feat(cli): support externals lib - feat(playground): add wallet-connector context api - feat(cli): upgrade tarojs to 3.4.4 - feat(sdk): expose esmoudle of plugin submodule with .mjs - feat(bundler): empty app.js for drop compatibility & fix independent … - feat(bundler & mpp-service): add bundler-cli & support output .pkg files - feat(sdk): clear detection when hidden - feat(demo): update runtime-web-host bundleAll params - feat(sdk): hotfix-3.7.6-cherry-pick-to-master timeline update - feat(sdk): hotfix-3.7.6-cherry-pick-to-master timeline update - feat(sdk): add more info about AppLaunch in runtimeloger - feat(sdk): framework-storage plugin - feat(bundler,cli): update bundler log info - feat(mpp-service): add package mpp-service to tools - feat(sdk): hotfix-3.7.3-onerror-monitor-upload - feat(sdk): try catch error in App lifecycle - feat(sdk): add load pageJS info in timeline logger - feat(sdk): add more info about AppLaunch in runtimeloger - feat(bundler): move page logic to page.worker.js - feat(sdk): add startAppLaunch handleAppLaunchCallback in runtimeloger - feat(demo): preloadRule demo app - feat(sdk,runtime): file system manger access api sdk,runtime,demo - feat(cli): add button open-type getUserProfile & getEmailAddress - feat(sdk): canIUse plugin - feat(demo): handle error demo - feat(runtime): remove native-ui - feat(sdk): add Button open-type attribute getUserProfile - feat(sdk): add Button open-type attribute openSetting - feat(sdk): add wallet-connector plugin - feat(lib): add binary-pkg to bundler - feat(sdk): add API isLoggedIn & add custom plugin ensure-logged-in - feat(demo): private-request demo - feat(runtime): filesystem permission - feat(sdk): plugin device-orientation-change - feat: add disableBounces page to demo app - feat(mp,sdk): file system plugins - feat: private-request plugin - feat(sdk): app-rpc logger add event - feat(mp): buffer-url mp plugin - feat(sdk): timeLogger-startup add loadAppJs and appLoad - feat(sdk): native-rpc-logger supprot event - feat(cli): add support autocomplete feature for DeprecatedInput - feat(sdk): support confirm event for web input - feat(sdk,mp): mp,sdk plugin tab bar red dot - feat(cli & bundler): provide source-map in prod mode - feat: update blank-page demo with navigate to a new page - feat: update blank page demo with input - feat(runtime): on-off plugin - feat(sdk): add system log label - feat(sdk): plugins show-leaderboard, cloud-storage - feat(mp): plugin background-fetch - feat(runtime): save image to photos album plugin - feat(bundler): extract base.bxml - feat(sdk): plugin beforeAppClose api and demo - feat: add blank-page demo - feat(sdk): add direction RTL support for native components include native-input - feat(runtime): clipboard plugin - feat(sdk): optimize vconsole, lazy load, split log and system panel - feat(sdk): report plugin - feat(mp-runtime): add webview plugin - feat: sync with mono 3.5.0 - feat: test([32d06ace](https://git.toolsfdg.net/fe/mini-program/commit/32d06aceb8d95036bc2f28bd72ea4f7347db3db2)) by ka - feat: test - feat: trigger - feat: failed trigger and do it one more time - feat: test publish - feat: modify release script - feat(Slider): add mp-slider component - feat: add fallback action handler - feat: add bn.login - feat(cli): archive bundle to zip file - feat(cli): do bundle after taro build - feat: add downloadFile and requestPayment - feat: add base component Radio and RadioGroup & fix wrong onChange target id - feat: add dist -d option - feat: add bn apis - feat(taro-plugin): 🎸 add bn typings for taro - feat(build): add build command in @mp/cli - feat: 🎸 add cli-init react template - feat: implement WorkerService with iframe - feat: add mp-checkbox & mp-checkbox-group - feat: add action defintions - feat: 🎸 add options to dev cli - feat: 🎸 init @mp/cli - feat: support api cors - feat: expose rpcworker on dev - feat: add toast action - feat: 🎸 change page in app.json from object to array - feat: enhance request taro - feat: enhance request taro - feat: enhance request taro - feat: 🎸 add set method - Feature/bundler - feat(runtime-render): connect mp event to taro event - feat: enhance request - feat: add icon - feat: add mp-text & fix input event - feat: 🎸 add entry html and update taro plugin - feat: 🎸 add **cid and **pageConfig to Page function - feature/bundle - feat: 🎸 remove isPage logic and add test cases - feat: 🎸 defineApp and defineComponent - feat: 🎸 _.config.json => _.json - feat: 🎸 add \_\_cid to components - feat: 🎸 add bundleAll method - feat: 🎸 add merge-page-config-plugin - feat: 🎸 return empty style and import pages - feat: 🎸 add bundleApp function - feat: export renderTaro - feat: output sdk manifest - feat: 🎸 add mp-tpl-loader and complete mp-bjs-loader - feat: 🎸 use mp-bjs-loader - feat: add mp-switch - feat: add mp-textarea - feat: add mp-label - feat: runner-web-cli - feat: add onTap - feat: add mp-input - feat: 🎸 add @babel/runtime - feat: 🎸 support css module and scss - feat: 🎸 clean memfs dir before run each test - feat: 🎸 set config.optimization and add test cases - feat: 🎸 extract css files - feat: 🎸 add webpack-chain and support css files - feat: 🎸 bundle single page - feat: 🎸 invoke AppShow before first page loaded - feat: 🎸 runner: support app-hide & app-show - feat: 🎸 bn.api - feat: 🎸 `runner` support navigate-pop and navigate-redirect - feat: add navigator.redirect - feat(public-api): init bn - feat(rpc): add callback error - feat: add app.js - feat: 🎸 add multi pages and remove app-launch / page-load event - feat: 🎸 add page2 and import worker.js on demand - feat: 🎸 set navigation bar title - feat: 🎸 add bn.request function - feat: 🎸 mock native functions - feat: navigator - feat: add App and Page - feat: navigator - feat(runtime-render): add mp- prefix - feat(runtime-render): add comments - feat(runtime-render): update text - feat(runtime-render): add tap event - feat: add load and unload method - feat: 🎸 support tsconfig.json in packages - feat: 🎸 add @vue/compiler - feat: multipage runner - feat: 🎸 compiler init - feat: add cmd typings - feat: add runner-web - feat: queue msg before ready - feat(event): add event support - feat: desctroy component when unmounted - feat: add build watch option and add methods and computed function - feat: 🎸 support methods and computed functionality - feat(compiler): add base compile functions - feat(project): add dev:all script - feat(project): add dev:all script - feat(project): specify format - feat(project): update dev:app scripts - feat(project): add owners - feat: add dev script - feat: use single rpc implementation - feat: counter demo - feat: first commit for runtime-\* - feat: 🎸 add rollup to build runtime bundle - feat: 🎸 minify code - feat: 🎸 add rollup to build runtime bundle - feat(rpc): add webwork rpc & native rpc - feat(rpc): change names - feat(rpc): add nativeBridge - feat(rpc): add nativeBridge - feat(rpc): fix issue - feat(rpc): fix issue - feat(rpc): add createRpcFromWorkerToView - feat(rpc): add result - feat(rpc): add createRpcFromViewToWorkder for dev - feat: define rpc interface ### Refactor - refactor(sdk): remove locationReadyManager - refactor(sdk): delete gcanvas useless code - refactor(demo): move component - refactor: websocket hostplugin and text-line-height - refactor: ide plugin login, location, download-package - refactor: sensor plugin migration - refactor: move plugins to runtime-plugins - refactor(demo): mp-web - refactor: ide plugin migration(error page, preview-image) - refactor(sdk): optimize logger - refactor: ide-host plugin migration - refactor(runtime): redefine definePlugin to support service - refactor(sdk): refactor plugins - refactor: plugins migration - refactor: clean dist of @mp/host - refactor(runtime): re-export by host itself - refactor(demo): component transform page - refactor(sdk): fix plugin migration types errors - refactor: new DSL demo page - tabbar - refactor(demo): new component demo based on bxml - refactor(sdk): migrate choose-image clipboard cloud-storage - refactor(sdk): migrate plugin-canvas - refactor(runtime): migrate plugins - refactor(plugins): plugins -> runtime-plugins - refactor(sdk): rename directories & fix watch mode - refactor: remove @mp/runtime-host - refactor(runtime): migrate plugins from to runtime-plugins - refactor(sdk): plugins -> runtime-plugins - refactor(runtime): code quality - refactor(plugin): migrate internal-plugins - refactor(runtime): add new desgin for plugin service - refactor(sdk,runtime): extract internal plugins & fix types for mp-ide - refactor(sdk,runtime): colocate host plugin & extract @mp/host-core - refactor: restructure folders - refactor: unit test of mp runtime - refactor: rename deviceInfo to viewportInfo - refactor(runtime): re-export @mp/plugins-mp - refactor(sdk): add new runtime-core and move plugins to runtime-plugins - refactor(runtime): rename runtime api - refactor: runtime re-export - refactor(runtime): add watch mode - refactor(runtime): export resolvePublicAsset instead of dirs - refactor(runtime): remove jump plugin effect - refactor(runtime): jump plugin - refactor(runtime): plugin performance-test and fix a bug cause by defaultTargetId is zero - refactor(runtime): mp-runtime dev mode - refactor(sdk,runtime): remove rollup warnings and prevent it - refactor(sdk): use disableBuiltInPlugins options instead of setIsMG - refactor(mp runtime): mp runtime api - refactor(runtime): remove useless service - refactor(runtime): move service plugin to IDE - refactor(runtime): move service plugin to IDE - refactor(runtime): move service plugin to IDE - refactor(sdk): monitor-upload service and plugin - refactor: update-manager - refactor(sdk): performance plugin - refactor: extract fs - refactor(sdk): share-panel plugin for mp & mg - refactor: navigation-bar plugin - refactor: rollup build - refactor: split action and event - refactor: separate action and event - refactor: events -> listeners - refactor: use cache & proxy - refactor: bind props with relation - refactor: rename customevent -> events & emitEvents - refactor: separate component props into normal props and custom events - refactor: using async setup to init instance - refactor: 💡 add webpack utils.ts - refactor: use $emit event - refactor: 💡 addStyleRule - refactor: change action to string from object - refactor: 💡 ViewManager.\_destroyView - refactor: remove render.js suffix - refactor: change page url - refactor: 💡 change name - refactor: pass rendererId by context - refactor: change ready process - refactor: change native bridge interface - refactor: 💡 @compiler -> @mp/compiler - refactor: use single bridge - refactor: rpc init process - refactor: update rpc message struct - refactor: use two bridge to communicate - refactor: change rpc interface - refactor: change rpc interface ### Performance Improvements - perf: app-rpc msg encoder - perf: pre-create worker - perf(sdk): use local js-sha3 ### Misc - Revert "refactor(sdk): remove locationReadyManager " (#888) - Revert "fix: cherry-pick cachePromise of getSystemInfo " (#867) - revert(sdk): revert getPhoneNumber/getEmailAddress feature because IOS not ready yet - revert(sdk): rollback to use the old get-user-profile action - Revert "fix(sdk): update image component from img to div with background-image " (#309) - Revert "feat(mp-runtime): add webview plugin" - Revert "feat: 🎸 change page in app.json from object to array " (#119) - Revert "feat(project): add dev:all script " (#21) ### Internal - chore(cicd): yaml files - chore(changelog): update changelog for version v3.14.0 - chore(changelog): update changelog for version v3.14.0-dev.4 - chore(changelog): update changelog for version v3.13.3 - chore(changelog): update changelog for version v3.14.0-dev.3 - chore(changelog): update changelog for version v3.14.0-dev.2 - chore(changelog): update changelog for version v3.14.0-dev.1 - chore(changelog): update changelog for version v3.13.2 - chore(tools): remove cicd - chore: fix dockerfile - chore(changelog): update changelog for version v3.13.1 - docs(demo): update automator readme - update cicd tool - update cicd tool - docs(docs): provide troubleshooting for canvas dependencies installing issue - cicd tools - docs: remove duplicated changelog for 3.13.0 - chore(changelog): update changelog for version v3.13.0 - chore(changelog): update changelog for version v3.13.0 - docs: changelog for hotfix 3.12.2 - chore(changelog): update changelog for version v3.12.3 - chore(changelog): update changelog for version v3.13.0-dev.5 - chore(changelog): update changelog for version v3.13.0-dev.4 - chore(changelog): update changelog for version v3.13.0-dev.3 - chore(changelog): update changelog for version v3.13.0-dev.2 - docs(sdk): components docs - chore: changelog automation - docs(sdk): view & text components docs - chore(sdk): getperformance update - test: taskify-unit-test - chore: deploy extended-lib to prod env - docs: add typedoc doc to generate plugin docs - chore: test publish @mp/extended-lib on QA env - chore(demo): release prod demos - chore: publish @mp/extended-lib - chore(demo): bump component-demo-public prod version - chore(demo): release improve web3 api feature with component-demo app - chore(sdk): debug log - chore(demo): bump qa demo version for radio-issue - style(demo): add style of public - docs(bundler): add how to use pkg-cli - chore: webstudio release public-demo on prod - build: sync webview demo - build: sync-demos - chore: build with bump version from hotfix or local - chore: webstudio release public-demo on prod - chore: webstudio release public demo to prod - chore: rebuild webstudio public-demo - chore: prepare demo app release - chore: webstudio test disabledSubpackage - chore: webstudio test subPackage - chore: bump version - docs: mp-host overview - chore: bump version - chore: webstudio - chore: release component-demo - chore(sdk): delete RendererReady - Chore/webstudio - chore: test-webstudio - chore: add service.ts to files field - chore(sdk): update local gen-sdk mainfest.json version - chore: webstudio - chore: hide migrated pages for testing purpose - chore: webstudio config - chore: webstudio config - chore: webstudio config - chore: bump version - chore(sdk): cherrypick 3.10.1 to master - chore(release): mp-sdk v3.10.0 - chore: bump versions - chore: image url - build: issue template - chore: test webstudio auto submit - chore: studio publish mp-sdk - chore: test webstudio - chore: webstudio demo - chore: webstudio - chore: add 1st version of issue templates - chore(lib): bump versions cause by router query parameter feature - docs: update documents about how to test plugin - chore(sdk): cherry pick - delay 30s check app temporary - chore(sdk): cherry pick 3.9.2 to master - Merge branch 'master' into release/3.9 - docs: format readme - chore(sdk): cherry pick 3.9.2 to master - chore(sdk): cherry pick 3.9.2 to master - chore: add concurrency script - chore(release): mp-sdk v3.9.0 - chore: forgot to add .cjs suffix - chore: fix yarn release script - chore(demo): migrate component-demo to use cli 2.4.9 - chore: bump npm versions - chore: add @tarojs/react to dependencies of babel-preset-bmp - chore(cli): remove useless webpack alias - docs(runtime): added migration plugin - chore: bump version - docs(demo): how to add new feature on new demo app - chore: bump npm versions - chore: bump npm versions - chore: trigger packages republish - chore(sdk): drop compatibility code isLegacyAppJsLoaded - chore(doc): update mp-runtime doc troubleshooting - chore: update automator README & puppeteer package - docs(sdk): add special cases description - docs(runtime): test host plugin - Merge pull request #471 from finley-x/release/3.8 - Merge branch 'master' into release/3.8 - chore: bump npm versions - chore(release): mp-sdk v3.8.0 - docs: plugin integrate with IDE & release - chore: add wallet created action - docs: how to development mp runtime - docs: add plugin docs - chore: set --unhandled-rejections=warn with jest to fix unit-test on node16 - chore: add @mp/mp-runtime-shared-plugins - chore: bump versions - chore: throw typescript check error - chore: bump mp-runtime version - chore: pre commit disallow empty files - Merge pull request #423 from finley-x/release/3.7.4 - chore(cli): re-trigger bump CLI v2.3.3 - chore: organize mono workspaces - chore(sdk): release/3.7.3 -> master - chore(sdk): restore yml - chore(sdk): restore yml - test(sdk): logger test update - chore(release): mp-sdk v3.7.2 - test(runtime): add inner audio unit tests - chore(sdk): canvas plugins - test(lib): improve logger unit tests - ci: commitlint allow multiple scopes - test(lib): add logger unit tests - chore(sdk): fix fs plugin demos - ci: fix commit-lint issue - chore(sdk): demo for fs and orientation plugin - chore: bump version to 1.1.0 - chore(sdk): fix Circular dependencies - chore(cli): downgrade Taro to 3.2.13 - chore(bundler & sdk): move patches to root of workspace - chore(bundler): add compiler-dom.d.ts - chore(bundler): use tsc to build bundler - build: fix cli build & render dev mode - test: remove jest errors - build(lib): update runtime-worker-common build script - test(sdk): fix report test error - test(sdk): fix report test error - chore: use tsc to build cli - chore: logger error caused by navigation-bar - build: fix validate sdk output & add runtime-worker-common as deps of MP_ONLY - chore: merge release/3.6 - chore: integrate v3.5.2 - Merge pull request #168 from kami-c/feature/test-ci-5 - Merge pull request #167 from fe/\_\_release-mp-sdk_prod_1.0.1_c7aa75d45e4516e684e941c544935c32a862b2ca_1646900584973 - release mp-sdk v1.0.1 - Merge pull request #154 from henry-w/mono-sdk-3.4.0 - moved from mono 3.4.0, add prowjob + config - Merge pull request #152 from michael-xu/feature/mp-slider - Merge pull request #151 from myron-li/dev - Merge pull request #150 from myron-li/dev - Merge pull request #148 from chengfan-lin/mp-cli-build-bundle-zip - Merge pull request #149 from myron-li/dev - Merge pull request #147 from myron-li/dev - Merge pull request #146 from michael-xu/feature/radio - update - Merge pull request #145 from myron-li/refactor-build - Merge pull request #144 from myron-li/fix-build - Merge pull request #143 from james-l/feat/patches - unit the style of module import - use cross-spwan instead of child_process - add livereload for dev server - clean up package.json of cli - added a link cmd to make it easy to install cli added cli related document - Merge pull request #142 from michael-xu/fix/origin-bundler-with-path - do patches before build - Merge pull request #139 from myron-li/work - chore: 🤖 update yarn.lock - Merge pull request #136 from myron-li/html-worker-container - Merge pull request #135 from luffy-wang/fix-for-debugger - Merge pull request #131 from myron-li/add-actions - Merge pull request #126 from myron-li/refactor-rpc - Merge pull request #125 from myron-li/MYRON-1 - Merge pull request #124 from myron-li/dev - Merge pull request #97 from michael-xu/feature/custom-event - Merge pull request #120 from james-l/Feature/watch-mode-bundler - added exception catching in bundle script of watch mode - test: 💍 add cid equal test case - complete w -> watch as watch mode argument - chore: upgrade vue - Merge pull request #121 from myron-li/toast - added the bundler usage to README.md - add watching mode for bundler - Merge pull request #117 from myron-li/action - Merge pull request #109 from luffy-wang/enhance-request - chore: 🤖 update service assets - Merge branch 'master' of https://git.toolsfdg.net/fe/mini-program into enhance-request - Merge pull request #115 from chengfan-lin/api-taro - Merge branch 'master' into feature/custom-event - Merge pull request #114 from bowen-zhu/feature/bundler - Merge branch 'master' of https://git.toolsfdg.net/fe/mini-program into enhance-request - Merge pull request #113 from myron-li/MYRON-1 - chore: fix typo - Merge pull request #111 from chengfan-lin/api-taro - Merge pull request #112 from james-l/simplify-taro-plugin - make bxss generate correct sourcemap when is in development - simplify taro plugin and make it work as an npm package - Merge pull request #108 from luffy-wang/add-icon - Merge pull request #107 from james-l/fix/yarn-command-of-build-taro-plugin - Merge pull request #106 from myron-li/batch-updated - optimize: batch setData call - Merge pull request #105 from michael-xu/feature/components - Merge pull request #104 from myron-li/optimize - chore: optimize build - Merge pull request #103 from bowen-zhu/fix/bunlder - Merge pull request #102 from james-l/fix/sourcemap-of-css - dont let bxss generate sourcemap - Merge pull request #101 from james-l/change-output-of-taro-plugin - Merge branch 'master' into change-output-of-taro-plugin - added components definitions of uikit requirements - test: 💍 add test cases - use tsc instead of rollup as the packer - Merge pull request #95 from myron-li/refactor - add sourcemap to bjs files - use a modified app loader instead of origin one - let page's code export via umd - make output of the page scripts ends with .bjs - Merge pull request #87 from bowen-zhu/feature/app-bundler - chore: 🤖 remove bundled files - chore: 🤖 add todos - chore: 🤖 rename .tpl -> .bxml - chore: 🤖 update package.json - test: 💍 update test cases - test: 💍 update test cases - Merge pull request #90 from james-l/Feature/taro-integration - add components - Merge pull request #91 from myron-li/custom-event - chore: custom component - add code to support lifecycle callback of taro for Page object - added REDME to taro plugin package - add taro platform plugin into repository - Merge pull request #89 from myron-li/bundle-demo - chore: add example - Merge pull request #88 from myron-li/rename - chore: rename - Merge pull request #84 from myron-li/taro - chore: 🤖 build bundler by tsc - Merge pull request #79 from michael-xu/feature/mp-components - chore: 🤖 split bundler - Merge pull request #77 from bowen-zhu/feature/bundler - test: 💍 remove useless test fixtures - test: 💍 add basic fixtures - Merge pull request #78 from myron-li/runner - chore: 🤖 remove unused example - Merge pull request #74 from bowen-zhu/feature/loader - test: 💍 add runInDom test function - chore: 🤖 rename and remove useless code - Merge branch 'master' of https://git.toolsfdg.net/fe/mini-program - chore: 🤖 setup bundler - chore: 🤖 add compiler example - merge upstream master - chore: update example - Merge branch 'master' of https://git.toolsfdg.net/fe/mini-program - add weather app demo - Merge pull request #71 from myron-li/fix-page-hooks - chore: 🤖 rename types - Merge pull request #69 from bowen-zhu/feature/runner - chore: 🤖 types - chore: 🤖 navigate in worker - chore: renemae variable - chore: update example - chore: rename variables - Merge pull request #68 from myron-li/navigator-redirect - Merge pull request #66 from bowen-zhu/fix/runner - Merge pull request #65 from myron-li/page-url - Merge pull request #64 from myron-li/app-js - Merge pull request #60 from bowen-zhu/feature/runner-navigation - chore: 🤖 remove redundant code - chore: 🤖 rename function names - chore: 🤖 add response interface - chore: 🤖 update types and ui - Merge pull request #63 from myron-li/integrate-app-and-page - Merge pull request #57 from myron-li/navigator - Merge pull request #54 from luffy-wang/add-app - enhance - create once only - Merge pull request #52 from sora-liu/master - typos - add createApp and interfaces - chore: rename pageid to rendererid - chore: 🤖 update compiler fixture - Merge pull request #51 from myron-li/init-process - chore: 🤖 build prod version - Merge pull request #48 from bowen-zhu/feature/compiler - chore: 🤖 compiler dir structure - Merge pull request #46 from myron-li/single-bridge - Merge pull request #45 from myron-li/multi-page - refacotr: change rpc message definition - Merge pull request #44 from myron-li/test - test: add component test - Merge pull request #43 from myron-li/setup-test - chore: setup jest - Merge pull request #40 from myron-li/fix-compatibility - Merge pull request #39 from myron-li/format - Merge pull request #38 from myron-li/compiler-helper - Merge pull request #37 from myron-li/worker-render-protocol - Merge pull request #36 from myron-li/update-rpc - change rpc - Merge pull request #34 from myron-li/mock-service - Merge pull request #32 from myron-li/bridge-ready - Merge pull request #31 from myron-li/multi-bridge - Merge pull request #30 from luffy-wang/change-rpc - Merge pull request #27 from myron-li/build-sdk - chore: add command to generate sdk - Merge pull request #26 from myron-li/cleanup - Merge pull request #25 from shenxiang-feng/master - Merge pull request #23 from luffy-wang/add-compile-functions - Merge pull request #19 from myron-li/patch - chore: update readme - chore: update readme - Merge pull request #10 from myron-li/dev-script - chore: 🤖 add todo - chore: rename packages - chore: 🤖 project setup - chore: 🤖 add @types/node - chore: 🤖 add eslint and prettier - chore: 🤖 build ts files - chore: 🤖 add lerna - init - wip - init ## [3.14.5] 2022-11-09 **Download: [SDK-3.14.5](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.5.zip)** ### Features - feat(sdk): add page-frame-resource points ## [4.0.1] 2022-11-04 **Download: [SDK-4.0.1](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.0.1.zip)** ### Bug Fixes - fix(sdk): env undefined ### Internal - chore(cicd): yaml files ## [3.14.4] 2022-11-03 **Download: [SDK-3.14.4](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.4.zip)** ### Features - feat(sdk): shareAppMessage support fallback url ### Internal - chore(cicd): yaml files ## [4.0.0] 2022-10-25 **Download: [SDK-4.0.0](https://ftp.binance.com/mp-sdk/prod/mp-sdk-4.0.0.zip)** ### Bug Fixes - fix(demo): update webgl demo with rgba - fix(demo): payment request use success callback instead - fix(sdk): useNativeImage - fix(mpp-service): copy source-code ignore node_module & hidden files - fix(sdk): fix image and keep **MP_WARN_DEPRECATED** - fix(sdk): gcanvas toDataURL and audio time update event - fix(server-side-bundle): upload bytecode pkg issue - fix(sdk): getUserProfile mini game doesn't need check tap event - fix(demo): native input width zero in android when container is a flex box - fix(sdk): reuqest text no response - fix(bundler): update dependencies to fix pkg-cli - fix(bundler): support error stack link jump of dev mode page.worker.js ### Features - feat(sdk): support multiple intersectionObserver - feat(sdk): navigateTo add target external - feat(sdk): update canIUse for new api - feat(runtime): downloa-package add two fields - feat(bundler): add monitor NEZHA_RENDER_PAGE_JS & update sorter of pkg - feat(host): remove canvas useless dep - feat(sdk): remove deprecated items for sdk4.0 - feat(sdk): getSystemInfo cache - feat(server-side-bundle): compile & upload worker code into bytecode when enableBytecode - feat(sdk): bump versions - feat(sdk): bump version for ide deps - feat(sdk): validate current page is tabBar page when call tabBar apis - feat(demo): update prod demo - feat(sdk): plugin createIntersectionObserver and fix selectorQuery setTimeout issue - feat(sdk): detect darkmode for appBaseInfo - feat(sdk): load app js advance after worker send $Ready - feat(sdk): generate bytecode for worker-service - feat(sdk): gcanvas buffer data optimize - feat: native image - feat(bundler): add new package node-qjsc - feat(sdk): getAppBaseInfo & getWindowInfo & getDeviceInfo - feat(runtime): expose updateBackground of create webview service for ide - feat(sdk): $renderer-ready action - feat(sdk): loadScriptSync method ### Misc - Revert "Revert "refactor(sdk): remove locationReadyManager " (#888)" (#929) ### Internal - chore(changelog): update changelog for version v3.14.3 - chore(changelog): update changelog for version v4.0.0-dev.3 - chore(runtime): add currentSize filed - chore: update public demo - chore(sdk): automator package rename - chore(changelog): update changelog for version v4.0.0-dev.2 - chore(changelog): update changelog for version v3.14.2 - chore: update public demo - chore: component-demo - chore: bump npm versions - chore(changelog): update changelog for version v4.0.0-dev.1 - chore(changelog): update changelog for version v3.14.1 ## [3.14.3] 2022-10-24 **Download: [SDK-3.14.3](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.3.zip)** ### Features - feat(sdk): generate bytecode for worker-service ## [3.14.2] 2022-10-17 **Download: [SDK-3.14.2](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.2.zip)** ### Features - feat(sdk): toDataURL and getuserprofile ## [3.14.1] 2022-10-05 **Download: [SDK-3.14.1](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.1.zip)** ### Bug Fixes - fix(demo): fix benchmark - fix(sdk, demo): check promise polyfill by using \_\_\_mp_polyfill - fix(demo): public demo read file - fix(sdk): native-cover-view not work when using taro - fix(demo): two-fa demo scene data is undefined - fix(demo): pull down refresh not works ### Features - feat(sdk): chainId should be number when pass to native - feat(demo): add promise polyfill demo for QA regression - feat: web host cli - feat(demo): release demo on QA env - feat(cli): cover-view support hover-class ### Internal - chore(changelog): update changelog for version v3.14.0 - chore(changelog): update changelog for version v3.14.0-dev.4 ## [3.14.0] 2022-09-29 **Download: [SDK-3.14.0](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.14.0.zip)** ### Bug Fixes - fix(sdk): cache promise online with polyfill - fix(sdk): mini game audio adapter - fix: disable ed and add @deprecated flag - fix(sdk): changelog issue - fix(sdk): callbackId could be zero - fix(sdk): input scrollbar css issue on android - fix(sdk): isCache undefined issue - fix(mpp-service): fix status api empty fail message - fix(sdk): add properties on webgl context - fix(sdk): fix timeOrigin 0 issues on IOS14 - fix(runtime): cannot resolve the font with url "bnshare://" - fix(sdk): fix getperformance firstRender - fix: cherry-pick cachePromise of getSystemInfo - fix(sdk): use promise polyfill fix promise task order in ios12 - ios14 - fix(sdk): error code detection of remote debug - fix(sdk): requestAnimationFrame NaN - fix(automator): web cli core apis - fix: add dependency to pass build job - fix(sdk): performance init appLaunch payload - fix: getPerformance first-render ### Features - feat(demo): improve twoFa demo - feat(demo): remove webauthn demo - feat(bundler): add statistics mode to pkg-cli & feat(mpp-service): support config msv - feat(sdk,demo): add private fps api and benchmark for render fps - feat(sdk): cache promise reject handler - feat(sdk): getperformance-evaluateScript - feat(lib): add promise polyfill source code and descreption - feat(sdk): gcanvas async method - feat(server-side-bundle): use X-Mp-Open-Api-Token to authorize - feat(sdk): add warn deprecated info for sdk 4.0 - feat(sdk): support injected prop in webview component - feat(sdk): add experimental on walletconnector - feat(bundler): support include options in project.config.json - feat(sdk): error with stack - feat(sdk): new render point NEZHA_INJECT_RENDERER_JS_END & update timeline point info - feat(lib): use body class to control theme rather than prefers-color-scheme - feat(lib): remote-debug route-change-done notify to render - feat(cli): add props to webview - feat(sdk): mpRuntimeLogger rename & add error code - feat(sdk): webgl finish api - feat(mpp-service): output version info to MPP_SERVICE_OUTPUT.json - feat(sdk): time app check after app-launch - feat(bundler): impl util-function analyzeSource & remove AddEntryAppJsPlugin ### Refactor - refactor(sdk): remove locationReadyManager ### Performance Improvements - perf: app-rpc msg encoder - perf: pre-create worker - perf(sdk): use local js-sha3 ### Misc - Revert "refactor(sdk): remove locationReadyManager " (#888) - Revert "fix: cherry-pick cachePromise of getSystemInfo " (#867) ### Internal - chore(changelog): update changelog for version v3.13.3 - chore(changelog): update changelog for version v3.14.0-dev.3 - chore(changelog): update changelog for version v3.14.0-dev.2 - chore(changelog): update changelog for version v3.14.0-dev.1 - chore(changelog): update changelog for version v3.13.2 - chore(tools): remove cicd - chore: fix dockerfile - chore(changelog): update changelog for version v3.13.1 - docs(demo): update automator readme - update cicd tool - update cicd tool - docs(docs): provide troubleshooting for canvas dependencies installing issue - cicd tools - docs: remove duplicated changelog for 3.13.0 - chore(changelog): update changelog for version v3.13.0 - chore(changelog): update changelog for version v3.13.0 ## [3.13.3] 2022-09-26 **Download: [SDK-3.13.3](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.13.3.zip)** ### Features - feat(sdk): android cache promise ## [3.13.2] 2022-09-20 **Download: [SDK-3.13.2](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.13.2.zip)** ### Misc - Revert "fix(sdk): cache promise for getSystemInfo " (#866) ## [3.13.1] 2022-09-16 **Download: [SDK-3.13.1](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.13.1.zip)** ### Bug Fixes - fix(sdk): cache promise for getSystemInfo - fix(sdk): requestAnimationFrame NaN ## [3.13.0] 2022-09-02 **Download: [SDK-3.13.0](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.13.0.zip)** ### Bug Fixes - fix(sdk): delete useless report - fix(sdk): loading when expect route-change type - fix(sdk): remove cachePromise to fix ios 13 eventloop issue - fix(sdk): fix: fix to signature error when include specific data struct issue - fix(sdk): remove type check in wallet-connect plugin - fix(sdk): gcanvas texImage2D flushnative - fix(sdk): fix taskify cache fail - fix(sdk): remove canvas service code - fix(sdk): fix applaunch-getPerformance - fix(sdk): fix webview sdk - fix(mpp-service): publish issue - fix(sdk): fix mg api host register ### Features - feat(mpp-service): output hostQrcode to a file - feat(sdk): sdk-loading - feat(lib): remote-debug new action & ignore native side delay error - feat(sdk): create webview sdk & demo - feat(runtime): disable click when loading display - feat(sdk): gcanvas supports cocos - feat(bundler): use zlib to compress pkg - feat(sdk): setInterval 0 with warning - feat(sdk): add api requestSubscribeMessage - feat(sdk): make-phone-call - feat(runtime): @mp/host catch error and send to parent window - feat(sdk): canvas to temp file path api and demo - feat(sdk): add FP/FCP/LCP entry for performance API - feat(demo): add readfile api to benchmark - feat(sdk): add route-change-done event to fix route entry negative duration - feat(demo): add apiBenchmark at globalThis to run customize api benchmark - feat(demo): add extended-libs page - feat(demo): demo for webgl - feat(cli): quick publish for dev & qa ### Refactor - refactor(sdk): delete gcanvas useless code ### Internal - docs: changelog for hotfix 3.12.2 - chore(changelog): update changelog for version v3.12.3 - chore(changelog): update changelog for version v3.13.0-dev.5 - chore(changelog): update changelog for version v3.13.0-dev.4 - chore(changelog): update changelog for version v3.13.0-dev.3 - chore(changelog): update changelog for version v3.13.0-dev.2 - docs(sdk): components docs - chore: changelog automation - docs(sdk): view & text components docs - chore(sdk): getperformance update - test: taskify-unit-test - chore: deploy extended-lib to prod env - docs: add typedoc doc to generate plugin docs ## [3.12.3] 2022-09-01 **Download: [SDK-3.12.3](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.12.3.zip)** ### Bug Fixes - fix(sdk): iOS 13.8 promise eventloop issue ### Internal - chore: changelog automation (#808) ## [3.12.2] 2022-08-31 **Download: [SDK-3.12.2](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.12.2.zip)** ### Bug Fixes - fix(sdk): fix taskify cache fail ## [3.12.1] 2022-08-12 **Download: [SDK-3.12.1](https://ftp.binance.com/mp-sdk/prod/mp-sdk-3.12.1.zip)** ### Bug Fixes - fix(sdk): navigateBackMiniProgram extra data should transform to string - fix(sdk): fix blank screen issue when relaunch because of taskify - fix(demo): public demo - fix(sdk): getCurrentPages error handler - fix(demo): textarea confirm-type ### Features - feat(sdk): add mt_start when monitorupload setdata - feat(extended-lib): integrate distribution API (test on dev env) - feat(cli): support plugins ### Internal - chore: test publish @mp/extended-lib on QA env - chore(demo): release prod demos - chore: publish @mp/extended-lib - chore(demo): bump component-demo-public prod version - chore(demo): release improve web3 api feature with component-demo app --- ## Document: Download Development Version URL: /zh-CN/docs/products/mini-program/framework/download-development # Download Development Version ## [5.12.0-dev.2] 2026-04-28 **Download: [5.12.0-dev.2(2.80 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.12.0-dev.2.zip)** ### Features - feat(sdk): editor support rtl ## [5.12.0-dev.1] 2026-04-26 **Download: [5.12.0-dev.1(2.80 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.12.0-dev.1.zip)** ### Features - feat(host): add RTL text direction and custom text align for editor ## [5.12.0-dev.0] 2026-04-21 **Download: [5.12.0-dev.0(2.80 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.12.0-dev.0.zip)** ### Bug Fixes - fix(sdk): add NODE_OPTIONS=--openssl-legacy-provider for Node 17+ build compat in renderer-mp - fix(host): remove copy webpack plugin to fix copy-webpack-plugin v11 compat - fix(host): add tslib 2.8.1 resolution for Node 24 exports compatibility - fix(host): pin isolated-vm to 6.1.2 for Node 24 / C++20 compatibility - fix(host): remove isolated-vm resolution, not used in project - fix(host): return align and divider in editor mark, revert keepOnSplit override - fix(cli): auto-recover from adb INSTALL_FAILED_UPDATE_INCOMPATIBLE - fix(ide-cli): prevent infinite recursion in console-to-WebSocket forwarding ### Features - feat(bundler): renderer components support shared chunks - feat(native-cli): add Android inspector and native MCP tooling ## [5.11.0-dev.2] 2026-04-02 **Download: [5.11.0-dev.2(2.76 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.11.0-dev.2.zip)** ### Bug Fixes - Fix/mp renderjs missing - fix(sdk): add backward compatibility for ViewPager2 in SwiperView - Fix/native cli preview UI layout - Fix/type 0331 ### Features - feat(sdk): add QJS bytecode compilation for renderer-service-hummer - feat(sdk): support virtual appid for widget ## [5.11.0-dev.1] 2026-03-31 **Download: [5.11.0-dev.1(2.21 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.11.0-dev.1.zip)** ### Bug Fixes - fix(cli): bundle native-cli resources and resolve adb - fix: showErrorPage for 600402 page_not_found error - fix(sdk): mcp bin - fix(lib): fix ide cli toolbar sync api - fix(cli): ide cli node version match ### Features - feat(sdk): add useNewWindow parameter to previewImage API - feat(cli): native-cli & ide-cli-mcp-server recover capabilities improve - Feat/ios orba - feat(cli): mcp tool stability improve - feat(sdk): screen cast - feat(cli): ide cli mcp server sync - feat(cli): add mobile screen viewer and simulator host capture ## [5.10.0-dev.2] 2026-03-11 **Download: [5.10.0-dev.2(2.21 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.10.0-dev.2.zip)** ### Bug Fixes - fix(sdk): fix video props type - fix(native-cli): prevent host hang on Ctrl+C ### Features - feat(sdk): support root portal to specific element - Feat/hummer lcp - feat(cli): sub mode default render path - feat(cli): native cli UI bridge - feat(cli): orba desktop mp side work - feat(cli): make get_log_files as example - feat(cli): native cli UI dev env - feat(cli): init native-cli project ## [5.10.0-dev.1] 2026-03-03 **Download: [5.10.0-dev.1(2.21 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.10.0-dev.1.zip)** ### Features - feat: fix error when stack is empty ## [5.9.0-dev.1] 2026-02-17 **Download: [5.9.0-dev.1(2.21 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.9.0-dev.1.zip)** ### Bug Fixes - fix(sdk): swiper autoheight child item ### Features - Feat/hummer swiper - Feat/hummer event - feat(cli): use custom ios runtime version - feat(cli): ios simulator support - feat(bundler): show error page when load module error ### Misc - Revert " fix(sdk): sortable items when height changes " (#2522) (#2541) ## [5.8.0-dev.1] 2026-01-29 **Download: [5.8.0-dev.1(2.21 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.8.0-dev.1.zip)** ### Bug Fixes - fix(sdk): cherry pick 5.7.1 - fix(sdk): sortable items when height changes - fix(sdkl): wallet prerender failed ### Features - feat(sdk): hummer gcanvas - feat(sdk): load appjs when reload worker - feat(sdk): enhance native event channel for CustomNativeComponent - feat(cli): miniprogram mcp server - feat(cli): more function in devtool ## [5.8.0-dev.1] 2026-01-28 **Download: [5.8.0-dev.1(1.88 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.8.0-dev.1.zip)** ### Bug Fixes - fix(sdk): sortable items when height changes - fix(sdkl): wallet prerender failed ### Features - feat(sdk): enhance native event channel for CustomNativeComponent - feat(cli): miniprogram mcp server - feat(cli): more function in devtool ## [5.7.0-dev.2] 2026-01-07 **Download: [5.7.0-dev.2(1.87 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.7.0-dev.2.zip)** ### Bug Fixes - fix(sdk): rm geature event listener binding ### Features - feat(sdk): hummer button functions - feat(sdk): support createContext with customNativeComponent widget rendererId ## [5.7.0-dev.1] 2025-12-29 **Download: [5.7.0-dev.1(1.87 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.7.0-dev.1.zip)** ### Bug Fixes - fix(sdk): rm geature event listener binding ### Features - feat(sdk): add internal doc site - feat(cli): auto perf ## [5.6.0-dev.2] 2025-12-19 **Download: [5.6.0-dev.2(1.87 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.6.0-dev.2.zip)** ### Bug Fixes - fix(sdk): fix prerender inject data path ## [4.51.5-dev.1] 2025-12-18 **Download: [4.51.5-dev.1(1.85 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.51.5-dev.1.zip)** ### Features - feat(bundler): update terser - feat(sdk): theme getter in systemInfo incorrect ## [5.6.0-dev.1] 2025-12-18 **Download: [5.6.0-dev.1(1.87 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.6.0-dev.1.zip)** ### Bug Fixes - fix(sdk,bundler): init nativeScrollNegotiation/enableBackToTop config - fix(sdk): reuse page issue on ios platform - fix(sdk): text dont filter nest components - fix(sdk): chain routechange handler when receviced multiple routechange - fix(lib): add missing code back to protect web import ### Features - feat(sdk): add extra type - feat(sdk): support debug prefetch configuration - feat(sdk): lottie comp support animationData props - feat(bundler): update terser avoid bugs of old ver ## [5.5.0-dev.1] 2025-11-27 **Download: [5.5.0-dev.1(1.80 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.5.0-dev.1.zip)** ### Features - feat(sdk): add private api getVisibilityState - feat(sdk): input support force-decimal-dot - feat(sdk): fliter standalone chunk js for bytecode pkg - feat(sdk): support webview markdown list style - feat(cli): release 1.0.0 stable version - feat(cli): dx improve ## [5.4.0-dev.2] 2025-11-06 **Download: [5.4.0-dev.2(1.80 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.4.0-dev.2.zip)** ### Features - feat(sdk): page timeline add check point ## [5.4.0-dev.1] 2025-11-05 **Download: [5.4.0-dev.1(1.80 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.4.0-dev.1.zip)** ### Bug Fixes - fix(sdk): cp view based sdk 5.0 issue - fix(sdk): cp tab area scroll - fix(sdk): render data and prerender data independent to resolve flutter blink - fix(sdk): ignore preload font on flutter - fix(bundler): compatibility for old android ### Features - feat(sdk): editor chart UI revamp - feat(sdk,bundler): customize renderer components - feat(sdk): add debug - feat(sdk): b8 widget custom lifecycle - feat(extendedLib): extended lib ci and checksum ## [5.3.0-dev.1] 2025-10-16 **Download: [5.3.0-dev.1(1.80 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.3.0-dev.1.zip)** ### Features - feat(sdk): update value for input - feat(script): add dev tag for publish-dev - feat(sdk): add scrollOffset for pageScrollTo - feat(sdk): support access node in SelectQuery - feat(sdk): flutterToImage and nativeComponent for iOS webview renderer - feat(sdk): remove root style 100% - feat(mpp-service): use label as rev ## [4.52.0-dev.1] 2025-10-14 **Download: [4.52.0-dev.1(1.85 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.52.0-dev.1.zip)** ### Features - feat(sdk): support custom native component in iOS ## [5.3.0-dev.1] 2025-10-10 **Download: [5.3.0-dev.1(1.81 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.3.0-dev.1.zip)** ### Bug Fixes - fix(cli): version sort ### Features - feat(sdk): remove root style 100% - feat(mpp-service): use label as rev ## [5.2.0-dev.1] 2025-09-25 **Download: [5.2.0-dev.1(1.81 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.2.0-dev.1.zip)** ### Bug Fixes - fix(sdk): fix prerender measure - fix(sdk): sdk5.2 cherry pick bn.removeWidgetSkeleton - fix(sdk): inst id not exist - fix(sdk): sdk5.2 cherry pick usePageScroll - fix(sdk): sdk5.x hummer log & nezha debug flag - fix(sdk): hotfix scrollview - fix(sdk): avoid XSS attack - fix(sdk): mounted to ensure nativeComponents context ready and dom instanceId for native widget map - fix(mpp-service): ai meta info upload without widgets - fix(sdk): remove unused log ### Features - feat(sdk): call all api - feat(sdk): preload font - feat(mpp-service): add widget qrcode request logic - feat(bundler): update widgetConfigs - feat(cli): dynamic bundle version support - feat(sdk): video class name - feat(cli): clean code & fix no-qjs flag & fix fs-extra copy failed - feat: add preload-worker - feat(cli): use libversion ## [4.51.0-dev.1] 2025-09-25 **Download: [4.51.0-dev.1(1.85 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.51.0-dev.1.zip)** ### Features - Feat call all - feat(sdk): sdk4.x support support formatter for all echart options ## [5.1.4-dev.2] 2025-09-22 **Download: [5.1.4-dev.2(1.81 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.1.4-dev.2.zip)** ### Features - feat(sdk): bn.removeWidgetSkeleton ## [5.1.4-dev.1] 2025-09-19 **Download: [5.1.4-dev.1(1.81 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.1.4-dev.1.zip)** ### Bug Fixes - fix(sdk): usePageScroll hooks not work - fix(sdk): hummer renderer support update single child ## [5.1.0-dev.1] 2025-09-03 **Download: [5.1.0-dev.1(1.81 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-5.1.0-dev.1.zip)** ### Bug Fixes - fix(bmp): pika ci error - fix(sdk): fix resolve native comp & input update timestamp - fix(sdk): render child node directly when component need children vnode - fix(sdk): host mini app events and setData damaged by widget flow - fix: revert comment - fix(sdk): @binance/bmp-xx deps - fix(sdk): scrollViewUpdate rendererId undefined - fix(lib): define EMPTY_OBJ ### Features - feat(lib): support legacy dynamic widget slot - feat(lib): release prod bmp-components and bmp-react - feat(bundler): remove prerender data after build in - feat(lib): update bmp component for ts - feat(lib): support legacy widget-slot - feat(sdk): update systemInfo cache when shellapp not restart - feat(sdk): prerender remove skeleton auto - feat(sdk): prerender support combined data - feat(lib): update typo and EMPTY_OBJ - feat(sdk): update taro-bn-components - feat(lib): remove useTheme - feat(bundler): support bundler version ### Misc - Revert "Merge master" - revert: root condition in setData ## [4.50.0-dev.1] 2025-09-03 **Download: [4.50.0-dev.1(1.85 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.50.0-dev.1.zip)** ### Bug Fixes - fix(sdk): mounted to ensure nativeComponents context ready and dom instanceId for native widget map - fix(mpp-service): ai meta info upload without widgets - fix(sdk): remove unused log ### Features - feat(sdk): video class name - feat(cli): clean code & fix no-qjs flag & fix fs-extra copy failed - feat: add preload-worker - feat(cli): use libversion - feat(bundler): support bundler version ## [4.48.0-dev.3] 2025-07-25 **Download: [4.48.0-dev.3(1.85 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.48.0-dev.3.zip)** ### Bug Fixes - fix(sdk): relaunch deeplink issue - fix(sdk): fix swiper autoplay ## [4.48.0-dev.2] 2025-07-24 **Download: [4.48.0-dev.2(1.85 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.48.0-dev.2.zip)** ### Features - feat(sdk): revert autoheight default value to false ## [4.48.0-dev.1] 2025-07-24 **Download: [4.48.0-dev.1(1.85 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.48.0-dev.1.zip)** ### Bug Fixes - Fix/swiper 0708 - fix(sdk): deeplink with data loader issue - fix(sdk): exports utils - fix(sdk): export bmp component utils - fix(sdk): scroll X in scroll Y ### Features - feat(sdk): swiper autoHeight - feat(sdk): mp plugin support AbortSignal - feat(sdk): add require error log - feat(cli): bundle watch process not exiting correctly - feat(cli): add error handler for ios debug target query - feat(cli): support inspect webview/webf with native devtool protocol message ### Misc - Revert "fix(sdk): export bmp component utils" ## [4.47.0-dev.3] 2025-07-03 **Download: [4.47.0-dev.3(1.84 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.47.0-dev.3.zip)** ### Bug Fixes - fix(sdk): expose the error before app init ### Features - feat(sdk): support nested scroll view - feat(sdk): blank detector - feat(sdk): support typewriter effect for flutter markdown - feat(sdk): support playsinline for video - feat(sdk): use \_\_mp_runtime_config.screenWidth for set rem - feat(mpp-service): add report file size functions - feat(extended-lib): mpp runtime vendor ## [4.47.0-dev.2] 2025-06-30 **Download: [4.47.0-dev.2(1.80 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.47.0-dev.2.zip)** ### Features - feat(sdk): new api bn.addPhoneCalendar & bn.addPhoneRepeatCalendar ## [4.47.0-dev.1] 2025-06-24 **Download: [4.47.0-dev.1(1.80 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.47.0-dev.1.zip)** ### Features - feat(cli): add meta info indicator and every day tip - feat(sdk): add new svg component demo ## [4.46.0-dev.3] 2025-06-13 **Download: [4.46.0-dev.3(1.80 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.46.0-dev.3.zip)** ### Features - feat(sdk): not set dataurl on style change ## [4.46.0-dev.2] 2025-06-13 **Download: [4.46.0-dev.2(1.80 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.46.0-dev.2.zip)** ### Features - feat(sdk): w3w timeline monitor ## [4.46.0-dev.1] 2025-06-11 **Download: [4.46.0-dev.1(1.80 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.46.0-dev.1.zip)** ### Bug Fixes - fix(sdk): hide home button api - fix(server-side-bundle): add bundler as dep ### Features - feat(sdk): flutter svg class support - feat(sdk): add ios timeline log fit regexp - feat(sdk): virtualList support size by function - feat(sdk): remove set rem in flutter - feat(sdk): add createEventSource support for IDE - feat(sdk): add `max-lines` for text-span - feat(sdk): support page preload - feat(sdk): negotiation scroll with native on Android - feat(extended-lib): use dynamicExtendedLib for all the libs and remove upload builtIn lib ## [4.45.3-dev.1] 2025-05-22 **Download: [4.45.3-dev.1(1.80 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.45.3-dev.1.zip)** ## [4.45.0-dev.1] 2025-05-14 **Download: [4.45.0-dev.1(1.73 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.45.0-dev.1.zip)** ### Features - feat(sdk): suspend & resume lifecycle ## [4.44.0-dev.1] 2025-04-29 **Download: [4.44.0-dev.1(1.73 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.44.0-dev.1.zip)** ### Bug Fixes - fix(sdk): set scroll top not work / request support enableCache - fix(sdk): `show-scrollbar` doesn't work ### Features - feat(sdk): support keyboard accessory item - feat(sdk): remove sync api - feat(sdk): domtoimage can ignore error when image not exist or load error - feat(sdk): scrollview support enableBackToTop - feat(sdk): showErrorPage support auto detect rendererId - feat(sdk): flutter scrollView add events - feat(cli): achieve pkg stability & log process stability optimization - feat(host): support five themes - feat(cli): support mcp refresh - feat(sdk): remove hack worker patch - feat(sdk): add dark_midnight support - feat(bundler): support polyfill self and XMLHttpRequest - feat(bundler): dynamic path by env. BUNDLER_PATCH - feat(extended-lib): support extended lib uikit flow - feat(host): support midnight ## [4.43.0-dev.2] 2025-04-10 **Download: [4.43.0-dev.2(1.72 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.43.0-dev.2.zip)** ### Bug Fixes - fix(sdk): flutter getAttribute polyfill ## [4.43.0-dev.1] 2025-04-09 **Download: [4.43.0-dev.1(1.72 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.43.0-dev.1.zip)** ### Bug Fixes - fix(sdk): fix input textarea type adjustPosition ### Features - feat(sdk): alpha chart for editor - feat(sdk): new component flutter markdown - feat(sdk): add `` & `` components - feat(sdk): support get prefetch data synchronous - feat: update process-md-paths - feat(cli): log process status indicator - feat: update md jobs - feat: add job to convert md path - feat(cli): filter standalone-chunks while addEntry - feat(sdk): input support max-digits-length - feat(cli): use release version devtool - feat(sdk): add runtime-plugin-create-event-source - feat(cli): chrome devtools Integration - console - feat: update llms.txt title and filter docs - feat: add upload-docs-md job ## [4.42.0-dev.1] 2025-03-18 **Download: [4.42.0-dev.1(1.72 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.42.0-dev.1.zip)** ### Bug Fixes - fix(sdk): add LCP report target - fix(sdk): drawer component visible when mounted - fix(mpp-service): fix qjs build for Andriod - fix(demo): pika no longer support `independent` ### Features - feat(cli): improve achieve stability - feat(cli): adjust glob params - feat(cli): manual update qjsc version - feat(cli): add syncPackInclude flag - feat(bmp): add direction type for sortable - feat(runtime): add api `fs.removeSavedFile` - feat(demo): add more chose file or media demo ## [4.41.0-dev.1] 2025-03-04 **Download: [4.41.0-dev.1(1.72 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.41.0-dev.1.zip)** ### Bug Fixes - fix(sdk): page frame await syntax error - fix op_line_number size increased and get_label_pos not changed on node-qjsc - fix(mp-service): fix track line and column numbers for expressions on… ### Features - feat(sdk): sortable support x-axis/free dragging - feat(sdk): add image info type - feat(sdk): init rem to avoid style issue in flutter renderer - feat(sdk): widget support selectorQuery & intersectionObserver - feat(sdk): implement lite-timeline sdk part - feat(sdk): improve virtual scrollview - feat(sdk): remove webf sync command during the initialization - feat(sdk): support disableCleanStack and cleanOtherStack - feat(sdk): increase priority of framework level message - feat(runtime): add plugin `addEventListenerToBody` - feat(server-side-bundle): add new qjs compilation ## [4.41.0-dev.3] 2025-02-28 **Download: [4.41.0-dev.3(1.72 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.41.0-dev.3.zip)** ### Features - feat(sdk): add image info type ## [4.41.0-dev.2] 2025-02-27 **Download: [4.41.0-dev.2(1.72 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.41.0-dev.2.zip)** ### Features - feat(sdk): init rem to avoid style issue in flutter renderer - feat(sdk): widget support selectorQuery & intersectionObserver ## [4.41.0-dev.1] 2025-02-25 **Download: [4.41.0-dev.1(1.72 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.41.0-dev.1.zip)** ### Bug Fixes - fix op_line_number size increased and get_label_pos not changed on node-qjsc - fix(mp-service): fix track line and column numbers for expressions on… ### Features - feat(sdk): implement lite-timeline sdk part - feat(sdk): improve virtual scrollview - feat(sdk): remove webf sync command during the initialization - feat(sdk): support disableCleanStack and cleanOtherStack - feat(sdk): increase priority of framework level message - feat(runtime): add plugin `addEventListenerToBody` - feat(server-side-bundle): add new qjs compilation ## [4.40.0-dev.2] 2025-02-10 **Download: [4.40.0-dev.2(2.48 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.40.0-dev.2.zip)** ### Bug Fixes - fix(bundler): loadScriptSync issue on android - fix(sdk): svg data url regexp missing text wrap - fix(sdk): fix cursor flashing on devices ### Features - feat(sdk): add disable-ios-embed props for ios native input ## [4.40.0-dev.1] 2025-02-06 **Download: [4.40.0-dev.1(2.48 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.40.0-dev.1.zip)** ### Bug Fixes - fix(sdk): handle non-enumerable CustomEvent properties type and detail - fix(sdk): cherry-pick virtual list hotfix - fix(sdk): clear unreachable rpc promise - fix(sdk): remove skyline sync ui command (#2058) - fix(sdk): mitigate the risk of memory leak - fix(host): loadScriptSync issue - fix(cli): change @shoelace-style/shoelace version to 2 ### Features - feat(sdk): get static template theme from body - feat(sdk): support remove skeleton after static templete rendered - feat(sdk): drawer support teleportTo - feat(demo): add fixed page input demo - feat(sdk): flutter svg support - feat(sdk): input component can highlight the inputed content - feat(sdk): flutter deprecated textarea add `cursor-spacing` - feat(sdk): support auto zip sdk in watch mode - feat(cli): add socket status indicator - feat(bundler): support standalone-chunks ## [4.39.5-dev.1] 2025-01-22 **Download: [4.39.5-dev.1(2.57 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.39.5-dev.1.zip)** ### Bug Fixes - fix(sdk): clear unreachable rpc promise ## [4.38.0-dev.2] 2024-12-26 **Download: [4.38.0-dev.2(2.50 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.38.0-dev.2.zip)** ### Features - feat(sdk): `MP.onError` message format & `MP.lifecycle` throw error ## [4.38.0-dev.1] 2024-12-25 **Download: [4.38.0-dev.1(2.50 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.38.0-dev.1.zip)** ### Bug Fixes - fix(sdk): adjust unload timming - fix(sdk): native input with number type issue - fix(cli): ide-cli pnpm dep package.json resolve failed ### Features - feat(sdk): add params in chooseFile - feat(sdk): scrollview support flex height virtual list - feat(sdk): svg inline tag performence improve - feat(bmp): `` support events - feat(sdk): `` support switching animation - feat(sdk): add `flutter-video` component - feat(sdk): throw bmp app `onError` - feat(sdk): add `` component - feat(extended-lib): update react/react-dom 18.3.1 - feat(sdk): echarts tooltip formatter support function - feat(cli): ide cli build failed not catch - feat(bmp): `PickerView` add options `maskClass|maskStyle|indicatorClass|indicatorStyle` - feat(cli): fix hot reload & change package name to ide-cli ## [4.37.0-dev.3] 2024-12-05 **Download: [4.37.0-dev.3(2.48 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.37.0-dev.3.zip)** ### Bug Fixes - fix(sdk): widget load timeline - fix(sdk): flutter deprecated-textarea autoheight style error - fix(sdk): trigger renderEffect before componentinit to fix patch issues ### Features - feat: sortable component - feat(sdk): flutter-scrollview add `refresher` props - feat:(sdk): builtin svg component ## [4.37.0-dev.2] 2024-12-03 **Download: [4.37.0-dev.2(2.46 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.37.0-dev.2.zip)** ### Bug Fixes - fix(sdk): fix page stack update timing ### Features - feat(lib): bmp-components - feat(sdk): deprecated textarea autoHeight support - feat(ide-cli): preview functions for binance devtool - feat: bundler - feat: sortable component ### Performance Improvements - perf: enhance scroll performance by reduce binding getter from event target ### Misc - Revert "chore: @mp/bundler dev" ## [4.37.0-dev.1] 2024-11-26 **Download: [4.37.0-dev.1(2.43 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.37.0-dev.1.zip)** ### Bug Fixes - fix(sdk): run setdata callback after vue nexttick - fix(bmp): update type `BnInputProps&BnTextareaProps` ### Features - feat(sdk): create chart context support options params - feat(sdk): DeprecatedTextarea add `autocorrect` & `autocapitalize` - feat(sdk): add scrollstart scrollend to scrollview - feat(sdk): add `flutter-container` - feat(sdk): add `option.url` in applyUpdate ## [4.36.0-dev.4] 2024-11-26 **Download: [4.36.0-dev.4(2.43 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.36.0-dev.4.zip)** ### Bug Fixes - fix(sdk): run setdata callback after vue nexttick - fix(bmp): update type `BnInputProps&BnTextareaProps` ### Features - feat(sdk): create chart context support options params - feat(sdk): DeprecatedTextarea add `autocorrect` & `autocapitalize` - feat(sdk): add scrollstart scrollend to scrollview - feat(sdk): add `flutter-container` - feat(sdk): add `option.url` in applyUpdate ## [4.36.0-dev.3] 2024-11-14 **Download: [4.36.0-dev.3(2.43 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.36.0-dev.3.zip)** ### Bug Fixes - fix(sdk): change handlePaste defaultValue ## [4.36.0-dev.2] 2024-11-14 **Download: [4.36.0-dev.2(2.43 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.36.0-dev.2.zip)** ## [4.36.0-dev.1] 2024-11-13 **Download: [4.36.0-dev.1(2.43 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.36.0-dev.1.zip)** ### Bug Fixes - fix(sdk): remove native component background color - fix(sdk): flutter-image remove eventListener ### Features - feat(sdk): add switch tab options in api - feat(sdk): add timeformat api - feat(sdk): add showBackButton api - feat(sdk): `native-textarea` add onPaste - feat(sdk): `native-textarea` add `alwaysEmbed` - feat(sdk): add the value of input type `decimals` - feat(sdk): flutter-deprecated-textarea add `autoFocus` ## [4.35.2-dev.1] 2024-11-07 **Download: [4.35.2-dev.1(2.43 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.35.2-dev.1.zip)** ### Bug Fixes - fix(sdk): release flutter image load - fix(sdk): wrap inline element with bn-span for bn-markdown ### Misc - Revert "chore: revert ui command" ## [4.35.0-dev.4] 2024-10-25 **Download: [4.35.0-dev.4(2.43 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.35.0-dev.4.zip)** ### Bug Fixes - fix(sdk): support inlineLayout for skyline ### Features - feat(sdk): new api page.updateRouteOptions ## [4.35.0-dev.3] 2024-10-24 **Download: [4.35.0-dev.3(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.35.0-dev.3.zip)** ### Bug Fixes - fix(sdk): flutter scroll refresher background color ### Features - feat(sdk): `DeprecatedTextarea` support `cursor/autoFocus/selection-start/selection-end` - feat(demo): add error handler bot modal demo ## [4.35.0-dev.2] 2024-10-24 **Download: [4.35.0-dev.2(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.35.0-dev.2.zip)** ### Features - feat(sdk): use tap for skyline ## [4.35.0-dev.1] 2024-10-23 **Download: [4.35.0-dev.1(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.35.0-dev.1.zip)** ### Bug Fixes - fix(sdk): android quickjs unsupport Unicode Property Escapes - fix(sdk): cherry pick webview message issue - fix(sdk): re-publish @mp/runtime-plugin-enable-sheet-gesture - fix(sdk): fix cursor issue - fix(runtime): premature return issue in ide enviroment's show-modal api - fix(sdk): editor pos nodeBefore return real textContent if node is nonTextNode - fix(sdk): `deprecated-textarea` support force update - fix(sdk): deprecated input does not update when is composing - fix(sdk): jarvis input does not update correctly ### Features - feat(sdk): add tab-switched api - feat(sdk): update caniuse api - feat(sdk): support multi pages in tabbar - feat(sdk): webview clearScrollStatus, invoke api - feat(sdk): add sticky-header & stick-section - feat(sdk): add `` - feat(sdk): setup markdown on flutter - feat(sdk): new api enable enableSheetGesture - feat(extended-lib): expose buildIn libs for server side bundle ## [4.35.0-dev.1] 2024-10-17 **Download: [4.35.0-dev.1(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.35.0-dev.1.zip)** ### Bug Fixes - fix(sdk): editor pos nodeBefore return real textContent if node is nonTextNode - fix(sdk): `deprecated-textarea` support force update - fix(sdk): deprecated input does not update when is composing - fix(sdk): jarvis input does not update correctly ### Features - feat(sdk): add `` - feat(sdk): setup markdown on flutter - feat(sdk): new api enable enableSheetGesture - feat(extended-lib): expose buildIn libs for server side bundle ## [4.34.0-dev.3] 2024-10-04 **Download: [4.34.0-dev.3(2.38 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.34.0-dev.3.zip)** ### Bug Fixes - fix(sdk): fix webview message action not work ### Features - feat(host): align response with native ## [4.34.0-dev.2] 2024-10-03 **Download: [4.34.0-dev.2(2.38 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.34.0-dev.2.zip)** ### Features - feat(sdk): flutter text component ## [4.34.0-dev.1] 2024-10-02 **Download: [4.34.0-dev.1(2.38 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.34.0-dev.1.zip)** ### Bug Fixes - fix(sdk): native list view conflict with sliver style - fix(automator): add timeout when run automator ### Features - feat(sdk): update markdown & pika version update - feat(sdk): support readme feature - feat(sdk): add 2 components `ContextMenu` & `ContextMenuItem` - feat(sdk): add `` component & lottie-context - feat(bundler): emit handlePageBundled when skeleton build finish - feat(bundler): upgrade webpack to support Node >=18 ## [4.33.0-dev.4] 2024-10-01 **Download: [4.33.0-dev.4(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.33.0-dev.4.zip)** ### Bug Fixes - fix(sdk): native list view conflict with sliver style - fix(automator): add timeout when run automator ### Features - feat(sdk): update markdown & pika version update - feat(sdk): support readme feature - feat(sdk): add 2 components `ContextMenu` & `ContextMenuItem` - feat(sdk): add `` component & lottie-context - feat(bundler): emit handlePageBundled when skeleton build finish - feat(bundler): upgrade webpack to support Node >=18 ## [4.33.0-dev.4] 2024-09-30 **Download: [4.33.0-dev.4(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.33.0-dev.4.zip)** ### Bug Fixes - fix(sdk): native list view conflict with sliver style - fix(automator): add timeout when run automator ### Features - feat(sdk): support readme feature - feat(sdk): add 2 components `ContextMenu` & `ContextMenuItem` - feat(sdk): add `` component & lottie-context - feat(bundler): emit handlePageBundled when skeleton build finish - feat(bundler): upgrade webpack to support Node >=18 ## [4.33.0-rc.1] 2024-09-12 **Download: [4.33.0-rc.1(NaN MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.33.0-rc.1.zip)** ## [4.33.0-dev.3] 2024-09-12 **Download: [4.33.0-dev.3(2.20 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.33.0-dev.3.zip)** ### Bug Fixes - fix(sdk): fix catchmove not work - fix(sdk):add textarea placeholder class prop ### Features - feat(demo): error handler demo - feat(sdk): add deeplink target type ## [4.33.0-dev.2] 2024-09-12 **Download: [4.33.0-dev.2(2.20 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.33.0-dev.2.zip)** ### Bug Fixes - fix(sdk): fix component patch error messsage ### Features - feat(sdk): hack textarea with **BN_IGNORE_IS_COMPOSING** id - feat(extended-lib): update react qjs ## [4.33.0-dev.1] 2024-09-10 **Download: [4.33.0-dev.1(2.20 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.33.0-dev.1.zip)** ### Bug Fixes - fix(sdk): fix drawer error and support accelaration - fix(lib): fix event channel type - fix(bundler): bundle watch mode should copy ignore files - fix(sdk): scroll y on scrollView is not works - fix(sdk): fix textarea props and type ### Features - feat(sdk): add component `flutter-image` - feat(demo): add style inject demo page - feat(sdk): add component flutter-scroll-view - feat(sdk): add plugin `runtime-plugin-update-page-query` - feat(sdk): add type `injected` for bmp-component - feat(sdk): add plugin `runtime-plugin-control-button` ### Misc - Revert "fix(sdk): vnode patch issues " (#1786) (#1796) ## [4.32.0-dev.2] 2024-08-22 **Download: [4.32.0-dev.2(2.20 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.32.0-dev.2.zip)** ### Features - feat(sdk): drawer component ## [4.32.0-dev.1] 2024-08-22 **Download: [4.32.0-dev.1(2.20 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.32.0-dev.1.zip)** ### Bug Fixes - fix(sdk): delay page set to make sure buforeRouteChange done - fix(bundler): disable sourcemap to reduce memory ### Features - feat(bundler): support static script, do not bundle into \_app.js and \_common.js - feat(bundler): mark build is done before send pageBundled - feat(bundler): add entry must trigger a rebuild - feat(sdk): scroll view support extra data prop - feat(sdk): performance babel plugin log format with timeline - feat(sdk): flutter scroll-view - feat(bundler): update watch page utils - feat(bundler): support ignore qjs options - feat(bundler): skeleton create style tags by script to avoid webf issues - feat(sdk): remove game script in sdk - feat(sdk): flutter scroll view - feat(sdk): add props for input - feat(bundler): update bundler for host - feat(doc): update doc - feat(demo): add input unfocuse issue - feat(sdk): lcp element timeline metrics ## [4.31.0-dev.2] 2024-07-31 **Download: [4.31.0-dev.2(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.31.0-dev.2.zip)** ### Bug Fixes - fix(lib): fix bmp component types - fix(bundler): fix expression bundler ### Features - feat(sdk): webview scrollChange event - feat(sdk): add logger for timeline log analyze - feat(sdk): scrollView skyline type list property support - feat(sdk): input prop disablePaste - feat(bundler): support bns in base.bxml and pika compile mode ## [4.31.0-dev.1] 2024-07-24 **Download: [4.31.0-dev.1(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.31.0-dev.1.zip)** ### Features - feat(sdk): editor chart ui revamp - feat(sdk): support create worker - feat(lib): add type of Script to bmp-components ## [4.30.0-dev.3] 2024-07-12 **Download: [4.30.0-dev.3(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.30.0-dev.3.zip)** ### Bug Fixes - fix(sdk): native component webview message ## [4.30.0-dev.2] 2024-07-11 **Download: [4.30.0-dev.2(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.30.0-dev.2.zip)** ### Bug Fixes - fix(sdk): native event in worker - fix(sdk): fix webview component ### Features - feat(sdk): webview component event api in queryselector ## [4.30.0-dev.1] 2024-07-10 **Download: [4.30.0-dev.1(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.30.0-dev.1.zip)** ### Bug Fixes - fix(sdk): intersectionObserver margin - fix(sdk): eventhandler of chart component - fix(extended-lib): ethers Event identifier duplicated and getGlobal function error ### Features - feat(sdk): support navigate api with animated - feat(sdk): bn.onCopy Api on Android - feat(host): export workerEnvCode for host - feat(extended-lib): upload bitcoinjs-lib & solana/web3.js - feat(extended-lib): upload ethers-5.5.4.js ## [4.29.0-dev.2] 2024-06-20 **Download: [4.29.0-dev.2(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.29.0-dev.2.zip)** ### Bug Fixes - fix(sdk): webview sdk only send invoke message - fix(sdk): image to figure will insert a new paragraph before the figure ### Features - feat(sdk): new api for webview component - feat(sdk): api show setting - feat(sdk): support fontFamily for native-input and native-textarea - feat(extended-lib): upload react-dom 18.2.0 - feat(sdk): remove load skeleton ## [4.29.0-dev.1] 2024-06-13 **Download: [4.29.0-dev.1(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.29.0-dev.1.zip)** ### Bug Fixes - fix(sdk): cursor is wired when editor tap keyboard enter ### Features - feat(sdk): add onCopy event for text component - feat: mini program performance babel plugin - feat(sdk):add ut coverage 98% ## [4.28.0-dev.1] 2024-05-28 **Download: [4.28.0-dev.1(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.28.0-dev.1.zip)** ### Features - feat(extended-lib): support web3 libs - feat(sdk): richtext support a href - feat(sdk): add page name to performance point - feat(sdk): widget props support functions in deeper obj - feat(sdk): webview status and invoke api - feat(sdk): add ut and increase coverage to 96.88% - feat(sdk): support dynamic rendering cache - feat(sdk): defer for taro useReady - feat(sdk): editor chart insert should focus next line ## [4.27.0-dev.4] 2024-05-09 **Download: [4.27.0-dev.4(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.27.0-dev.4.zip)** ### Bug Fixes - fix(sdk): image should not add appid for bn protocal src in widget - fix(sdk): page query not ready when onload ## [4.27.0-dev.3] 2024-05-08 **Download: [4.27.0-dev.3(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.27.0-dev.3.zip)** ### Features - feat(sdk): api getrandomvalues - feat(sdk): widgetslot props can use functions start with 'on' - feat(plugin): sdk support w3w evm configurable - feat(sdk): add flutter input comp - feat(lib): add getWidgetId and try get ctx from current.widget - feat(sdk): widget can load base.bxml in target app ## [4.27.0-dev.2] 2024-04-30 **Download: [4.27.0-dev.2(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.27.0-dev.2.zip)** ### Features - feat(sdk): api hide back button ## [4.27.0-dev.1] 2024-04-26 **Download: [4.27.0-dev.1(2.42 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.27.0-dev.1.zip)** ### Bug Fixes - fix(extended-lib): postpublish script throw error ### Features - feat(sdk): editor echart card - feat(sdk): cross app rpc support sync action - feat(sdk): bump - feat(host): support big int ## [4.26.0-w3w] 2024-04-22 **Download: [4.26.0-w3w(NaN MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.26.0-w3w.zip)** ### Bug Fixes - fix(host): support webassembly on host ### Features - feat(sdk): web3 plugin use shell app - feat(demo):host shell app add basebxml & preload - feat(server-side-bundle): add bytecode full - feat(sdk): api open document ## [4.26.0-dev.1] 2024-04-17 **Download: [4.26.0-dev.1(2.41 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.26.0-dev.1.zip)** ### Bug Fixes - fix(sdk): hover class not disappear - fix(sdk): create webview support widget - fix(host): widget ref not works and webview size not correct - fix(sdk): chart component need delay to setOptions ### Features - feat(sdk): cross app rpc api - feat(demo): native component demo update - feat(bundler): support widget extended lib - feat(sdk): bns can work on exp - feat(sdk): cherry-pick: delay onReady for tarojs & add more error message info for appjs load - feat(cli): webf lint add new rules - feat(lib): check media query in webf - feat(sdk): taro page await app loaded ## [4.25.0-dev.2] 2024-03-27 **Download: [4.25.0-dev.2(2.40 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.25.0-dev.2.zip)** ### Bug Fixes - fix(extended-lib): add missing deps ### Features - feat(sdk): custom native component ## [4.25.0-dev.1] 2024-03-27 **Download: [4.25.0-dev.1(2.40 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.25.0-dev.1.zip)** ### Bug Fixes - fix(sdk): fix createwebview node-bridge issu - fix(sdk): fix bmp-component type ### Features - feat(sdk): improve doc 0325 - feat(sdk): add new prop webPreferences - feat(bundler): add solution for dynamic lib - feat(sdk): render earlier for pages with static template configuration ## [4.23.0-dev.2] 2024-02-16 **Download: [4.23.0-dev.2(2.40 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.23.0-dev.2.zip)** ### Bug Fixes - fix(sdk): when user delete all content web input may act unexpected ## [4.23.0-dev.1] 2024-02-16 **Download: [4.23.0-dev.1(2.40 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.23.0-dev.1.zip)** ### Bug Fixes - fix(sdk): remote-debug env update - fix(sdk): remote debugger resend ready to IDE ### Features - feat(sdk): add error code for widget when renderer destroy during init - feat(sdk): widget can get props without properties define ## [4.22.0-dev.2] 2024-01-24 **Download: [4.22.0-dev.2(2.40 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.22.0-dev.2.zip)** ### Features - feat(sdk): webf lint adjustment - feat(sdk): add api setPageScrollable ## [4.22.0-dev.1] 2024-01-22 **Download: [4.22.0-dev.1(2.39 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.22.0-dev.1.zip)** ### Bug Fixes - fix(sdk): label trigger itemClick event for radio and checkbox ### Features - feat(sdk): limit data point max length - feat(sdk): closeWidget can close native opend widget - feat(sdk): editor support \n inside paste content ## [4.21.0-dev.1] 2024-01-08 **Download: [4.21.0-dev.1(2.39 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.21.0-dev.1.zip)** ### Features - feat(sdk): editor link paste with strick whitelist validator - feat(bundler): increase SOURCEMAP_SIZE_LIMIT to 10MB ## [4.20.0-dev.1] 2023-12-12 **Download: [4.20.0-dev.1(2.39 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.20.0-dev.1.zip)** ### Bug Fixes - fix(sdk): flutter gradient issue - fix(bundler): using prettier as formatter ## [4.19.0-dev.3] 2023-11-22 **Download: [4.19.0-dev.3(2.39 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.19.0-dev.3.zip)** ### Bug Fixes - fix(bundler): fix IDE can not reload ### Features - feat(sdk): cherry-pick: add preloadflutterwebview api ## [4.19.0-dev.2] 2023-11-21 **Download: [4.19.0-dev.2(2.39 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.19.0-dev.2.zip)** ### Features - feat(sdk): add error code to show error page - feat(sdk): add renderer Type in getCurrentPages api - feat(sdk): createSelectorQuery select support rootPortal options - feat(sdk): add latest version to update event ## [4.19.0-dev.1] 2023-11-14 **Download: [4.19.0-dev.1(2.39 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.19.0-dev.1.zip)** ### Features - feat(sdk): editor enter event - feat(sdk): enableCursor for developers to use native cursor ## [4.18.0-dev.3] 2023-11-02 **Download: [4.18.0-dev.3(2.39 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.18.0-dev.3.zip)** ### Bug Fixes - fix(sdk): fix webview sdk to compatible with node bridget - fix(cli): fix scroll-speed-limit default value - fix(cli): fix scroll-speed-limit default value ### Features - feat(sdk): hold atom selection - feat(sdk): web input support inputmode and pattern - feat(bundler): merge widgetconfig to appconfig - feat(sdk): support atom selection ## [4.18.0-dev.2] 2023-10-30 **Download: [4.18.0-dev.2(2.39 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.18.0-dev.2.zip)** ### Features - feat(sdk): add scrollSpeedLimit to avoid blank frame of virtual list ## [4.17.2-dev.1] 2023-10-23 **Download: [4.17.2-dev.1(2.39 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.17.2-dev.1.zip)** ### Bug Fixes - fix(sdk): support input focus and blur action by developers ## [4.18.0-dev.1] 2023-10-23 **Download: [4.18.0-dev.1(2.39 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.18.0-dev.1.zip)** ### Bug Fixes - fix(sdk): support input focus and blur action by developers ### Features - feat(sdk): editor support mention and hardBreak ## [4.16.3-dev.1] 2023-10-13 **Download: [4.16.3-dev.1(2.39 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.16.3-dev.1.zip)** ### Bug Fixes - fix(sdk): clone data avoid reuse data object when reopen page ## [4.17.0-dev.2] 2023-10-13 **Download: [4.17.0-dev.2(2.39 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.17.0-dev.2.zip)** ### Bug Fixes - fix(sdk): clone data avoid reuse data object when reopen page ### Features - feat(lib): bmp-api openWidget add support for convention path ## [4.17.0-dev.1] 2023-10-10 **Download: [4.17.0-dev.1(2.39 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.17.0-dev.1.zip)** ### Bug Fixes - fix(sdk): cherry pick 4.16.2 + try catch instance update - fix(sdk): using show-scrollbar disable scrollbar - fix(sdk): iOS cursor always at the edge of the word, selection update event not trigger ### Features - feat(sdk): report error during renderer launching process - feat(sdk): scroll view support scrollWithAnimation and scrollIntoViewAlignment - feat(sdk): support swiper rtl props - feat(sdk): widget support open dialog - feat(tools):webf style linter - feat(sdk): report LCP only after user interacts - feat(sdk): set tab bar list api - feat(lib): refactor WidgetSlot as react component - feat(lib): bmp-react & bmp-component add support for widget ## [4.16.0-dev.2] 2023-09-19 **Download: [4.16.0-dev.2(2.38 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.16.0-dev.2.zip)** ### Bug Fixes - fix(demo): component-demo use built-in chart - fix(sdk): decode extra data without appid - fix(sdk): swiper located to wrong child when children updated - fix(bundler): fix expression not work on tag in `bn:for` - fix(demo): independent package config - fix(demo): private-close-app require shouldClose payload - fix(bundler): decompress replace unzipper ### Features - feat(sdk): echarts tooltip support basic dom - feat(sdk): widget in widgetslot support lifecycles ## [4.16.0-dev.1] 2023-09-11 **Download: [4.16.0-dev.1(2.38 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.16.0-dev.1.zip)** ### Bug Fixes - fix(bundler): bundler watch has 60s cache ### Features - feat(sdk): editor internal plugin link support ## [4.15.0-dev.3] 2023-08-29 **Download: [4.15.0-dev.3(2.34 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.15.0-dev.3.zip)** ### Bug Fixes - fix(sdk): enbale flutter qjs - fix(sdk): swiper may throw error when disable indicatorDots ### Features - feat(sdk): add more info to showErrorPage and add widget error report - feat(sdk): export standard error to developers ## [4.15.0-dev.2] 2023-08-25 **Download: [4.15.0-dev.2(2.34 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.15.0-dev.2.zip)** ### Bug Fixes - fix(sdk): widget props can get in worker - fix(sdk): cursor always jump to the first position when value change from an empty string - fix(sdk): check demo page ci ### Features - feat(sdk): bump version - feat(sdk): dynamic widget support props and add openWidget API - feat(sdk): sdk ut to 95% - feat(bundler): build qjs for renderer in flutter ## [4.15.0-dev.1] 2023-08-17 **Download: [4.15.0-dev.1(1.45 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.15.0-dev.1.zip)** ### Bug Fixes - fix(bundler): source-map issue of swc-loader - fix(sdk): reset transform when refresher unmount ### Features - feat(demo): enable flutter - feat(bundler): server side bundle add more files into qjs ## [4.14.0-dev.2] 2023-08-09 **Download: [4.14.0-dev.2(1.45 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.14.0-dev.2.zip)** ### Bug Fixes - fix(sdk): customize component data not update when return a data getter ### Features - feat(sdk): editor transform pasted content - feat(demo): pika extendedlib - feat(sdk): scroll-view supports scroll-anchor - feat(sdk): api bn.preloadWebContent to preload webview content advance - Feat/metadata ## [4.14.0-dev.1] 2023-08-01 **Download: [4.14.0-dev.1(1.46 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.14.0-dev.1.zip)** ### Bug Fixes - fix(cli): webview component onmessage event - fix(sdk): cherry-pick fix web input seqId - fix(sdk): cherry-pick editor remove link and style recover (#1515) - fix(sdk): cherry-pick editor split figure bugs - fix(sdk): object spread syntax error - fix(cli): add webview component, webpack chain error - fix(bundler): lock unzipper version cause new version may lost file - fix(host): block TextEncoder prop ### Features - feat(sdk): editor paste event props - feat(sdk): echart component ## [4.13.1-dev.1] 2023-07-27 **Download: [4.13.1-dev.1(1.15 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.13.1-dev.1.zip)** ### Bug Fixes - fix(sdk): editor split figure bugs - fix(sdk): object spread sytax error - fix(sdk): add seqId to web input event ## [4.13.0-dev.2] 2023-07-26 **Download: [4.13.0-dev.2(1.14 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.13.0-dev.2.zip)** ### Bug Fixes - fix(demo): intersection observer usage - fix(sdk): bundler remove touchmove prevent modifer ### Misc - Revert "fix(sdk): iOS native component created failed when container is not visible " ## [4.13.0-dev.1] 2023-07-18 **Download: [4.13.0-dev.1(1.14 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.13.0-dev.1.zip)** ### Bug Fixes - fix(demo): editor toolbar bottom 0 when platform is not iOS - fix(sdk): iOS native component created failed when container is not visible - fix: cherry-pick from 4.12.1 - fix(sdk): cancel load-script when redirect - fix(lib): add type of removeSkeleton ### Features - feat(sdk): editor selectImage api - feat(mpp-service) add released pr - feat(sdk): support walletkit and init func - feat(demo): add manual to web input public demo ## [4.12.0-dev.1] 2023-06-28 **Download: [4.12.0-dev.1(1.13 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.12.0-dev.1.zip)** ### Bug Fixes - fix(sdk): font-family should go with system font-family - fix(sdk): domtoimage svg base64 not have datatype - fix(sdk): add export type - fix(demo): fix canvas toTempFilePath - fix(server-side-bundle): remove subpackage prefix of sourceURL - fix(server-side-bundle): sourceURL issue of qjs ### Features - feat(sdk): control input - feat(server-side-bundle): add sentry project name and releaseid - feat(sdk): split figure into fig-caption and image ### Performance Improvements - perf: add filesystem cache ## [4.11.0-dev.3] 2023-06-09 **Download: [4.11.0-dev.3(1.13 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.11.0-dev.3.zip)** ### Bug Fixes - fix(sdk): domtoImage local image support for android - fix(demo): fix share demo ## [4.11.0-dev.2] 2023-06-07 **Download: [4.11.0-dev.2(1.12 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.11.0-dev.2.zip)** ### Bug Fixes - fix(sdk): video fullscreenchange on IOS - fix(cli): hack taro catch event - fix(demo): update prefetch image path - fix(mpp-service): newVersionFromServer might be null issue - fix(demo): reset zoom ref when toggle camera position - fix(sdk): dom to image support private static server images ### Features - feat(server-side-bundle): use file path as sourceURL of qjs - feat(sdk): support udpsocket api - feat(sdk): 🎸 [plugin] add universal web3 provider ## [4.10.2-dev.1] 2023-06-06 **Download: [4.10.2-dev.1(1.14 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.10.2-dev.1.zip)** ### Bug Fixes - fix(sdk): fix startCheckPageTimeline error ## [4.11.0-dev.1] 2023-05-29 **Download: [4.11.0-dev.1(1.11 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.11.0-dev.1.zip)** ### Bug Fixes - fix(sdk): editorContext insertCoin not works - fix(mpp-service): min versoin should not replace the input version - fix(mpp-service): set min upload version as 0.0.1 - fix(automator): read route of undefined issue - fix(mpp-service): disable contentType when getUploadFileKey - fix(demo): websocket url not work ### Features - feat(sdk): dom to image support native canvas - feat(sdk): editor extension link - feat(sdk,bundler,demo): support skeleton - feat(sdk,bundler,demo): add camera component & createCameraContext API ## [4.10.1-dev.1] 2023-05-25 **Download: [4.10.1-dev.1(1.14 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.10.1-dev.1.zip)** ### Bug Fixes - fix(sdk): renderer service compatitable with es5 ## [4.10.0-dev.4] 2023-05-19 **Download: [4.10.0-dev.4(1.10 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.10.0-dev.4.zip)** ### Bug Fixes - fix(sdk): canIUseCustom support string params - fix(cli): support catch touchend ### Features - feat(demo): add prefetchRules ## [4.9.2-dev.1] 2023-05-19 **Download: [4.9.2-dev.1(1.09 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.9.2-dev.1.zip)** ### Bug Fixes - fix(sdk): canIUseCustom support string params ## [4.10.0-dev.3] 2023-05-18 **Download: [4.10.0-dev.3(1.10 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.10.0-dev.3.zip)** ### Bug Fixes - fix(sdk): fix ths issue about get appConfig & getPage - fix(sdk): callbackify error no stack ### Features - feat(sdk): getUserOpenId return token ## [4.9.1-dev.2] 2023-05-17 **Download: [4.9.1-dev.2(1.09 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.9.1-dev.2.zip)** ## [4.10.0-dev.2] 2023-05-16 **Download: [4.10.0-dev.2(1.09 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.10.0-dev.2.zip)** ### Bug Fixes - fix(sdk): load page frame after load base.bxml success ## [4.10.0-dev.1] 2023-05-15 **Download: [4.10.0-dev.1(1.09 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.10.0-dev.1.zip)** ### Bug Fixes - fix(mpp-service): add contentType filed when upload for security - fix(host): download support put - fix(demo): add private send transaction demo - fix(cli): webview injected not work - fix(demo): webview page not found ### Features - feat(sdk): editor coin - feat(sdk): editor image scrollIntoView - feat(sdk): editor image default spinner - feat(sdk): Mini Game touch event optimization - feat(bundler): support bxs ## [4.9.1-dev.1] 2023-05-15 **Download: [4.9.1-dev.1(1.10 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.9.1-dev.1.zip)** ### Bug Fixes - fix(sdk): update load script error code ### Features - feat(sdk): use appConfig after init appConfig & add appConfig detection & syncGetPage or asyncGetPage - feat(host): set custom http headers for fetch requests ## [4.9.0-dev.3] 2023-04-26 **Download: [4.9.0-dev.3(1.09 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.9.0-dev.3.zip)** ### Bug Fixes - fix(demo): production convertToMPUrl usage ### Features - feat(sdk): ut from plugin-location to plugin-request-subscribe-message ## [4.9.0-dev.2] 2023-04-25 **Download: [4.9.0-dev.2(1.09 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.9.0-dev.2.zip)** ### Bug Fixes - fix(sdk): editor caption selection and image keyboard handler - fix(host): definitions for bn.env - fix(sdk): unhandleRejection support polyfilled promise ### Features - feat(sdk): file method support put method - feat(demo): add beforeRouteChange usage to component-demo ## [4.9.0-dev.1] 2023-04-24 **Download: [4.9.0-dev.1(1.09 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.9.0-dev.1.zip)** ### Bug Fixes - fix(sdk): fix edtior editing image error - fix(sdk): init performance observer after worker ready - fix(sdk): editor delete image event stopropagation - fix(sdk): fix load page.js error to report 603505 when webview is des… - fix(demo): fix event-channel demo - fix(demo): on/off pairs ### Features - feat(sdk,bundler): add show confirm bar for input - feat(sdk): srcollview pulldown refresher ## [4.9.0-dev.1] 2023-04-24 **Download: [4.9.0-dev.1(1.09 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.9.0-dev.1.zip)** ### Bug Fixes - fix(sdk): fix edtior editing image error - fix(sdk): init performance observer after worker ready - fix(sdk): editor delete image event stopropagation - fix(sdk): fix load page.js error to report 603505 when webview is des… - fix(demo): fix event-channel demo - fix(demo): on/off pairs ### Features - feat(sdk,bundler): add show confirm bar for input - feat(sdk): srcollview pulldown refresher ## [4.8.0-dev.2] 2023-04-06 **Download: [4.8.0-dev.2(1.09 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.8.0-dev.2.zip)** ### Features - feat(sdk): bids use monitorupload - feat(demo): editor component demo ## [4.8.0-dev.1] 2023-04-04 **Download: [4.8.0-dev.1(1.09 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.8.0-dev.1.zip)** ### Bug Fixes - fix(sdk): editor image selection and focus - fix(mpp-service): print the old and new version ### Features - feat(sdk): remove settimeout for page.show - feat(sdk): page-not-found - feat(sdk): add page-frame-html in sdk - feat(sdk): chooseMedia & chooseFile API # Download Development Version ## [4.7.0-dev.6] 2023-03-17 **Download: [4.7.0-dev.6(1.07 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.7.0-dev.6.zip)** ### Bug Fixes - fix(sdk): editor image cursor position and delete use touchend event - fix(sdk): update report data object & cancel startupTimeout when load resources ## [4.7.0-dev.5] 2023-03-16 **Download: [4.7.0-dev.5(1.07 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.7.0-dev.5.zip)** ### Bug Fixes - fix(sdk): editor image support update and deletable, hashtag keyboard key unexpected issue ## [4.7.0-dev.4] 2023-03-16 **Download: [4.7.0-dev.4(1.07 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.7.0-dev.4.zip)** ### Bug Fixes - fix(sdk): update load-script payload to ensure the cache is loaded - fix(sdk): update event channel if page init before eventChannel ## [4.7.0-dev.3] 2023-03-14 **Download: [4.7.0-dev.3(1.07 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.7.0-dev.3.zip)** ### Bug Fixes - fix(sdk): fix native input color issues on ios13 - fix(demo): update pika to fix input issue - fix(sdk): update dom to image scale impl and fix image / font issues - fix(sdk): rename getUserOpenId & doc-api - getUserOpenId/getUserKycStatus ### Features - feat(sdk): editor focus and mark - feat(sdk): add startupTimeout & restore time compensation ## [4.7.0-dev.2] 2023-03-13 **Download: [4.7.0-dev.2(1.07 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.7.0-dev.2.zip)** ### Bug Fixes - fix(sdk): editor focus and mark ### Features - feat(sdk): catch html - feat(sdk): figure ## [4.7.0-dev.1] 2023-03-09 **Download: [4.7.0-dev.1(1.07 MB)](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.7.0-dev.1.zip)** ### Bug Fixes - fix(host): get-image-info is broken on IDE - fix(host): bn.request support arraybuffer body - fix(demo): radio page issue ### Features - feat(sdk): editor extension update and docs - feat(sdk): loading progress animation - feat(host): createBufferUrl support svg - feat(demo): add dom to image demo - feat(sdk): method domToImage - feat(sdk): exitMiniProgram support force close - feat(sdk): new api - getuseropenid getuserkycstatus - feat(sdk): editor component & editorContext api - feat(sdk):load resource fail or slowly ## [4.6.0-dev.2] 2023-02-22 **Download: [SDK-4.6.0-dev.2](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.6.0-dev.2.zip)** ### Bug Fixes - fix(sdk): add native-send-appLuanch timer ([532dde2e](https://git.toolsfdg.net/fe/mini-program/commit/532dde2e37e8c3ff48cbf655238b88a9a1ff0dcd)) by finley.x@binance.com ### Internal - chore: bump commit after write files ([9378fed1](https://git.toolsfdg.net/fe/mini-program/commit/9378fed122a9613f50aac333ff8543d12893bbbc)) by dylan.z@binance.com ## [4.6.0-dev.1] 2023-02-21 **Download: [SDK-4.6.0-dev.1](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.6.0-dev.1.zip)** ### Bug Fixes - fix(bundler): css variables rpx to rem align with wechat ([5fcfd131](https://git.toolsfdg.net/fe/mini-program/commit/5fcfd1319437e3fd52389083be12f459cb53d243)) by dylan.z@binance.com - fix(sdk): mini game view port size ([fc6048f0](https://git.toolsfdg.net/fe/mini-program/commit/fc6048f03ed5b9cb7357654e8a5699124fa38898)) by henry.w@binance.com - fix(sdk): getChildrenNode util function ([7c5764b6](https://git.toolsfdg.net/fe/mini-program/commit/7c5764b60831fa1c194490a907a1ad10e7ded92b)) by henry.w@binance.com - fix(sdk): rendererId zero issue in native ui ([c3d9020b](https://git.toolsfdg.net/fe/mini-program/commit/c3d9020b10630ac6c12f71595fb3c80cd3e7d2cf)) by dylan.z@binance.com - fix(bundler): catchmove value should be an exp ([dc53e87f](https://git.toolsfdg.net/fe/mini-program/commit/dc53e87f6ccb59b859b0eb13171f5038c98910da)) by lawrence.w@binance.com - fix(sdk): swiper Item blank ([7981ff89](https://git.toolsfdg.net/fe/mini-program/commit/7981ff894557f9145b619a68c823252654826014)) by finley.x@binance.com - fix(demo):fix custom demo textarea maxlength ([c28c58aa](https://git.toolsfdg.net/fe/mini-program/commit/c28c58aa2556d9e8eb21ef3b46269461bcf308c4)) by henry.w@binance.com ### Features - feat(demo): control picker view demo ([b80c088c](https://git.toolsfdg.net/fe/mini-program/commit/b80c088cd6307f659af3fba713787becc824479c)) by lawrence.w@binance.com - feat(sdk): detect page timeline ([0b1381a4](https://git.toolsfdg.net/fe/mini-program/commit/0b1381a4406d0767f736836a8418aede38ccd44f)) by finley.x@binance.com - feat(host): support pageReadyCallback ([1339544e](https://git.toolsfdg.net/fe/mini-program/commit/1339544ec010a520efab2e822bfe15d4249fdc66)) by dylan.z@binance.com ### Refactor - refactor: remove any type in AppCommandMap ([9b2411bd](https://git.toolsfdg.net/fe/mini-program/commit/9b2411bde6250820403082572e38070d9c9fc443)) by lucifer.l@binance.com ### Internal - docs: add api comment for documentation ([7993a741](https://git.toolsfdg.net/fe/mini-program/commit/7993a741307a4049768fcfe771cfbb3ad6231723)) by dylan.z@binance.com - chore: update bump with git auto push ([e25b674f](https://git.toolsfdg.net/fe/mini-program/commit/e25b674f8ed8fd0638bc25122a9d8c6efb223d6d)) by dylan.z@binance.com - chore: change UT coverage scope and threshold ([50820980](https://git.toolsfdg.net/fe/mini-program/commit/50820980c6a0d517e0a19df8d2ed740965c36f40)) by lucifer.l@binance.com - docs: format issue ([05c3cc6e](https://git.toolsfdg.net/fe/mini-program/commit/05c3cc6e632ea84fc316a8db27fa7c9337d2ca24)) by dylan.z@binance.com - docs: update config ([aaae5561](https://git.toolsfdg.net/fe/mini-program/commit/aaae556164f3bd260fbed971c490f090b6327a25)) by dylan.z@binance.com - docs: excited features of the JSCore team 202302 ([1b38cbfe](https://git.toolsfdg.net/fe/mini-program/commit/1b38cbfe6c2344120f532eed76bda7a6990a7fc8)) by dylan.z@binance.com - [WIP]fix(sdk): controlled picker view ([661aa89a](https://git.toolsfdg.net/fe/mini-program/commit/661aa89ad9c3289ce614f2b77995d4ebf6d08bfa)) by lawrence.w@binance.com - mpp service support binance us host app ([fb8edeb8](https://git.toolsfdg.net/fe/mini-program/commit/fb8edeb8c6840cc84ef840c6ca84dcfc3a51fd72)) by leo.cc@binance.com # [4.5.1-dev.1] 2023-02-14 **Download: [SDK-4.5.1-dev.1](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.5.1-dev.1.zip)** ### Bug Fixes - fix(sdk): cherry-pick - picker view control mode ([01449416](https://git.toolsfdg.net/fe/mini-program/commit/01449416c3989a0e9d2e89811987e30c8d40bdbd)) by lawrence.w@binance.com ## [3.14.16-dev.1] 2023-02-10 **Download: [SDK-3.14.16-dev.1](https://ftp.binance.com/mp-sdk/dev/mp-sdk-3.14.16-dev.1.zip)** ### Bug Fixes - fix(sdk): cherry-pick - picker view control mode ([d9a10d59](https://git.toolsfdg.net/fe/mini-program/commit/d9a10d599fb2ab6d7c222c2204917dcd7511a888)) by lawrence.w@binance.com # [4.5.0-dev.2] 2023-02-01 **Download: [SDK-4.5.0-dev.2](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.5.0-dev.2.zip)** ### Bug Fixes - fix(sdk): fix requestBinanceCardInfo error response & cicd ([b18093ab](https://git.toolsfdg.net/fe/mini-program/commit/b18093abab0f1aa938d804d91d93e6c55e2ba949)) by lawrence.w@binance.com - fix(bundler): compile optional chaining when using latest caniuse-lite ([771dc7af](https://git.toolsfdg.net/fe/mini-program/commit/771dc7af2ea7eb809d3c3834f5733052dfb6df27)) by jolin.h@binance.com - fix(sdk): android css transition native component ([a70840e6](https://git.toolsfdg.net/fe/mini-program/commit/a70840e6d95fd2488bfe0993377224da6defa855)) by henry.w@binance.com ### Features - feat(sdk): add binance-card-info api ([65680864](https://git.toolsfdg.net/fe/mini-program/commit/65680864e327d5b81eca872e11ca4db55039948e)) by lawrence.w@binance.com - feat(demo): migrate to pika ([8cdffe8c](https://git.toolsfdg.net/fe/mini-program/commit/8cdffe8c1f46bb9181a915b7f21fc9a512db2063)) by dylan.z@binance.com - feat(sdk): jssdk dashboard rename & calculate ([ea78ac01](https://git.toolsfdg.net/fe/mini-program/commit/ea78ac01e11f57278428b190b600e0e008e0fc53)) by finley.x@binance.com - feat(sdk): wallet connector use new wallet provider ([ca346f5d](https://git.toolsfdg.net/fe/mini-program/commit/ca346f5d4f9560ae2fb59c2c2fdbb251eb8f4a33)) by zane.x@binance.com ### Refactor - refactor: throw error for the non-supported apis in IDE ([62e2ad65](https://git.toolsfdg.net/fe/mini-program/commit/62e2ad659b2143dd6eac1567fb2016758a4294e6)) by lucifer.l@binance.com ### Internal - docs: remove the app.config.json issue since pika will support it ([747343ed](https://git.toolsfdg.net/fe/mini-program/commit/747343ed66a9de848d6399a9e9521a6ba5f883e1)) by dylan.z@binance.com ## [4.5.0-dev.1] 2023-01-18 **Download: [SDK-4.5.0-dev.1](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.5.0-dev.1.zip)** ### Features - feat(lib): add WebViewComponent to @binance/bmp-components - feat(demo): add English desc to image mode demo - feat(sdk): remove window info cache for view-base mode - feat(lib): add getCurrentInstance & getTabBar to @binance/bmp-react ### Internal - docs: getCurrentInstance query incorrect ## [4.4.0-dev.5] 2023-01-12 **Download: [SDK-4.4.0-dev.5](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.4.0-dev.5.zip)** ### Bug Fixes - fix(sdk): fit audio platform api getters/setters on Andriod - fix(sdk): add RootPortal type ## [4.4.0-dev.4] 2023-01-11 **Download: [SDK-4.4.0-dev.4](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.4.0-dev.4.zip)** ### Bug Fixes - fix(sdk): mpc method - fix(lib): update types of bmp-react ### Features - feat(sdk): webview component supports message ### Internal - chore: update config for FAQ - docs: faq about app.config.json ## [4.4.0-dev.3] 2023-01-10 **Download: [SDK-4.4.0-dev.3](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.4.0-dev.3.zip)** ### Bug Fixes - fix(sdk): types of bn.call & add RootPortal to bmp-components ### Features - feat(sdk): add runtime-plugin-mpc - feat(automator): impove `setupProxyMethod` & add test - feat(sdk): create buffer url supports extension option ### Internal - docs(sdk): darkmode ## [4.4.0-dev.2] 2023-01-06 **Download: [SDK-4.4.0-dev.2](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.4.0-dev.2.zip)** ### Bug Fixes - fix(demo): caret-color - fix(lib): virtual-list use new bmp packages - fix(sdk): update canIuse info ### Features - feat(demo): add audio and write file benchemark - feat(sdk): swiper support previousMargin/nextMargin/snapToEdge - feat(automator): add mock api for automator - feat(lib): bmp-api & bmp-components & bmp-react - feat(sdk): add error log for 603114 ## [4.4.0-dev.1] 2023-01-04 **Download: [SDK-4.4.0-dev.1](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.4.0-dev.1.zip)** ### Bug Fixes - fix(sdk): cherry pick fix picker view component - fix(lib): @binance/mp-components don't import @tarojs/components - fix(sdk): image reload after src changes ### Features - feat(sdk): View support prop: catchMove - feat(demo): images add mode & readFile add length & position config - feat(lib): generate types for @binance/mp-service - feat(sdk): root-portal ### Internal - chore(sdk): cherry pick update sdk loading - test: add more unit tests for host ## [4.3.0-dev.4] 2022-12-22 **Download: [SDK-4.3.0-dev.4](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.3.0-dev.4.zip)** ### Bug Fixes - fix(sdk): mini game keyboard event ### Features - feat: integrate automator on CI ### Internal - chore: remove `yarn playwright install --with-deps` ## [4.3.0-dev.3] 2022-12-21 **Download: [SDK-4.3.0-dev.3](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.3.0-dev.3.zip)** ### Bug Fixes - fix(demo): fix demo navigation bar page - fix(bundler): fix babel env target ### Features - feat(sdk): loadFontFace - feat(sdk): file system api use platform api - feat(sdk): expose navigateBackMiniProgram, add mpModalType prop to navigateToMiniProgram - feat(sdk): webview bounce and loading bar ### Refactor - refactor: rename host-mp-ide to host-ide ### Internal - docs(sdk): integrate with doc-system - chore(package.json): fix installing sqllite3 in macos ## [4.3.0-dev.2] 2022-12-19 **Download: [SDK-4.3.0-dev.2](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.3.0-dev.2.zip)** ### Bug Fixes - fix(demo): api navigation bar input element - fix(sdk): cherry-pick from release/3.14 ### Features - feat(lib): fork implement from @tarojs/components to @binance/mp-components - feat(sdk): create buffer url use platformAPI ### Internal - chore(package.json): add packageManager field - chore: replace resolve with join - chore(sdk): cherry-pick from 4.2.1 - chore: update version remote and pwd alias ## [4.3.0-dev.1] 2022-12-14 **Download: [SDK-4.3.0-dev.1](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.3.0-dev.1.zip)** ### Bug Fixes - fix(runtime): network service setupServices multiple times - fix(automator): update @binance/mp-web for fix some issue and add `sdkPath` option - fix(bundler): launch MP with page of independent subpackage - fix(sdk): Image widthfix/heightFix mode can update size automatically - fix(demo): fix universal-share css ### Features - feat(sdk): createInnerAudioContext use platform api - feat(demo): fix create buffer url demo ### Internal - chore: bump local - chore: update prefetch rule of component demo - docs: demos readme ## [4.2.0-dev.4] 2022-11-30 **Download: [SDK-4.2.0-dev.4](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.2.0-dev.4.zip)** ### Bug Fixes - fix(bundler): reorder files in pkg - renderer files first - fix(sdk): fix web canvas width and height ### Features - feat(sdk): gcanvas optimazation ### Internal - chore: remove useless message in changelog.md by 'bot' ## [4.2.0-dev.3] 2022-11-30 **Download: [SDK-4.2.0-dev.3](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.2.0-dev.3.zip)** ### Bug Fixes - fix(automator): replace parcel with http server to fix the installation issue from BIDS - fix(sdk): selectorQuery return empty when error - fix(runtime): remove BXML spaces ### Features - feat(demo): add a rendererId 0 issue test case ### Refactor - refactor(sdk): plugins including show-leaderboard, storage and tab-bar ### Internal - chore: redirect blank page issue ## [4.2.0-dev.2] 2022-11-24 **Download: [SDK-4.2.0-dev.2](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.2.0-dev.2.zip)** ### Bug Fixes - fix(bundler): remove setImmediate polyfill to fix pika MP white screen on iOS ### Refactor - refactor(sdk): native ui plugin - refactor(sdk): replace enum with union type ### Internal - chore(changelog): @mp/worker-mg@1.0.23 - chore(changelog): @mp/server-side-bundle@1.0.15 - chore(changelog): @mp/runtime-service-web@0.2.29 - chore(changelog): @mp/gen-sdk@1.0.25 - chore(changelog): @mp/host@0.2.58 - chore(changelog): @binance/mp-automator@2.0.7 - chore(changelog): @mp/remote-debug@1.0.25 - chore(changelog): @mp/mp-runtime-shared-plugins@1.1.24 - chore(changelog): @mp/runtime-plugin-user-info@1.0.16 - chore(changelog): @mp/runtime-plugin-ensure-resources@1.0.15 - chore(changelog): @mp/runtime-plugin-load-subpackage@1.0.13 - chore(changelog): @mp/plugins-mg@1.0.48 - chore(changelog): @mp/runtime-plugin-download-package@1.0.16 - chore(changelog): @mp/webview@1.0.16 - chore(changelog): @mp/runtime-plugin-performance@1.0.19 - chore(changelog): @mp/runtime-plugin-fps@1.0.9 - chore(changelog): @mp/app-command@1.0.18 - chore(changelog): @mp/runtime-plugin-create-intersection-observer@1.0.9 - chore(changelog): @mp/runtime-plugin-wallet-connector@1.0.5 - chore(changelog): @mp/runtime-plugin-current-ui-event@1.0.9 - chore(changelog): @mp/plugins-mp-internal@1.0.15 - chore(changelog): @mp/runtime-plugin-sensor-compass@1.0.8 - chore(changelog): @mp/runtime-plugin-app-lifecycle@1.0.8 - chore(changelog): @mp/runtime-plugin-system-info@1.0.13 - chore(changelog): @mp/runtime-plugin-sensor-gyroscope@1.0.8 - chore(changelog): @mp/runtime-plugin-keyboard@1.0.8 - chore(changelog): @mp/runtime-plugin-request-subscribe-message@1.0.6 - chore(changelog): @mp/runtime-plugin-sensor-accelerometer@1.0.8 - chore(changelog): @mp/runtime-plugin-app-internal@1.0.10 - chore(changelog): @mp/runtime-plugin-custom-plugin@1.0.13 - chore(changelog): @mp/runtime-plugin-ensure-logged-in@1.0.7 - chore(changelog): @mp/runtime-plugin-share-panel@1.0.11 - chore(changelog): @mp/runtime-plugin-inner-audio@1.0.7 - chore(changelog): @mp/runtime-plugin-update-manager@1.0.13 - chore(changelog): @mp/runtime-plugin-location@1.0.9 - chore(changelog): @mp/runtime-plugin-save-image-to-photos-album@1.0.8 - chore(changelog): @mp/runtime-plugin-audio-interruption@1.0.7 - chore(changelog): @mp/runtime-plugin-websocket@1.0.13 - chore(changelog): @mp/runtime-plugin-sensor-device-motion@1.0.8 - chore(changelog): @mp/runtime-plugin-upload-file@1.0.12 - chore(changelog): @mp/runtime-plugin-share-menu@1.0.5 - chore(changelog): @mp/runtime-plugin-scan-code@1.0.8 - chore(changelog): @mp/runtime-plugin-file-system-manager@1.0.8 - chore(changelog): @mp/runtime-plugin-create-webview@1.0.12 - chore(changelog): @mp/runtime-plugin-authorize@1.0.6 - chore(changelog): @mp/runtime-plugin-error-page@1.0.9 - chore(changelog): @mp/runtime-plugin-image-info@1.0.14 - chore(changelog): @mp/runtime-plugin-make-phone-call@1.0.6 - chore(changelog): @mp/runtime-plugin-can-use@1.0.14 - chore(changelog): @mp/bundler@3.0.9 - chore(changelog): @mp/runtime-plugin-framework-storage@1.0.4 - chore(changelog): @mp/runtime-plugin-choose-image@1.0.8 - chore(changelog): @mp/host-core@1.0.14 - chore(changelog): @binance/mp-cli@2.4.29 - chore(changelog): @mp/mpp-service@1.0.34 - chore(changelog): update changelog for version v4.2.0-dev.1 - chore(changelog): @binance/mp-web@0.0.34 - chore(changelog): @binance/mp-automator@2.0.5 - chore(changelog): @mp/runtime-sdk-electron@0.1.28 - chore(changelog): @mp/host@0.2.57 - chore(changelog): @mp/gen-sdk@1.0.24 - chore(changelog): @mp/mp-runtime-shared-plugins@1.1.23 - chore(changelog): @mp/runtime-service-web@0.2.28 - chore(changelog): @mp/remote-debug@1.0.24 - chore(changelog): @mp/runtime-plugin-load-subpackage@1.0.12 - chore(changelog): @mp/plugins-mp@1.0.47 - chore(changelog): @mp/plugins-mg@1.0.47 - chore(changelog): @mp/runtime-worker-common@1.0.26 - chore(changelog): @mp/runtime-plugin-download-package@1.0.15 - chore(changelog): @mp/runtime-plugin-ensure-resources@1.0.14 ## [4.2.0-dev.1] 2022-11-23 **Download: [SDK-4.2.0-dev.1](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.2.0-dev.1.zip)** ### Bug Fixes - fix(automator): fix some bugs & add `.waitFor` - fix(sdk): native component css - fix(sdk): (cherry-pick) reduce the blank page - fix(runtime): no need to add webview when open new page - fix(demo): input style of storage pages & update privatePrefetchRules - fix(sdk): cherry pick - load-script-progress event when mp background event to lead blank screen - fix(sdk): cherry pick fix location plugin - fix(cli): skip generation of unmatched tags - fix(demo): request pages issue of component-demo - fix(sdk): load \_\_app.js after $ready - fix(sdk): remove generating worker-service-game.qjs - fix(runtime): vibrate shifting bug - fix(demo): show isPrefetch in request pages ### Features - feat(sdk): demo update & delete appTimeline - feat(sdk): native webview component - feat(demo): runtime benchmark add getAppBaseInfo apis - feat(sdk): (cherry-pick)support caretColor for Input and TextArea components - feat(automator): automator added headless option & refactor `.launch` & demo page - feat(demo): move sync-api-demo to component-demo & update prefetchRules - feat(sdk): api on add to favorites - feat(bundler): generate fileTree for analyzeSource - feat(sdk): first render new fields - feat(runtime): support selecting sdk ### Refactor - refactor(host): plugin user-info - refactor(host): plugin & remove twoFA demo ### Internal - chore(changelog): @mp/runtime-service-web@0.2.27 - chore(changelog): @mp/server-side-bundle@1.0.13 - chore(changelog): @binance/mp-automator@2.0.4 - chore(changelog): @binance/mp-web@0.0.33 - chore(changelog): @mp/runtime-sdk-electron@0.1.27 - chore(changelog): @mp/gen-sdk@1.0.23 - chore(changelog): @mp/runtime-worker-common@1.0.25 - chore(changelog): @mp/worker-mg@1.0.21 - chore(changelog): @mp/mp-runtime-shared-plugins@1.1.22 - chore(changelog): @mp/remote-debug@1.0.23 - chore(changelog): @mp/host@0.2.56 - chore(changelog): @mp/runtime-plugin-load-subpackage@1.0.11 - chore(changelog): @mp/plugins-mg@1.0.46 - chore(changelog): @mp/runtime-plugin-ensure-resources@1.0.13 - chore(changelog): @mp/runtime-plugin-user-info@1.0.15 - chore(changelog): @mp/runtime-plugin-download-package@1.0.14 - chore(changelog): @mp/webview@1.0.15 - chore(changelog): @mp/runtime-plugin-performance@1.0.17 - chore(changelog): @mp/runtime-plugin-fps@1.0.8 - chore(changelog): @mp/app-command@1.0.17 - chore(changelog): @mp/runtime-plugin-create-selector-query@1.0.11 - chore(changelog): @mp/runtime-plugin-wallet-connector@1.0.4 - chore(changelog): @mp/runtime-plugin-create-intersection-observer@1.0.8 - chore(changelog): @mp/runtime-plugin-current-ui-event@1.0.8 - chore(changelog): @mp/runtime-plugin-request-subscribe-message@1.0.5 - chore(changelog): @mp/runtime-plugin-app-lifecycle@1.0.7 - chore(changelog): @mp/runtime-plugin-ensure-logged-in@1.0.6 - chore(changelog): @mp/plugins-mg-internal@1.0.13 - chore(changelog): @mp/runtime-plugin-update-manager@1.0.12 - chore(changelog): @mp/runtime-plugin-auth-capture@1.0.6 - chore(changelog): @mp/runtime-plugin-sensor-gyroscope@1.0.7 - chore(changelog): @mp/runtime-plugin-upload-file@1.0.11 - chore(changelog): @mp/runtime-plugin-web3@1.0.4 - chore(changelog): @mp/runtime-plugin-network@1.0.8 - chore(changelog): @mp/runtime-plugin-websocket@1.0.12 - chore(changelog): @mp/runtime-plugin-save-image-to-photos-album@1.0.7 - chore(changelog): @mp/runtime-plugin-sensor-compass@1.0.7 - chore(changelog): @mp/runtime-plugin-sensor-orientation@1.0.6 - chore(changelog): @mp/runtime-plugin-image-info@1.0.13 - chore(changelog): @mp/runtime-plugin-location@1.0.8 - chore(changelog): @mp/mpp-service@1.0.33 - chore(changelog): @mp/runtime-plugin-app-internal@1.0.9 - chore(changelog): @mp/runtime-plugin-keyboard@1.0.7 - chore(changelog): @mp/runtime-plugin-custom-plugin@1.0.12 - chore(changelog): @mp/runtime-plugin-share-panel@1.0.10 - chore(changelog): @mp/runtime-plugin-download-file@1.0.6 - chore(changelog): @mp/runtime-plugin-choose-image@1.0.7 - chore(changelog): @mp/runtime-plugin-make-phone-call@1.0.5 - chore(changelog): @mp/runtime-plugin-authorize@1.0.5 - chore(changelog): @mp/runtime-plugin-system-info@1.0.12 - chore(changelog): @mp/runtime-plugin-preview-image@1.0.8 - chore(changelog): @mp/runtime-plugin-scan-code@1.0.7 - chore(changelog): @mp/runtime-plugin-on-off@1.0.9 - chore(changelog): @mp/runtime-plugin-create-webview@1.0.11 - chore(changelog): @mp/runtime-plugin-can-use@1.0.13 - chore(changelog): @mp/runtime-plugin-clipboard@1.0.7 - chore(changelog): @mp/bundler@3.0.7 - chore(changelog): @mp/runtime-plugin-file-system-manager@1.0.7 - chore(changelog): @mp/runtime-plugin-favorite@1.0.2 - chore(changelog): @mp/runtime-shared@1.0.15 - chore(changelog): @mp/host-core@1.0.13 - chore(changelog): @binance/mp-cli@2.4.28 - chore(changelog): @binance/mp-web@0.0.32 - chore(changelog): @binance/mp-automator@2.0.3 - chore(changelog): @binance/mp-automator@2.0.2 - chore(changelog): @mp/runtime-sdk-electron@0.1.26 - chore(changelog): @mp/runtime-service-web@0.2.26 - chore(changelog): @binance/mp-web@0.0.31 - chore(changelog): @mp/host@0.2.55 - chore(changelog): @mp/worker-mg@1.0.20 - chore(changelog): @mp/remote-debug@1.0.22 - chore(changelog): @mp/plugins-mg@1.0.45 - chore(changelog): @mp/runtime-worker-common@1.0.24 - chore(changelog): @mp/runtime-plugin-download-package@1.0.13 - chore(changelog): @mp/runtime-plugin-performance@1.0.16 - chore(changelog): update changelog for version v3.14.8 - chore(changelog): @mp/runtime-service-web@0.2.25 - chore(changelog): @mp/gen-sdk@1.0.21 - chore(changelog): @binance/mp-web@0.0.30 - chore(changelog): @mp/runtime-worker-common@1.0.23 - chore(changelog): @mp/worker-mg@1.0.19 - chore(changelog): @mp/remote-debug@1.0.21 - chore(changelog): @mp/runtime-plugin-user-info@1.0.14 - chore(changelog): @mp/plugins-mp@1.0.44 - chore(changelog): update changelog for version v4.0.3 - chore(changelog): @mp/mpp-service@1.0.32 - chore(changelog): @binance/mp-automator@2.0.0 - chore(changelog): @mp/bundler@3.0.6 - chore(changelog): @mp/server-side-bundle@1.0.12 - chore(changelog): @binance/mp-web@0.0.29 - chore(changelog): @mp/runtime-service-web@0.2.24 - chore(changelog): @binance/mp-automator@1.0.14 - chore(changelog): @binance/mp-web@0.0.28 - chore(changelog): @mp/host@0.2.53 - chore(changelog): @mp/gen-sdk@1.0.20 - chore(changelog): @mp/worker-mg@1.0.18 - chore(changelog): @mp/mp-runtime-shared-plugins@1.1.19 - chore(changelog): @mp/plugins-mg@1.0.43 - chore(changelog): @mp/runtime-worker-common@1.0.22 - chore(changelog): @mp/remote-debug@1.0.20 - chore(changelog): @mp/plugins-mp@1.0.43 - ci: fix git push tag one by one - chore(changelog): @mp/server-side-bundle@1.0.11 - chore(changelog): @mp/mpp-service@1.0.31 - chore(changelog): @mp/bundler@3.0.5 - chore(changelog): update changelog for version v3.14.7 - chore: add caretColor demo - chore(changelog): update changelog for version v3.14.6 - chore(changelog): update changelog for version v4.1.0 - chore(changelog): update changelog for version v4.1.0 - chore(changelog): @binance/mp-cli@2.4.27 - chore(changelog): update changelog for version v4.0.2 - chore(changelog): @mp/gen-sdk@1.0.17 - chore(changelog): @mp/gen-sdk@1.0.16 - chore: gen-sdk local - chore(changelog): @binance/mp-automator@1.0.9 - chore(changelog): @binance/mp-web@0.0.23 - chore(changelog): update changelog for version v4.1.0-dev.3 ## [4.1.0-dev.3] 2022-11-10 **Download: [SDK-4.1.0-dev.3](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.1.0-dev.3.zip)** ### Bug Fixes - fix(cli): mpService should support both function api and object api ### Features - feat(sdk): web canvas component - feat(demo): mini game system info demo ### Internal - chore(changelog): @binance/mp-cli@2.4.26 - chore(changelog): @binance/mp-automator@1.0.7 - chore(changelog): @binance/mp-web@0.0.21 - chore(mp-web): update start script - chore(changelog): update changelog for version v3.14.5 - chore(changelog): @binance/mp-cli@2.4.25 - chore: fix changelog.md - chore(changelog): update changelog for version v4.1.0-dev.2 ## [4.1.0-dev.2] 2022-11-09 **Download: [SDK-4.1.0-dev.2](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.1.0-dev.2.zip)** ### Bug Fixes - fix(mp-web): support absolute path - fix(changelog): changelog bug: 3.14.5-dev.1 & 4.0.2-dev.1 - fix(sdk): add readme for deprecated usage - fix(sdk): cherry pick - await load appJs - fix(sdk): fix image style not work - fix(cli): remove .npmrc and add npm token - fix(cli): duplicate resolve issue of ConditionNamesPlugin - fix(sdk): network service - fix(sdk): ready replace uirenderserviceready - fix(host): create webview files issue - fix(host): support private-request command - fix(runtime): download-file not work - fix(sdk): env undefined - fix(sdk): revoke native buffer issue - fix(mp-web): fix sw.js ready timeline issue - fix(sdk): native-image onload and image bug ### Features - feat(sdk): load gcanvas on demand - feat(sdk): add page-frame-resource points - feat(automator): refactor mp-web & inject mp-web to automator - feat(sdk): gcanvas createJSBuffer, less cpu cost - feat(automator): support plugins service to fix service undefined issue - feat(bundler): add **REPORT_POINTS** for renderer - feat(sdk): nezhaRenderPageJs point - feat(automator): allow reloading the mini-program - feat(cli): update publish yml file - feat(sdk): truncate long rpc logs limit length - feat(sdk): shareAppMessage support fallback url - feat(sdk): add debounce to navigator - feat(cli): support conditional exports bmp - feat(sdk): renderer to native page ready - feat(sdk): add param usePrefetchCache to bn.request - feat(demo): release component-demo PROD - feat(sdk): getPerformance support entryType: loadPackage downloadPackage - feat(sdk): scroll-view support showScrollbar - feat(sdk): mg keyboard api - feat(demo): taro version runtime benchmark ### Refactor - refactor(sdk): migrate wallet-connector plugin - refactor(host): share-menu(sdk & host)and network - refactor(sdk): migrate toast plugin ### Misc - Revert "fix(sdk): env undefined" ### Internal - chore(changelog): @binance/mp-cli@2.4.24 - chore(demo): update prefetchRules of component-demo - chore(changelog): @binance/mp-cli@2.4.23 - ci: fix bump exclude checked cache files - chore(changelog): @mp/gen-sdk@1.0.12 - ci: fix wrong git tag versions for manifest and changelog - chore(changelog): update changelog for version v3.14.5 - ci: pass the job if there is nothing to be validated - chore(changelog): @binance/mp-web@0.0.18 - chore(changelog): @binance/mp-web@0.0.17 - docs: update how to fixed log when version validate failed - chore(changelog): update changelog for version v3.14.5-dev.1 - docs(sdk): add docs about yarn bump - chore(changelog): update changelog for version v4.0.2-dev.1 - chore: fix submodule error by removing temp file - chore(changelog): @binance/mp-cli@2.4.22 - chore: bump version issue cause by cicd - chore: local auto bump support - chore(changelog): @binance/mp-cli@2.4.21 - chore: update ci - chore(changelog): update changelog for version v4.0.1 - chore: version validate - chore: rename pipeline name - chore: update npm-publish job - ci: fix release job for git fetch failed on CI - chore: test new job success - chore(changelog): update changelog for version v3.14.4 - chore: bump host deps chain - chore(changelog): update changelog for version v4.0.1-dev.1 - ci: setup ci changelog & release automatically - chore(sdk): bump plugins version - chore(sdk): plugin bump version - chore(sdk): bump versions - chore(sdk): add mg adapter file - chore(changelog): update changelog for version v4.1.0-dev.1 ## [3.14.5-dev.1] 2022-11-08 **Download: [SDK-3.14.5-dev.1](https://ftp.binance.com/mp-sdk/dev/mp-sdk-3.14.5-dev.1.zip)** ### Features - feat(sdk): add page-frame-resource points ## [4.0.2-dev.1] 2022-11-08 **Download: [SDK-4.0.2-dev.1](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.0.2-dev.1.zip)** ### Bug Fixes - fix(sdk): cherry pick - fix image style not work - fix(sdk): await load appJs ## [4.0.1-dev.1] 2022-11-02 **Download: [SDK-4.0.1-dev.1](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.0.1-dev.1.zip)** ### Bug Fixes - fix(sdk): env undefined ### Internal - chore(cicd): yaml files ## [4.1.0-dev.1] 2022-10-27 **Download: [SDK-4.1.0-dev.1](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.1.0-dev.1.zip)** ### Bug Fixes - fix(runtime): width of scroll-bar should be zero - fix(automator): support download-package rpc - fix(cli): update web host cli ### Features - feat(demo): virtual list - feat(runtime): support bn.env.USER_DATA_PATH - feat(sdk): remove monitor because native didn't support the commands - feat(sdk): loadScriptSync rpc ### Refactor - refactor(host): update manager and webview plugin - refactor(sdk): migrate web3 plugin ### Internal - chore(cicd): migrate prowjobs - chore(changelog): update changelog for version v4.0.0 - chore: noopify commands ## [4.0.0-dev.3] 2022-10-19 **Download: [SDK-4.0.0-dev.3](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.0.0-dev.3.zip)** ### Bug Fixes - fix(sdk): useNativeImage - fix(mpp-service): copy source-code ignore node_module & hidden files ### Features - feat(sdk): navigateTo add target external - feat(sdk): update canIUse for new api - feat(runtime): downloa-package add two fields ### Internal - chore(runtime): add currentSize filed - chore: update public demo - chore(sdk): automator package rename - chore(changelog): update changelog for version v4.0.0-dev.2 ## [4.0.0-dev.2] 2022-10-17 **Download: [SDK-4.0.0-dev.2](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.0.0-dev.2.zip)** ### Bug Fixes - fix(sdk): fix image and keep **MP_WARN_DEPRECATED** - fix(sdk): gcanvas toDataURL and audio time update event - fix(server-side-bundle): upload bytecode pkg issue - fix(sdk): getUserProfile mini game doesn't need check tap event ### Features - feat(bundler): add monitor NEZHA_RENDER_PAGE_JS & update sorter of pkg - feat(host): remove canvas useless dep - feat(sdk): remove deprecated items for sdk4.0 - feat(sdk): getSystemInfo cache - feat(server-side-bundle): compile & upload worker code into bytecode when enableBytecode - feat(sdk): bump versions - feat(sdk): bump version for ide deps - feat(sdk): validate current page is tabBar page when call tabBar apis - feat(demo): update prod demo - feat(sdk): plugin createIntersectionObserver and fix selectorQuery setTimeout issue - feat(sdk): detect darkmode for appBaseInfo - feat(sdk): load app js advance after worker send $Ready ### Misc - Revert "Revert "refactor(sdk): remove locationReadyManager " (#888)" (#929) ### Internal - chore(changelog): update changelog for version v3.14.2 - chore: update public demo - chore: component-demo - chore: bump npm versions - chore(changelog): update changelog for version v4.0.0-dev.1 ## [4.0.0-dev.1] 2022-10-12 **Download: [SDK-4.0.0-dev.1](https://ftp.binance.com/mp-sdk/dev/mp-sdk-4.0.0-dev.1.zip)** ### Bug Fixes - fix(demo): native input width zero in android when container is a flex box - fix(sdk): reuqest text no response - fix(bundler): update dependencies to fix pkg-cli - fix(bundler): support error stack link jump of dev mode page.worker.js ### Features - feat(sdk): generate bytecode for worker-service - feat(sdk): gcanvas buffer data optimize - feat: native image - feat(bundler): add new package node-qjsc - feat(sdk): getAppBaseInfo & getWindowInfo & getDeviceInfo - feat(runtime): expose updateBackground of create webview service for ide - feat(sdk): $renderer-ready action - feat(sdk): loadScriptSync method ### Internal - chore(changelog): update changelog for version v3.14.1 ## [3.14.0-dev.4] 2022-09-26 **Download: [SDK-3.14.0-dev.4](https://ftp.binance.com/mp-sdk/dev/mp-sdk-3.14.0-dev.4.zip)** ### Bug Fixes - fix(sdk): cache promise online with polyfill - fix(sdk): mini game audio adapter - fix: disable ed and add @deprecated flag - fix(sdk): changelog issue ### Features - feat(demo): improve twoFa demo - feat(demo): remove webauthn demo - feat(bundler): add statistics mode to pkg-cli & feat(mpp-service): support config msv ### Misc - Revert "refactor(sdk): remove locationReadyManager " (#888) ### Internal - chore(changelog): update changelog for version v3.13.3 - chore(changelog): update changelog for version v3.14.0-dev.3 ## [3.14.0-dev.3] 2022-09-23 **Download: [SDK-3.14.0-dev.3](https://ftp.binance.com/mp-sdk/dev/mp-sdk-3.14.0-dev.3.zip)** ### Bug Fixes - fix(sdk): callbackId could be zero - fix(sdk): input scrollbar css issue on android - fix(sdk): isCache undefined issue ### Features - feat(sdk,demo): add private fps api and benchmark for render fps ### Internal - chore(changelog): update changelog for version v3.14.0-dev.2 ## [3.14.0-dev.2] 2022-09-22 **Download: [SDK-3.14.0-dev.2](https://ftp.binance.com/mp-sdk/dev/mp-sdk-3.14.0-dev.2.zip)** ### Bug Fixes - fix(mpp-service): fix status api empty fail message ### Features - feat(sdk): cache promise reject handler - feat(sdk): getperformance-evaluateScript - feat(lib): add promise polyfill source code and descreption ### Refactor - refactor(sdk): remove locationReadyManager ### Internal - chore(changelog): update changelog for version v3.14.0-dev.1 ## [3.14.0-dev.1] 2022-09-21 **Download: [SDK-3.14.0-dev.1](https://ftp.binance.com/mp-sdk/dev/mp-sdk-3.14.0-dev.1.zip)** ### Bug Fixes - fix(sdk): add properties on webgl context - fix(sdk): fix timeOrigin 0 issues on IOS14 - fix(runtime): cannot resolve the font with url "bnshare://" - fix(sdk): fix getperformance firstRender - fix: cherry-pick cachePromise of getSystemInfo - fix(sdk): use promise polyfill fix promise task order in ios12 - ios14 - fix(sdk): error code detection of remote debug - fix(sdk): requestAnimationFrame NaN - fix(automator): web cli core apis - fix: add dependency to pass build job - fix(sdk): performance init appLaunch payload - fix: getPerformance first-render ### Features - feat(sdk): gcanvas async method - feat(server-side-bundle): use X-Mp-Open-Api-Token to authorize - feat(sdk): add warn deprecated info for sdk 4.0 - feat(sdk): support injected prop in webview component - feat(sdk): add experimental on walletconnector - feat(bundler): support include options in project.config.json - feat(sdk): error with stack - feat(sdk): new render point NEZHA_INJECT_RENDERER_JS_END & update timeline point info - feat(lib): use body class to control theme rather than prefers-color-scheme - feat(lib): remote-debug route-change-done notify to render - feat(cli): add props to webview - feat(sdk): mpRuntimeLogger rename & add error code - feat(sdk): webgl finish api - feat(mpp-service): output version info to MPP_SERVICE_OUTPUT.json - feat(sdk): time app check after app-launch - feat(bundler): impl util-function analyzeSource & remove AddEntryAppJsPlugin ### Performance Improvements - perf: app-rpc msg encoder - perf: pre-create worker - perf(sdk): use local js-sha3 ### Internal - chore(changelog): update changelog for version v3.13.2 - chore(tools): remove cicd - chore: fix dockerfile - chore(changelog): update changelog for version v3.13.1 - docs(demo): update automator readme - update cicd tool - update cicd tool - docs(docs): provide troubleshooting for canvas dependencies installing issue - cicd tools - docs: remove duplicated changelog for 3.13.0 - chore(changelog): update changelog for version v3.13.0 - chore(changelog): update changelog for version v3.13.0 ## [3.13.0-dev.5] 2022-09-01 **Download: [SDK-3.13.0-dev.5](https://ftp.binance.com/mp-sdk/dev/mp-sdk-3.13.0-dev.5.zip)** ### Bug Fixes - fix(sdk): loading when expect route-change type - fix(sdk): remove cachePromise to fix ios 13 eventloop issue ### Internal - chore(changelog): update changelog for version v3.13.0-dev.4 ## [3.13.0-dev.4] 2022-08-31 **Download: [SDK-3.13.0-dev.4](https://ftp.binance.com/mp-sdk/dev/mp-sdk-3.13.0-dev.4.zip)** ### Bug Fixes - fix(sdk): fix: fix to signature error when include specific data struct issue - fix(sdk): remove type check in wallet-connect plugin ### Internal - chore(changelog): update changelog for version v3.13.0-dev.3 ## [3.13.0-dev.3] 2022-08-31 **Download: [SDK-3.13.0-dev.3](https://ftp.binance.com/mp-sdk/dev/mp-sdk-3.13.0-dev.3.zip)** ### Features - feat(sdk): sdk-loading ### Internal - chore(changelog): update changelog for version v3.13.0-dev.2 ## [3.13.0-dev.2] 2022-08-30 **Download: [SDK-3.13.0-dev.2](https://ftp.binance.com/mp-sdk/dev/mp-sdk-3.13.0-dev.2.zip)** ### Bug Fixes - fix(sdk): gcanvas texImage2D flushnative - fix(sdk): fix taskify cache fail - fix(sdk): remove canvas service code ### Features - feat(lib): remote-debug new action & ignore native side delay error - feat(sdk): create webview sdk & demo - feat(runtime): disable click when loading display - feat(sdk): gcanvas supports cocos - feat(bundler): use zlib to compress pkg ### Internal - docs(sdk): components docs - chore: changelog automation ## [3.13.0-dev.1] 2022-08-23 **Download: [SDK-3.13.0-dev.1](https://ftp.binance.com/mp-sdk/dev/mp-sdk-3.13.0-dev.1.zip)** ### Bug Fixes - fix(sdk): fix applaunch-getPerformance - fix(sdk): fix webview sdk - fix(mpp-service): publish issue - fix(sdk): fix mg api host register ### Features - feat(sdk): setInterval 0 with warning - feat(sdk): add api requestSubscribeMessage - feat(sdk): make-phone-call - feat(runtime): @mp/host catch error and send to parent window - feat(sdk): canvas to temp file path api and demo - feat(sdk): add FP/FCP/LCP entry for performance API - feat(demo): add readfile api to benchmark - feat(sdk): add route-change-done event to fix route entry negative duration - feat(demo): add apiBenchmark at globalThis to run customize api benchmark - feat(demo): add extended-libs page - feat(demo): demo for webgl - feat(cli): quick publish for dev & qa ### Refactor - refactor(sdk): delete gcanvas useless code ### Internal - docs(sdk): view & text components docs - chore(sdk): getperformance update - test: taskify-unit-test - chore: deploy extended-lib to prod env - docs: add typedoc doc to generate plugin docs --- ## Document: Custom Component URL: /zh-CN/docs/products/mini-program/framework/custom-component # Custom Component ## Custom Component Developers can abstract parts of a page into custom components for use across different pages, or to divide a page into multiple low-coupling modules for easy maintenance. Custom components work almost in the same way as basic components. ### Creating a Custom Component Like a page, a custom component includes json, bxml, bxss, and js files. To create a custom component, first declare the custom component in the json file. ```json { "component": true } ``` You can then write a component template in the bxml file and a component style in the bxss file, as you would when creating a page. Code example: ```html {{innerText}} ``` ```css /* This style applies only to this custom component */ .inner { color: red; } ``` Note: You should not use ID selectors, attribute selectors, or tag name selectors in the component's bxss. In the js file of the custom component, you should register the component using `Component()`, specifying the component's property definitions, data, and custom methods. The component's property values and data are used to render the bxml of the component. The property values are passed to the component externally. Code example: ```js Component({ properties: { // The innerText property is defined here, and the property value can be set when the component is used. innerText: { type: String, value: "default value", }, }, data: { // Here are some internal component data someData: {}, }, methods: { // A custom method customMethod: function () {}, }, }); ``` ### Using a Custom Component To use a registered custom component, you need to declare a reference to it in the page's json file. You should specify the tag name of each custom component and the file path to the appropriate custom component: ```json { "usingComponents": { "component-tag-name": "path/to/the/custom/component" } } ``` Then, you can use the custom components in the page's bxml in much the same way as you would use base components. The node name is the custom component's tag name, and the node property is the property value passed to the component. Code example: ```html ``` Once the custom component's bxml node structure is combined with the data, it will be inserted at the referenced location. --- ## Document: Configuration URL: /zh-CN/docs/products/mini-program/framework/configuration # Configuration The `app.json` file, located in the root directory of Mini Program, is utilized to impose global configurations on Mini Programs. The contents of this file should be a JSON object encompassing the following properties: ### Configuration Items | Property | Type | Default Value | Required | Description | | ------------- | ------------------------------ | ------------- | -------- | ----------------------------------------------------------------------- | | entryPagePath | `string` | - | ✓ | index page name | | pages | `string[]` | - | ✓ | Page Path List | | window | `Object` | - | - | Global default window behavior | | tabBar | `Object` | - | - | Behavior of the `tab` bar at the bottom of the page. | | subPackages | `Object[]` | - | - | subPackage structure configuration. | | darkmode | `boolean` | - | - | whether app is in darkmode | | theme | `{light?:Object,dark?:Object}` | - | - | theme configuration, basically replaced by themeLocation | | themeLocation | `string` | - | - | Indicate the location of theme.json,it's required when darkmode is true | ### window | Property | Type | Default Value | Required | Description | | ---------------------------- | ---------- | ------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | navigationBarBackgroundColor | `HexColor` | #000000 | - | The navigation bar background color | | navigationBarButtonColor | `HexColor` | #707A8A | - | The button color in the navigation. | | navigationBarTitleText | `string` | - | ✓ | Title text of the navigation bar | | navigationBarTextStyle | `string` | white | - | The title color of the navigation bar, only supports black or white | | navigationStyle | `string` | default | - | The navigation bar style. Only the following values are supported. `default`: the default style. `custom`: custom navigation bar, only retains the Mini Program control button in the upper-right corner, click [here](/docs/mini-program/framework/extended#navigation) for details. | | backgroundTextStyle | `string` | dark | - | The pull-down loading style, only dark and light are supported. | | backgroundColor | `HexColor` | #ffffff | - | The background color of the window. | ### tabBar Should the Mini Program operate as a multi-tab application (employing a tab bar at the lower or upper part of the application interface for toggling between tabs), the tabBar configuration setting allows you to define the interaction with the tab bar, as well as control the specific pages that appear when the user alternates between the given tabs. | Property | Type | Default Value | Required | Description | | --------------- | ---------- | ------------- | -------- | ---------------------------------------------------------------------------------------- | | color | `HexColor` | | ✓ | The default color of the tab bar text, only supports hex color codes. | | selectedColor | `HexColor` | | ✓ | The color of the tab bar text when being selected, only supports hex color codes. | | backgroundColor | `HexColor` | | ✓ | The color of the tab bar background, only supports hex color codes. | | borderStyle | `string` | black | | The border color of the tab bar, only supports `black` and `white`. | | list | `array` | | ✓ | The tab list (see the `list` property description), supports 2 to 5 tabs. | | position | `string` | bottom | | The tabBar position, only supports `bottom` and `top`. | | custom | `boolean` | false | | A custom tabBar, click [here](/docs/mini-program/framework/extended#tabbar) for details. | The list property accepts an array, **which can only configure 2 to 5 tabs**. The tabs are listed in the order of the array. Each item is an object with the following properties: | Property | Type | Default Value | Required | Description | | ---------------- | -------- | ------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | pagePath | `string` | | ✓ | The page path, which must be defined first in pages. | | text | `string` | | ✓ | The text of tab buttons. | | iconPath | `string` | | | The image path. The size of the icon is limited to 40 KB, suggested dimensions: 81px by 81px, online images are not supported. **When `position` is set to `top`, the icon is not displayed.** | | selectedIconPath | `string` | | | The image path for the selected icon. The size of the icon is limited to 40 KB, suggested dimensions: 81px by 81px, online images are not supported. **When `position` is set to `top`, the icon is not displayed.** | ### subPackages In certain scenarios, developers might need to segment a Mini Program into distinct subunits, bundling these subsidiary packages into separate subpackages during construction, hence enabling users to load them on an as-needed basis. During the development of a subpackage project, one or more subpackages may appear. Every subpackaged Mini Program should encompass a main package embodying the default start page/TabBar page, along with common resources and necessary JS scripts used by all subpackages. The subdivisions of sub-packages are subject to the developer's configuration. Upon initiating the Mini Program, the user's device downloads the main package by default, launching the pages housed within the main package. When a user navigates to a page within a subpackage, the related subpackage is downloaded and displayed upon successful completion of the download. > Supported from SDK ^3.2.0, IDE ^2.9.0 and Native ^2.40.0 | Property | Type | Default Value | Required | Description | | ----------- | ---------- | ------------- | -------- | ---------------------------------- | | root | `string` | | ✓ | root of subPackage | | name | `string` | | | alias name | | pages | `string[]` | | ✓ | page list related to root | | independent | `boolean` | | ✓ | If it is an independent subPackage | ### useExtendedLib This indicates the extra library that's needed. Right now, you can use this for: - react When you set useExtendedLib, it's like you're adding the newest version of that library's npm Package. The good part is, this doesn't make your Mini Program package bigger. The RC (Release Candidate) tool version lets you add references in sub-packages. You can use it like this: Use `true` to get the latestVersion. ```json { "useExtendedLib": { "react": true } } ``` You can also specify the exact version you want to use. ```json { "useExtendedLib": { "react": "17.0.2" } } ``` ### prefetchRules Data prefetching lets the Mini Program start a request early when it's first turned on, and it saves the response from the request. Then, when you actually make the request, you can use the saved data to cut down on the time for network requests. Here's how it works: ![img](https://bin.bnbstatic.com/image/julia/docs/mini-program/prefetch-flow.png) #### Configure prefetch rules Data prefetching rules need to be configured in app.json, examples are as follows: ```json { "prefetchRules": { // launch path that need to be configured with prefetch requests "pages/index/index": { // request url "https://developer.binance.com/${pageid}": { // request method "method": "POST", // request header "header": { "token": "${token}" }, // request body "data": { "pageSize": "${pageSize}", "pageNum": 1 }, // request response type "responseType": "text", "hitPrefetchExtraRules": { "requiredQueryKeys": ["testid"], "requiredHeaderKeys": ["token"] } } }, // match all launch paths "*": { // local file path, language is the variable "file://nezha-i18n-data_${language}.json": { // whether to wait for the file download to complete when starting the mini program "mandatory": true } } } } ``` #### Configure variables To make requests dynamic, we use configuration variables. These have the format ${variable}. To assign the variable, we replace the text ${variable} in the prefetchRules configuration string with the value of the variable. #### Variable data source Configuration variables can come from three places, listed by priority: 1. The query parameters in the Mini Program's page route 2. Data that developers have saved in storage 3. Data from the getSystemInfo interface, such as language When the client looks for a variable, it starts with the highest priority source. If it finds the variable there, it stops looking. If not, it checks the next source. If it can't find the variable in any of the sources, it won't make the request. #### Request url The url is the basic part of a request. With a complete url, we can start a request. Right now, we can use a variable in the path and query of a url, but not in the host. For example, let's say the prefetch configuration is set up a certain way. If the page route is pages/index/index?pageid=1000, and the developer stored the pageSize variable with a value of 10, then the final prefetch request will be https://developer.binance.com/1000?pagesize=10&pagenum=1 ```json { "prefetchRules": { "pages/index/index": { "https://developer.binance.com/${pageid}?pagesize=${pageSize}&pagenum=1": {} } } } ``` #### Request parameters The value of the request address serves as the request parameters. These include method, header, data, and responseType, which correspond to the bn.request API's parameters. These parameters also support configuration variables. Here is a table outlining the default values rules for method, header, data, and responseType: | Property | Type | Default Value | Required | Description | | ------------ | ------------------ | ------------------------------------ | -------- | ----------------------------------------------------- | | header | `object` | {'content-type': 'application/json'} | | Request header | | method | `string` | GET | | Request method, support GET, POST | | data | `string or object` | null | | Request data, needs to be consistent to hit the cache | | responseType | `string` | text | | Response data type, optional value: text | For example, suppose the request parameters are configured as follows: ```json { "https://developer.binance.com/${pageid}": { "method": "POST", "header": { "token": "${token}" }, "data": { "pageSize": "${pageSize}", "pageNum": 1 } } } ``` If the page route is pages/index/index?pageid=1000, the developer has stored the pageSize variable with a value of 10, and also stored the token variable with a value of test_token, then the parameters of the final prefetch request would look like this: ```json { "https://developer.binance.com/1000": { "method": "POST", "header": { "token": "test_token" }, "data": { "pageSize": "10", "pageNum": 1 } } } ``` #### Use prefetch cache The bn.request function includes an extra parameter, usePrefetchCache, and the return data includes the attribute isPrefetch to indicate whether the data was prefetched. Here's an example: ```json { "prefetchRules": { "pages/index/index": { "https://developer1.binance.com/${sid}?testid=${testid}&testdata=${sData}": { "method": "POST", "header": { "testCookie": "${sCookie}", "token": "xxxs1823730" }, "data": { "mData": "${mData}" }, "responseType": "" } } } } ``` ```js //storage const testCookie = bn.getStorageSync("sData"); const sCookie = bn.getStorageSync("sCookie"); const mData = bn.getStorageSync("mData"); //request const token = "xxxs1823730"; const { sid, testid } = option.query; const url = `https://developer1.binance.com/${sid}?testid=${testid}&testdata=${sData}`; const header = { testCookie, token }; const data = { mData }; bn.request({ url, header, data, method: "POST", dataType: "json", responseType: "text", usePrefetchCache: true, success: (res) => { console.log("Whether the returned data is from prefetching:", res.isPrefetch); console.log("Response data:", res.data); }, }); ``` #### Configure Matching rules Like the example at the beginning. You can configure `"hitPrefetchExtraRules"` property to control the behavior of matching rules. This property includes two keys: ```json { "prefetchRules": { "pages/index/index": { "https://developer.binance.com/?a=${a}&b=bbb": { "header": { "c": "${c}", "d": "ddd" }, "hitPrefetchExtraRules": { "requiredQueryKeys": ["a", "b"], "requiredHeaderKeys": ["c"] } } } } } ``` ![img](https://bin.bnbstatic.com/image/julia/docs/mini-program/match-rule.png) When native get a prefetchRule, need to replace the variable first and get the accurate url & parameters, and parse the accurate url to query keys and values (eg. query key is **a**, query value might be **aaa** in above example). If **requiredQueryKeys** is not declared or is a empty array, it will be considered as using exact match. | requiredQueryKeys | Rule URL / Request URL | hit | | -------------------------------------------- | --------------------------------------------------------------------------------------- | --- | | [] | https://developer.binance.com/?a=aaa&b=bbb / https://developer.binance.com/?b=bbb&a=aaa | yes | | [] a is extra | https://developer.binance.com/?b=bbb / https://developer.binance.com/?b=bbb&a=aaa | no | | [] a is missing | https://developer.binance.com/?b=bbb&a=aaa / https://developer.binance.com/?b=bbb | no | | ["b"] a is extra | https://developer.binance.com/?b=bbb / https://developer.binance.com/?b=bbb&a=aaa | yes | | ["b"] a is different | https://developer.binance.com/?b=bbb&a=ccc / https://developer.binance.com/?b=bbb&a=aaa | yes | | ["b"] a is missing | https://developer.binance.com/?b=bbb&a=aaa / https://developer.binance.com/?b=bbb | yes | | ["b"] b is missing | https://developer.binance.com/?b=bbb&a=aaa / https://developer.binance.com/?a=aaa | no | | ["b"] b is different | https://developer.binance.com/?b=bbb&a=aaa / https://developer.binance.com/?b=ccc&a=aaa | no | | ["a", "b"] | https://developer.binance.com/?b=bbb&a=aaa / https://developer.binance.com/?b=aaa&a=aaa | no | | ["c", "b"] c is not in rule url, exact match | https://developer.binance.com/?b=bbb&a=aaa / https://developer.binance.com/?a=ccc&b=bbb | no | | [b] b is not in rule url, exact match | https://developer.binance.com/?a=aaa / https://developer.binance.com/?b=bbb | no | The behavior of requiredHeaderKeys is similar to requiredQueryKeys, but it effects header field, not query of url #### File Prefetch Besides prefetching network requests, we also support prefetching files. The file prefetch configuration is similar to the network request configuration, but the value of the request address is the local file path. The file path also supports configuration variables. For example, if the file prefetch rules are set up as follows: ```json { "prefetchRules": { "pages/index/index": { "file://nezha-i18n-data_${language}.json": { "mandatory": true } } } } ``` If the page route is pages/index/index, and the client language is zh_CN, the variable 'language' will be replaced with 'zh_CN', which is retrieved from the getSystemInfo API. Therefore, the final prefetch request will be file://nezha-i18n-data_zh_CN.json. Upon launching the mini-program, the client will immediately begin downloading the file://nezha-i18n-data_zh_CN.json file using parallel download. If the value of `mandatory` is set as `true`, the mini-program will only launch once the file has successfully downloaded. If it's not set as `true`, the mini-program will launch immediately without waiting for the file to be downloaded (non-blocking). Developers can then use the bn.getFileSystemManager API to read the contents of the file. Here's an example: ```js const fs = bn.getFileSystemManager(); const filePath = "file://nezha-i18n-data_zh_CN.json"; const res = fs.readFileSync(filePath, "utf8"); console.log("File content:", res); ``` ## Page Configuration For each Mini Program page, you may use the .json file that shares the same name as the Mini Program to configure the window behaviors of that page. The configuration items in the current page will overwrite the corresponding `window` configuration items in the app.json file. The file content of this json file should be a JSON object. Here's an example: ```json { "navigationBarBackgroundColor": "#ffffff", "navigationBarTextStyle": "black", "navigationBarTitleText": "Binance API feature demo", "backgroundColor": "#eeeeee", "backgroundTextStyle": "light", "initialRenderingCache": "static", "staticTemplate": { "enable": true, "removeSkeleton": true, "data": { "list": [] } } } ``` | Property | Type | Default Value | Required | Description | | --------------------- | ------------------------------------------------------- | ------------- | -------- | --------------------------------------------------------------------------- | | initialRenderingCache | `"static"`\|`"dynamic"` | | - | Enable rendering cache. | | staticTemplate | `{enable:boolean,removeSkeleton?:boolean,data?:Object}` | | - | Page template can render as static template based on data in configuration. | ## DarkMode We provide developers the ability to incorporate Dark Mode in their applets. ### Enable DarkMode To enable Dark Mode, set `{ "darkmode" : true }` in the `app.json` file. Once enabled, all basic components will display different default styles based on the system theme. The navigation bar and tab bar will automatically switch according to the following configuration. ### Related Configuration When `{ "darkmode": true }` is set in app.json, certain applet configuration items can be set via variables, enabling definition of colors or icons under different themes in the variable configuration file as follows: 1. Configure `themeLocation` in `app.json`, specifying the path to the variable configuration file `theme.json`. For instance, to add `theme.json` in the root directory, configure `{"themeLocation": "/path/to/theme.json"}` 2. Define related variables in `theme.json`. 3. In `app.json`, reference variables that start with `@`. Properties that support configuration through variables include: 1. The window property of the global configuration and the property under the page configuration - navigationBarBackgroundColor - navigationBarTextStyle - backgroundColor - backgroundTextStyle - backgroundColorTop - backgroundColorBottom 2. Global configuration properties of window.tabBar - color - selectedColor - backgroundColor - borderStyle - list - iconPath - selectedIconPath ### Variable configuration file theme.json The `theme.json` file is used for variable definitions related to the color theme. Prioritize setting the path to `theme.json` in `themeLocation`, as the variable configuration cannot be read otherwise. The configuration file must contain the following properties: | Attribute | Type | Required | Description | | --------- | ------ | -------- | ---------------------------------- | | light | object | Yes | Variables definition in light mode | | dark | object | Yes | Variables definition in dark mode | Both light and dark modes can define variable names and values in the key:value format, as shown below: ```js { "light": { "navBgColor": "#f6f6f6", "navTxtStyle": "black" }, "dark": { "navBgColor": "#191919", "navTxtStyle": "white" } } ``` After the definition is completed, it can be referenced at the beginning of `@` in the relevant properties of the `global configuration` or `page configuration`, for example: ```js // global configuration { "window": { "navigationBarBackgroundColor": "@navBgColor", "navigationBarTextStyle": "@navTxtStyle" } } // page configuration { "navigationBarBackgroundColor": "@navBgColor", "navigationBarTextStyle": "@navTxtStyle" } ``` ### Configuration example `app.json` (the example omits configuration items other than those related to the theme) ```js { "window": { "navigationBarBackgroundColor": "@navBgColor", "navigationBarTextStyle": "@navTxtStyle", "backgroundColor": "@bgColor", "backgroundTextStyle": "@bgTxtStyle", "backgroundColorTop": "@bgColorTop", "backgroundColorBottom": "@bgColorBottom" }, "tabBar": { "color": "@tabFontColor", "selectedColor": "@tabSelectedColor", "backgroundColor": "@tabBgColor", "borderStyle": "@tabBorderStyle", "list": [{ "iconPath": "@iconPath1", "selectedIconPath": "@selectedIconPath1" }, { "iconPath": "@iconPath2", "selectedIconPath": "@selectedIconPath2" }] } } ``` `theme.json` ```js { "light": { "navBgColor": "#f6f6f6", "navTxtStyle": "black", "bgColor": "#ffffff", "bgTxtStyle": "light", "bgColorTop": "#eeeeee", "bgColorBottom": "#efefef", "tabFontColor": "#000000", "tabSelectedColor": "#3cc51f", "tabBgColor": "#ffffff", "tabBorderStyle": "black", "iconPath1": "image/icon1_light.png", "selectedIconPath1": "image/selected_icon1_light.png", "iconPath2": "image/icon2_light.png", "selectedIconPath2": "image/selected_icon2_light.png", }, "dark": { "navBgColor": "#191919", "navTxtStyle": "white", "bgColor": "#1f1f1f", "bgTxtStyle": "dark", "bgColorTop": "#191919", "bgColorBottom": "#1f1f1f", "tabFontColor": "#ffffff", "tabSelectedColor": "#51a937", "tabBgColor": "#191919", "tabBorderStyle": "white", "iconPath1": "image/icon1_dark.png", "selectedIconPath1": "image/selected_icon1_dark.png", "iconPath2": "image/icon2_dark.png", "selectedIconPath2": "image/selected_icon2_dark.png", } } ``` ### Get the current system theme If `"darkmode": true` is declared in `app.json`, the output of `bn.getSystemInfo` or `bn.getSystemInfoSync` will include a theme attribute, the value of which can be either 'light' or 'dark'. If `app.json` does not include the `"darkmode": true` declaration, the theme attribute is inaccessible (meaning, 'theme' would be undefined). ### Listening for Theme Switching Events There are two ways to monitor for theme switching: 1. In `App()`, insert the `onThemeChange` callback function. This callback will get triggered when the theme switches. 2. Utilize `bn.onThemeChange` to monitor for theme changes. You can cancel the monitoring using `bn.offThemeChange`. ### BXSS Adaptation In `BXSS`, we support theme adaptation through the media query `prefers-color-scheme`. This approach is consistent with the adaptation method used in Web. See the example below: ```css /* normal css style begin */ .case-background { background: white; } .case-text { color: black; } /* normal css style end */ @media (prefers-color-scheme: dark) { /* style under DarkMode start */ .case-background { background: #1b1b1b; } .case-text { color: #ffffff; } /* style under DarkMode end */ } ``` --- ## Document: BNS URL: /zh-CN/docs/products/mini-program/framework/bns # BNS ## BNS BNS (Binance Script) is a scripting language designed for Mini Programs. Alongside BXML, it helps construct the page structure. ### Introduction BNS code can either be drafted within the `...` tags in a bxml file or in a .bns file. Each .bns file and `...` tag constitutes an individual module. Each module maintains its separate scope. Essentially, variables and functions established in a module are naturally private and hidden from other modules. If a module needs to expose its internal private variables and functions, it can only do so through module.exports. The `...` tag has two attributes - module and src. The module attribute is mandatory and ought to be unique. The src attribute is optional. If it isn't specified, the content within the `...` tags serves as the module code. ### Event Binding BNS functions can be employed to react to Mini Program events. At present, they can only respond to built-in component events, and do not support custom component events. Besides pure logical operations, BNS functions can also interact with the encapsulated ComponentDescriptor instance and set the component's classes and styles. For interactive animation, setting the style and class is sufficient. Example: BXML: ```xml module.exports = { changeToRed(e, instance) { instance.setClass('red'); }, changeToBlue(e, instance) { instance.setClass('blue') }, } Click to change font-size to 20px Click to change color to red Click to change color to blue ``` JS: ```js // /pages/comm.bns module.exports = { changeTo20Px(e, instance) { instance.setStyle({ "font-size": "20px", }); }, }; ``` The event handler accepts two parameters: e and instance. - e is the Event Target, the same as the event object in the Mini Program event binding function. - instance is the ComponentDescriptor instance of the current component, which can be used to set the class and style of the component. Currently, only two methods are supported, setClass and setStyle. --- ## Document: Upload to mini program platform URL: /zh-CN/docs/products/mini-program/devtools/upload # Upload to mini program platform To use the IDE, log in with your Binance account and ensure your APPID is accurate (located in the Details Panel). If your project was initiated with CLI, run the following command in the root directory of the project to generate code for a real device: ```bash $ bmp build ``` ![img](https://bin.bnbstatic.com/image/julia/docs/mini-program/ide-6.png) By clicking 'Upload' in the Tool Bar, the IDE will bundle and upload your application. Post-upload, manage your app version via the [mpp website](https://developers.binance.com/en/mpp/). --- ## Document: Toolbar URL: /zh-CN/docs/products/mini-program/devtools/toolbar # Toolbar ## Introduction Situated at the top of the main page, the toolbar in Devtool houses the most frequently utilized features in the IDE. This guide will walk you through these features from left to right. ![toolbar](https://bin.bnbstatic.com/image/julia/docs/mp-ide/toolbar.png) ## Toggle UI By clicking 'Editor', 'Debugger', 'Simulator', you can show and hide these three areas respectively. Refer to 'IDE Debugging' and 'Simulator' documents for more information. toggle.jpg ## Main Features ### Compile Mode toggle.jpg By default, the initial startup page of the mini-app is the first page listed in the app.json file without any parameters. To facilitate debugging of other pages or setting parameters, follow these steps: 1. Click the '+' sign in the dropdown list of this item to add a compile mode. 2. In the pop-up window, fill out the 'Mode Name', 'Page Parameters', and 'Global Parameters'. Then, select the 'Start Page' and click 'OK'. 3. The simulator will now display the new startup page with parameters automatically included. > Note: Check 'Simulation update at next refresh' in the pop-up window if you wish to simulate the > effect of applet updating. See the 'UpdateManager' documentation for more details. ### Preview Use real machine preview to check the functioning of the API in a mini app. ### Remote Debug Developers can inspect logs and elements from the native IDE using remote debugging. Refer to the 'remote-debug' document for more information. ### Clear Cache Clear authorization data and file cache with a single click. ### Upload toggle.jpg This feature allows you to upload your project code to the backend. The options available before uploading include: - Upload version: Each time you upload, the version is incremented by 0.0.1 by default. This version should be greater than the online version to ensure each code version in the backend is unique. - MSV: This stands for the minimum required SDK Version for your app. This is the lowest version your app can support. ### Details #### Basic Info This includes basic information about your app such as the appid, app name, local directory, output directory, etc. The local directory indicates where your mini-app is located. The output directory shows where your mini-app data is stored. This data includes the bundled app generated by the internal bundler, system data created by SDK, user data generated by mini-app users, and more. Click 'open' for more details. detail1.jpg #### Performance Analysis This is the same as 'Code Quality'. See the 'Code Quality' document for more details. details2.jpg #### Local Setting These settings allow developers to configure the SDK and Bundler versions, use a local SDK, and modify certain debugging behaviors. ##### 1. Select SDK This option lets you choose the SDK version used for running and debugging WeChat Mini Programs. The SDK is responsible for parsing, compiling, and executing Mini Program code. The selected version appears in the dropdown menu (e.g., 4.33.2). Developers can switch to a different SDK version if needed for compatibility testing. ##### 2. Local SDK Allows developers to use a custom or locally built SDK instead of the default WeChat SDK. You can specify the local SDK path (e.g., /Users/user/Works/mini-program/dist). To enable this, check the checkbox next to "Local SDK." Useful for testing modifications in the SDK or debugging specific issues. ##### 3. Select Bundler Determines the Bundler version used for packaging and building the Mini Program. The Bundler is responsible for compressing, minifying, and structuring the project files. The selected version appears in the dropdown menu (e.g., 3.0.127). Developers can switch to a different Bundler version for performance testing or debugging. select-bundler.gif ##### 4. Debugging Option: Disable Domain & Certificate Verification This involves whether to check the network request of the officially released mini-program (bn.request, bn.connectSocket, bn.downloadFile, bn.uploadFile) and whether the business domain name is allowed to be loaded by the '' component and has been configured as a legal domain name. Moreover, the TLS version of the domain name, the validity of the HTTPS certificate, and the server domain name can be configured in the MPP. This option could be enabled during the development process. This way, the IDE will not verify the security domain name, '' business domain name, TLS version, and HTTPS certificate. This aids in conveniently completing the debugging work during development. local-setting.jpg #### Project Setting Domain Info fetched from backend. You can edit these items by mp-admin site. The security domain name information of the mini app will be displayed, and the legal domain name can be set in MPP detail4.jpg --- ## Document: Storage Panel URL: /zh-CN/docs/products/mini-program/devtools/storage # Storage Panel The Storage Panel serves to display the data storage of the current project after utilizing the [bn.setStorage](/products/mini-program/framework/api#mpservicesetstorage) command. In the Storage Panel, you can perform tasks such as deleting (by pressing the delete key), adding, and modifying data directly. ![img.png](https://bin.bnbstatic.com/image/julia/docs/mini-program/storage-panel.png) --- ## Document: Startup Page URL: /zh-CN/docs/products/mini-program/devtools/startup-page # Startup Page Upon launching the Binance Devtool, a list of your existing projects will be displayed. project list ## Creating a Project A Mini Program project can be swiftly created locally by following these steps: 1. Click the first tile on your project list. 2. Input your chosen project name. 3. Specify the target folder for your project (note, an empty folder will not be accepted). 4. Choose the nature of your project (either Mini Program or Mini Game). 5. Select your preferred template. create a project Alternatively, a new project can be created utilizing @binance/mp-cli. By executing the following command, CLI will generate a simple project: ```bash $ bmp init [project-name] ``` ## Opening an Existing Project Existing projects can be opened by typing **import** and selecting your project's folder. Your selected project card will be placed at the front of the project list. ![img](https://bin.bnbstatic.com/image/julia/docs/mini-program/ide-3.png) If your project was created using CLI, run the following command in the root directory of the project: ```bash $ bmp dev ``` ## Managing Projects Local projects can be deleted either one by one or in batches. manage project --- ## Document: Source Map URL: /zh-CN/docs/products/mini-program/devtools/sourcemap # Source Map A source map is a file that maps from the transformed source code to the original source code. This helps the browser to reconstruct the original source and display the reconstructed original in the debugger. Debugging with a source map, rather than the transformed state of the source code that the browser has downloaded, makes the process much easier. ## Enable Source Map You can enable source map under `Setting -> General Settings`. sourcemap ## Download Source Map There are two ways to download a source map. 1. Upon successful upload, you can download the source map by clicking the `Download SourceMap` button. download sourcemap 2. You can also download source map files from `Detail -> Download` in the mini program manager platform. download sourcemap in mini program manager platform --- ## Document: Simulator URL: /zh-CN/docs/products/mini-program/devtools/simulator # Simulator The simulator is designed to emulate the behavior of Mini Programs within the Binance app. It allows you to run the compiled codes of the Mini Programs directly. simulator.jpg The following features are primarily located at the top of the simulator window: - Device switch: This allows you to choose different device sizes, including both iOS and Android devices. - Scale control: This enables you to control the scale of the Mini Program. - Text Size: This allows you to adjust the text size on the device. - Language: This enables you to change the device's language. - Network status: This lets you update the current network status (Wifi,2g,3g,4g, etc.). - Theme: This function allows you to switch between dark mode and light mode. - Capsule: This feature lets you switch the visibility of the capsule. - Home/Return: This mocks the scene value when you land your mini program. - Standalone window: This allows you to set the simulator to a standalone window (Tap the **Debugger**). simulator devices.jpg simulator i18n.jpg --- ## Document: Settings URL: /zh-CN/docs/products/mini-program/devtools/settings # Settings All settings can be accessed via the tooltip of DevTools. To explore the `Project Settings` and `General Settings` features, simply click through. settings ## General Settings Here, you can customise the Binance DevTools' appearance, code editor operational habits, and styles. The available configurations include: - Language: Currently, only English is supported. - space: This is the default directory when initiating a project. - At Project Open: Set projects to compile automatically upon opening. - Compilation: Activate your source map for enhanced debugging capabilities. - Theme (found in the appearance panel): Choose among Dark, Light or Follow System options for your display. general settings
general appearance settings ## Project Settings [See more at the detail](toolbar.md#details) --- ## Document: Remote Debug URL: /zh-CN/docs/products/mini-program/devtools/remote-debug # Remote Debug Developers can inspect logs and elements from the native IDE using remote debug. ## Environment - native version >= 2.53.0 - sdk version >= 3.14.0 ## Other Requirements - ‼️ Your mobile device should be on the same local network as your computer. - ‼️ Scan the QR code with the same Binance account that your IDE is logged into. ## How to Use 1. Click the Remote Debug Button located at the top of the IDE. ![remote-debug-icon](https://bin.bnbstatic.com/image/julia/docs/mp-ide/remote-debug/remote-debug-icon.png) > You must be logged in before proceeding with this step. 2. Scan the QR code generated in the previous step. ![remote-debug-qrcode](https://bin.bnbstatic.com/image/julia/docs/mp-ide/remote-debug/remote-debug-qrcode.png) 3. A panel will appear after scanning the QR code. ![remote-debug-panel](https://bin.bnbstatic.com/image/julia/docs/mp-ide/remote-debug/remote-debug-panel.png) 4. You can perform various operations, inspect logs, and view elements using this panel. In the debugger for remote debugging, you can debug code in the Console panel, view the source code of a Mini Program, and perform breakpoint or single-step debugging in the Sources panel. You can execute `bn` related functions within it. ![img](https://bin.bnbstatic.com/image/julia/docs/mini-program/remote-debug-bn.png) 5. The page will automatically refresh when any code changes. If you prefer it not to, you can click the off button. ![remote-debug-off](https://bin.bnbstatic.com/image/julia/docs/mp-ide/remote-debug/remote-debug-off.png) ## FAQ Q: Failed to connect to IDE? A: Ensure that your mobile device and IDE are on the same local network for the mobile device to access the IDE via IP and port. Q: Why is it loading all the time? A: Try capturing the network requests to see which request is pending. The network might be unstable, so please wait for a few minutes. If it still doesn't work, you can ask someone for help. 1. If the request URL starts with `/local-app-info/`, ask the IDE team for help. 2. If the request URL starts with `detail`, ask the BE team for help. 3. For other requests, ask the IOS or Android team for help. Q: What's the difference between remote debug and preview? A: Remote debug will pop up a `Remote Debug` window. Furthermore, remote debug will fetch `worker-remote-debug.js` and `render-remote-debug.js`. These two files will replace Bridge with WebSocketBridge. WebSocketBridge will forward all the requests for you. --- ## Document: Preview the Developing Application on the Device URL: /zh-CN/docs/products/mini-program/devtools/preview # Preview the Developing Application on the Device To begin with, log in to the IDE with your Binance account and ascertain that the APPID is correct (visible in the Details Panel). If you've created the project using CLI, execute the following command in the project's root directory to generate code for the actual device: ```bash $ bmp build ``` ![img](https://bin.bnbstatic.com/image/julia/docs/mini-program/ide-5.png) By clicking 'Preview' in the Tool Bar, the IDE will bundle and upload your application. Upon successful upload, the IDE will generate a QR Code. Scan this QR code using Binance App to preview your application. ## FAQ ### Unable to open the app and received a 404 error code for the devtools preview feature To resolve this, clear cache by clicking the 'clean' button at the top of the IDE, then restart the IDE and try again. --- ## Document: Overview URL: /zh-CN/docs/products/mini-program/devtools/overview # Overview Binance DevTools is a platform developed to simplify and boost efficiency in the creation and debugging of Binance Mini Programs. We've recently updated this tool to version [2.23.2](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.23.2.dmg). Key improvements include a better visual display, a smoother interaction experience, and enhanced performance. This notable upgrade aims to enrich the developer's experience in creating Binance Mini Programs. overview.jpg --- ## Document: Logical Layer Memory Debugging URL: /zh-CN/docs/products/mini-program/devtools/memory # Logical Layer Memory Debugging Developers can utilize the **Memory** panel in the **Simulator** to capture a snapshot of the JS heap memory of the mini program's logic layer. This allows for the analysis of memory distribution and aids in resolving memory leaks. ![img.png](https://bin.bnbstatic.com/image/julia/docs/mini-program/memory-debugger-simulator-01.png) ![img.png](https://bin.bnbstatic.com/image/julia/docs/mini-program/memory-debugger-simulator-02.png) > For comprehensive instructions, please refer to the **Memory** panel in Chrome's developer tools. --- ## Document: Main Page URL: /zh-CN/docs/products/mini-program/devtools/main-page # Main Page The Main Page is divided into four key components: Menu, Toolbar, Debugger, and Simulator. - Menu: Includes options such as Edit, Environment, Devtools, Settings and Help. - Toolbar: Offers functions like Show/Hide, Preview, Remote Debug, etc. - Debugger: Provides Local Debug for features like bxml, console, audit, and others. - Simulator: Represents the current mini-app on display. ## UI Here's an example of the User Interface (UI), using version 2.23.2. ![devtool-main-page](https://bin.bnbstatic.com/image/julia/docs/mp-ide/devtool-main-page.png) --- ## Document: Local Panels URL: /zh-CN/docs/products/mini-program/devtools/local-panels # Local Panels With the introduction of Binance devTools 2.19.0 came new features, specifically, the mock data panel and audit panel. ## Audit ### Instructions The audit panel reviews your mini app's implementations, delivering an estimation score indicative of its adherence to best practices. With the latest version of Binance DevTools, new tools have been introduced to assist developers in applying best practices to their mini programs. The Audit Panel can be used to measure just how closely your mini program adheres to suggested methods for optimizing performance and user experience. ### Basic Usage 1. Click the **Run** button at the top-left (pictured below) and perform functions on the Mini Program interface. Upon running, the page will be scrutinized for "Experience Rating". ![img.png](https://bin.bnbstatic.com/image/julia/docs/mini-program/audits-panel-run.png) 2. Click **Stop** to cease the analysis, whereby an analysis report will appear, which you can use to refine your setup. 3. If you want to rerun the experience rating, click **Clear experience rating** at the top of the report to reset. Do bear in mind that the system doesn't currently support report storage services. Once experience ratings have been cleared, they are no longer viewable. ![img.png](https://bin.bnbstatic.com/image/julia/docs/mini-program/audits-panel-clear.png) ## Mock The mock data panel allows developers to mock all of the JS APIs of mini programs, making it possible to debug all features, especially those requiring native capabilities on the devtools, thereby saving significant development time. In the interests of facilitating small program development, the developer tool offers API Mock capability, simulating the calling results of some APIs. ### Instructions ### Basic Usage Find the entry for Mock in the Tab at the top of the tool debug panel and click + New Rule. ![img.png](https://bin.bnbstatic.com/image/julia/docs/mini-program/mock-panel-add.png) Example rule: ![img.png](https://bin.bnbstatic.com/image/julia/docs/mini-program/mock-panel-example-rule.png) Result of hitting the rule above: ![img.png](https://bin.bnbstatic.com/image/julia/docs/mini-program/mock-panel-resault.png) ### Rule Priority When multiple rules are set up for an API, the first rule will be matched first. Once a rule is hit, subsequent rules will not be executed. ### Data Templates Complex simulated data needs can be served by data templates, designed for rapid generation of data to your specifications. _The syntax of the data template is from the open-source library [Mock.js](https://github.com/nuysoft/Mock/wiki/Syntax-Specification). For detailed syntax, review the project documentation._ Data previews are generated in real-time from the template in the template editor, aiding confirmation of the template's accuracy. ![img.png](https://bin.bnbstatic.com/image/julia/docs/mini-program/mock-panel-template-data.png) ### Rule Import and Export If you need to share rules with other project members, you can export the rule configuration in Mock, and then send the configuration file to other members for them to import. The operational entry is shown below: ![img.png](https://bin.bnbstatic.com/image/julia/docs/mini-program/mock-panel-share-rule.png) #### Example Here's a getSystemInfoSync example of the import & export feature. It consists of three steps: - Create `getSystemInfoSync` mock Rules. - Export the rules as a config file to a local folder. - Import the local config file saved earlier in another project. You can use the append or cover mode to import the rules file. ![img.png](https://bin.bnbstatic.com/image/julia/docs/mp-ide/mock-example-step-1.jpg) ![img.png](https://bin.bnbstatic.com/image/julia/docs/mp-ide/mock-example-step-2.jpg) ![img.png](https://bin.bnbstatic.com/image/julia/docs/mp-ide/mock-example-step-3.jpg) ## Code Quality The latest version of Binance DevTools offers new tools designed to assist developers in applying best practices to their mini programs. The Code Quality Panel allows you to scan your mini-program project and receive suggestions about resource sizing to improve performance. ![applog-panel](https://bin.bnbstatic.com/image/julia/docs/mp-ide/analyze-tool.png) ## AppLog The AppLog is designed to assist developers in fine-tuning the performance of their mini programs. It lists all records from the framework, providing detailed insights into how the framework will perform when rendering the mini program. ![applog-panel](https://bin.bnbstatic.com/image/julia/docs/mp-ide/applog-panel.png) ## SourceMap To address issues where SDK errors in mini programs can't be restored, a SourceMap panel has been introduced. Developers simply enter the row and column number where the copied and pasted error is located, then select the version and the corresponding file, which will ensure the source code can be displayed. ![sourcemap-panel](https://bin.bnbstatic.com/image/julia/docs/mp-ide/sourcemap-panel.png) ## Timeline As we know, mini-programs need to run in specific containers, with the render and worker processes separated. This separation creates significant challenges for diagnosing and analyzing issues. The Timeline panel addresses this problem. By providing a complete log, it can display timelines for the native, worker, and render modules for different app IDs and sessions. It also shows a waterfall of resource and network requests, along with key performance data. ![Timeline Performance ](https://bin.bnbstatic.com/image/julia/docs/mp-ide/ide_timeline_panel.png) As shown in the image, you can zoom into a specific module area by scrolling down. Following the prompts, you can identify Long Task and memory warning situations. Clicking on a task will display its original log, allowing you to review and analyze the source code at that time. ![Timeline Performance Log ](https://bin.bnbstatic.com/image/julia/docs/mp-ide/ide_timeline_panel_log.png) ### Performance Timeline A simple panel for developers to see the key metrics such as FCP / LCP / FR and so on. ### Network and Resource Panel For us to detect the resource download timing, such as \_\_app.js, worker.js. If you know how the request happened on mini program, it will be very interesting to see the panel. Mostly the request is created by worker then handle by native and response to worker handlers. When it send from worker to native, it is handle by the rpc bridge, this step we call it as `queue`. After it will handle by native, native will request and get the response like browser fetch api, we call it `request`. Finally it will forward the response to worker, then developers can access the response, the whole step we call it `response`. Under normal circumstances, there should be only a minimal duration difference between the request and response steps. If not, worker is too busy and waiting a long time to response it. ![Timeline Network Log ](https://bin.bnbstatic.com/image/julia/docs/mp-ide/ide_network_timeline.png) ### Worker Timeline The mostly important frame for developers, since code always run at the worker. It list all the jssdk api function call and js engine sync task, such as timer. Additional, the custom log from developers. The dangerous red color means it is [long task](https://web.dev/articles/optimize-long-tasks), please try to optimize it if you consider the better performance. ![Timeline Network Log ](https://bin.bnbstatic.com/image/julia/docs/mp-ide/ide_timeline_worker.png) ### Custom Timeline log We analyze logs on the framework side through a specific format. Additionally, we provide developers with the ability to output custom logs to this timeline, as long as they adhere to the following log format. Please parse the `sync` property to check the long task, it will be helpful for optimization. ```txt [NEZ_C(W|R)][timestamp(endTime)][timestamp(startTime)][name]stringifyPayload(JSONString | string) ``` ### Timeline Usage Pre-require: - Binance App: >=2.87.0 - Binance App Type: Debug App - SDK >= 4.\* (renderer detail log for be available for 4.31.0) - IDE >= 2.49.0 #### iOS Logger Collect your log via `console` application in macOS, make sure the log includes - `Date and Time` - `Category` - `Message` **Make sure the log format endsWith `Message` body**. ![Timeline Network Log ](https://bin.bnbstatic.com/image/julia/docs/mp-ide/ide_timeline_log.png) After you start recording the log, please open the mini app to collect the log. Waiting for a few second to get fully log once you finish the app operation. Then just save all the log to the `txt` file. #### Android Logger For android, you enable the logcat. After all the step already, open the binance app and terminal. Copy the shell command to your terminal to write the log into the file. ```bash adb logcat -> timeline.txt ``` Open your mini app now! --- ## Document: FAQ URL: /zh-CN/docs/products/mini-program/devtools/faq # FAQ For quick troubleshooting, we provide a detailed FAQ guide. You can browse it sequentially or use specific keywords to perform a search. For a simplified read, we've categorised the FAQs according to features: Simulator, Devtool Panels, Upload, Network, Preview & Remote Debug, and Extension. ## Simulator ### Dark Mode `darkMode: false` is not working At present, this feature is unsupported. You can verify it on the native side. ## Devtool Panels ### Excessive logs in console For minimising console logs, follow these steps: 1. Go to the toolbar and select `Devtools -> openApp Devtool`. 2. Run script (`document.querySelectorAll('webview')[1].openDevTools()`) in the console panel. 3. Run script (`localStorage.setItem('devtool-debugger', '1')`) in the console panel. 4. Refresh window and run a test now 😄 A dedicated package will be released soon to fix this. ### BXML is empty Upgrade your IDE to version 2.25.0 or later. ### Mocking API with different responses according to the parameters 1. Upgrade your IDE to version 2.26.0 or later. 2. Create multiple mock items each with different rules. ## Upload ### Encountered 400 error during upload Click `details` and verify if the logo is displayed correctly. If not, ensure that your appid and current environment are set correctly. ## Network ### Network requests failing - Activate `Does not verify valid domain names, web-view (business domain names), TLS versions and HTTPS certificates` found in `Details - Local Settings`. ### Image component is blank - Inspect the image node in BXML panel and confirm that the origin-src is correct. If not, review your code. ## Preview & Remote Debug ### Preview loading perpetually Ensure your IDE version is 2.25.0 or above, then clear cache and try again. ### Preview error Here is a list of common error codes, their causes, and remedies to assist developers in troubleshooting quickly. - `350002` means resource not found, please make sure you're using production package or change the env to be production if you're using development package. And make sure you app is in-house mode. - `603301` means invalid (type invalid or cannot download, such as webp type image, not sure we have error code for this before) - `603302` means image not found, please check the url of the image. - `603501` means \_\_app.js is missing, please upgrade your IDE and try again. --- ## Document: Download Stable Version URL: /zh-CN/docs/products/mini-program/devtools/download-stable # Download Stable Version ## [2.54.0] 2024-12-06 \*\*Download: [MacOS(196.75 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.54.0.dmg) ### Features - feat: update @mp/bundler version to support svg ## [2.53.0] 2024-11-04 \*\*Download: [MacOS(196.96 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.53.0.dmg) ### Bug Fixes - fix: find extend lib file missing - fix: android qjs pkg support - fix(runtime): premature return issue in ide enviroment's show-modal api ### Features - feat: rank long task in timeline - feat: update timeline ## [2.52.0] 2024-10-04 \*\*Download: [MacOS(199.94 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.52.0.dmg) ### Features - feat: support preview qjs for android - feat(bundler): update bundler version - feat: support navigationBarButtonColor in ide - feat: support prefers-color-scheme ### Performance Improvements - perf: remove widget bundle and ignore skeleton error ## [2.51.0] 2024-09-13 \*\*Download: [MacOS(193.38 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.51.0.dmg) ### Bug Fixes - fix: update file service response for upload plugin ## [2.50.0] 2024-08-23 \*\*Download: [MacOS(193.38 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.50.0.dmg) ### Bug Fixes - fix: bundle pages rpc in bundeWatch for page updates - fix: always enable css agent and timeline renderWorker log bug ### Features - feat: update bundle watch add entry - feat: auto start detected port server - feat: use localips utils - feat: react devtools support - feat: add render worker support ### Performance Improvements - perf: only bundle all pages once then diff the change file to add page entry in watch mode - perf: hot reload without bundleApp ## [2.49.0] 2024-08-01 \*\*Download: [MacOS(187.82 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.49.0.dmg) ### Bug Fixes - fix: update sentry crash dsn and increase remote debug frame size - fix: bundle end then show the qrCode ### Features - feat: timeline support logan file and timezone offeset - feat(chore): update bundler - feat(bundler): update bundler - feat: timeline custom format - feat: new timeline profiler panel ### Performance Improvements - perf: enhance the user experience of the preview&remote-debug mode ## [2.48.0] 2024-07-12 \*\*Download: [MacOS(187.64 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.48.0.dmg) ### Bug Fixes - fix: preview slowly ### Features - feat: update block props in remote debug worker - feat: upgrade CDP method and show remote debug url at the popup - feat: webf cdp dom ## [2.47.0] 2024-06-26 \*\*Download: [MacOS(187.67 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.47.0.dmg) ### Bug Fixes - fix: load script still need defer ### Features - feat: support extendedLib for preview and remote-debug mode ## [2.46.0] 2024-06-03 \*\*Download: [MacOS(187.66 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.46.0.dmg) ### Bug Fixes - fix: no config error from mock ### Features - feat: increase maxReceivedFrameSize and add detail log for close reason - feat: bump mp deps - feat: support flutter cdp - feat: support mock env - feat: update bundler - feat: webf websocket renderer remote debug support ## [2.45.0] 2024-04-22 \*\*Download: [MacOS(187.70 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.45.0.dmg) ### Features - feat: deprecated built in libs - feat: update host - feat: interal local sdk ## [2.44.0] 2024-04-03 \*\*Download: [MacOS(188.23 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.44.0.dmg) ### Bug Fixes - fix: build error notarization - fix(doc): fix doc with chatgpt ### Features - feat: support dynamic libs ## [2.43.0] 2024-03-11 \*\*Download: [MacOS(183.39 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.43.0.dmg) ### Bug Fixes - fix: func is undefined ### Features - feat: remote debug support flutter renderer ## [2.42.0] 2024-02-19 \*\*Download: [MacOS(183.40 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.42.0.dmg) ## [2.41.1] 2024-02-19 \*\*Download: [MacOS(183.39 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.41.1.dmg) ### Bug Fixes - fix: env update - fix: remote debugger white screen ## [2.41.0] 2024-01-29 \*\*Download: [MacOS(183.39 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.41.0.dmg) ### Bug Fixes - fix: remove window download ## [2.40.0] 2023-11-27 **Download: [MacOS(182.98 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.40.0.dmg) ** ### Bug Fixes - fix: audit storage panel ### Features - feat(IDE): support webf-lint ## [2.39.0] 2023-11-06 **Download: [MacOS(175.69 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.39.0.dmg) ** ## [2.38.0] 2023-10-12 **Download: [MacOS(175.82 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.38.0.dmg) ** ### Bug Fixes - fix(ide): bids login page cannot open ## [2.36.0] 2023-09-06 **Download: [MacOS(175.82 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.36.0.dmg) ** ### Features - feat(IDE): update bundler - feat(IDE): support widget ## [2.35.0] 2023-08-15 **Download: [MacOS(184.27 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.35.0.dmg) ** ### Bug Fixes - fix: nightly build private repo issue - fix(ide): login page error ### Features - feat: measure devtool waiting time after modifying source code ## [2.34.0] 2023-07-31 **Download: [MacOS(181.48 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.34.0.dmg) ** ### Bug Fixes - fix: remote debug not work when not using preview - fix: webview src can't be http resource ### Performance Improvements - perf: enable bundle with system-cache ## [2.33.0] 2023-06-30 **Download: [MacOS(182.38 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.33.0.dmg) ** ### Bug Fixes - fix: [clamp] min should not be greater than max ## [2.32.1] 2023-06-12 **Download: [MacOS(182.35 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.32.1.dmg) ** ### Bug Fixes - fix: appid undefined ## [2.32.0] 2023-06-12 **Download: [MacOS(182.36 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.32.0.dmg) ** ### Bug Fixes - fix: object has been destroyed issue - fix: webContent undefined issue - fix: reply was never sent issue - fix: show dialog and stop when bundle failed ### Features - feat: Support skeleton ### Misc - revert: remove systeminforamtion ## [2.31.0] 2023-05-19 **Download: [MacOS(181.13 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.31.0.dmg) ** ### Bug Fixes - fix: cannot upload with contentType - fix: temp file not show - fix: create webview not works - fix: add contentType filed when upload for security - fix: bindings not found issue - fix: preview issue ### Features - feat: force pika with eta - feat: sourcemap viewer for mini-sdk - feat: bundler error ui - feat: login extension support dev mode - feat: add metric data for IPC channel - feat: data report for login extension ### Performance Improvements - perf: on demand bundleAll - perf: setup server on demand ## [2.30.0] 2023-04-07 **Download: [MacOS(155.92 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.30.0.dmg) ** ### Bug Fixes - fix: requestHeaders missing when using login extension ### Features - feat: filter other usage of cpu and memory - feat: login extension support qa env ## [2.29.0] 2023-03-20 **Download: [MacOS(155.88 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.29.0.dmg) ** ### Bug Fixes - fix: non pika response undefined - fix: pika build fold support ### Features - feat: remove systeminforamtion - feat: support uploading extension ## [2.28.0] 2023-02-24 **Download: [MacOS(159.06 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.28.0.dmg) ** ### Bug Fixes - fix: preview cache when websocket keep alive - fix: nightly build tags not update - fix: renderer logs not saved ### Features - feat: hide internal requests - feat: better capture timing - feat: add problem panel ## [2.27.0] 2023-02-03 **Download: [MacOS(154.65 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.27.0.dmg) ** ### Bug Fixes - fix: loading project board no data - fix: pass the skip verify domain configuration - fix: nightly build version with stable version - fix(bundler): root-portal component not work - fix: force update crash - fix: time picker mismatch - fix: non-pika remote upstream repo incorrect - fix: non-pika data appid is empty - fix: no tags in the nightly builder - fix: performance float issue in the test - fix: unit test error - fix: no response issue when use debugger ### Features - feat: format process name - feat: add changelog link for developer to check version info - feat: only expose worker context - feat: mock panel supports searching by name ## [2.26.0] 2023-01-16 **Download: [MacOS(154.61 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.26.0.dmg) ** ### Bug Fixes - fix: date picker style align native - fix: force update issue - fix: resolve pika and inner bmp path - fix: code quality issue and upload sentry symbols - fix: performance measure point no report ### Features - feat: add otf fonts for BinancePlex - feat: all the point - feat: support multi match - feat: reporter build duration in cicd - feat: auto fill upload form when last upload fail - feat: provide login extension for internal developers - feat: auto update by env ## [2.25.1] 2023-01-06 **Download: [MacOS(154.17 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.25.1.dmg) ** ### Bug Fixes - fix: resolve pika and inner bmp path ## [2.25.0] 2022-12-22 **Download: [MacOS(154.18 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.25.0.dmg) ** ### Bug Fixes - fix: csp protocol for blob - fix: msv auto fill not works - fix: reload app lead to BXML panel empty ### Features - feat: provide code quality panel UI - feat: metrics data collection - feat: write msv to project.config.json - feat: hide useless bxml panel and breadcrumbs ## [2.24.2] 2022-12-15 **Download: [MacOS(145.17 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.24.2.dmg) ** ### Bug Fixes - fix: performance measure point no report (#654) ## [2.24.1] 2022-12-09 **Download: [MacOS(145.17 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.24.1.dmg) ** ### Bug Fixes - fix: eslint - fix: reload app lead to BXML panel empty ### Features - feat: metrics data collection ## [2.24.0] 2022-12-01 **Download: [MacOS(143.41 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.24.0.dmg) ** ### Bug Fixes - fix: remove BXML spaces - fix: high cpu load issue - fix: page log not show - fix: default value not set in the form instance ### Features - feat: hide internal requests ## [2.23.2] **Download: [MacOS(143.24 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.23.2.dmg) ** ### Bug Fixes - fix: high cpu load issue - fix: default value not set in the form instance ## [2.23.1] **Download: [MacOS(143.24 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.23.1.dmg) ** ### Bug Fixes - fix: yarn lock cause withFileTypes of null ### Internal - ci: use prod check instead - chore(changelog): update changelog for version v2.23.0 - chore(changelog): update changelog for version v2.23.0-development.1 ## [2.23.0] **Download: [MacOS(139.13 MB)](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.23.0.dmg) ** ### Bug Fixes - fix: use bn-image tag instead of img to detect - fix: add same local network info when preview - fix: preview logo image styles - fix: show error when user's libVersion field not valid - fix: latest version has cache in yarn.lock - fix: audit panel export to html ### Features - feat: support msv auto fill - feat: migrate buitin sdk from 3.4.0 to 3.6.2 ### Refactor - refactor: remove plugin - refactor: remove share menu and network plugin - refactor(sdk): move plugin into skd host plugin ### Internal - ci: add package size when release - fead(ide): update bundler version - docs: custom compilation - chore: update settings - docs: setting - doc: public doc- Detail Dialog - doc: remote debug public doc - chore(changelog): update changelog for version v2.22.3 - chore(changelog): update changelog for version v2.22.3-development.1 - docs: startup page - docs: simulator - doc: public doc about main page and toolbar - doc: public doc about main page and toolbar - chore(changelog): update changelog for version v2.22.2 - chore(changelog): update changelog for version v2.22.2-development.1 - chore: upgrade @mp/host - docs: update img url - docs: update readme and overview - chore(changelog): update changelog for version v2.22.1 - chore(changelog): update changelog for version v2.22.1-development.1 ## [2.22.3] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.22.3.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/production/binance-devtools-setup-2.22.3.exe)** ### Features - feat: update bundler to ^3.0.0 ## [2.22.2] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.22.2.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/production/binance-devtools-setup-2.22.2.exe)** ### Internal - chore: upgrade @mp/host ## [2.22.1] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.22.1.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/production/binance-devtools-setup-2.22.1.exe)** ### Bug Fixes - fix: update error message - fix: skip loading when launch if no auto compile ### Features - feat: audit panel support base64 image cheking ### Internal - chore: update electron builder - chore(cicd): migrate prowjobs - chore(cicd): migrate prowjobs - ci(flow): migrate to flow cicd pipeline - chore(changelog): update changelog for version v2.22.0 ## [2.22.0] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.22.0.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/production/binance-devtools-setup-2.22.0.exe)** ### Bug Fixes - fix: capture time and timeout update - fix(ide): upload dialog issues - fix(ide): open project type error in hostRenderer - fix: copy source-code ignore node_module & .git - fix: msv support multiselection - fix: sourcemap dev mode link not works - fix: add file size field - fix: changelog issue - fix: reload devtool if needed ### Features - feat: update latest sdk deps and docs updates - feat(sdk): loadScriptSync rpc - feat(ide): create project validate - feat: validate upload parameters and refactor the dialog - feat(ide): capture preview of mp - feat(ide): update deps - feat: support webview template - feat(ide): support create webview - feat(panel): audit panel support exporting JSON - feat(plugin): plugin refactor and better types - feat: sourcemap zip with version - feat: guide user to use `code quality` - feat: support sourcemap download ### Internal - chore(changelog): update changelog for version v2.22.0-development.2 - chore(changelog): update changelog for version v2.22.0-development.1 - chore(changelog): update changelog for version v2.22.0-development.1 - doc: devtool panels - chore(changelog): update changelog for version v2.21.1-development.1 - chore(ide): compile check - chore: update MSV - chore(changelog): update changelog for version v2.21.0 - WIP: remote debug devtools use ws as protocol channel - chore(changelog): update changelog for version v2.21.0-development.1 ## [2.21.0] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.21.0.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/production/binance-devtools-setup-2.21.0.exe)** ### Features - feat(applog-panel): implement applog panel - feat: [IDE] Static analyze mp code using bundler's ability - feat: [IDE] Make console panel log more clean on production version ### Internal - chore: update bundler version - chore: update dependency - chore(changelog): update changelog for version v2.20.0 - chore(changelog): update changelog for version v2.20.0-development.1 ## [2.20.0] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.20.0.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/production/binance-devtools-setup-2.20.0.exe)** ### Bug Fixes - fix(ide-devtools-panel): fix audits - fix(audit-score): fix light theme color - fix: handle taro built mp - fix: replace template chinese comment and add logs page - fix: fix mock method no data - fix: fix mock fail template ### Features - feat: Audit panel detect performance remaining metrics - feat: repeat call warn in ide - feat: check local sdk version also - feat(audit-panel): deal with taro mp setData - feat(audit-score): research and implement audit score calculation - feat(audit-experience): add more columns into experience metrics - feat(audit-panel): Audit panel detect performance remaining metrics - feat(audit-panel): detect render cost time | init render, setData render - feat(audit): add experience related metric - feat(audit-panel): implement audit panel best practice metrics - feat(ide): mock open-type getPhoneNumber getEmailAddress behavior - feat(audit-panel): optimize report context - feat(ide-devtools-panel): audit panel render performance metrics - feat(mock panel): optimize mock panel - feat: show error message when webview fails to load ### Internal - chore: bump @mp/host version - docs: update v2.19.0-development.1 change log - chore(changelog): update changelog for version v2.19.0 ## [2.19.0] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.19.0.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/production/binance-devtools-setup-2.19.0.exe)** ### Bug Fixes - fix: use shelljs replace zx & install dep on linux - fix: remove duplicate them change emit event - fix: executeJavaScript causes bxml not to be displayed - fix: bxml page node has redundant spaces - fix(mock panel): fix ordered before existing data & generated template error - fix(mock panel): fix some bugs - fix: loading assets from resources - fix: fix no proxy method when open IDE for the first time - fix: fix-select-method - fix(ide): remote debug - fix: remove zx dependency ### Features - feat: clean console context - feat: clean console panel context selector - feat: close watcher to stop compile - feat: add mock sys - feat: setdata cnt adjust and bug fix - feat: integrate @mp/extended-lib - feat(devtools): implement audit panel for detect setData ### Refactor - refactor: plugin remove location, download-package, login - refactor: Mock Panel Better user behavior - refactor: move sensor plugin ### Internal - chore(ide): @mp/host upgrade to 0.2.25 - chore: optimization code - chore: universal link - chore(changelog): update changelog for version v2.18.1 - chore: changelog automation ## [2.18.1] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.18.1.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/production/binance-devtools-setup-2.18.1.exe)** ### Bug Fixes - fix: plainText body not supported ## [2.18.0] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/production/binance-devtools-2.18.0.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/production/binance-devtools-setup-2.18.0.exe)** ### Bug Fixes - fix: [IDE]custom launch condition mode-name show issue - fix: remove unnessary http request in mp-runtime-container ### Features - feat: update framework-load-script - feat: integrate service-side-bundle - feat(sdk): handle not found page ### Refactor - refactor: move plugins to runtime-plugins - refactor: plugin migration(error page, preview image) - refactor: migrate ide clipborad plugin - refactor: plugin migration ### Internal - chore: upgrade dependencies --- ## Document: Download Developer Version URL: /zh-CN/docs/products/mini-program/devtools/download-rc # Download Developer Version ## [2.56.0-development.2] 2025-09-18 \*\*Download: [MacOS(205.20 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.56.0-development.2.dmg) ### Bug Fixes - fix: filter standalone-chunk from addEntry ### Features - feat: check node enviroment before download bundler - feat: feature request 2547 & 1893 - feat: support EventSource for IDE - feat: support five themes - feat: midnight -> dark_midnight - feat: support midnight - feat: enhance change bundler feature - feat: implement lite-timeline devtool panel ui - feat: support dynamic bundler - feat: support standalone-chunks - feat(ide): add diagnosticPage ## [2.56.0-development.1] 2025-01-17 \*\*Download: [MacOS(196.78 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.56.0-development.1.dmg) ## [2.55.0-development.1] 2025-01-10 \*\*Download: [MacOS(196.78 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.55.0-development.1.dmg) ## [2.50.0-development.2024082101] 2024-08-21 \*\*Download: [MacOS(193.36 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.50.0-development.2024082101.dmg) ### Features - feat: update bundle watch add entry ## [2.33.0-development.1] 2023-06-30 **Download: [MacOS(182.34 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.33.0-development.1.dmg) ** ### Bug Fixes - fix: [clamp] min should not be greater than max ## [2.32.1-development.1] 2023-06-12 **Download: [MacOS(182.35 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.32.1-development.1.dmg) ** ### Bug Fixes - fix: loading project not end - fix: appid undefined ## [2.31.0-development.1] 2023-04-27 **Download: [MacOS(175.06 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.31.0-development.1.dmg) ** ### Bug Fixes - fix: bindings not found issue - fix: preview issue ### Features - feat: bundler error ui - feat: login extension support dev mode - feat: add metric data for IPC channel - feat: data report for login extension ### Performance Improvements - perf: setup server on demand ## [2.26.0-development.1] 2023-01-11 **Download: [MacOS(154.61 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.26.0-development.1.dmg) ** ### Bug Fixes - fix: date picker style align native - fix: force update issue - fix: resolve pika and inner bmp path - fix: code quality issue and upload sentry symbols - fix: performance measure point no report ### Features - feat: add otf fonts for BinancePlex - feat: all the point - feat: support multi match - feat: reporter build duration in cicd - feat: auto fill upload form when last upload fail - feat: provide login extension for internal developers - feat: auto update by env ## [2.25.0-development.2] 2022-12-13 **Download: [MacOS(154.16 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.25.0-development.2.dmg) ** ### Bug Fixes - fix: csp protocol for blob - fix: msv auto fill not works ## [2.25.0-development.1] 2022-12-12 **Download: [MacOS(154.16 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.25.0-development.1.dmg) ** ### Bug Fixes - fix: reload app lead to BXML panel empty ### Features - feat: provide code quality panel UI - feat: metrics data collection - feat: write msv to project.config.json - feat: hide useless bxml panel and breadcrumbs ## [2.24.1-development.1] 2022-12-09 **Download: [MacOS(145.17 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.24.1-development.1.dmg) ** ### Bug Fixes - fix: eslint - fix: reload app lead to BXML panel empty ### Features - feat: metrics data collection ## [2.24.0-development.1] **Download: [MacOS(143.42 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.24.0-development.1.dmg) ** ### Bug Fixes - fix: remove BXML spaces - fix: high cpu load issue - fix: page log not show - fix: default value not set in the form instance ### Features - feat: hide internal requests ## [2.23.2-development.1] **Download: [MacOS(143.23 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.23.2-development.1.dmg) ** ### Bug Fixes - fix: high cpu load issue - fix: default value not set in the form instance ## [2.23.1-development.1] **Download: [MacOS(143.23 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.23.1-development.1.dmg) ** ### Bug Fixes - fix: yarn lock cause withFileTypes of null ### Internal - ci: use prod check instead - chore(changelog): update changelog for version v2.23.0 - chore(changelog): update changelog for version v2.23.0-development.1 ## [2.23.0-development.1] **Download: [MacOS(143.23 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.23.0-development.1.dmg) ** ### Bug Fixes - fix: yarn lock cause withFileTypes of null - fix: use bn-image tag instead of img to detect - fix: add same local network info when preview - fix: preview logo image styles - fix: show error when user's libVersion field not valid - fix: latest version has cache in yarn.lock - fix: audit panel export to html ### Features - feat: support msv auto fill - feat: migrate buitin sdk from 3.4.0 to 3.6.2 ### Refactor - refactor: remove plugin - refactor: remove share menu and network plugin - refactor(sdk): move plugin into skd host plugin ### Internal - ci: use prod check instead - chore(changelog): update changelog for version v2.23.0 - chore(changelog): update changelog for version v2.23.0-development.1 - ci: add package size when release - fead(ide): update bundler version - docs: custom compilation - chore: update settings - docs: setting - doc: public doc- Detail Dialog - doc: remote debug public doc - chore(changelog): update changelog for version v2.22.3 - chore(changelog): update changelog for version v2.22.3-development.1 - docs: startup page - docs: simulator - doc: public doc about main page and toolbar - doc: public doc about main page and toolbar - chore(changelog): update changelog for version v2.22.2 - chore(changelog): update changelog for version v2.22.2-development.1 - chore: upgrade @mp/host - docs: update img url - docs: update readme and overview - chore(changelog): update changelog for version v2.22.1 - chore(changelog): update changelog for version v2.22.1-development.1 ## [2.22.3-development.1] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.22.3-development.1.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/development/binance-devtools-setup-2.22.3-development.1.exe)** ### Features - feat: update bundler to ^3.0.0 ## [2.22.2-development.1] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.22.2-development.1.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/development/binance-devtools-setup-2.22.2-development.1.exe)** ### Internal - chore: upgrade @mp/host ## [2.22.1-development.1] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.22.1-development.1.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/development/binance-devtools-setup-2.22.1-development.1.exe)** ### Bug Fixes - fix: update error message - fix: skip loading when launch if no auto compile ### Features - feat: audit panel support base64 image cheking ### Internal - chore: update electron builder - chore(cicd): migrate prowjobs - chore(cicd): migrate prowjobs - ci(flow): migrate to flow cicd pipeline - chore(changelog): update changelog for version v2.22.0 ## [2.22.0-development.2] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.22.0-development.2.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/development/binance-devtools-setup-2.22.0-development.2.exe)** ### Bug Fixes - fix: capture time and timeout update - fix(ide): upload dialog issues - fix(ide): open project type error in hostRenderer - fix: copy source-code ignore node_module & .git - fix: msv support multiselection ### Features - feat(sdk): loadScriptSync rpc - feat(ide): create project validate - feat: validate upload parameters and refactor the dialog - feat(ide): capture preview of mp - feat(ide): update deps - feat: support webview template - feat(ide): support create webview ### Internal - doc: devtool panels - chore(changelog): update changelog for version v2.22.0-development.1 ## [2.22.0-development.1] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.22.0-development.1.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/development/binance-devtools-setup-2.22.0-development.1.exe)** ### Bug Fixes - fix(ide): open project type error in hostRenderer - fix: copy source-code ignore node_module & .git - fix: msv support multiselection ### Features - feat(ide): capture preview of mp - feat(ide): update deps - feat: support webview template - feat(ide): support create webview ### Internal - doc: devtool panels - chore(changelog): update changelog for version v2.21.1-development.1 ## [2.21.1-development.1] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.21.1-development.1.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/development/binance-devtools-setup-2.21.1-development.1.exe)** ### Bug Fixes - fix: sourcemap dev mode link not works - fix: add file size field - fix: changelog issue - fix: reload devtool if needed ### Features - feat(ide): update deps - feat(panel): audit panel support exporting JSON - feat(plugin): plugin refactor and better types - feat: sourcemap zip with version - feat: guide user to use `code quality` - feat: support sourcemap download ### Internal - chore(ide): compile check - chore: update MSV - chore(changelog): update changelog for version v2.21.0 - WIP: remote debug devtools use ws as protocol channel - chore(changelog): update changelog for version v2.21.0-development.1 ## [2.21.0-development.1] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.21.0-development.1.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/development/binance-devtools-setup-2.21.0-development.1.exe)** ### Features - feat(applog-panel): implement applog panel - feat: [IDE] Static analyze mp code using bundler's ability - feat: [IDE] Make console panel log more clean on production version ### Internal - chore: update bundler version - chore: update dependency - chore(changelog): update changelog for version v2.20.0 - chore(changelog): update changelog for version v2.20.0-development.1 ## [2.20.0-development.1] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.20.0-development.1.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/development/binance-devtools-setup-2.20.0-development.1.exe)** ### Bug Fixes - fix(ide-devtools-panel): fix audits - fix(audit-score): fix light theme color - fix: handle taro built mp - fix: replace template chinese comment and add logs page - fix: fix mock method no data - fix: fix mock fail template ### Features - feat: Audit panel detect performance remaining metrics - feat: repeat call warn in ide - feat: check local sdk version - feat(audit-panel): deal with taro mp setData - feat(audit-score): research and implement audit score calculation - feat(audit-experience): add more columns into experience metrics - feat(audit-panel): Audit panel detect performance remaining metrics - feat(audit-panel): detect render cost time | init render, setData render - feat(audit): add experience related metric - feat(audit-panel): implement audit panel best practice metrics - feat(ide): mock open-type getPhoneNumber getEmailAddress behavior - feat(audit-panel): optimize report context - feat(ide-devtools-panel): audit panel render performance metrics - feat(mock panel): optimize mock panel - feat: show error message when webview fails to load ### Internal - chore: bump @mp/host version - docs: update v2.19.0-development.1 change log - chore(changelog): update changelog for version v2.19.0 ## [2.19.0-development.1] **Download: [MacOS](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.19.0-development.1.dmg) | [Windows](https://ftp.binance.com/mp-ide/windows/development/binance-devtools-setup-2.19.0-development.1.exe)** ### Bug Fixes - fix: remove duplicate them change emit event - fix: executeJavaScript causes bxml not to be displayed - fix: bxml page node has redundant spaces - fix(mock panel): fix ordered before existing data & generated template error - fix(mock panel): fix some bugs - fix: loading assets from resources - fix: fix no proxy method when open IDE for the first time - fix: fix-select-method - fix(ide): remote debug - fix: remove zx dependency ### Features - feat: clean console context - feat: clean console panel context selector - feat: close watcher to stop compile - feat: add mock sys - feat: setdata cnt adjust and bug fix - feat: integrate @mp/extended-lib - feat(devtools): implement audit panel for detect setData ### Refactor - refactor: plugin remove location, download-package, login - refactor: Mock Panel Better user behavior - refactor: move sensor plugin ### Internal - chore(ide): @mp/host upgrade to 0.2.25 - chore: optimization code - chore: universal link - chore(changelog): update changelog for version v2.18.1 - chore: changelog automation --- ## Document: Download Nightly Version URL: /zh-CN/docs/products/mini-program/devtools/download-nightly # Download Nightly Version ## [2.55.0-development.20250924] 2025-09-24 \*\*Download: [MacOS(205.20 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.55.0-development.20250924.dmg) ### Features - feat: check node enviroment before download bundler ## [2.55.0-development.20250626] 2025-06-26 \*\*Download: [MacOS(205.20 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.55.0-development.20250626.dmg) ### Features - feat: feature request 2547 & 1893 ## [2.55.0-development.20250610] 2025-06-10 \*\*Download: [MacOS(205.20 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.55.0-development.20250610.dmg) ### Features - feat: support EventSource for IDE ## [2.55.0-development.20250421] 2025-04-21 \*\*Download: [MacOS(198.14 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.55.0-development.20250421.dmg) ### Features - feat: support five themes - feat: midnight -> dark_midnight ## [2.55.0-development.20250421] 2025-04-21 \*\*Download: [MacOS(198.14 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.55.0-development.20250421.dmg) ### Features - feat: support five themes - feat: midnight -> dark_midnight ## [2.55.0-development.20250416] 2025-04-16 \*\*Download: [MacOS(198.19 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.55.0-development.20250416.dmg) ### Features - feat: midnight -> dark_midnight ## [2.55.0-development.20250410] 2025-04-11 \*\*Download: [MacOS(201.11 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.55.0-development.20250410.dmg) ### Features - feat: support midnight ## [2.55.0-development.20250407] 2025-04-07 \*\*Download: [MacOS(196.23 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.55.0-development.20250407.dmg) ### Bug Fixes - fix: filter standalone-chunk from addEntry ## [2.55.0-development.20250305] 2025-03-05 \*\*Download: [MacOS(196.23 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.55.0-development.20250305.dmg) ### Features - feat: enhance change bundler feature - feat: implement lite-timeline devtool panel ui ## [2.55.0-development.20250303] 2025-03-03 \*\*Download: [MacOS(196.19 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.55.0-development.20250303.dmg) ### Features - feat: support dynamic bundler ## [2.55.0-development.20250214] 2025-02-26 \*\*Download: [MacOS(196.23 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.55.0-development.20250214.dmg) ### Features - feat(ide): adjust lite-timeline tip - feat(ide): add lite-timeline panel ## [2.55.0-development.20250213] 2025-02-13 \*\*Download: [MacOS(196.18 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.55.0-development.20250213.dmg) ## [2.55.0-development.20250122] 2025-01-22 \*\*Download: [MacOS(196.20 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.55.0-development.20250122.dmg) ### Features - feat: support standalone-chunks ## [2.55.0-development.20250120] 2025-01-20 \*\*Download: [MacOS(201.36 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.55.0-development.20250120.dmg) ### Features - feat(ide): add diagnosticPage ## [2.54.0-development.20241121] 2024-11-29 \*\*Download: [MacOS(196.78 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.54.0-development.20241121.dmg) ## [2.54.0-development.20241120] 2024-11-20 \*\*Download: [MacOS(196.78 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.54.0-development.20241120.dmg) ## [2.53.0-development.20241101] 2024-11-01 \*\*Download: [MacOS(196.95 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.53.0-development.20241101.dmg) ### Bug Fixes - fix: find extend lib file missing ### Features - feat: rank long task in timeline ## [2.53.0-development.20241030] 2024-10-30 \*\*Download: [MacOS(196.95 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.53.0-development.20241030.dmg) ### Bug Fixes - fix: android qjs pkg support ### Features - feat: update timeline ## [2.53.0-development.20241022] 2024-10-22 \*\*Download: [MacOS(196.96 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.53.0-development.20241022.dmg) ### Bug Fixes - fix(runtime): premature return issue in ide enviroment's show-modal api ## [2.52.0-development.20240922] 2024-09-30 \*\*Download: [MacOS(193.68 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.52.0-development.20240922.dmg) ## [2.52.0-development.20240921] 2024-09-30 \*\*Download: [MacOS(193.68 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.52.0-development.20240921.dmg) ### Features - feat(bundler): update bundler version ## [2.52.0-development.20240920] 2024-09-30 \*\*Download: [MacOS(193.69 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.52.0-development.20240920.dmg) ### Features - feat(bundler): update bundler version ## [2.52.0-development.20240919] 2024-09-19 \*\*Download: [MacOS(193.69 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.52.0-development.20240919.dmg) ### Features - feat: support navigationBarButtonColor in ide - feat: support prefers-color-scheme ## [2.52.0-development.20240918] 2024-09-18 \*\*Download: [MacOS(193.69 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.52.0-development.20240918.dmg) ### Performance Improvements - perf: remove widget bundle and ignore skeleton error ## [2.51.0-development.20240903] 2024-09-03 \*\*Download: [MacOS(193.38 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.51.0-development.20240903.dmg) ## [2.51.0-development.20240902] 2024-09-02 \*\*Download: [MacOS(193.38 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.51.0-development.20240902.dmg) ## [2.50.0-development.20240821] 2024-08-21 \*\*Download: [MacOS(193.37 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.50.0-development.20240821.dmg) ### Bug Fixes - fix: bundle pages rpc in bundeWatch for page updates ### Features - feat: update bundle watch add entry ### Performance Improvements - perf: only bundle all pages once then diff the change file to add page entry in watch mode ## [2.50.0-development.20240821] 2024-08-21 \*\*Download: [MacOS(193.36 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.50.0-development.20240821.dmg) ### Performance Improvements - perf: only bundle all pages once then diff the change file to add page entry in watch mode ## [2.50.0-development.20240819] 2024-08-19 \*\*Download: [MacOS(193.32 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.50.0-development.20240819.dmg) ### Features - feat: auto start detected port server ### Performance Improvements - perf: hot reload without bundleApp ## [2.50.0-development.20240816] 2024-08-16 \*\*Download: [MacOS(193.32 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.50.0-development.20240816.dmg) ### Features - feat: use localips utils ## [2.50.0-development.20240815] 2024-08-15 \*\*Download: [MacOS(193.34 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.50.0-development.20240815.dmg) ### Features - feat: react devtools support ## [2.50.0-development.20240813] 2024-08-13 \*\*Download: [MacOS(187.86 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.50.0-development.20240813.dmg) ### Features - feat: add render worker support ## [2.50.0-development.20240805] 2024-08-05 \*\*Download: [MacOS(187.82 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.50.0-development.20240805.dmg) ### Bug Fixes - fix: always enable css agent and timeline renderWorker log bug ## [2.49.0-development.20240731] 2024-07-31 \*\*Download: [MacOS(187.84 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.49.0-development.20240731.dmg) ### Features - feat(chore): update bundler ## [2.49.0-development.20240725] 2024-07-25 \*\*Download: [MacOS(187.84 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.49.0-development.20240725.dmg) ### Features - feat(bundler): update bundler ## [2.49.0-development.20240722] 2024-07-22 \*\*Download: [MacOS(187.78 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.49.0-development.20240722.dmg) ### Bug Fixes - fix: bundle end then show the qrCode ### Features - feat: timeline custom format ## [2.49.0-development.20240719] 2024-07-19 \*\*Download: [MacOS(187.79 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.49.0-development.20240719.dmg) ### Features - feat: new timeline profiler panel ## [2.49.0-development.20240716] 2024-07-16 \*\*Download: [MacOS(187.66 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.49.0-development.20240716.dmg) ### Performance Improvements - perf: enhance the user experience of the preview&remote-debug mode ## [2.48.0-development.20240711] 2024-07-11 \*\*Download: [MacOS(187.67 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.48.0-development.20240711.dmg) ### Bug Fixes - fix: preview slowly ### Features - feat: update block props in remote debug worker ## [2.48.0-development.20240702] 2024-07-02 \*\*Download: [MacOS(187.65 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.48.0-development.20240702.dmg) ### Features - feat: upgrade CDP method and show remote debug url at the popup ## [2.48.0-development.20240627] 2024-06-27 \*\*Download: [MacOS(187.65 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.48.0-development.20240627.dmg) ### Features - feat: webf cdp dom ## [2.47.0-development.20240620] 2024-06-20 \*\*Download: [MacOS(187.65 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.47.0-development.20240620.dmg) ### Features - feat: support extendedLib for preview and remote-debug mode ## [2.46.0-development.20240531] 2024-05-31 \*\*Download: [MacOS(187.65 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.46.0-development.20240531.dmg) ### Features - feat: increase maxReceivedFrameSize and add detail log for close reason ## [2.46.0-development.20240529] 2024-05-29 \*\*Download: [MacOS(187.61 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.46.0-development.20240529.dmg) ### Features - feat: bump mp deps - feat: support flutter cdp ## [2.46.0-development.20240517] 2024-05-17 \*\*Download: [MacOS(187.67 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.46.0-development.20240517.dmg) ### Bug Fixes - fix: no config error from mock ### Features - feat: support mock env ## [2.46.0-development.20240516] 2024-05-16 \*\*Download: [MacOS(187.67 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.46.0-development.20240516.dmg) ### Features - feat: update bundler ## [2.46.0-development.20240514] 2024-05-14 \*\*Download: [MacOS(187.67 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.46.0-development.20240514.dmg) ### Features - feat: webf websocket renderer remote debug support ## [2.46.0-development.20240510] 2024-05-10 \*\*Download: [MacOS(187.67 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.46.0-development.20240510.dmg) ## [2.45.0-development.20240420] 2024-04-20 \*\*Download: [MacOS(191.33 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.45.0-development.20240420.dmg) ### Features - feat: update host ## [2.45.0-development.20240415] 2024-04-15 \*\*Download: [MacOS(188.21 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.45.0-development.20240415.dmg) ### Features - feat: interal local sdk ## [2.44.0-development.20240318] 2024-03-18 \*\*Download: [MacOS(183.41 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.44.0-development.20240318.dmg) ### Bug Fixes - fix(doc): fix doc with chatgpt ## [2.43.0-development.20240307] 2024-03-07 \*\*Download: [MacOS(183.42 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.43.0-development.20240307.dmg) ### Bug Fixes - fix: func is undefined ## [2.43.0-development.20240305] 2024-03-05 \*\*Download: [MacOS(183.41 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.43.0-development.20240305.dmg) ## [2.43.0-development.20240221] 2024-02-21 \*\*Download: [MacOS(183.40 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.43.0-development.20240221.dmg) ### Features - feat: remote debug support flutter renderer ## [2.42.0-development.20240201] 2024-02-01 \*\*Download: [MacOS(183.40 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.42.0-development.20240201.dmg) ### Bug Fixes - fix: remote debugger white screen ## [2.41.0-development.20231219] 2023-12-19 \*\*Download: [MacOS(182.99 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.41.0-development.20231219.dmg) ## [2.41.0-development.20231128] 2023-11-28 \*\*Download: [MacOS(182.99 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.41.0-development.20231128.dmg) ### Bug Fixes - fix: remove window download ## [2.40.0-development.20231124] 2023-11-24 **Download: [MacOS(182.99 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.40.0-development.20231124.dmg) ** ## [2.40.0-development.20231123] 2023-11-23 **Download: [MacOS(182.99 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.40.0-development.20231123.dmg) ** ## [2.40.0-development.20231119] 2023-11-20 **Download: [MacOS(182.99 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.40.0-development.20231119.dmg) ** ### Features - feat(IDE): support webf-lint ## [2.39.0-development.20231103] 2023-11-03 **Download: [MacOS(175.70 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.39.0-development.20231103.dmg) ** ## [2.36.0-development.20230829] 2023-09-20 **Download: [MacOS(177.57 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.36.0-development.20230829.dmg) ** ### Bug Fixes - fix: add node gyp ## [2.36.0-development.20230826] 2023-09-20 **Download: [MacOS(177.57 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.36.0-development.20230826.dmg) ** ### Bug Fixes - fix: upgrade electron-builder ## [2.36.0-development.20230825] 2023-09-19 **Download: [MacOS(175.88 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.36.0-development.20230825.dmg) ** ### Bug Fixes - fix: release ## [2.36.0-development.20230824] 2023-08-25 **Download: [MacOS(175.87 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.36.0-development.20230824.dmg) ** ### Features - feat(IDE): update bundler ## [2.36.0-development.20230816] 2023-08-16 **Download: [MacOS(175.83 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.36.0-development.20230816.dmg) ** ### Features - feat(IDE): support widget ## [2.35.0-development.20230809] 2023-08-09 **Download: [MacOS(184.28 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.35.0-development.20230809.dmg) ** ### Bug Fixes - fix: nightly build private repo issue - fix(ide): login page error ### Features - feat: measure devtool waiting time after modifying source code ## [2.33.0-development.20230619] 2023-06-19 **Download: [MacOS(182.34 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.33.0-development.20230619.dmg) ** ### Bug Fixes - fix: [clamp] min should not be greater than max ## [2.32.0-development.20230609] 2023-06-09 **Download: [MacOS(182.34 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.32.0-development.20230609.dmg) ** ### Bug Fixes - fix: object has been destroyed issue ## [2.32.0-development.20230608] 2023-06-08 **Download: [MacOS(182.35 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.32.0-development.20230608.dmg) ** ### Bug Fixes - fix: webContent undefined issue - fix: reply was never sent issue - fix: show dialog and stop when bundle failed ### Features - feat: Support skeleton ### Misc - revert: remove systeminforamtion ## [2.32.0-development.20230520] 2023-05-20 **Download: [MacOS(181.14 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.32.0-development.20230520.dmg) ** ## [2.31.0-development.20230518] 2023-05-18 **Download: [MacOS(181.14 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.31.0-development.20230518.dmg) ** ### Bug Fixes - fix: cannot upload with contentType ## [2.31.0-development.20230512] 2023-05-12 **Download: [MacOS(181.14 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.31.0-development.20230512.dmg) ** ## [2.31.0-development.20230511] 2023-05-11 **Download: [MacOS(179.41 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.31.0-development.20230511.dmg) ** ### Bug Fixes - fix: temp file not show - fix: create webview not works ### Performance Improvements - perf: on demand bundleAll ## [2.31.0-development.20230510] 2023-05-10 **Download: [MacOS(179.41 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.31.0-development.20230510.dmg) ** ### Bug Fixes - fix: add contentType filed when upload for security ## [2.31.0-development.20230504] 2023-05-04 **Download: [MacOS(175.26 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.31.0-development.20230504.dmg) ** ### Features - feat: force pika with eta ## [2.31.0-development.20230428] 2023-04-28 **Download: [MacOS(175.24 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.31.0-development.20230428.dmg) ** ### Features - feat: sourcemap viewer for mini-sdk ## [2.31.0-development.20230426] 2023-04-26 **Download: [MacOS(175.06 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.31.0-development.20230426.dmg) ** ### Features - feat: bundler error ui ## [2.31.0-development.20230424] 2023-04-24 **Download: [MacOS(175.05 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.31.0-development.20230424.dmg) ** ### Bug Fixes - fix: bindings not found issue ## [2.31.0-development.20230417] 2023-04-17 **Download: [MacOS(170.55 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.31.0-development.20230417.dmg) ** ### Performance Improvements - perf: setup server on demand ## [2.31.0-development.20230414] 2023-04-14 **Download: [MacOS(170.56 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.31.0-development.20230414.dmg) ** ### Features - feat: login extension support dev mode ## [2.31.0-development.20230413] 2023-04-13 **Download: [MacOS(170.56 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.31.0-development.20230413.dmg) ** ### Bug Fixes - fix: preview issue ## [2.31.0-development.20230412] 2023-04-12 **Download: [MacOS(170.56 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.31.0-development.20230412.dmg) ** ### Features - feat: add metric data for IPC channel - feat: data report for login extension ## [2.30.0-development.20230404] 2023-04-04 **Download: [MacOS(155.89 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.30.0-development.20230404.dmg) ** ### Features - feat: filter other usage of cpu and memory ## [2.30.0-development.20230329] 2023-03-29 **Download: [MacOS(155.87 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.30.0-development.20230329.dmg) ** ### Bug Fixes - fix: requestHeaders missing when using login extension ## [2.30.0-development.20230323] 2023-03-23 **Download: [MacOS(155.89 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.30.0-development.20230323.dmg) ** ### Features - feat: login extension support qa env ## [2.29.0-development.20230317] 2023-03-17 **Download: [MacOS(155.89 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.29.0-development.20230317.dmg) ** ### Features - feat: remove systeminforamtion ## [2.29.0-development.20230311] 2023-03-11 **Download: [MacOS(156.00 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.29.0-development.20230311.dmg) ** ### Bug Fixes - fix: pika build fold support ## [2.29.0-development.20230308] 2023-03-08 **Download: [MacOS(159.09 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.29.0-development.20230308.dmg) ** ## [2.29.0-development.20230303] 2023-03-03 **Download: [MacOS(159.09 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.29.0-development.20230303.dmg) ** ### Features - feat: support uploading extension ## [2.29.0-development.20230302] 2023-03-02 **Download: [MacOS(159.07 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.29.0-development.20230302.dmg) ** ## [2.28.0-development.20230222] 2023-02-22 **Download: [MacOS(159.10 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.28.0-development.20230222.dmg) ** ### Bug Fixes - fix: nightly build tags not update - fix: renderer logs not saved ### Features - feat: better capture timing - feat: add problem panel ## [2.26.0-development.20230216] 2023-02-16 **Download: [MacOS(159.10 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.26.0-development.20230216.dmg) ** ### Features - feat: better capture timing ## [2.26.0-development.20230213] 2023-02-13 **Download: [MacOS(154.65 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.26.0-development.20230213.dmg) ** ### Bug Fixes - fix: renderer logs not saved ## [2.26.0-development.20230208] 2023-02-08 **Download: [MacOS(154.64 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.26.0-development.20230208.dmg) ** ### Bug Fixes - fix: loading project board no data - fix: pass the skip verify domain configuration ### Features - feat: add problem panel ## [2.26.0-development.20230202] 2023-02-02 **Download: [MacOS(154.67 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.26.0-development.20230202.dmg) ** ### Bug Fixes - fix: nightly build version with stable version - fix(bundler): root-portal component not work ## [2.26.0-development.20230201] 2023-02-01 **Download: [MacOS(154.61 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.26.0-development.20230201.dmg) ** ### Features - feat: format process name ## [2.26.0-development.20230131] 2023-01-31 **Download: [MacOS(154.61 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.26.0-development.20230131.dmg) ** ### Bug Fixes - fix: force update crash - fix: time picker mismatch ### Features - feat: add changelog link for developer to check version info - feat: only expose worker context ## [2.26.0-development.20230130] 2023-01-30 **Download: [MacOS(154.61 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.26.0-development.20230130.dmg) ** ### Bug Fixes - fix: non-pika remote upstream repo incorrect ## [2.26.0-development.20230119] 2023-01-19 **Download: [MacOS(154.60 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.26.0-development.20230119.dmg) ** ### Bug Fixes - fix: non-pika data appid is empty ## [2.26.0-development.20230118] 2023-01-18 **Download: [MacOS(154.61 MB)](https://ftp.binance.com/mp-ide/mac/development/binance-devtools-2.26.0-development.20230118.dmg) ** ### Bug Fixes - fix: no tags in the nightly builder - fix: performance float issue in the test - fix: unit test error - fix: no response issue when use debugger ### Features - feat: mock panel supports searching by name --- ## Document: How to Use Devtools URL: /zh-CN/docs/products/mini-program/devtools/devtool # How to Use Devtools ## Login ![img](https://bin.bnbstatic.com/image/julia/docs/mini-program/ide-login.png) ![img](https://bin.bnbstatic.com/image/julia/docs/mini-program/ide-login-2.png) ![img](https://bin.bnbstatic.com/image/julia/docs/mini-program/ide-login-3.png) ## Inspect Tool 1. Use `Open inspect tool` to add a request header. ![img](https://bin.bnbstatic.com/image/julia/docs/mini-program/ide-devtools-1.png) Write your request (It won't work if the request URL is incorrect). ```ts async onRequest(){ await bn.request({ url: 'https://www.devfdg.net/en/js-sdk-demo-ui/request' }) }, ``` 2. Add your header. ![img](https://bin.bnbstatic.com/image/julia/docs/mini-program/ide-devtools-2.png) ![img](https://bin.bnbstatic.com/image/julia/docs/mini-program/ide-devtools-3.png) ## How to Debug WebView Click the `Devtool` menu and select `Open Current Webview Component Devtools`. A devtool dialog will then appear. ![webview-devtool-menu](https://bin.bnbstatic.com/image/julia/docs/mp-ide/webview-devtool-menu.png) Ensure there's a webview component when you select `Open Current Webview Component Devtools`. If there isn't, nothing will happen. --- ## Document: Custom Compilation URL: /zh-CN/docs/products/mini-program/devtools/custom-compilation # Custom Compilation Developers can use the compile button on the toolbar to compile the current code, and the devtools will automatically refresh the simulator. Additionally, developers can add or select custom compilation conditions to preview the compilation of their project code. This assists developers in debugging issues by entering a specific page from different scene values. custom compilation **Note: Compilation conditions are tied to individual projects, and each project can save its own compilation conditions.** create custom compilation Fields include: - Mode Name: The name for the current compilation. For example: `test`. - Startup Page: The entry page path of the compilation such as `pages/test`. - Parameters: The query string that will append to the startup page, for instance: `name=nezha&type=mp`. - Enter Scene: The Scene value of mini project upon launch. - Launch Options: Switch for 'the simulator update at next refresh'. scene values --- ## Document: /products/link-and-trade/Fast-API/Introduction URL: /zh-CN/docs/products/link-and-trade/Fast-API/Introduction # Introduction Fast API can help users quickly authorize specific account permissions, create API keys, and automatically connect to third-party API link platforms. For more details, please refer to the [FAQ](https://www.binance.com/en/support/faq/what-is-fast-api-and-how-does-it-work-6aa7e2253c544d91b60746bfd03fd75d). ## Onboarding Steps 1. Log in [Binance Developer center](https://developers.binance.com/en/docs) with [verified entity(enterprise) account](https://www.binance.com/en/support/faq/how-to-complete-entity-verification-kyb-on-binance-step-by-step-guide-360015552032) 2. Apply for "**Entity KYB**" & "**OAuth Security KYB**" 3. Once both passed, client can create "**Client ID**", upload "**logo(60 x60)**" and set up "**callback url**". We will send an Email that include “**Client ID**” and “**Client Secret**”(**please do not share your Client secret with anyone**) 4. Download the [SDK](https://drive.google.com/file/d/1xFvDTEjUQCL8bviGR9FfszzTiV6pN8Ci/view) for utilizing the pop up dialogues. 5. Apply for the oAuth scopes required. 6. Start development of oAuth and Fast API. ### Minimum requirements for Fast API: - **account:status** - **create:apikey** (For Spot & Margin trading permission, and Futures trading permission) _Or_ **create:apikey:margin** (For Margin Loan, repay, and Transfer permission) _Or_ **create:apikey:options** (For European Options Trading permission) - **user:openId** ## Remarks 1. The baseurl is "https://www.binanceapis.com/oauth-api" 2. When Link clients start to use oAuth, they will get their unique “Client ID” and “Client secret”. 3. When each User grants permission via oAuth, the Link client will get an unique “User’s open ID” and an "Access token". 4. Access token will be expired once the User’s API key is generated. 5. **Each user account** can only use the Fast API to connect with **Each Link client Once**. 6. Link client need to provide a public key for encrypting User’s API key, when requesting the API generation. Additionally, Link clients should be able to decrypt the API key package, and store it safely. 7. When Link client request to generate a user's API key, it should state clearly if this API key should have certain permission(s). In request params: - enableTrade → whether to enable Spot & Margin Trading - enableFutureTrade → whether to enable Futures Trading - enableMargin → whether to enable Margin Loan, Repay and Transfer - enableEuropeanOptions → whether to enable European Options Trading 8. To know if a user has a Futures account, Link client should use Oauth to check the user's status.and show the necessary Front end UI to allow the user to select. The standard Front end is provided as a SDK. ## Common Error messages ### 050009 - Invalid public key. Solution: 1. Do not use pem format 2. Encode the Public key ### 050010 - API generation failed. ### 001512 - Each account can only generate one API key for a certain third party via Fast API. ### 001464 - You have reached the API Key limit. Please delete the unused ones to create new API Keys. ### 2000039xxx - There may be multi error starting with 2000039, which represents the error message related to compliance. --- ## Document: /products/kyc-saas/general/Webhook-Notifications URL: /zh-CN/docs/products/kyc-saas/general/Webhook-Notifications # Webhook Notifications The webhook notifications function can be implemented by passing a `notifyUrl` when calling our KYC endpoints to initialize KYC. `notifyUrl` is a mandatory parameter when initiating KYC. If not required, you can pass a "." instead. Binance will send a POST request webhook to your notifyUrl when there are updates to the KYC record. If the system's request to your notifyUrl fails, the system will auto retry as per the below policy: - On first failure, retry in 3 minutes - On second failure, retry in 5 minutes - On third failure, retry in 10 minutes ## Request sample ```json { "bizEntityKey": "BROKERKEY", "entityCustomerId": "45712345678999212345", "kycType": "USER", "eventType": "USER-STATUS", "eventVo": { "statusInfo": { "bizEntityKey": "BROKERKEY", "entityCustomerId": "45712345678999212345", "kycUserId": "45712345678999212345", "userType": "USER", "kycType": "USER", "kycStatus": "REJECT", "failReason": "This ID number has been used. Log in to your original account to complete the transaction.", "basicStatus": "PASS", "basicFailReason": "", "identityStatus": "REJECT", "identityFailReason": "This ID number has been used. Log in to your original account to complete the transaction.", "faceStatus": "REJECT", "faceFailReason": "This ID number has been used. Log in to your original account to complete the transaction.", "wckStatus": "INITIAL", "dbCreateTime": 1751010142158, "dbModifyTime": 1751010192997, "identityCompleteTime": 1751010192926, "faceCompleteTime": 1751010192931, "riskRateLevel": "MEDIUM", "riskRateScore": 31 }, "levelInfo": { "currentLevel": { "levelName": "INTERMEDIATE", "levelDesc": "INTERMEDIATE", "kycStatus": "REFUSED", "limit": { "fiatCurrency": "USD", "withdrawFiatDailyLimit": 20000, "cryptoCurrency": "BTC", "depositCryptoDailyLimit": -1, "withdrawCryptoDailyLimit": 100 } }, "kycPass": false, "hasMultipleLevels": false, "passedLevels": [] }, "basicInfo": { "id": 4581048056761212345, "bizEntityKey": "BROKERKEY", "bizKey": "BROKERKEY", "kycUserId": "45712345678999212345", "basicType": "USER", "basicStatus": "PASS", "firstName": "BO", "middleName": "testMiddleName", "lastName": "LI", "residentialCountry": "AE", "dob": "1986-08-14", "postalCode": "123456", "city": "bbb", "address": "aaa", "submitIp": "192.168.1.1", "dbCreateTime": 1751010142182, "dbModifyTime": 1751010142182, "country": "AE", "requestTime": 1751010142182, "requestIp": "192.168.1.1" } }, "version": 1751010193080 } ``` ## Notify Webhook Verification 1. Receive the webhook request body as String 2. Use the `HmacSHA256` algorithm to sign the request body String obtained in 1st step, and compare the value of request header - `X-SHA2-Signature` , if they are the same, then the request body is valid, otherwise invalid. ### javascript example ```javascript const crypto = require("crypto"); const secret = ""; const postData = ""; const hash = crypto.createHmac("sha256", secret).update(postData).digest("hex"); ``` ### java example ```java import org.apache.commons.codec.binary.Hex; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; public class App { public static void main(String[] args) throws Exception { String rawString = ""; Mac sha256Hmac = Mac.getInstance("HmacSHA256"); SecretKeySpec secretKey = new SecretKeySpec("".getBytes(), "HmacSHA256"); sha256Hmac.init(secretKey); String eventSignature = new String(Hex.encodeHex(sha256Hmac.doFinal(rawString.getBytes(StandardCharsets.UTF_8)))); System.err.println(eventSignature); } } ``` --- ## Document: /products/kyc-saas/general/Request-Specifications URL: /zh-CN/docs/products/kyc-saas/general/Request-Specifications # Request Specifications ## General API Information - The base endpoint is: **https://cb.link-kycapi.com** - All endpoints return either a JSON object or array. - All request parameters should be passed in the request body as either a JSON object or array. - All endpoints require passing a valid `X-SHA-Signature` header. - Do note that the signature generation method here may not align with the method used for calling other Binance API endpoints (such as https://fapi.binance.com) - All endpoints should be called from whitelisted IP addresses. - Otherwise, it is expected that you would encounter a HTTP `403` return code. ## Signature Generation 1. KYC Data should be sent in the Request Body in JSON format. 2. Convert the Request Body JSON to a JSON String 3. Use the **HmacSHA256** algorithm to sign the JSON String, and assign the result to the `X-SHA-Signature` request header. ## Examples 1. Request Body to be sent: ```json { "bizEntityKey": "", "entityCustomerId": "", "kycType": "USER", "extra": {}, "notifyUrl": "" } ``` 2. Converted Request BODY to JSON String: ```json { "bizEntityKey": "", "entityCustomerId": "", "kycType": "USER", "extra": {}, "notifyUrl": "" } ``` 3. Sign the JSON String (see below examples). ### NodeJS Example ```javascript const crypto = require("crypto"); const secret = ""; const postData = { bizEntityKey: "", // entity key will be decided and given Binance team entityCustomerId: "", kycType: "USER", extra: {}, notifyUrl: "", }; const hash = crypto.createHmac("sha256", secret).update(JSON.stringify(postData)).digest("hex"); ``` ### Java Example ```java import org.apache.commons.codec.binary.Hex; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; public class App { public static void main(String[] args) throws Exception { String rawString = "{ \"bizEntityKey\": \"\", \"entityCustomerId\": \"\", \"kycType\": \"USER\", \"extra\": { }, \"notifyUrl\": \"\" }"; Mac sha256Hmac = Mac.getInstance("HmacSHA256"); SecretKeySpec secretKey = new SecretKeySpec("".getBytes(), "HmacSHA256"); sha256Hmac.init(secretKey); String eventSignature = new String(Hex.encodeHex(sha256Hmac.doFinal(rawString.getBytes(StandardCharsets.UTF_8)))); System.err.println(eventSignature); } } ``` ### Python Example ```python import requests import json import hmac import hashlib body = { "bizEntityKey": "", "entityCustomerId": "", "kycType": "USER", "extra": { }, "notifyUrl": "" } api_secret = '' ##please replace with your own json.dumps(body, separators=(',', ':')) #use this instead to remove extra spaces signature = hmac.new(api_secret.encode(), json_str.encode(), hashlib.sha256).hexdigest() ``` --- ## Document: /products/kyc-saas/general/Overall-Workflow URL: /zh-CN/docs/products/kyc-saas/general/Overall-Workflow # Getting Started Integrating with Binance Link KYC Saas broadly follows the below steps. 1. Create an Exchange Link sub-account via API. 2. KYC is processed for the user in one of two methods. 3. Validate that KYC is passed. 4. Create an API Key for the sub-account, and proceed from there. # Sub Account Creation Flow with Link Module integration 1. Create a Sub account `POST /sapi/v1/broker/subAccount` 2. Complete KYC and bind to Sub account via KYC module through one of: - Share KYC API `/bapi/ekyc/v2/public/ekyc/customer/share-kyc-data` - Oauth Link `/bapi/ekyc/v2/public/ekyc/customer/add-account-info-list` 3. Check KYC Status is passed `/bapi/ekyc/v2/public/ekyc/customer/check-kyc-status` - Requirement: `data.levelInfo.currentLevel.kycStatus` = `PASS` 4. Create Sub account API Key `POST /sapi/v1/broker/subAccountApi` --- ## Document: /products/derivatives-trading-usds-futures/websocket-market-streams/Live-Subscribing-Unsubscribing-to-streams URL: /zh-CN/docs/products/derivatives-trading-usds-futures/websocket-market-streams/Live-Subscribing-Unsubscribing-to-streams # 实时订阅/取消数据流 - 以下数据可以通过websocket发送以实现订阅或取消订阅数据流。示例如下。 - 响应内容中的`id`是无符号整数,作为往来信息的唯一标识。 ## 订阅一个信息流 > **请求** ```json { "method": "SUBSCRIBE", "params": ["btcusdt@aggTrade", "btcusdt@depth"], "id": 1 } ``` > **响应** ```json { "result": null, "id": 1 } ``` ## 取消订阅一个信息流 > **请求** ```json { "method": "UNSUBSCRIBE", "params": ["btcusdt@depth"], "id": 312 } ``` > **响应** ```json { "result": null, "id": 312 } ``` ## 已订阅信息流 > **请求** ```json { "method": "LIST_SUBSCRIPTIONS", "id": 3 } ``` > **响应** ```json { "result": ["btcusdt@aggTrade"], "id": 3 } ``` ## 设定属性 当前,唯一可以设置的属性是设置是否启用`combined`("组合")信息流。 当使用`/ws/`("原始信息流")进行连接时,combined属性设置为`false`,而使用 `/stream/`进行连接时则将属性设置为`true`。 > **请求** ```json { "method": "SET_PROPERTY", "params": ["combined", true], "id": 5 } ``` > **响应** ```json { "result": null "id": 5 } ``` ## 检索属性 > **请求** ```json { "method": "GET_PROPERTY", "params": ["combined"], "id": 2 } ``` > **响应** ```json { "result": true, // Indicates that combined is set to true. "id": 2 } ``` ## 错误信息 | 错误信息 | 描述 | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | | {"code": 0, "msg": "Unknown property"} | `SET_PROPERTY` 或 `GET_PROPERTY`中应用的参数无效 | | {"code": 1, "msg": "Invalid value type: expected Boolean"} | 仅接受`true`或`false` | | {"code": 2, "msg": "Invalid request: property name must be a string"} | 提供的属性名无效 | | {"code": 2, "msg": "Invalid request: request ID must be an unsigned integer"} | 参数`id`未提供或`id`值是无效类型 | | {"code": 2, "msg": "Invalid request: unknown variant %s, expected one of `SUBSCRIBE`, `UNSUBSCRIBE`, `LIST_SUBSCRIPTIONS`, `SET_PROPERTY`, `GET_PROPERTY` at line 1 column 28"} | 错字提醒,或提供的值不是预期类型 | | {"code": 2, "msg": "Invalid request: too many parameters"} | 数据中提供了不必要参数 | | {"code": 2, "msg": "Invalid request: property name must be a string"} | 未提供属性名 | | {"code": 2, "msg": "Invalid request: missing field `method` at line 1 column 73"} | 数据未提供`method` | | {"code":3,"msg":"Invalid JSON: expected value at line %s column %s"} | JSON 语法有误. | --- ## Document: /products/derivatives-trading-usds-futures/websocket-market-streams/Important-WebSocket-Change-Notice URL: /zh-CN/docs/products/derivatives-trading-usds-futures/websocket-market-streams/Important-WebSocket-Change-Notice # WebSocket Base URL 迁移公告(重要变更) ## 变更背景 由于现有 WebSocket 服务流量持续升高,我们对 WebSocket URL 结构进行了拆分与升级:以 **Root** 作为根路径,并新增 **Public / Market / Private** 三类入口,供不同频率与类型的数据分别接入,从而提升整体稳定性与可扩展性。 ## 变更摘要(What’s New) - **新增 3 个 WebSocket Base URL(Root + 分流路径)** - Public(高频公共行情/盘口):`wss://fstream.binance.com/public` - Market(常规公共市场数据):`wss://fstream.binance.com/market` - Private(用户私有数据):`wss://fstream.binance.com/private` - **支持两种访问模式** - `ws` 模式:使用 URL path 拼接订阅流 - `stream` 模式:使用 `?streams=`(或 private 的 `listenKey/events`)参数传入订阅流 - **继续支持 Combined Streams(组合订阅)** - **Private 维度支持 listenKey + events 订阅方式(可多 listenKey、多 event)** ## 新 URL 使用方式(Examples) ### Public / Market:组合订阅 - `ws` 模式(path 拼接) - `wss://fstream.binance.com/public/ws/bnbusdt@depth/ethusdt@depth` - `wss://fstream.binance.com/market/ws/btcusdt@aggTrade/ethusdt@aggTrade` - `stream` 模式(query 传 streams) - `wss://fstream.binance.com/market/stream?streams=bnbusdt@aggTrade/btcusdt@markPrice` - `wss://fstream.binance.com/public/stream?streams=btcusdt@depth/ethusdt@depth` ### Private:listenKey & events - `ws` 模式(示例:listenKey + events) - `wss://fstream.binance.com/private/ws?listenKey=&events=ORDER_TRADE_UPDATE/ACCOUNT_UPDATE` - `stream` 模式(示例:多 listenKey + 多 events) - `wss://fstream.binance.com/private/stream?listenKey=&events=ORDER_TRADE_UPDATE&listenKey=&events=ACCOUNT_UPDATE` > 也支持使用 JSON `SUBSCRIBE` 请求订阅流(params 中可混合 market/public stream 与 listenKey 事件)。 ## Endpoint 与 Stream 映射(摘录) ### Public(高频公共数据) - Individual Symbol Book Ticker:`@bookTicker` - All Book Tickers:`!bookTicker` - Partial Book Depth:`@depth`(支持 `@500ms` / `@100ms`) - Diff. Book Depth:`@depth`(支持 `@500ms` / `@100ms`) ### Market(常规市场数据) - Aggregate Trade:`@aggTrade` - Mark Price:`@markPrice` 或 `@markPrice@1s` - Mark Price (All market):`!markPrice@arr` 或 `!markPrice@arr@1s` - Kline/Candlestick:`@kline_` - Continuous Kline:`_@continuousKline_` - Mini Ticker:`@miniTicker`;All mini ticker:`!miniTicker@arr` - Ticker:`@ticker`;All ticker:`!ticker@arr` - Liquidation Order:`@forceOrder`;All:`!forceOrder@arr` - Composite Index:`@compositeIndex` - Contract Info:`!contractInfo` - Multi-Assets Mode Asset Index:`!assetIndex@arr` 或 `@assetIndex` ## 兼容性与迁移建议(Migration) - **旧 URL 将继续可用至 2026-04-23**,届时将被永久下线。建议用户在此日期前完成迁移到新的 `/public`、`/market`、`/private` 入口。 - **升级完成后,未迁移的连接将仅能接收 `wss://fstream.binance.com/public` 下的数据。`/market` 和 `/private` 下的频道将停止推送数据。** 例如,`wss://fstream.binance.com/ws/btcusdt@depth` 仍可正常接收数据,但 `wss://fstream.binance.com/ws/btcusdt@markPrice` 将无法接收。 - 迁移优先级建议: 1. 高频盘口/核心公共数据 → 迁移到 `/public` 2. 常规市场数据(markPrice/kline/ticker 等)→ 迁移到 `/market` 3. 用户数据(listenKey 相关)→ 迁移到 `/private` - 客户端 SDK/连接管理建议: - 建议按数据类型拆分连接(public/market/private 分开建连),降低单连接负载与抖动风险。 - 如需组合订阅,优先使用 `stream` 模式的 `?streams=` 管理订阅列表(private 按 listenKey/events 管理)。 ## 行动项(Action Required) - 请评估并更新你们的 WebSocket 连接配置: - 将 Base URL 替换为新的 `/public`、`/market`、`/private` - 确认订阅 stream 名称与所属入口一致(Public vs Market vs Private) - **请在 2026-04-23 前完成迁移。** 届时旧 URL(`wss://fstream.binance.com/ws`、`wss://fstream.binance.com/stream`)将不再可用。 --- ## Document: /products/derivatives-trading-usds-futures/websocket-market-streams/How-to-manage-a-local-order-book-correctly URL: /zh-CN/docs/products/derivatives-trading-usds-futures/websocket-market-streams/How-to-manage-a-local-order-book-correctly # 如何正确在本地维护一个orderbook副本 1. 订阅 **wss://fstream.binance.com/public/stream?streams=btcusdt@depth** 2. 开始缓存收到的更新。同一个价位,后收到的更新覆盖前面的。 3. 访问Rest接口 **https://fapi.binance.com/fapi/v1/depth?symbol=BTCUSDT&limit=1000**获得一个1000档的深度快照 4. 将目前缓存到的信息中`u`< 步骤3中获取到的快照中的`lastUpdateId`的部分丢弃(丢弃更早的信息,已经过期)。 5. 将深度快照中的内容更新到本地orderbook副本中,并从websocket接收到的第一个`U` `<= ``lastUpdateId` **且** `u` >`= ``lastUpdateId` 的event开始继续更新本地副本。 - U = 来自 WebSocket 流的 firstUpdateId(第一个更新 ID)。 - u = 来自 WebSocket 流的 finalUpdateId(最后一个更新 ID)。 - lastUpdateId = 你从 REST 深度快照中获取的 更新 ID。 6. 每一个新event的`pu`应该等于上一个event的`u`,否则可能出现了丢包,请从step3重新进行初始化。 7. 每一个event中的挂单量代表这个价格目前的挂单量**绝对值**,而不是相对变化。 8. 如果某个价格对应的挂单量为0,表示该价位的挂单已经撤单或者被吃,应该移除这个价位。 --- ## Document: /products/derivatives-trading-usds-futures/websocket-market-streams/Connect URL: /zh-CN/docs/products/derivatives-trading-usds-futures/websocket-market-streams/Connect # 市场数据连接 - 本篇所列出的所有wss接口需用下列方式连接: - Base Url:**wss://fstream.binance.com** - 三个分流入口,按数据类型分别接入: - **Public**(高频公共行情/盘口数据):`wss://fstream.binance.com/public` - **Market**(常规公共市场数据):`wss://fstream.binance.com/market` - **Private**(用户私有数据):`wss://fstream.binance.com/private` - 支持两种访问模式: - `ws` 模式:通过 URL path 拼接订阅流 — **/ws/<streamName>** - `stream` 模式:通过 query 参数传入 — **/stream?streams=<streamName1>/<streamName2>/<streamName3>** - 连接样例: - `wss://fstream.binance.com/market/ws/bnbusdt@aggTrade` - `wss://fstream.binance.com/public/ws/bnbusdt@depth/ethusdt@depth` - `wss://fstream.binance.com/market/stream?streams=bnbusdt@aggTrade/btcusdt@markPrice` > **重要提示:** 如果连接 URL 中未指定分流路径(`/public`、`/market` 或 > `/private`),则该连接将仅能接收 **Public** 类别的数据。属于 `/market` 或 `/private` > 类别的 stream 将不会推送数据。例如,`wss://fstream.binance.com/ws/btcusdt@depth` > 仍可正常接收(因为 `@depth` 属于 `/public`),但 `wss://fstream.binance.com/ws/btcusdt@markPrice` > 将无法接收(因为 `@markPrice` 属于 `/market`)。各 stream 与入口的完整映射关系及迁移说明,请参考 > [WebSocket Base URL 迁移公告](Important-WebSocket-Change-Notice)。 - 订阅组合streams时,事件payload会以这样的格式封装 **{"stream":"<streamName<","data":<rawPayload>}** - stream名称中所有交易对均为**小写**。 - 每个链接有效期不超过24小时,请妥善处理断线重连。 - 服务端每3分钟会发送ping帧,客户端应当在10分钟内回复pong帧,否则服务端会主动断开链接。允许客户端发送不成对的pong帧(即客户端可以以高于15分钟每次的频率发送pong帧保持链接)。 - Websocket服务器每秒最多接受10个订阅消息。 - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅 **1024** 个Streams。 --- ## Document: /products/derivatives-trading-usds-futures/faq/stp-faq URL: /zh-CN/docs/products/derivatives-trading-usds-futures/faq/stp-faq # 自我交易预防 (Self Trade Prevention - STP) 常见问题 ## 什么是 Self Trade Prevention - STP? 自我交易预防是指阻止订单与来自同一账户或者同一 `tradeGroupId` 账户的订单交易。 ## 什么是自我交易(self-trade)? 在以下任一情况下都可能发生自我交易: - 属于同一账户的订单之间交易。 - 属于相同 `tradeGroupId` 的账户的订单之间交易。 ## STP 触发时会发生什么? 如果订单会触发自我交易,系统将执行三种可能的模式: `EXPIRE_TAKER` - 此模式通过立即使吃单者(taker)的剩余数量过期来预防交易。 `EXPIRE_MAKER` - 此模式通过立即使潜在挂单者(maker)的剩余数量过期来预防交易。 `EXPIRE_BOTH` - 此模式通过立即同时使吃单和挂单者的剩余数量过期来预防交易。 STP 的发生取决于 **Taker 订单** 的 STP 模式。
因此,订单薄上的订单的 STP 模式不再有效果,并且将在所有未来的订单处理中被忽略。 ## 如何在订单上设置自我交易预防 ? 自我交易预防可以通过下单接口的参数`selfTradePreventionMode`设置,相关接口如下: - POST `/fapi/v1/order` - POST `/fapi/v1/batchOrders` ## 什么是交易组 Id(Trade Group Id)? 属于同一 `tradeGroupId` 的账户被视为同一交易组。相同交易组成员提交的订单有 STP 资格。 每个账户可以从 `GET /fapi/v1/accountConfig`(REST API)确认账户是否属于同一个 `tradeGroupId`。 `tradeGroupId` 也存在 `GET /api/v3/preventedMatches`(Rest API)或 `myPreventedMatches`(Websocket API)的响应中。 如果该值为 `-1`,这表示账户未设置 `tradeGroupId`,因此 STP 只能发生在同一账户的订单之间。 我们将在之后的更新提供将子账户设置为同一`tradeGroupId`的功能 ## 如何知道有那些交易对支持 STP? 所有`GET fapi/v1/exchangeInfo`中的交易对都支持`selfTradePreventionMode`。 ## 哪些订单类型支持 STP? `LIMIT`/`MARKET`/`STOP`/`TAKE_PROFIT`/`STOP_MARKET`/`TAKE_PROFIT_MARKET`/`TRAILING_STOP_MARKET` 在Time in force(timeInForce)设置为`GTC`/ `IOC`/ `GTD`时支持STP。当Time in force(timeInForce)为`FOK` 或 `GTX`时订单STP设置不生效 ## 改单是否支持 STP? 目前不支持。改单会将订单的`selfTradePreventionMode` 重制为 `NONE` ## 如何知道订单因为 STP 而过期? 订单的状态会是 `EXPIRED_IN_MATCH`. 在用户信息流推送 `ORDER_TRADE_UPDATE`,如果订单因为STP过期字段`X`会显示`EXPIRED_IN_MATCH` ```javascript { "e":"ORDER_TRADE_UPDATE", // Event Type "E":1568879465651, // Event Time "T":1568879465650, // Transaction Time "o":{ "s":"BTCUSDT", // Symbol "c":"TEST", // Client Order Id // special client order id: // starts with "autoclose-": liquidation order // "adl_autoclose": ADL auto close order // "settlement_autoclose-": settlement order for delisting or delivery "S":"SELL", // Side "o":"TRAILING_STOP_MARKET", // Order Type "f":"GTC", // Time in Force "q":"0.001", // Original Quantity "p":"0", // Original Price "ap":"0", // Average Price "sp":"7103.04", // Stop Price. Please ignore with TRAILING_STOP_MARKET order "x":"EXPIRED", // Execution Type "X":"EXPIRED_IN_MATCH", // Order Status "i":8886774, // Order Id "l":"0", // Order Last Filled Quantity "z":"0", // Order Filled Accumulated Quantity "L":"0", // Last Filled Price "N":"USDT", // Commission Asset, will not push if no commission "n":"0", // Commission, will not push if no commission "T":1568879465650, // Order Trade Time "t":0, // Trade Id "b":"0", // Bids Notional "a":"9.91", // Ask Notional "m":false, // Is this trade the maker side? "R":false, // Is this reduce only "wt":"CONTRACT_PRICE", // Stop Price Working Type "ot":"TRAILING_STOP_MARKET", // Original Order Type "ps":"LONG", // Position Side "cp":false, // If Close-All, pushed with conditional order "AP":"7476.89", // Activation Price, only puhed with TRAILING_STOP_MARKET order "cr":"5.0", // Callback Rate, only puhed with TRAILING_STOP_MARKET order "pP": false, // ignore "si": 0, // ignore "ss": 0, // ignore "rp":"0", // Realized Profit of the trade "V": "EXPIRE_MAKER", // selfTradePreventionMode "pm":"QUEUE", // price match type "gtd":1768879465650 // good till date } } ``` ## STP 的一些示例: 假设以下示例的所有订单都是在同一个账户下发送。 **情况 A - 用户发送带有 `EXPIRE_MAKER` 的订单,该订单将与订单薄上已有的订单撮合。** ``` Maker 订单 1: symbol=BTCUSDT side=BUY type=LIMIT quantity=1 price=20002 selfTradePreventionMode=EXPIRE_MAKER Maker 订单 2: symbol=BTCUSDT side=BUY type=LIMIT quantity=1 price=20001 selfTradePreventionMode=EXPIRE_MAKER Taker 订单 1: symbol=BTCUSDT side=SELL type=LIMIT quantity=1 price=20000 selfTradePreventionMode=EXPIRE_MAKER ``` **结果:** : 由于 STP,订单薄上的订单将会过期,taker 订单将继续在订单薄。 Maker 订单 1 ```json { "orderId": 292864710, "symbol": "BTCUSDT", "status": "FILLED", "clientOrderId": "testMaker1", "price": "20002", "avgPrice": "20002", "origQty": "1", "executedQty": "1", "cumQuote": "20002", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_MAKER", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` Maker 订单 2 ```json { "orderId": 292864711, "symbol": "BTCUSDT", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testMaker2", "price": "20001", "avgPrice": "0.0000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_MAKER", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` Taker 订单的响应 ```json { "orderId": 292864712, "symbol": "BTCUSDT", "status": "PARTIALLY_FILLED", "clientOrderId": "testTaker1", "price": "20000", "avgPrice": "20002", "origQty": "2", "executedQty": "1", "cumQuote": "20002", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "SELL", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_MAKER", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` **情况 B - 用户发送带有 `EXPIRE_TAKER` 的订单,该订单将与订单薄上已有的订单撮合。** ``` Maker 订单 1: symbol=BTCUSDT side=BUY type=LIMIT quantity=1 price=20002 selfTradePreventionMode=EXPIRE_MAKER Maker 订单 2: symbol=BTCUSDT side=BUY type=LIMIT quantity=1 price=20001 selfTradePreventionMode=EXPIRE_MAKER Taker 订单 1: symbol=BTCUSDT side=SELL type=LIMIT quantity=2 price=3 selfTradePreventionMode=EXPIRE_TAKER ``` **结果:** : 已经在订单薄上的订单将保留,而taker订单将过期。 Maker 订单 1 ```json { "orderId": 292864710, "symbol": "BTCUSDT", "status": "FILLED", "clientOrderId": "testMaker1", "price": "20002", "avgPrice": "0.0000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_MAKER", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` Maker 订单 2 ```json { "orderId": 292864711, "symbol": "BTCUSDT", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testMaker2", "price": "20001", "avgPrice": "0.0000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_MAKER", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` Taker 订单的状态 ```json { "orderId": 292864712, "symbol": "BTCUSDT", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testTaker1", "price": "20000", "avgPrice": "0.0000", "origQty": "3", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "SELL", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_TAKER", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` **情况 C - 用户发送带有 `EXPIRE_BOTH` 的订单,该订单将与订单薄上已有的订单撮合。** ``` Maker 订单: symbol=BTCUSDT side=BUY type=LIMIT quantity=1 price=20002 selfTradePreventionMode=EXPIRE_MAKER Taker 订单: symbol=BTCUSDT side=SELL type=LIMIT quantity=3 price=20000 selfTradePreventionMode=EXPIRE_BOTH ``` **结果:** 两个订单都将过期。 Maker 订单 ```json { "orderId": 292864710, "symbol": "BTCUSDT", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testMaker1", "price": "20002", "avgPrice": "0.0000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_MAKER", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` Taker 订单 ```json { "orderId": 292864712, "symbol": "BTCUSDT", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testTaker1", "price": "20000", "avgPrice": "0.0000", "origQty": "3", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "SELL", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_BOTH", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` **情况 D - 用户在订单薄上有一个带有 `EXPIRE_MAKER` 的订单,然后发送一个带有 `EXPIRE_TAKER` 的新订单,该订单将与订单薄上的订单撮合。** ``` Maker Order: symbol=BTCUSDT side=BUY type=LIMIT quantity=1 price=1 selfTradePreventionMode=EXPIRE_MAKER Taker Order: symbol=BTCUSDT side=SELL type=LIMIT quantity=1 price=1 selfTradePreventionMode=EXPIRE_TAKER ``` **结果:** 将使用 taker 订单的 STP 模式,因此 taker 订单将过期。 Maker 订单 ```json { "orderId": 292864710, "symbol": "BTCUSDT", "status": "NEW", "clientOrderId": "testMaker1", "price": "20002", "avgPrice": "0.0000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_MAKER", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` Taker 订单 ```json { "orderId": 292864712, "symbol": "BTCUSDT", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testTaker1", "price": "20000", "avgPrice": "0.0000", "origQty": "3", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "SELL", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_TAKER", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` **情况 E - 用户发送带有 `EXPIRE_MAKER` 的市价订单,该订单将与订单薄上已有的订单撮合。** ``` Maker 订单: symbol=ABCDEF side=BUY type=LIMIT quantity=1 price=1 selfTradePreventionMode=EXPIRE_MAKER Taker 订单: symbol=ABCDEF side=SELL type=MARKET quantity=3 selfTradePreventionMode=EXPIRE_MAKER ``` **结果:** 由于 STP,订单薄上的订单会过期,状态为 `EXPIRED_IN_MATCH`。由于订单薄上的流动性低,新订单也已过期但状态为 `EXPIRED`。 Maker 订单 ```json { "orderId": 292864710, "symbol": "BTCUSDT", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testMaker1", "price": "20002", "avgPrice": "0.0000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_MAKER", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` Taker 订单 ```json { "orderId": 292864712, "symbol": "BTCUSDT", "status": "EXPIRED", "clientOrderId": "testTaker1", "price": "20000", "avgPrice": "0.0000", "origQty": "3", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "SELL", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_MAKER", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` --- ## Document: /products/derivatives-trading-options/websocket-market-streams/Live-Subscribing-Unsubscribing-to-streams URL: /zh-CN/docs/products/derivatives-trading-options/websocket-market-streams/Live-Subscribing-Unsubscribing-to-streams # 实时订阅/取消数据流 - 以下数据可以通过websocket发送以实现订阅或取消订阅数据流。示例如下。 - 响应内容中的`id`是无符号整数,作为往来信息的唯一标识。 ## 订阅一个信息流 > **请求** ```json { "method": "SUBSCRIBE", "params": ["btc-210630-9000-p@ticker", "btc-210630-9000-p@depth"], "id": 1 } ``` > **响应** ```json { "result": null, "id": 1 } ``` ## 取消订阅一个信息流 > **请求** ```json { "method": "UNSUBSCRIBE", "params": ["btc-210630-9000-p@ticker"], "id": 312 } ``` > **响应** ```json { "result": null, "id": 312 } ``` ## 已订阅信息流 > **请求** ```json { "method": "LIST_SUBSCRIPTIONS", "id": 3 } ``` > **响应** ```json { "result": ["btc-210630-9000-p@ticker"], "id": 3 } ``` ## 设定属性 当前,唯一可以设置的属性是设置是否启用`combined`("组合")信息流。 当使用`/ws/`("原始信息流")进行连接时,combined属性设置为`false`,而使用 `/stream/`进行连接时则将属性设置为`true`。 > **响应** ```json { "result": null "id": 5 } ``` > **请求** ```json { "method": "SET_PROPERTY", "params": ["combined", true], "id": 5 } ``` ## 检索属性 > **请求** ```json { "method": "GET_PROPERTY", "params": ["combined"], "id": 2 } ``` > **响应** ```json { "result": true, // Indicates that combined is set to true. "id": 2 } ``` ## 错误信息 | 错误信息 | 描述 | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | | {"code": 0, "msg": "Unknown property"} | `SET_PROPERTY` 或 `GET_PROPERTY`中应用的参数无效 | | {"code": 1, "msg": "Invalid value type: expected Boolean"} | 仅接受`true`或`false` | | {"code": 2, "msg": "Invalid request: property name must be a string"} | 提供的属性名无效 | | {"code": 2, "msg": "Invalid request: request ID must be an unsigned integer"} | 参数`id`未提供或`id`值是无效类型 | | {"code": 2, "msg": "Invalid request: unknown variant %s, expected one of `SUBSCRIBE`, `UNSUBSCRIBE`, `LIST_SUBSCRIPTIONS`, `SET_PROPERTY`, `GET_PROPERTY` at line 1 column 28"} | 错字提醒,或提供的值不是预期类型 | | {"code": 2, "msg": "Invalid request: too many parameters"} | 数据中提供了不必要参数 | | {"code": 2, "msg": "Invalid request: property name must be a string"} | 未提供属性名 | | {"code": 2, "msg": "Invalid request: missing field `method` at line 1 column 73"} | 数据未提供`method` | | {"code":3,"msg":"Invalid JSON: expected value at line %s column %s"} | JSON 语法有误. | --- ## Document: /products/derivatives-trading-options/websocket-market-streams/How-to-manage-a-local-order-book-correctly URL: /zh-CN/docs/products/derivatives-trading-options/websocket-market-streams/How-to-manage-a-local-order-book-correctly # 如何正确在本地维护一个orderbook副本 1. 订阅 **wss://fstream.binance.com/public/stream?streams=btc-200630-9000-p@depth@100ms** 2. 开始缓存收到的更新。同一个价位,后收到的更新覆盖前面的。 3. 访问Rest接口 **https://eapi.binance.com/eapi/v1/depth?symbol=btc-200630-9000-p&limit=1000**获得一个1000档的深度快照 4. 将目前缓存到的信息中`u`< 步骤3中获取到的快照中的`lastUpdateId`的部分丢弃(丢弃更早的信息,已经过期)。 5. 将深度快照中的内容更新到本地orderbook副本中,并从websocket接收到的第一个`U` `<= ``lastUpdateId` **且** `u` >`= ``lastUpdateId` 的event开始继续更新本地副本。 - U = 来自 WebSocket 流的 firstUpdateId(第一个更新 ID)。 - u = 来自 WebSocket 流的 finalUpdateId(最后一个更新 ID)。 - lastUpdateId = 你从 REST 深度快照中获取的 更新 ID。 6. 每一个新event的`pu`应该等于上一个event的`u`,否则可能出现了丢包,请从step3重新进行初始化。 7. 每一个event中的挂单量代表这个价格目前的挂单量**绝对值**,而不是相对变化。 8. 如果某个价格对应的挂单量为0,表示该价位的挂单已经撤单或者被吃,应该移除这个价位。 --- ## Document: /products/derivatives-trading-options/websocket-market-streams/Connect URL: /zh-CN/docs/products/derivatives-trading-options/websocket-market-streams/Connect # 连接 - Base Url:**wss://fstream.binance.com/public/** or **wss://fstream.binance.com/market/** - 订阅单一stream格式为 **/ws/\** - 组合streams的URL格式为 **/stream?streams=\/\/\** - 连接样例: - `wss://fstream.binance.com/public/ws/btc-210630-9000-p@ticker` - `wss://fstream.binance.com/market/stream?streams=btc-210630-9000-p@markPriceoptionMarkPrice` - 订阅组合streams时,事件payload会以这样的格式封装 **{"stream":"\","data":\}** - 订阅stream的交易对需要**小写** - 每个链接有效期不超过24小时,请妥善处理断线重连。 - 服务端每5分钟会发送ping帧,客户端应当在15分钟内回复pong帧,否则服务端会主动断开链接。允许客户端发送不成对的pong帧(即客户端可以以高于15分钟每次的频率发送pong帧保持链接)。 - Websocket服务器每秒最多接受10个订阅消息。 - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅 **200** 个Streams。 --- ## Document: /products/derivatives-trading-options/faq/stp-faq URL: /zh-CN/docs/products/derivatives-trading-options/faq/stp-faq # 自我交易预防 (Self Trade Prevention - STP) 常见问题 ## 什么是 Self Trade Prevention - STP? 自我交易预防是指阻止订单与来自同一账户或者同一 `tradeGroupId` 账户的订单交易。 ## 什么是自我交易(self-trade)? 在以下任一情况下都可能发生自我交易: - 属于同一账户的订单之间交易。 - 属于相同 `tradeGroupId` 的账户的订单之间交易。 ## STP 触发时会发生什么? 如果订单会触发自我交易,系统将执行三种可能的模式: `EXPIRE_TAKER` - 此模式通过立即使吃单者(taker)的剩余数量过期来预防交易。 `EXPIRE_MAKER` - 此模式通过立即使潜在挂单者(maker)的剩余数量过期来预防交易。 `EXPIRE_BOTH` - 此模式通过立即同时使吃单和挂单者的剩余数量过期来预防交易。 STP 的发生取决于 **Taker 订单** 的 STP 模式。
因此,订单薄上的订单的 STP 模式不再有效果,并且将在所有未来的订单处理中被忽略。 ## 如何在订单上设置自我交易预防 ? 自我交易预防可以通过下单接口的参数`selfTradePreventionMode`设置,相关接口如下: - POST `/eapi/v1/order` - POST `/eapi/v1/batchOrders` ## 什么是交易组 Id(Trade Group Id)? 属于同一 `tradeGroupId` 的账户被视为同一交易组。相同交易组成员提交的订单有 STP 资格。 每个账户可以从 `GET /eapi/v1/accountConfig`(REST API)确认账户是否属于同一个 `tradeGroupId`。 如果该值为 `-1`,这表示账户未设置 `tradeGroupId`,因此 STP 只能发生在同一账户的订单之间。 用户可以通过子账户API管理页面将子账户分组到同一个tradeGroupId。 ## 如何知道有那些交易对支持 STP? 所有`GET /eapi/v1/exchangeInfo`中的交易对都支持`selfTradePreventionMode`。 ## 哪些订单类型支持 STP? 所有类型订单在Time in force(timeInForce)设置为GTC/ IOC/ GTD时支持STP。 当Time in force(timeInForce)为FOK 或 GTX时订单STP设置不生效。 ## 如何知道订单因为 STP 而过期? 订单的状态会是 `EXPIRED_IN_MATCH`. 在用户信息流推送 `ORDER_TRADE_UPDATE`,如果订单因为STP过期字段`X`会显示`EXPIRED_IN_MATCH` ```javascript { "e":"ORDER_TRADE_UPDATE", // Event Type "E":1568879465651, // Event Time "T":1568879465650, // Transaction Time "o":{ "s":"BTC-260228-70000-C", // Symbol "c":"TEST", // Client Order Id // special client order id: // starts with "autoclose-": liquidation order // "adl_autoclose": ADL auto close order // "settlement_autoclose-": settlement order for delisting or delivery "S":"SELL", // Side "o":"TRAILING_STOP_MARKET", // Order Type "f":"GTC", // Time in Force "q":"0.001", // Original Quantity "p":"0", // Original Price "ap":"0", // Average Price "sp":"7103.04", // Stop Price. Please ignore with TRAILING_STOP_MARKET order "x":"EXPIRED", // Execution Type "X":"EXPIRED_IN_MATCH", // Order Status "i":8886774, // Order Id "l":"0", // Order Last Filled Quantity "z":"0", // Order Filled Accumulated Quantity "L":"0", // Last Filled Price "N":"USDT", // Commission Asset, will not push if no commission "n":"0", // Commission, will not push if no commission "T":1568879465650, // Order Trade Time "t":0, // Trade Id "b":"0", // Bids Notional "a":"9.91", // Ask Notional "m":false, // Is this trade the maker side? "R":false, // Is this reduce only "wt":"CONTRACT_PRICE", // Stop Price Working Type "ot":"TRAILING_STOP_MARKET", // Original Order Type "ps":"LONG", // Position Side "cp":false, // If Close-All, pushed with conditional order "AP":"7476.89", // Activation Price, only pushed with TRAILING_STOP_MARKET order "cr":"5.0", // Callback Rate, only pushed with TRAILING_STOP_MARKET order "pP": false, // ignore "si": 0, // ignore "ss": 0, // ignore "rp":"0", // Realized Profit of the trade "V": "EXPIRE_MAKER", // selfTradePreventionMode "pm":"QUEUE", // price match type "gtd":1768879465650 // good till date } } ``` ## STP 的一些示例: 假设以下示例的所有订单都是在同一个账户下发送。 **情况 A - 用户发送带有 `EXPIRE_MAKER` 的订单,该订单将与订单薄上已有的订单撮合。** ``` Maker 订单 1: symbol=BTC-260228-70000-C side=BUY type=LIMIT quantity=1 price=51 selfTradePreventionMode=EXPIRE_MAKER Taker 订单 1: symbol=BTC-260228-70000-C side=SELL type=LIMIT quantity=2 price=50 selfTradePreventionMode=EXPIRE_MAKER ``` **结果** : 由于 STP,订单薄上的订单将会过期,taker 订单将继续在订单薄。 Maker 订单 ```json { "orderId": 4611875134427365378, "symbol": "BTC-260228-70000-C", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testMaker1", "price": "51", "avgPrice": "0.0000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_MAKER", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` Taker 订单的响应 ```json { "orderId": 4611875134427365379, "symbol": "BTC-260228-70000-C", "status": "FILLED", "clientOrderId": "testTaker1", "price": "50", "avgPrice": "50", "origQty": "2", "executedQty": "2", "cumQuote": "50", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "SELL", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_MAKER", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` **情况 B - 用户发送带有 `EXPIRE_TAKER` 的订单,该订单将与订单薄上已有的订单撮合。** ``` Maker 订单 1: symbol=BTC-260228-70000-C side=BUY type=LIMIT quantity=1 price=51 selfTradePreventionMode=EXPIRE_TAKER Taker 订单 1: symbol=BTC-260228-70000-C side=SELL type=LIMIT quantity=2 price=50 selfTradePreventionMode=EXPIRE_TAKER ``` **结果** : 已经在订单薄上的订单将保留,而taker订单将过期。 Maker 订单 ```json { "orderId": 4611875134427365378, "symbol": "BTC-260228-70000-C", "status": "NEW", "clientOrderId": "testMaker1", "price": "51", "avgPrice": "0.0000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_TAKER", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` Taker 订单的状态 ```json { "orderId": 4611875134427365379, "symbol": "BTC-260228-70000-C", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testTaker1", "price": "50", "avgPrice": "0.0000", "origQty": "2", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "SELL", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_TAKER", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` **情况 C - 用户发送带有 `EXPIRE_BOTH` 的订单,该订单将与订单薄上已有的订单撮合。** ``` Maker 订单: symbol=BTC-260228-70000-C side=BUY type=LIMIT quantity=1 price=51 selfTradePreventionMode=EXPIRE_BOTH Taker 订单: symbol=BTC-260228-70000-C side=SELL type=LIMIT quantity=3 price=50 selfTradePreventionMode=EXPIRE_BOTH ``` **结果** : 两个订单都将过期。 Maker 订单 ```json { "orderId": 4611875134427365378, "symbol": "BTC-260228-70000-C", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testMaker1", "price": "51", "avgPrice": "0.0000", "origQty": "1", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "BUY", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_BOTH", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` Taker 订单 ```json { "orderId": 4611875134427365379, "symbol": "BTC-260228-70000-C", "status": "EXPIRED_IN_MATCH", "clientOrderId": "testTaker1", "price": "50", "avgPrice": "0.0000", "origQty": "3", "executedQty": "0", "cumQuote": "0", "timeInForce": "GTC", "type": "LIMIT", "reduceOnly": false, "closePosition": false, "side": "SELL", "positionSide": "BOTH", "stopPrice": "0", "workingType": "CONTRACT_PRICE", "priceMatch": "NONE", "selfTradePreventionMode": "EXPIRE_BOTH", "goodTillDate": "null", "priceProtect": false, "origType": "LIMIT", "time": 1692849639460, "updateTime": 1692849639460 } ``` --- ## Document: /products/derivatives-trading-coin-futures/websocket-market-streams/Live-Subscribing-Unsubscribing-to-streams URL: /zh-CN/docs/products/derivatives-trading-coin-futures/websocket-market-streams/Live-Subscribing-Unsubscribing-to-streams # 实时订阅/取消数据流 - 以下数据可以通过websocket发送以实现订阅或取消订阅数据流。示例如下。 - 响应内容中的`id`是无符号整数,作为往来信息的唯一标识。 ## 订阅一个信息流 > **请求** ```json { "method": "SUBSCRIBE", "params": ["btcusd_200925@aggTrade", "btcusd_200925@depth"], "id": 1 } ``` > **响应** ```json { "result": null, "id": 1 } ``` ## 取消订阅一个信息流 > **请求** ```json { "method": "UNSUBSCRIBE", "params": ["btcusd_200925@depth"], "id": 312 } ``` > **响应** ```json { "result": null, "id": 312 } ``` ## 已订阅信息流 > **请求** ```json { "method": "LIST_SUBSCRIPTIONS", "id": 3 } ``` > **响应** ```json { "result": ["btcusd_200925@aggTrade"], "id": 3 } ``` ## 设定属性 当前,唯一可以设置的属性是设置是否启用`combined`("组合")信息流。 当使用`/ws/`("原始信息流")进行连接时,combined属性设置为`false`,而使用 `/stream/`进行连接时则将属性设置为`true`。 > **请求** ```json { "method": "SET_PROPERTY", "params": ["combined", true], "id": 5 } ``` > **响应** ```json { "result": null "id": 5 } ``` ## 检索属性 > **请求** ```json { "method": "GET_PROPERTY", "params": ["combined"], "id": 2 } ``` > **响应** ```json { "result": true, // Indicates that combined is set to true. "id": 2 } ``` --- ## Document: /products/derivatives-trading-coin-futures/websocket-market-streams/How-to-manage-a-local-order-book-correctly URL: /zh-CN/docs/products/derivatives-trading-coin-futures/websocket-market-streams/How-to-manage-a-local-order-book-correctly # 如何正确在本地维护一个orderbook副本 1. 订阅 **wss://dstream.binance.com/stream?streams=btcusd_200925@depth** 2. 开始缓存收到的更新。同一个价位,后收到的更新覆盖前面的。 3. 访问Rest接口 **https://dapi.binance.com/dapi/v1/depth?symbol=BTCUSD_200925&limit=1000**获得一个1000档的深度快照 4. 将目前缓存到的信息中`u`< 步骤3中获取到的快照中的`lastUpdateId`的部分丢弃(丢弃更早的信息,已经过期)。 5. 将深度快照中的内容更新到本地orderbook副本中,并从websocket接收到的第一个`U` `<= ``lastUpdateId` **且** `u` >`= ``lastUpdateId` 的event开始继续更新本地副本。 - U = 来自 WebSocket 流的 firstUpdateId(第一个更新 ID)。 - u = 来自 WebSocket 流的 finalUpdateId(最后一个更新 ID)。 - lastUpdateId = 你从 REST 深度快照中获取的 更新 ID。 6. 每一个新event的`pu`应该等于上一个event的`u`,否则可能出现了丢包,请从step3重新进行初始化。 7. 每一个event中的挂单量代表这个价格目前的挂单量**绝对值**,而不是相对变化。 8. 如果某个价格对应的挂单量为0,表示该价位的挂单已经撤单或者被吃,应该移除这个价位。 --- ## Document: /products/derivatives-trading-coin-futures/websocket-market-streams/Connect URL: /zh-CN/docs/products/derivatives-trading-coin-futures/websocket-market-streams/Connect # 市场数据连接 - 本篇所列出的所有wss接口,共有如下两种连接方式: - 连接方式: - Base Url:**wss://dstream.binance.com** - 订阅单一stream格式为 **/ws/\** - 组合streams的URL格式为 **/stream?streams=\/\/\** - 连接样例: - `wss://dstream.binance.com/ws/bnbusdt@aggTrade` - `wss://dstream.binance.com/stream?streams=bnbusdt@aggTrade/btcusdt@markPrice` - 订阅组合streams时,事件payload会以这样的格式封装 **{"stream":"\","data":\}** - stream名称中所有交易对均为**小写**。 - 每个链接有效期不超过24小时,请妥善处理断线重连。 - 服务端每3分钟会发送ping帧,客户端应当在10分钟内回复pong帧,否则服务端会主动断开链接。允许客户端发送不成对的pong帧(即客户端可以以高于10分钟每次的频率发送pong帧保持链接)。 - Websocket服务器每秒最多接受10个订阅消息。 - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅 **1024** 个Streams。 --- ## Document: /products/derivatives-trading-coin-futures/portfolio-margin-endpoints/General-Info URL: /zh-CN/docs/products/derivatives-trading-coin-futures/portfolio-margin-endpoints/General-Info # 经典统一账户接口 为了给币安合约用户提供更加优质的服务及提高用户的资金利用率,币安将推出经典统一账户计划。该计划将以合约钱包、现货杠杆钱包的总资产作为保证金来计算。关于经典统一帐户:币安经典统一帐户计划是一项跨资产保证金计划,支持超过 200 种有效的加密资产。 U 本位合约、币本位合约以及杠杆钱包中支持的加密资产和头寸将作为有效的联合抵押品,以确定经典统一账户的权益、保证金余额和维持保证金要求。 FAQ: [币安合约经典统一账户总览](https://www.binance.com/cn/support/faq/5054378212d240cca17ecd6006c11f23) 仅对特定用户开放此功能,详情:[加入经典统一账户计划](https://www.binance.com/cn/support/faq/a7834b9bc03140728583a90bcb469144) --- ## Document: /products/connect-prime/webhook/webhook URL: /zh-CN/docs/products/connect-prime/webhook/webhook # Webhook Whenever a key event (currently only "order status change") occurs, Binance Connect will send a webhook message, and the partner (client) can receive this message at the webhook callback url and react accordingly, such as updating order data and frontend UI. ### Request Headers | **Field** | **Type** | **Remarks** | | ---------------------- | --------- | -------------------------------------------------------- | | X-BN-Connect-Timestamp | timestamp | timestamp | | X-BN-Connect-Signature | string | SHA256withRSA(**requestBody** + **X-Connect-Timestamp**) | | X-BN-Connect-For | string | Same with your client id (X-Tesla-ClientId) | ### Request Body | Field | Type | Remarks | | ---------------- | --------- | ------------------------------------------------ | | webhookEventType | string | fixed value: prime_order_event | | orderId | string | Binance order ID | | clientOrderId | string | Client side order ID | | direction | string | BUY or SELL | | fiatCurrency | string | Fiat currency | | cryptoCurrency | string | Crypto currency | | fiatAmount | decimal | Fiat amount | | cryptoAmount | decimal | Crypto Amount | | price | decimal | Price. 1 crypto currency = {price} fiat currency | | status | string | FILLED/FAILED | | createTime | timestamp | Order creation time (UTC) | | settleTime | timestamp | Settlement time (UTC) | ### Response Body - HTTP status code is 200 - Response body is in JSON format. | **Field** | **Type** | **Remarks** | | ------------- | -------- | ----------------------------------------------------------- | | returnCode | string | SUCCESS or other code you wish to return to Binance Connect | | returnMessage | string | the message you wish to return to Binance Connect | ### How signature works The encryption/decryption and verification process of webhook is exactly the opposite/mirrored of API request process. The sender and receiver of the two are opposite, but they are both processes that signed by the sender with a private key and verified by the receiver with a public key. For API requests, the partner (client) generates a pair of keys. The private key is kept securely and privately by the partner (client). Then the partner (client) uses the private key to sign when initiating API requests. The public key is shared to Bianance Connect, with which Binance will verify the signature of the API request to ensure that the request is indeed initiated by the partner (client). For webhook, it's an opposite/mirrored process. Binance Connect generates a pair of keys. The private key is kept securely and privately by Binance Connect. Then Binance Connect uses the private key to sign when initiating the webhook message. The public key is shared to the partner (client), with which the partner (client) can verify the signature of the webhook message to ensure that the message is indeed initiated by Binance. #### The webhook signature flow is as follows: ![signature-Webhook.png](../images/signature-Webhook-prime.png) ### Verify signature As mentioned above, Binance Connect initiates a webhook request to the webhook callback url provided by the partner ( client). And the partner (client) should verify the identity of the request initiator based on the public key provided by Binance Connect. The example code below shows how to verify signature with public key: ```java public static boolean verify(String srcData, PublicKey publicKey, String sign) throws Exception { Signature signature = Signature.getInstance("SHA256withRSA"); signature.initVerify(publicKey); signature.update(srcData.getBytes()); return signature.verify(Base64.decodeBase64(sign.getBytes())); } ``` # ### Example Request Body: ```json { "webhookEventType": "prime_order_event", "orderId": "1234567890", "clientOrderId": "myOrder001", "direction": "BUY", "fiatCurrency": "EUR", "cryptoCurrency": "BTC", "fiatAmount": 100, "cryptoAmount": 0.00102181, "price": 97849.27, "status": "FILLED", "createTime": 1692951399, "settleTime": 1692954999 } ``` --- ## Document: /products/connect-prime/open-apis/9.get-balance URL: /zh-CN/docs/products/connect-prime/open-apis/9.get-balance # Get Balance Please refer to [user-assets](../../wallet/asset/user-assets.md) --- ## Document: /products/connect-prime/open-apis/8.get-transaction-list URL: /zh-CN/docs/products/connect-prime/open-apis/8.get-transaction-list # Get Transaction List ``` POST /papi/v1/ramp/connect/prime/transactions ``` ### Request Body | Field | Type | Mandatory | Remarks | | --------- | --------- | --------- | --------------------------------------- | | userId | string | Yes | Customer’s Binance sub-account ID | | startTime | timestamp | Yes | Start timestamp | | endTime | timestamp | Yes | End timestamp | | direction | string | No | BUY or SELL | | page | int | No | Page number. Default: 1 | | rows | int | No | Records per page. Default: 10. Max: 100 | #### Example ```json { "userId": "54321123456", "startTime": 1756113110, "endTime": 1756545215, "direction": "BUY", "page": 1, "rows": 10 } ``` ```shell curl -X POST https://{domain}/papi/v1/ramp/connect/prime/transactions \ -H 'Content-Type: application/json' \ -H 'X-Tesla-ClientId: {your client id}' \ -H 'X-Tesla-SignAccessToken: {your access token}' \ -H 'X-Tesla-Timestamp: {now}' \ -H 'X-Tesla-Signature: {signature}' \ -d '{"userId":"{testUserId}","startTime":1762313981786,"endTime":1762400381786,"rows":20,"page":1}' ``` ### Response Body | Field | Type | Remarks | | ------- | ------------ | ---------------------------------------- | | total | int | Total number of records across all pages | | records | object array | records | | page | int | Current page number. | | rows | int | Records per page. | #### Record object | Field | Type | Remarks | | -------------- | --------- | ----------------------------------------------- | | orderId | string | Binance order ID | | clientOrderId | string | Client side order ID | | direction | string | BUY or SELL | | fiatCurrency | string | Fiat currency | | cryptoCurrency | string | Crypto currency | | fiatAmount | decimal | Fiat amount | | cryptoAmount | decimal | Crypto Amount | | price | decimal | Price. 1 crypto currency= {price} fiat currency | | status | string | PROCESSING / FILLED / FAILED | | spreadAmount | string | Revenue from Spread (in Fiat Currency) | | createTime | timestamp | Order creation time (UTC) | | settleTime | timestamp | Settlement time (UTC) | #### Example ```json { "total": 100, "page": 1, "rows": 10, "records": [ { "orderId": "1234567890", "clientOrderId": "myOrder001", "direction": "BUY", "fiatCurrency": "EUR", "cryptoCurrency": "BTC", "fiatAmount": 100, "cryptoAmount": 0.00102181, "price": 97849.27, "status": "FILLED", "spreadAmount": "0.99", "createTime": "1692951399", "settleTime": "1692954999" } ] } ``` --- ## Document: /products/connect-prime/open-apis/7.get-single-transaction URL: /zh-CN/docs/products/connect-prime/open-apis/7.get-single-transaction # Get Single Transaction ``` POST /papi/v1/ramp/connect/prime/transaction ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | --------- | -------- | ------------- | ---------------- | | orderId | string | Yes | Binance order ID | #### Example ```json { "orderId": "1234567890" } ``` ```shell curl -X POST https://{domain}/papi/v1/ramp/connect/prime/transaction \ -H 'Content-Type: application/json' \ -H 'X-Tesla-ClientId: {your client id}' \ -H 'X-Tesla-SignAccessToken: {your access token}' \ -H 'X-Tesla-Timestamp: {now}' \ -H 'X-Tesla-Signature: {signature}' \ -d '{"orderId":""}' ``` ### Response Body | **Field** | **Type** | **Remarks** | | -------------- | --------- | ----------------------------------------------- | | orderId | string | Binance order ID | | clientOrderId | string | Client side order ID | | direction | string | BUY or SELL | | fiatCurrency | string | Fiat currency | | cryptoCurrency | string | Crypto currency | | fiatAmount | decimal | Fiat amount | | cryptoAmount | decimal | Crypto Amount | | price | decimal | Price. 1 crypto currency= {price} fiat currency | | status | string | PROCESSING / FILLED / FAILED | | spreadAmount | string | Revenue from Spread (in Fiat Currency) | | createTime | timestamp | Order creation time (UTC) | | settleTime | timestamp | Settlement time (UTC) | #### Example ```json { "orderId": "1234567890", "clientOrderId": "myOrder001", "direction": "BUY", "fiatCurrency": "EUR", "cryptoCurrency": "BTC", "fiatAmount": 100, "cryptoAmount": 0.00102181, "price": 97849.27, "status": "FILLED", "spreadAmount": "0.99", "createTime": "1692951399", "settleTime": "1692954999" } ``` --- ## Document: /products/connect-prime/open-apis/6.execute-quote URL: /zh-CN/docs/products/connect-prime/open-apis/6.execute-quote # Execute Quote ``` POST /papi/v1/ramp/connect/prime/quote/execute ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | ------------- | -------- | ------------- | ----------------------------------- | | quoteId | string | Yes | Quote ID | | clientOrderId | string | Yes | Client side order ID. Max length:50 | #### Example ```json { "quoteId": "8Bj35OZEYupTIwdaxQW7vybKNH0J1Cic", "clientOrderId": "OLCingeRI6mT4z9SQqVaABDwK5t3fcFU" } ``` ```shell curl -X POST https://{domain}/papi/v1/ramp/connect/prime/quote/execute \ -H 'Content-Type: application/json' \ -H 'X-Tesla-ClientId: {your client id}' \ -H 'X-Tesla-SignAccessToken: {your access token}' \ -H 'X-Tesla-Timestamp: {now}' \ -H 'X-Tesla-Signature: {signature}' \ -d '{"quoteId":"","clientOrderId":"496334425271"}' ``` ### Response Body | **Field** | **Type** | **Remarks** | | --------- | -------- | ---------------------------- | | orderId | string | Binance order ID | | status | string | PROCESSING / FILLED / FAILED | #### Example ```json { "orderId": "lhJ0uBwFPcCkbxnypoqNzUvri1e8jatT", "status": "PROCESSING" } ``` --- ## Document: /products/connect-prime/open-apis/5.get-quote URL: /zh-CN/docs/products/connect-prime/open-apis/5.get-quote # Get Quote ``` POST /papi/v1/ramp/connect/prime/quote ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | -------------- | -------- | ------------- | --------------------------------------------------------------------------------- | | userId | string | Yes | Customer’s Binance sub-account ID | | fiatCurrency | string | Yes | fiat currency | | cryptoCurrency | string | Yes | crypto currency | | direction | string | Yes | BUY or SELL | | amount | decimal | Yes | Requested amount. | | amountType | int | Yes | Specify whether the total amount is in fiat:1 or crypto:2 | | customSpread | decimal | Yes | Specify the custom spread value. For example, 0.01 means a 1% spread (0.01 = 1%). | #### Example ```json { "userId": "54321123456", "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "direction": "BUY", "amount": 100, "amountType": 1, "customSpread": 0.01 } ``` ```shell curl -X POST https://{domain}/papi/v1/ramp/connect/prime/quote \ -H 'Content-Type: application/json' \ -H 'X-Tesla-ClientId: {your client id}' \ -H 'X-Tesla-SignAccessToken: {your access token}' \ -H 'X-Tesla-Timestamp: {now}' \ -H 'X-Tesla-Signature: {signature}' \ -d '{"userId":"{testUserId}","fiatCurrency":"EUR","cryptoCurrency":"BNB","direction":"BUY","amount":10,"amountType":1,"customSpread":0.01}' ``` ### Response Body | **Field** | **Type** | **Remarks** | | ------------ | --------- | ----------------------------------------------- | | quoteId | string | Quote ID | | totalAmount | string | total amount | | quotePrice | string | Price. 1 crypto currency= {price} fiat currency | | expiredAt | timestamp | Expired at millisecond timestamp | | spreadAmount | string | Revenue from Spread (in Fiat Currency) | #### Example ```json { "quoteId": "e064b9eacded478192c45110117926aaasdmladsoi", "totalAmount": "114.70018989", "quotePrice": "0.865734", "expiredAt": 1756179222140, "spreadAmount": "0.99" } ``` --- ## Document: /products/connect-prime/open-apis/4.get-fiat-crypto-amount-limit URL: /zh-CN/docs/products/connect-prime/open-apis/4.get-fiat-crypto-amount-limit # Get Fiat and Crypto Amount Limit ``` POST /papi/v1/ramp/connect/prime/fiat-crypto-amount-limit ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | -------------- | -------- | ------------- | --------------------------------------------------------------------------------- | | userId | string | Yes | Customer's Binance sub-account ID | | fiatCurrency | string | Yes | fiat currency | | cryptoCurrency | string | Yes | crypto currency | | direction | string | Yes | BUY or SELL | | amount | decimal | Yes | Requested amount. | | amountType | int | Yes | Specify whether the total amount is in fiat:1 or crypto:2 | | customSpread | decimal | Yes | Specify the custom spread value. For example, 0.01 means a 1% spread (0.01 = 1%). | #### Example ```json { "userId": "54321123456", "fiatCurrency": "EUR", "cryptoCurrency": "BTC", "direction": "BUY", "amount": 100, "amountType": 1, "customSpread": 0.01 } ``` ```shell curl -X POST https://{domain}/papi/v1/ramp/connect/prime/fiat-crypto-amount-limit \ -H 'Content-Type: application/json' \ -H 'X-Tesla-ClientId: {your client id}' \ -H 'X-Tesla-SignAccessToken: {your access token}' \ -H 'X-Tesla-Timestamp: {now}' \ -H 'X-Tesla-Signature: {signature}' \ -d '{"userId":"{testUserId}","fiatCurrency":"EUR","cryptoCurrency":"BNB","direction":"BUY","amount":10,"amountType":1,"customSpread":0.01}' ``` ### Response Body | **Field** | **Type** | **Remarks** | | -------------- | -------- | ----------------------- | | fiatMinLimit | decimal | fiat min amount limit | | fiatMaxLimit | decimal | fiat max amount limit | | cryptoMinLimit | decimal | crypto min amount limit | | cryptoMaxLimit | decimal | crypto max amount limit | #### Example ```json { "fiatMinLimit": "10", "fiatMaxLimit": "10000000", "cryptoMinLimit": "0.00448887", "cryptoMaxLimit": "4488.87147336" } ``` --- ## Document: /products/connect-prime/open-apis/3.get-trading-pair URL: /zh-CN/docs/products/connect-prime/open-apis/3.get-trading-pair # Get Trading Pair ``` POST /papi/v1/ramp/connect/prime/trading-pair ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | -------------- | -------- | ------------- | -------------------------------------- | | userId | string | Yes | Customer’s Binance sub-account ID | | fiatCurrency | string | Yes (BUY) | For Buy, must fill-in fiat currency | | cryptoCurrency | string | Yes (SELL) | For Sell, must fill-in crypto currency | | direction | string | Yes | BUY or SELL | #### Example For buy flow ```json { "userId": "54321123456", "fiatCurrency": "USD", "direction": "BUY" } ``` ```shell curl -X POST https://{domain}/papi/v1/ramp/connect/prime/trading-pair \ -H 'Content-Type: application/json' \ -H 'X-Tesla-ClientId: {your client id}' \ -H 'X-Tesla-SignAccessToken: {your access token}' \ -H 'X-Tesla-Timestamp: {now}' \ -H 'X-Tesla-Signature: {signature}' \ -d '{"userId":"{testUserId}","fiatCurrency":"EUR","direction":"BUY"}' ``` For sell flow ```json { "userId": "54321123456", "cryptoCurrency": "BTC", "direction": "SELL" } ``` ```shell curl -X POST https://{domain}/papi/v1/ramp/connect/prime/trading-pair \ -H 'Content-Type: application/json' \ -H 'X-Tesla-ClientId: {your client id}' \ -H 'X-Tesla-SignAccessToken: {your access token}' \ -H 'X-Tesla-Timestamp: {now}' \ -H 'X-Tesla-Signature: {signature}' \ -d '{"userId":"{testUserId}","cryptoCurrency":"BTC","direction":"SELL"}' ``` ### Response Body | **Field** | **Type** | **Remarks** | | -------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | fiatCurrency | string | fiat currency | | cryptoCurrency | string | crypto currency | | precision | int | The precision of the cryptocurrency applies if the direction is BUY, and the precision of the fiat currency applies if the direction is SELL. | #### Example ```json [ { "fiatCurrency": "EUR", "cryptoCurrency": "BNB", "precision": 8 }, { "fiatCurrency": "EUR", "cryptoCurrency": "BTC", "precision": 8 }, { "fiatCurrency": "EUR", "cryptoCurrency": "ETH", "precision": 8 } ] ``` --- ## Document: /products/connect-prime/open-apis/2.get-crypto-list-for-sell URL: /zh-CN/docs/products/connect-prime/open-apis/2.get-crypto-list-for-sell # Get Crypto List for Sell ``` POST /papi/v1/ramp/connect/prime/sell/crypto-list ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | --------- | -------- | ------------- | --------------------------------- | | userId | string | Yes | Customer’s Binance sub-account ID | #### Example ```json { "userId": "54321123456" } ``` ```shell curl -X POST https://{domain}/papi/v1/ramp/connect/prime/sell/crypto-list \ -H 'Content-Type: application/json' \ -H 'X-Tesla-ClientId: {your client id}' \ -H 'X-Tesla-SignAccessToken: {your access token}' \ -H 'X-Tesla-Timestamp: {now}' \ -H 'X-Tesla-Signature: {signature}' \ -d '{"userId":"{testUserId}"}' ``` ### Response Body | **Field** | **Type** | **Remarks** | | ----------------- | ------------ | -------------------------------- | | cryptoCurrencies | object array | crypto currency list | | └─ cryptoCurrency | string | crypto currency code | | └─ precision | int | the precision of crypto currency | #### Example ```json { "cryptoCurrencies": [ { "cryptoCurrency": "BTC", "precision": 8 }, { "cryptoCurrency": "ETH", "precision": 8 }, { "cryptoCurrency": "BNB", "precision": 8 }, { "cryptoCurrency": "USDC", "precision": 6 } ] } ``` --- ## Document: /products/connect-prime/open-apis/12.get-discover-price URL: /zh-CN/docs/products/connect-prime/open-apis/12.get-discover-price # Get Discover Price ``` POST /papi/v1/ramp/connect/prime/info/discover ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | ------------ | -------- | ------------- | ------------------------------------ | | fiatCurrency | string | Yes | Fiat currency code, support AED only | #### Example ```json { "fiatCurrency": "AED" } ``` ```shell curl -X POST https://{domain}/papi/v1/ramp/connect/prime/info/discover \ -H 'Content-Type: application/json' \ -H 'X-Tesla-ClientId: {your client id}' \ -H 'X-Tesla-SignAccessToken: {your access token}' \ -H 'X-Tesla-Timestamp: {now}' \ -H 'X-Tesla-Signature: {signature}' \ -d '{"fiatCurrency":"AED"}' ``` ### Response Body | **Field** | **Type** | **Remarks** | | --------------------------------- | -------- | ------------------------------------------------ | | cryptoCurrencies | array | Array of cryptocurrency data | | cryptoCurrencies[].cryptoCurrency | string | Cryptocurrency code, e.g., BTC, ETH | | cryptoCurrencies[].fiatCurrency | string | Fiat currency code, e.g., AED | | cryptoCurrencies[].quotation | decimal | Quotation price in the specified fiat currency | | cryptoCurrencies[].changes | decimal | 24-hour change percentage (positive or negative) | #### Example ```json { "cryptoCurrencies": [ { "cryptoCurrency": "BTC", "fiatCurrency": "AED", "quotation": 16609.58, "changes": -1.56 }, { "cryptoCurrency": "ETH", "fiatCurrency": "AED", "quotation": 0.9973, "changes": 0.01 }, { "cryptoCurrency": "SOL", "fiatCurrency": "AED", "quotation": 0.055, "changes": -4.81 }, { "cryptoCurrency": "USDT", "fiatCurrency": "AED", "quotation": 0.000051, "changes": -5.41 }, { "cryptoCurrency": "USDC", "fiatCurrency": "AED", "quotation": 1.1, "changes": -4.81 } ] } ``` ### Cache Policy The API response is cached for 10 seconds to improve performance and reduce server load. --- ## Document: /products/connect-prime/open-apis/11.get-kline-data URL: /zh-CN/docs/products/connect-prime/open-apis/11.get-kline-data # Get Kline Data ``` POST /papi/v1/ramp/connect/prime/info/klines ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | -------------- | -------- | ------------- | -------------------------------------------------- | | cryptoCurrency | string | Yes | Cryptocurrency trading pair symbol, e.g., BTC, ETH | | interval | string | Yes | Kline interval (see supported intervals below) | | startTime | long | Yes | Start time in milliseconds (UTC) | | endTime | long | Yes | End time in milliseconds (UTC) | #### Supported Kline Intervals | **Interval** | **Value** | | ------------ | --------- | | 3 minutes | 3m | | 1 hour | 1h | | 1 day | 1d | #### Example ```json { "cryptoCurrency": "BTC", "interval": "1h", "startTime": 1704067200000, "endTime": 1704153600000 } ``` ```shell curl -X POST https://{domain}/papi/v1/ramp/connect/prime/info/klines \ -H 'Content-Type: application/json' \ -H 'X-Tesla-ClientId: {your client id}' \ -H 'X-Tesla-SignAccessToken: {your access token}' \ -H 'X-Tesla-Timestamp: {now}' \ -H 'X-Tesla-Signature: {signature}' \ -d '{"cryptoCurrency":"BTC","interval":"1h","startTime":1704067200000,"endTime":1704153600000}' ``` ### Response Body The response is an array of kline data. Each kline is represented as an array of values: | **Index** | **Type** | **Remarks** | | --------- | -------- | ------------------------------------ | | 0 | long | Kline open time in milliseconds | | 1 | string | Opening price | | 2 | string | Highest price during the interval | | 3 | string | Lowest price during the interval | | 4 | string | Closing price | | 5 | string | Trading volume (base asset) | | 6 | long | Kline close time in milliseconds | | 7 | string | Trading volume (quote asset) | | 8 | int | Number of trades during the interval | | 9 | string | Taker buy volume (base asset) | | 10 | string | Taker buy volume (quote asset) | | 11 | string | Unused field, can be ignored | #### Example ```json [ [1704067200000, "42500.00", "42800.50", "42300.00", "42650.25", "1234.56789", 1704070799999, "52456789.12", 8456, "617.28394", "26228394.56", "0"], [1704070800000, "42650.25", "42900.00", "42550.00", "42800.00", "987.65432", 1704074399999, "42123456.78", 6789, "493.82716", "21061728.39", "0"] ] ``` ### Notes - `startTime` and `endTime` are required and must be provided in milliseconds (UTC). - Interval values are case-sensitive. - Klines are uniquely identified by their open time. --- ## Document: /products/connect-prime/open-apis/10.get-symbol-detail URL: /zh-CN/docs/products/connect-prime/open-apis/10.get-symbol-detail # Get Symbol Detail ``` POST /papi/v1/ramp/connect/prime/info/symbol-detail ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | -------------- | -------- | ------------- | ---------------------------------------- | | cryptoCurrency | string | Yes | Cryptocurrency code, e.g., BTC, ETH, SOL | #### Example ```json { "cryptoCurrency": "BTC" } ``` ```shell curl -X POST https://{domain}/papi/v1/ramp/connect/prime/info/symbol-detail \ -H 'Content-Type: application/json' \ -H 'X-Tesla-ClientId: {your client id}' \ -H 'X-Tesla-SignAccessToken: {your access token}' \ -H 'X-Tesla-Timestamp: {now}' \ -H 'X-Tesla-Signature: {signature}' \ -d '{"cryptoCurrency":"BTC"}' ``` ### Response Body | **Field** | **Type** | **Remarks** | | ----------------- | --------- | ----------------------------------------- | | symbol | string | Cryptocurrency code, e.g., BTC, ETH | | marketCap | decimal | Total market capitalization in USD | | volume | decimal | 24-hour trading volume in USD | | rank | integer | Market ranking by market cap | | circulatingSupply | decimal | Current circulating supply | | maxSupply | long | Maximum supply limit (null if infinite) | | totalSupply | long | Total supply including locked tokens | | issueDate | timestamp | Token issuance date (ISO 8601 format) | | website | string | Official website URL | | whitePaperUrl | string | Whitepaper URL | | dominance | decimal | Market dominance percentage | | description | string | Cryptocurrency description (English only) | #### Example ```json { "symbol": "BTC", "marketCap": 325678900000.5, "volume": 28456789000.25, "rank": 1, "circulatingSupply": 19500000.0, "maxSupply": 21000000, "totalSupply": 21000000, "issueDate": null, "website": "https://bitcoin.org", "whitePaperUrl": "https://bitcoin.org/bitcoin.pdf", "dominance": 45.8, "description": "Bitcoin is a decentralized digital currency, without a central bank or single administrator, that can be sent from user to user on the peer-to-peer bitcoin network without the need for intermediaries." } ``` ### Cache Policy The API response is cached for 1 day and updates daily. --- ## Document: /products/connect-prime/open-apis/1.get-fiat-list-for-buy URL: /zh-CN/docs/products/connect-prime/open-apis/1.get-fiat-list-for-buy # Get Fiat List for Buy ``` POST /papi/v1/ramp/connect/prime/buy/fiat-list ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | --------- | -------- | ------------- | --------------------------------- | | userId | string | Yes | Customer’s Binance sub-account ID | #### Example ```json { "userId": "54321123456" } ``` ```shell curl -X POST https://{domain}/papi/v1/ramp/connect/prime/buy/fiat-list \ -H 'Content-Type: application/json' \ -H 'X-Tesla-ClientId: {your client id}' \ -H 'X-Tesla-SignAccessToken: {your access token}' \ -H 'X-Tesla-Timestamp: {now}' \ -H 'X-Tesla-Signature: {signature}' \ -d '{"userId":"{testUserId}"}' ``` ### Response Body | **Field** | **Type** | **Remarks** | | -------------- | ------------ | ------------------------------ | | fiatCurrencies | object array | fiat currency list | | └─ currency | string | fiat currency code | | └─ precision | int | the precision of fiat currency | #### Example ```json { "fiatCurrencies": [ { "currency": "AUD", "precision": 2 }, { "currency": "USD", "precision": 2 }, { "currency": "EUR", "precision": 2 } ] } ``` --- ## Document: /products/connect-prime/basics/9.typical-sell-flow URL: /zh-CN/docs/products/connect-prime/basics/9.typical-sell-flow # Typical Sell Flow ## Overview This document describes the standard cryptocurrency sell flow using Binance Connect Prime service. The sequence diagram below illustrates the interaction between partner systems and Binance Connect Prime Open APIs throughout the sell process. ## Participants - **User (u)**: End user selling cryptocurrency - **Merchant (m)**: Partner's system/application - **Connect Prime (c)**: Binance Connect Prime service - **Binance Asset SAPI (a)**: Binance Asset Service API for balance management ## Flow Steps ### 1. Get Crypto List for Sell - User initiates the sell flow - Merchant forwards the request to Connect Prime - Connect Prime returns the list of supported cryptocurrencies for selling - Merchant returns/displays the crypto list to the user ### 2. Get User's Crypto Balance - The merchant queries Binance Asset SAPI for the user's balance - Binance Asset SAPI returns balance details - The merchant displays the balance to the user ### 3. Cryptocurrency Selection - The system sets the default cryptocurrency by user's crypto balance or default option - The user selects a cryptocurrency from the available list ### 4. Get Trading Pair Info - The user/merchant requests trading pair information - The merchant requests supported trading pairs from Connect Prime - Connect Prime returns trading pair information - The merchant returns/displays the trading pair info to the user ### 5. Display Available Fiat Currencies - The system displays the available fiat currencies - The user selects the target fiat currency to receive ### 6. Get Fiat and Crypto Amount Limits (optional) - The merchant requests fiat and crypto amount limits from Connect Prime - Connect Prime returns the limits - The merchant side can validate the user's input amount before requesting a quote and displaying valid range to the user - you can skip this step if not needed and quote API will handle the validation ### 7. Get Quote - The user enters the sell amount - The merchant requests a real-time quote from Connect Prime - Connect Prime returns quote details - The merchant displays the quote information to the user ### 8. Execute Quote - The user confirms and proceeds - The merchant sends an execute quote request to Connect Prime - Connect Prime returns an order ID; the order is created ### 9. Transaction Status Monitoring - System enters a polling loop to monitor transaction status - Merchant continuously queries Connect Prime for transaction details - Connect Prime returns current transaction status - Status updates are relayed back to the user - Process continues until transaction is completed - Connect Prime sends webhook notifications to Merchant for status updates ### 10. Transaction Completion - Once the sell transaction is completed, Connect Prime will invoke [merchant side's transfer API](10.merchant-side-API-requirements.md#transfer-api) to transfer the fiat amount to the user's account - Refer to [Merchant-side API Requirements](10.merchant-side-API-requirements.md) for more details ### Sequence Diagram ![open-api-sell.png](../images/open-api-sell.png) --- ## Document: /products/connect-prime/basics/8.typical-buy-flow URL: /zh-CN/docs/products/connect-prime/basics/8.typical-buy-flow # Typical Buy Flow ## Overview This document describes the standard cryptocurrency purchase flow using Binance Connect Prime service. The sequence diagram below illustrates the interaction between partner systems and Binance Connect Prime Open APIs throughout the purchase process. ## Participants - **User (u)**: End user purchasing cryptocurrency - **Merchant (m)**: Partner's system/application - **Connect Prime (c)**: Binance Connect Prime service ## Flow Steps ### 1. Get Fiat List for Buy - User initiates the buy flow - Merchant forwards the request to Connect Prime - Connect Prime returns available fiat currencies for buy - Merchant returns the fiat list to the user ### 2. Fiat Currency Selection - System displays the available fiat list and sets the default fiat currency - User selects their preferred fiat currency from the available list ### 3. Get Trading Pair Info - User/Merchant requests available trading pairs - Merchant queries Connect Prime for supported cryptocurrency trading pairs - Connect Prime returns trading pair info - Merchant returns trading pair info to the user ### 4. Display Available Cryptocurrencies - System displays the available cryptocurrencies to the user - User selects their desired cryptocurrency ### 5. Get Fiat and Crypto Amount Limits (optional) - Merchant requests fiat and crypto amount limits from Connect Prime - Connect Prime returns limits - The merchant side can validate the user's input amount before requesting a quote and displaying valid range to the user - you can skip this step if not needed and quote API will handle the validation ### 6. Get Quote - User inputs the buy amount - Merchant requests real-time quote from Connect Prime - Connect Prime returns quote details - Merchant displays quote information to the user ### 7. Transfer Fiat to Binance's Account - User confirms and decides to proceed with the purchase - Merchant transfers the user's fiat to Binance's designated fiat account on the merchant side - This is a merchant-internal operation — no Connect Prime API call is involved - The fiat transfer must be completed before calling Execute Quote ### 8. Execute Quote - Merchant sends execute quote request to Connect Prime - Connect Prime processes the request and returns an order ID - During the process, Connect Prime will invoke [merchant's check transaction API](10.merchant-side-API-requirements.md#check-merchant-side-transaction-status-api) to verify the fiat transfer in step (7) has been received - If verification fails, Connect Prime will return an error and the order will not be created. Then Connect Prime will invoke [merchant's refund API](10.merchant-side-API-requirements.md#refund-api-buy) to refund the user. - Refer to [Merchant-side API Requirements](10.merchant-side-API-requirements.md) for more details - Order is officially created in the system ### 9. Transaction Status Monitoring - System enters a polling loop to monitor transaction status - Merchant continuously queries Connect Prime for transaction details - Connect Prime returns current transaction status - Status updates are relayed back to the user - Process continues until transaction is completed - Connect Prime sends webhook notifications to Merchant for status updates ### Sequence Diagram ![open-api-buy.png](../images/open-api-buy.png) --- ## Document: /products/connect-prime/basics/7.order-status URL: /zh-CN/docs/products/connect-prime/basics/7.order-status # Order status | **Code** | **Type** | **Description** | **Remarks** | | -------- | ---------- | -------------------------------------------------------------------------- | ----------- | | 1 | PROCESSING | The order is being processed and the transaction is ongoing. | | | 20 | FILLED | The transaction has been successfully completed. This is a final state. | | | 99 | FAILED | The transaction has failed and the order is closed. This is a final state. | | --- ## Document: /products/connect-prime/basics/6.apply-developer-account URL: /zh-CN/docs/products/connect-prime/basics/6.apply-developer-account # How to apply partner developer account If you are a partner (client) who wants to integrate Binance Connect Prime’s Open API. Please contact Binance Connect team and provide the following items: - [Public key](3.request-signing.md) for API requests (private key kept by the partner/client safely); - IP addresses used to config whitelist; - Webhook callback url; Once Binance Connect receives these items and completes the configuration, Binance Connect will provide the following items to the partner (client): - Client id; - Sign access token; - Public key and partner code for webhook (private key kept by Binance Connect safely); Then the partner (client) will be able to call all Open APIs. > \*_Regarding different environments, please refer to > “[Environments and API base URLs](4.base-urls.md)”. It's recommended to start with the QA > environment first._ --- ## Document: /products/connect-prime/basics/5.error-code URL: /zh-CN/docs/products/connect-prime/basics/5.error-code # Error code | **Code** | **Type** | **Message** | | -------- | --------------------------- | ------------------------------------------------------------------------- | | 1230101 | SYS_ERROR | System error | | 1230102 | SYS_BUSY | System busy. Try again later | | 1230303 | ILLEGAL_PARAMETERS | The parameter {0} is illegal | | 1230304 | INVALID_DIRECTION | Invalid trading direction: {0} | | 1230305 | NO_PAYMENT_METHOD_AVAILABLE | No payment method available for the specified currency pair and direction | | 1230306 | INVALID_AMOUNT_TYPE | Invalid amount type {0}. Must be 1 (fiat) or 2 (crypto) | | 1230307 | QUOTE_GENERATION_FAILED | Failed to generate quote from external service | | 1230308 | QUOTE_CACHE_FAILED | Failed to cache quote in Redis | | 1230309 | DUPLICATE_ORDER_SUBMISSION | Duplicate order submission detected | | 1230310 | QUOTE_EXPIRED | Quote has expired or not found | | 1230311 | ORDER_EXECUTION_FAILED | Order execution failed | | 1230312 | MERCHANT_NOT_EXIST | Merchant does not exist or is inactive | | 1230313 | CUSTOM_SPREAD_EXCEEDED | Custom spread {0} is out of bounds [{1}, {2}] | | 1230314 | INVALID_ORDER_STATUS | Invalid order status | | 1230315 | LIMIT_CALCULATION_FAILED | Limit calculation failed. Please check your parameters | # ### Example Response: ```json { "success": false, "code": "1230310", "message": "Quote has expired or not found", "data": null } ``` --- ## Document: /products/connect-prime/basics/4.base-urls URL: /zh-CN/docs/products/connect-prime/basics/4.base-urls # Environments and API base URLs According to different environments, please use the following base URLs for API requests: | Environment | URL | | ----------- | ----------------------------------- | | QA | Please ask for Binance Connect team | | Production | Please ask for Binance Connect team | --- ## Document: /products/connect-prime/basics/3.request-signing URL: /zh-CN/docs/products/connect-prime/basics/3.request-signing # API request signing The private key and public key are generated by the partner (client). The partner (client) should keep the private key securely and privately, and inform Binance Connect of the public key, then Binance Connect will be able to verify the API requests from the partner (client). # ### Generating key pairs You can use code or the OpenSSL tool to generate key pairs, depending on which one you prefer. #### Generating key pairs with code The example code below shows how to generate public and private keys: ```java import org.apache.commons.codec.binary.Base64; import java.security.KeyPairGenerator; import java.security.KeyPair; KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA"); generator.initialize(1024); KeyPair kp = generator.generateKeyPair();   String privateK = Base64.encodeBase64String(kp.getPrivate().getEncoded()); String publicK = Base64.encodeBase64String(kp.getPublic().getEncoded()); System.out.println("-----Generating private key-----"); System.out.println(privateK); System.out.println("\n\n-----Generating public key-----"); System.out.println(publicK); ``` #### Generating key pairs with OpenSSL tool Please follow the steps below: 1. Generate private key with command: ``` openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:1024 ``` 2. Extract the DER encoding of the private key with command: ``` openssl rsa -in private_key.pem -outform DER -out private_key.der ``` 3. Convert the DER-encoded private key to Base64 encoding with command: ``` openssl base64 -in private_key.der -out private_key.base64 -A | tr -d '\n' | sed 's/\//\//g' ``` > \*_Please keep the file "private_key.base64" generated by this command securely and privately. The > private key will be used to generate the signature._ 4. Generate public key with command: ``` openssl rsa -in private_key.pem -pubout -outform DER -out public_key.der ``` 5. Convert the DER-encoded public key to Base64 encoding with command: ``` openssl base64 -in public_key.der -out public_key.base64 -A | tr -d '\n' | sed 's/\//\//g' ``` > \*_Please send the file "public_key.base64" generated by this command to Binance Connect for use > in verifying API requests._ # ### Generating signature and set HTTP headers The signature is generated by request body (json string), timestamp and partner (client) private key, the following is the example code: ```java import org.apache.commons.codec.binary.Base64; import java.security.KeyFactory; import java.security.PrivateKey; import java.security.Signature; import java.security.spec.PKCS8EncodedKeySpec; import org.springframework.http.HttpHeaders; import org.springframework.util.MultiValueMap; public class TestRequestSigning {     public static void main(String[] args) throws Exception {         MultiValueMap httpHeaders = new HttpHeaders();         String clientPrivateKey = "Your client private key";         String jsonBody = "{\n" +                 "\t\"id\": \"10000001\",\n" +                 "\t\"name\": Jack\n" +                 "}";// Please use utf-8 encoding if body contains special characters such as emoticons.         Long timestamp = System.currentTimeMillis();         PrivateKey cPrivateKey = generatePrivateKey(clientPrivateKey);         String signature = sign(jsonBody + timestamp.toString(), cPrivateKey);         httpHeaders.add("X-Tesla-Signature", signature);     }     public static PrivateKey generatePrivateKey(String privateKey) throws Exception {         PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKey));         KeyFactory keyFactory = KeyFactory.getInstance("RSA");         return keyFactory.generatePrivate(privateKeySpec);     }     public static String sign(String srcData, PrivateKey privateKey) throws Exception {         Signature signature = Signature.getInstance("SHA256withRSA");         signature.initSign(privateKey);         signature.update(srcData.getBytes());         return new String(Base64.encodeBase64(signature.sign()));     } } ``` # ### How signature works #### The signature flow is as follows: ![signature-flow](../images/signature-API-prime.png) # ### Use [Postman](https://www.postman.com/) to sign and test API requests 1. Configure environment variables Create an environment (such as QA) in Postman and add these environment variables for subsequent reference: `base_url`, `client_id`, `access_token`, `private_key`. Please note that the format of the value of `private_key` should be like this: ```javascript -----BEGIN PRIVATE KEY----- MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANAAMnEOR1NIBIbwnDwHu19L/Jv0s4eEDHEjQ24OHjkHQ3CHWj4Ik4iFZyX9MvQsmZEzkDx8mJkkgAmIGjYkkZhEny1z6GPW55+ruo4dLYIRurESYRufZxI49BtIeLOOwL9ZFOnVfxBh8T7xyCvMmMcF93Suv6RcbTWXk8EC0pkXAgMBAAECgYA2cXbChNxCfj1BHMWoKNXwkbEjGR/MvtGK45IIwoVCpBYQ5DzIs/H58AEZvnaR1wKzMO32Bx7iJt2koQ1LUrMQ0UB9ydxhP2BogHvt9ZDI49+UPkTS92HMgPixi6O1HE6nOOu4rHR+6j7pdGcB+dneTwgPngWdk71VsbX8ZzPZsQJBAOGPmztuIpgXCxPlyLWCuEa9zTKc9lHiBe65ZN1jvUq1GCLClVcx/oEtEb9CCo7u1vacr/1sGFPxgBdvzv2y8HMCQQDsEfGEhp/79keDnjvJZ+TLfP4r+u1Gw0gAuj4Cay316K3f3q2OEqNm9lMNzg5dVYb78sVRd+guZ88u9etRBX/NAkAheIrjdcNiaED3keiHrr8jmDSj5xDSM8UHmLEz/QHw3RCYz+ETUFLg3kw84lLoxN5XOAcRhwHRKwwD7k577RqrAkEAhBiGTOIII7Vrzvp7+fdoz3ThxTpkC3S6la2hhTj0PuY0ZVD1TMqhJLwxPUhQQWnaXqE6SJwQD+eGx4BUbMHnAQJBAKomO+rK7ycU9OSRpEbPt2yQskwCcY2fiLgDy0Sy1hWmp/e5Cowt2Uyzp6uk/4QwMkfFApYzWtvjrnRkru19rMw= -----END PRIVATE KEY----- ``` 2. Set up library [postman-util-lib](https://joolfe.github.io/postman-util-lib/) for Postman Add a Postman global variable named `pmlib_code`, and set the value of it as the source code in the [library bundle content](https://joolfe.github.io/postman-util-lib/dist/bundle.js). 3. Configure HTTP headers: add Pre-request scripts to collection or request of Postman Add the following code to the Pre-request script: ```javascript eval(pm.globals.get("pmlib_code")); pm.request.headers.add({ key: "Content-Type", value: "application/json", }); pm.request.headers.add({ key: "X-Tesla-ClientId", value: pm.environment.get("client_id"), }); pm.request.headers.add({ key: "X-Tesla-SignAccessToken", value: pm.environment.get("access_token"), }); const timestamp = new Date().getTime(); let jsonBody = new String(); if (pm.request.body.raw) { jsonBody = pm.request.body.raw; } const dataToSign = jsonBody + timestamp.toString(); const privateKey = pm.environment.get("private_key"); const sha256withRSA = new pmlib.rs.KJUR.crypto.Signature({ alg: "SHA256withRSA" }); sha256withRSA.init(privateKey); sha256withRSA.updateString(dataToSign); const signature = pmlib.rs.hextob64(sha256withRSA.sign()); pm.request.headers.add({ key: "X-Tesla-Signature", value: signature, }); pm.request.headers.add({ key: "X-Tesla-Timestamp", value: timestamp.toString(), }); ``` 4. Everything is ready, feel free to test the API requests! --- ## Document: /products/connect-prime/basics/2.common-response URL: /zh-CN/docs/products/connect-prime/basics/2.common-response # Common API response | Field | Type | Mandatory | Remarks | | ------- | ------ | --------- | ------------------------------------------------------------------------------------------ | | success | bool | Yes | true means success. | | code | string | Yes | “000000” means success. Other error codes please refer to “[error code](5.error-code.md)”. | | data | object | No | A json object of returned data. | | message | string | No | Error message, please refer to “[error code](5.error-code.md)”. | --- ## Document: /products/connect-prime/basics/10.merchant-side-API-requirements URL: /zh-CN/docs/products/connect-prime/basics/10.merchant-side-API-requirements # Binance Connect Prime API Requirements Document ## Table of Contents - [General API Convention](#general-api-convention) - [Base URL](#base-url) - [Authorization (flexible)](#authorization-flexible) - [API Response Envelope](#api-response-envelope) - [Buy flow](#buy-flow) - [Check merchant side transaction status API](#check-merchant-side-transaction-status-api) - [General Buy Flow](#general-buy-flow) - [Minimum Requirements](#minimum-requirements) - [Refund API (BUY)](#refund-api-buy) - [General Refund Flow (BUY)](#general-refund-flow-buy) - [Minimum Requirements](#minimum-requirements-1) - [Sell flow](#sell-flow) - [Transfer API](#transfer-api) - [General Sell Flow](#general-sell-flow) - [Minimum Requirements](#minimum-requirements-2) - [Miscellaneous Requirements](#miscellaneous-requirements) - [Get historical transaction list](#get-historical-transaction-list) - [General Key Notes](#general-key-notes) --- The purpose of this API document is to enable seamless integration between merchant side and Binance Connect Prime, facilitating efficient transaction processing, data retrieval, and other essential operations. The document details the endpoints, request and response formats, authentication methods, and error handling protocols to ensure a clear and consistent implementation. ## General API Convention ### Base URL - **Production environment URL** (real money) - **Testing/Sandbox environment URL** (test money) ### Authorization (flexible) **Below are two common authorization methods for demonstration purposes. The authorization details can be discussed at a later time.** **Token-based authentication:** - HTTP header: `Authorization: Bearer ` **Private-Public-Key signing** - Account-based authentication ### API Response Envelope **Response envelope:** - All endpoints return HTTP code with a JSON body --- ## Buy flow ### Check merchant side transaction status API: #### General Buy Flow: 1. On Merchant Side, user transfers fiat to Binance's account 2. The merchant will call our API to execute the quote, providing information about the transaction in step (1) (e.g. transactionId, orderId, etc…) 3. Binance will verify that we have received the fiat from the user 4. After confirming fiat funds have been received, Binance releases crypto to the user #### Minimum Requirements To facilitate point (2), we would require an endpoint that allows us to check the status of the transaction sent by the user. The transaction status should be exhaustive, ideally an enum. Here's an example: ```java public enum TransactionStatus { PENDING(0), COMPLETED(0), FAILED(0), } ``` --- ### Refund API (BUY) #### General Refund Flow (BUY): 1. On Merchant Side, user transfers fiat to Binance's account 2. The merchant will call our API to execute the quote, providing information about the transaction in step (1) (e.g. transactionId, etc…) 3. Binance will verify that we have received the fiat from the user 4. Binance executes buy transaction based on the given quote 5. Quote has expired 6. Binance calls a provided endpoint to refund fiat back to user #### Minimum Requirements Since fiat funds are already transferred before buy flow was initiated on Binance's side, we need to refund the user in the event we are unable to process the given quote. We would need: - An endpoint that allows Binance to refund the user's fiat transfer in step (1) back to the user. - An endpoint that allows Binance to check the status of the refund. #### Refund API Specification **Request:** Binance will call the merchant's refund endpoint with the following parameter: | Field | Type | Mandatory | Remarks | | ------------- | ------ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | clientOrderId | string | Yes | The unique order ID originally provided by the merchant during Execute Quote. This is the sole identifier for the refund — no `userId` or additional fields are required. | **Request Example:** ```json { "clientOrderId": "YOUR_UNIQUE_ORDER_ID_001" } ``` **Response:** The merchant should return the refund status: | Field | Type | Mandatory | Remarks | | -------- | ------ | --------- | ----------------------------------------------- | | refundId | string | Yes | Merchant-side unique refund identifier | | status | string | Yes | Refund status: `PENDING`, `COMPLETED`, `FAILED` | **Response Example:** ```json { "success": true, "code": "000000", "data": { "refundId": "refund_abc123", "status": "PENDING" } } ``` **Key Design Points:** - `clientOrderId` is the **only identifier** needed to locate the original transaction. The merchant should be able to look up the user and transaction details on their side using this ID alone. - The refund endpoint **must be idempotent**: calling it multiple times with the same `clientOrderId` should not create duplicate refunds. - Binance will subsequently call the **refund status check endpoint** with the same `clientOrderId` (or `refundId`) to poll for refund completion. --- ## Sell flow ### Transfer API #### General Sell Flow: 1. Merchant calls Binance API to execute sell quote 2. Binance will calculate the corresponding fiat amount based on the given quote. 3. Binance will call Merchant's API to transfer the fiat amount calculated in step (2) to the user's account #### Minimum Requirements Since Binance will be transferring fiat to the user, we would need: - An endpoint to initiate a fiat fund transfer to a user - An endpoint that allows Binance to check the status of the refund. --- ## Miscellaneous Requirements ### Get historical transaction list For book-keeping purposes, Binance performs T+1 reconciliation. We would require an endpoint that allows us to fetch our past transactions. **Key Information that's required:** - transactionId / orderId - Fiat currency and amount - Direction (transfer IN or OUT) - CreatedAt Timestamp (when the transaction was initiated) - CompletedAt Timestamp (when the transaction finished processing) ### General Key Notes: - For each unique transaction, Idempotency must be ensured. (i.e. transactionId, orderId must be unique) --- ## Document: /products/connect-prime/basics/1.common-request-headers URL: /zh-CN/docs/products/connect-prime/basics/1.common-request-headers # Common API request headers | Parameter | Description | Mandatory | Remarks | | ----------------------- | ----------------------------------------------------------------------------------- | --------- | ------------------------------------------------------ | | Content-Type | application/json | Yes | | | X-Tesla-ClientId | Partner (client) id provided by Binance Connect | Yes | | | X-Tesla-SignAccessToken | Access token provided by Binance Connect | Yes | | | X-Tesla-Signature | A signature generated by request body, timestamp and partner (client) private key\* | Yes | Refer to “[API Request signing](3.request-signing.md)” | | X-Tesla-Timestamp | Timestamp in millisecond | Yes | | > \*_The private key and public key are generated by the partner (client). Please refer to > “[API Request signing](3.request-signing.md)” for the generation method._ --- ## Document: /products/connect-2.0/webhook/webhook URL: /zh-CN/docs/products/connect-2.0/webhook/webhook # Webhook Whenever a key event (currently only "order status change") occurs, Binance Connect will send a webhook message, and the partner (client) can receive this message at the webhook callback url and react accordingly, such as updating order data and frontend UI. ### Request Headers | **Field** | **Type** | **Remarks** | | ---------------------- | --------- | -------------------------------------------------------- | | X-BN-Connect-Timestamp | timestamp | timestamp | | X-BN-Connect-Signature | string | SHA256withRSA(**requestBody** + **X-Connect-Timestamp**) | | X-BN-Connect-For | string | Same with your client id (X-Tesla-ClientId) | ### Request Body | **Field** | **Type** | **Remarks** | | --------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | webhookEventType | string | A fixed value: connect_order_event | | externalOrderId | string | The unique order id from the partner side. | | type | int | 1: buy, 2: sell, 3: send | | businessType | int | 1: fiat, 2: p2p, 3: send, 4: convert | | status | int | Please refer to "[Order status](../basics/7.order-status.md)" | | payMethodCode | string | The payment method code is from payment method list API | | payMethodSubCode | string | The payment method sub code is from payment method list API | | fiatCurrency | string | fiat currency | | cryptoCurrency | string | crypto currency | | openUserId | string | OpenUserId represents a Binance user ID that has been securely hashed. This field is provided to merchants to facilitate the identification of whether multiple orders originate from the same user. | | fiatAmount | string | fiat amount | | cryptoAmount | string | crypto amount | | feeAmount | string | fee amount | | feeCurrency | string | fee currency, USD or crypto | | revenueAmount | string | partner revenue amount | | revenueCurrency | string | partner revenue currency, USD or crypto | | networkFee | string | network fee amount | | withdrawWalletAddress | string | withdraw wallet address | | withdrawNetwork | string | withdraw network | | withdrawMemo | string | withdraw network memo | | withdrawTxHash | string | withdraw tx hash | | orderDetailLink | string | order detail link | | orderTime | timestamp | order time | | completionTime | timestamp | completion time | | updateTime | timestamp | update time | | convertInfo | object | Convert information. This field is only present for Convert orders. Refer to **ConvertInfo** | | swapDetailInfoVo | object | If the order has swap operation. Then this field has value. Refer to **SwapDetailInfoVo** | | userData | string | AES-encrypted JSON string (see details below). Disabled by default; contact us to enable | #### SwapDetailInfoVo | **Field** | **Type** | **Remarks** | | --------------------------------- | -------- | --------------------------------------------------------------------------------- | | fromCryptoCurrencyContractAddress | string | The "from" crypto contract address, typically a stablecoin or native token. | | toCryptoCurrencyContractAddress | string | The contract address of the target coin the user intends to swap online. | | toCryptoCurrencyAmount | string | The final amount of cryptocurrency the user swapped and received in their wallet. | #### ConvertInfo | **Field** | **Type** | **Remarks** | | -------------- | -------- | --------------------------------------------------- | | fromCoin | string | The source cryptocurrency being converted from | | fromCoinAmount | string | The amount of source cryptocurrency being converted | #### userData field - Type: string - Remarks: When enabled, `userData` contains a JSON object (serialized to a string) that is encrypted with AES. The field value is the AES-encrypted ciphertext encoded as a string. This field is disabled by default — please contact us if you need it enabled and for access to the AES key and configuration. - Decryption reference: follow the AES decryption instructions described in [Binance documentation](/products/binance-pay-merchant/authentication#decryption-instructions-for-merchant-data-sharing) - JSON structure (plaintext before AES encryption): | Field | Type | Remarks | | ---------------- | ------ | ------------------------------- | | firstName | string | User's first name | | middleName | string | User's middle name (optional) | | lastName | string | User's last name | | residenceCountry | string | Country code of residence (ISO) | | birthday | string | Birthday in YYYY-MM-DD format | | country | string | Country code (ISO) | | refundAddress | string | Refund crypto address (if any) | | refundNetwork | string | Network of refund (e.g., ETH) | | refundMemo | string | Refund memo/memo field (if any) | Notes: - Field names and types above show the expected JSON keys that will be present after decrypting `userData`. - The concrete AES parameters (mode, IV, padding) and key delivery method will be provided when the field is enabled; see the decryption reference link above for an example. ### Response Body - HTTP status code is 200 - Response body is in JSON format. | **Field** | **Type** | **Remarks** | | ------------- | -------- | ----------------------------------------------------------- | | returnCode | string | SUCCESS or other code you wish to return to Binance Connect | | returnMessage | string | the message you wish to return to Binance Connect | ### How signature works The encryption/decryption and verification process of webhook is exactly the opposite/mirrored of API request process. The sender and receiver of the two are opposite, but they are both processes that signed by the sender with a private key and verified by the receiver with a public key. For API requests, the partner (client) generates a pair of keys. The private key is kept securely and privately by the partner (client). Then the partner (client) uses the private key to sign when initiating API requests. The public key is shared to Bianance Connect, with which Binance will verify the signature of the API request to ensure that the request is indeed initiated by the partner (client). For webhook, it's an opposite/mirrored process. Binance Connect generates a pair of keys. The private key is kept securely and privately by Binance Connect. Then Binance Connect uses the private key to sign when initiating the webhook message. The public key is shared to the partner (client), with which the partner (client) can verify the signature of the webhook message to ensure that the message is indeed initiated by Binance. #### The webhook signature flow is as follows: ![signature-Webhook.png](../images/signature-Webhook.png) ### Verify signature As mentioned above, Binance Connect initiates a webhook request to the webhook callback url provided by the partner ( client). And the partner (client) should verify the identity of the request initiator based on the public key provided by Binance Connect. The example code below shows how to verify signature with public key: ```java public static boolean verify(String srcData, PublicKey publicKey, String sign) throws Exception { Signature signature = Signature.getInstance("SHA256withRSA"); signature.initVerify(publicKey); signature.update(srcData.getBytes()); return signature.verify(Base64.decodeBase64(sign.getBytes())); } ``` # ### Example Request Body: ```json { "webhookEventType": "connect_order_event", "externalOrderId": "180401941923045", "type": 1, "businessType": 1, "status": 2, "payMethodCode": "BUY_P2P", "payMethodSubCode": "BANK", "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "openUserId": "f47ac10b58cc4372a5670e02b2c3d479", "fiatAmount": "100", "cryptoAmount": "107.8", "feeAmount": "1", "feeCurrency": "USDT", "revenueAmount": "0.08", "revenueCurrency": "USDT", "networkFee": "0.5", "withdrawWalletAddress": "0xbb4CdB98Bd36B01bD1cBaEA52De08d9173bc095c", "withdrawNetwork": "BSC", "withdrawMemo": "", "withdrawTxHash": "0xcb163e2e6322cd6aa7bc4d45306029e846c0c06e9cdee45a06e88801d1231e71", "orderDetailLink": "https://www.binance.com/en/my/wallet/exchange/buysell-history?type=buy", "orderTime": 1723186761000, "completionTime": 1723206761000, "updateTime": 1734446642930 } ``` ### Example (Convert Order) Request Body: ```json { "webhookEventType": "connect_order_event", "networkFee": null, "feeCurrency": "USDT", "type": 1, "businessType": 4, "withdrawMemo": "", "revenueAmount": null, "cryptoCurrency": "USDT", "withdrawTxHash": "", "completionTime": null, "orderTime": 1753344231742, "payMethodSubCode": "CUMBERLAND", "cryptoAmount": "1.03", "orderDetailLink": null, "payMethodCode": "SPOT", "revenueCurrency": "USDT", "convertInfoVo": { "fromCoin": "BNB", "fromCoinAmount": 0.00137386 }, "swapDetailInfoVo": null, "updateTime": 1753344255279, "externalOrderId": "830315252102", "withdrawWalletAddress": "0xbb4CdB98Bd36B01bD1cBaEA52De08d9173bc095c", "fiatCurrency": "", "fiatAmount": "0", "withdrawNetwork": "ETH", "status": 11 } ``` --- ## Document: /products/connect-2.0/send-primary-mode/send-primary-mode URL: /zh-CN/docs/products/connect-2.0/send-primary-mode/send-primary-mode # Send primary mode As we know, Binance Connect has a wide range of application scenarios. In addition to on-ramp (buy) and off-ramp (sell), Binance Connect can also be used as a crypto payment channel/tool, that is, users can directly use the crypto balance in their Binance wallet to make third-party payments. This is the "send primary mode" we launched. In send primary mode, the product process and user flow are different from the normal on-ramp (buy), as follows: - Send (transfer) crypto will be promoted as the first priority; - Buy crypto related features will be downgraded and hidden, users don't need to buy crypto, they only need to send (transfer) crypto from their Binance wallet; - Only in one case, when the crypto balance in user's Binance wallet is insufficient, the flow will return back to the buy crypto process, to avoid users being blocked here; ## How to integrate send primary mode If you are going to integrate send primary mode, please follow these instructions: 1. Contact Binance Connect team to enable this feature for you (it's disabled by default); 2. Pass `"SEND_PRIMARY": true` or `"SEND_PRIMARY_FLEXIBLE": true` in the `customization` parameter of the pre-order API. Please refer to [Customization](../basics/9.customization.md). ### Difference between SEND_PRIMARY and SEND_PRIMARY_FLEXIBLE - **SEND_PRIMARY**: The crypto amount is locked and fixed based on the amount specified in the pre-order API. Users cannot modify the amount on the Binance Connect page. Should work together with `amountType: 2`. - **SEND_PRIMARY_FLEXIBLE**: The crypto amount specified in the pre-order API will be used as a default value, but users can freely input and modify the amount on the Binance Connect page. This provides more flexibility for users to adjust the payment amount as needed. > **Note**: You should only use either `SEND_PRIMARY` or `SEND_PRIMARY_FLEXIBLE`, not both at the > same time. ## Typical Send Flow 1. **Initiate Send & Fetch Info** - The user initiates a crypto transfer from Binance on the partner's frontend. - The partner's backend requests the list of supported crypto networks and trading pairs from Binance Connect. - This information is then relayed to the partner's frontend to be displayed to the user. 2. **Confirm & Create Pre-order** - The user confirms the details on the partner's frontend. - The partner's backend sends a pre-order request to Binance Connect. - Binance Connect returns a `redirectUrl` in the response. 3. **Redirect to Binance** - The partner's frontend redirects the user to the Binance App/website using the `redirectUrl`. 4. **Complete Flow on Binance** - The user completes the send process on the Binance platform. - Note: If the user's balance is insufficient, the flow will include a buy step before sending. 5. **Webhook Notification** - Binance Connect sends a webhook notification to the partner's backend about the order status update. 6. **Query Order Status** - The partner's backend can then query the order details from Binance Connect to get the final status of the transaction. ## Diagram ![send-flow.png](../images/send-flow.png) --- ## Document: /products/connect-2.0/sandbox/4.order-status-transition URL: /zh-CN/docs/products/connect-2.0/sandbox/4.order-status-transition # Order Status Transition ``` POST /papi/v1/ramp/connect/sandbox/order-status-transition ``` The Order Status Transition API allows merchants to manually transition order statuses in the sandbox environment for testing purposes. This API simulates various order state changes without requiring actual payment processing or blockchain transactions. Refer to the order status list [7.order-status.md](../basics/7.order-status.md) ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | --------------- | -------- | ------------- | ----------------------------------------------------------------------------- | | externalOrderId | string | Yes | The unique order id from the partner side. Supports only letters and numbers. | | targetStatus | int | Yes | The target status to transition to. Must be a positive integer. | ### Response Body | **Field** | **Type** | **Remarks** | | --------- | -------- | ---------------------------------- | | success | boolean | Indicates if the request succeeded | | code | string | Response code | | message | string | Response message | The API supports different status transitions based on the order type and business type. Below are the supported transitions: ### 1. BUY Orders (FIAT/P2P Business Type) #### For Regular Withdraw Orders: | Target Status Code | Status Name | Description | | ------------------ | ------------------- | -------------------------------------- | | 2 | ON_RAMP_COMPLETED | purchase crypto completed successfully | | 11 | WITHDRAW_PROCESSING | Withdrawal is being processed | | 96 | WITHDRAW_ABANDONED | Withdrawal was abandoned | | 97 | ON_RAMP_FAILED | purchase crypto failed | | 98 | WITHDRAW_FAILED | Withdrawal failed | | 20 | COMPLETED | Order fully completed | #### For Swap Orders (Buy Any Token): | Target Status Code | Status Name | Description | | ------------------ | ----------------- | -------------------------------------- | | 2 | ON_RAMP_COMPLETED | purchase crypto completed successfully | | 15 | SWAP_PROCESSING | Token swap is being processed | | 93 | SWAP_ABANDONED | Token swap was abandoned | | 94 | SWAP_FAILED | Token swap failed | | 97 | ON_RAMP_FAILED | purchase crypto failed | | 20 | COMPLETED | Order fully completed | ### 2. BUY Orders (CONVERT Business Type) | Target Status Code | Status Name | Description | | ------------------ | ------------------- | ---------------------------------------- | | 4 | CONVERT_COMPLETED | Crypto conversion completed successfully | | 11 | WITHDRAW_PROCESSING | Withdrawal is being processed | | 92 | CONVERT_FAILED | Crypto conversion failed | | 96 | WITHDRAW_ABANDONED | Withdrawal was abandoned | | 98 | WITHDRAW_FAILED | Withdrawal failed | | 20 | COMPLETED | Order fully completed | ### 3. SEND Orders (Send Crypto) | Target Status Code | Status Name | Description | | ------------------ | --------------- | ------------------------ | | 20 | COMPLETED | Crypto sent successfully | | 98 | WITHDRAW_FAILED | Crypto send failed | ## Status Transition Flow ### BUY Order (FIAT/P2P) - Regular Flow ``` INIT(0) → ON_RAMP_PROCESSING(1) → ON_RAMP_COMPLETED(2) → WITHDRAW_PROCESSING(11) → COMPLETED(20) ``` ### BUY Order (FIAT/P2P) - Swap Flow ``` INIT(0) → ON_RAMP_PROCESSING(1) → ON_RAMP_COMPLETED(2) → SWAP_PROCESSING(15) → COMPLETED(20) ``` ### BUY Order (CONVERT) Flow ``` INIT(0) → CONVERT_PROCESSING(3) → CONVERT_COMPLETED(4) → WITHDRAW_PROCESSING(11) → COMPLETED(20) ``` ### SEND Order Flow ``` INIT(0) → WITHDRAW_PROCESSING(11) → COMPLETED(20) ``` # ### Example 1: Transition order to completed status Request Parameters: ```json { "externalOrderId": "946972922319", "targetStatus": 11 } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": null } ``` ### Example 2: Transition order to pending status Request Parameters: ```json { "externalOrderId": "946972922320", "targetStatus": 20 } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": null } ``` ### Example 3: Transition order to failed status Request Parameters: ```json { "externalOrderId": "946972922321", "targetStatus": 40 } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": null } ``` --- ## Document: /products/connect-2.0/sandbox/3.place-buy-any-token-order URL: /zh-CN/docs/products/connect-2.0/sandbox/3.place-buy-any-token-order # Place Buy Any Token Order ``` POST /papi/v1/ramp/connect/sandbox/place-buy-any-token-order ``` This endpoint allows you to place test orders in the sandbox environment for buying any token, including tokens that may not be listed on Binance spot markets. ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | --------------- | -------- | ------------- | ----------------------------------------------------------------------------- | | externalOrderId | string | Yes | The unique order id from the partner side. Supports only letters and numbers. | | fiatCurrency | string | Yes | Fiat currency code (e.g., EUR, USD) | | requestedAmount | string | Yes | Requested amount. Must be greater than 0 and less than 9999999999999999 | | amountType | int | Yes | Specify whether the requested amount is in fiat:1 or crypto:2 | ### Response Body | **Field** | **Type** | **Remarks** | | --------- | -------- | ---------------------------------- | | success | boolean | Indicates if the request succeeded | | code | string | Response code | | message | string | Response message | # ### Example 1: Buy any token with fiat amount Request Parameters: ```json { "externalOrderId": "599518801876", "fiatCurrency": "EUR", "requestedAmount": "150", "amountType": 1 } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": null } ``` ### Example 2: Buy any token with crypto amount Request Parameters: ```json { "externalOrderId": "599518801877", "fiatCurrency": "USD", "requestedAmount": "100", "amountType": 2 } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": null } ``` --- ## Document: /products/connect-2.0/sandbox/2.place-convert-feature-order URL: /zh-CN/docs/products/connect-2.0/sandbox/2.place-convert-feature-order # Place Convert Feature Order ``` POST /papi/v1/ramp/connect/sandbox/place-convert-feature-order ``` This endpoint allows you to place test convert orders in the sandbox environment to simulate cryptocurrency conversion scenarios. ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | ------------------ | -------- | ------------- | ------------------------------------------------------------------------------------------ | | externalOrderId | string | Yes | The unique order id from the partner side. Supports only letters and numbers. | | fromCryptoCurrency | string | Yes | The source cryptocurrency to convert from (e.g., BNB, ETH) | | toCryptoCurrency | string | Yes | The target cryptocurrency to convert to (e.g., USDT, BTC) | | toCryptoAmount | string | Yes | The amount of target cryptocurrency. Must be greater than 0 and less than 9999999999999999 | ### Response Body | **Field** | **Type** | **Remarks** | | --------- | -------- | ---------------------------------- | | success | boolean | Indicates if the request succeeded | | code | string | Response code | | message | string | Response message | # ### Example 1: Convert BNB to USDT Request Parameters: ```json { "externalOrderId": "830315252102", "fromCryptoCurrency": "BNB", "toCryptoCurrency": "USDT", "toCryptoAmount": "100" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": null } ``` ### Example 2: Convert ETH to BTC Request Parameters: ```json { "externalOrderId": "830315252103", "fromCryptoCurrency": "ETH", "toCryptoCurrency": "BTC", "toCryptoAmount": "0.5" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": null } ``` --- ## Document: /products/connect-2.0/sandbox/1.place-order URL: /zh-CN/docs/products/connect-2.0/sandbox/1.place-order # Place Order ``` POST /papi/v1/ramp/connect/sandbox/place-order ``` This endpoint allows you to place test orders in the sandbox environment to simulate the complete order lifecycle without using real funds. ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | --------------- | -------- | ------------- | ----------------------------------------------------------------------------- | | externalOrderId | string | Yes | The unique order id from the partner side. Supports only letters and numbers. | | fiatCurrency | string | Yes | Fiat currency code (e.g., EUR, USD) | | cryptoCurrency | string | Yes | Crypto currency code (e.g., USDT, BTC) | | requestedAmount | string | Yes | Requested amount. Must be greater than 0 and less than 9999999999999999 | | amountType | int | Yes | Specify whether the requested amount is in fiat:1 or crypto:2 | | type | string | Yes | Order type: BUY, BUY_P2P, SEND | ### Response Body | **Field** | **Type** | **Remarks** | | --------- | -------- | ---------------------------------- | | success | boolean | Indicates if the request succeeded | | code | string | Response code | | message | string | Response message | # ### Example 1: Place a BUY order Request Parameters: ```json { "externalOrderId": "946972922319", "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "requestedAmount": "100", "amountType": 1, "type": "BUY" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": null } ``` ### Example 2: Place a BUY_P2P order Request Parameters: ```json { "externalOrderId": "946972922320", "fiatCurrency": "USD", "cryptoCurrency": "BTC", "requestedAmount": "0.5", "amountType": 2, "type": "BUY_P2P" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": null } ``` ### Example 3: Place a SEND order Request Parameters: ```json { "externalOrderId": "946972922321", "fiatCurrency": "EUR", "cryptoCurrency": "ETH", "requestedAmount": "1.5", "amountType": 2, "type": "SEND" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": null } ``` --- ## Document: /products/connect-2.0/sandbox/0.overview URL: /zh-CN/docs/products/connect-2.0/sandbox/0.overview # Sandbox APIs Overview ## Overview The Sandbox APIs provide a safe testing environment for partners to integrate with Binance Connect without using real funds or affecting production systems. These APIs allow you to simulate the complete order lifecycle, test different order types, and verify your integration before going live. **_Note1: The sandbox environment is isolated from production. All data and operations here do not impact real user accounts or transactions._** **_Note2: Invoke the pre-order API first, then use the sandbox APIs below._** ## Purpose The sandbox environment enables you to: - Test order placement flows without real transactions - Simulate various order types (BUY, BUY_P2P, SEND, Convert) - Manually control order status transitions for testing webhooks and order state management - Validate your integration with different scenarios and edge cases ## Available APIs ### 1. Place Order Place standard test orders to simulate regular cryptocurrency purchase flows. ### 2. Place Convert Feature Order Test cryptocurrency conversion scenarios where users convert from one crypto to another. ### 3. Place Buy Any Token Order Simulate purchases of any token, including tokens not listed on Binance spot markets. ### 4. Order Status Transition Manually trigger order status changes to test your order lifecycle management and webhook handling. ## Testing Flow A typical testing workflow in the sandbox: 1. **Place an Order**: Use one of the place order endpoints to create a test order 2. **Verify Order Creation**: Check that your system correctly receives and processes the order 3. **Trigger Status Transitions**: Use the order status transition API to simulate different order states 4. **Test Webhooks**: Verify your webhook handlers correctly process status updates 5. **Validate Order Queries**: Use the order query API to fetch and verify order details ## Key Differences from Production - No real funds are used - Orders don't execute actual blockchain transactions - Status transitions are manual and controlled by the partner - All operations are isolated to the sandbox environment ## Getting Started To start testing with sandbox APIs: 1. Ensure you have sandbox credentials configured 2. Review the individual API documentation for each endpoint 3. Start with simple order placement and gradually test more complex scenarios 4. Use the order status transition API to simulate various order states ## Best Practices - Test all possible order types your integration will support - Verify error handling for invalid requests - Test webhook delivery and processing for all status transitions - Validate order query functionality with different order states - Test edge cases like very small or large amounts --- ## Document: /products/connect-2.0/on-ramp-buy-apis/8.get-p2p-trading-pairs URL: /zh-CN/docs/products/connect-2.0/on-ramp-buy-apis/8.get-p2p-trading-pairs # Get P2P-only trading pairs ``` POST /papi/v1/ramp/connect/buy/p2p/trading-pairs ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | ------------ | -------- | ------------- | ------------------------------ | | fiatCurrency | string | No | Filter by target fiat currency | ### Response Body (list of json object) | **Field** | **Type** | **Remarks** | | ---------------- | -------- | ---------------------- | | fiatCurrency | string | | | cryptoCurrencies | array | Crypto currency object | | cryptoCurrency | string | Crypto currency symbol | ### Example Request: ```json { "fiatCurrency": "EUR" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": [ { "fiatCurrency": "EUR", "cryptoCurrencies": [ { "cryptoCurrency": "USDC" }, { "cryptoCurrency": "BTC" } ] } ] } ``` --- ## Document: /products/connect-2.0/on-ramp-buy-apis/7.get-payment-method-list-v2 URL: /zh-CN/docs/products/connect-2.0/on-ramp-buy-apis/7.get-payment-method-list-v2 # Get payment method list v2 ``` POST /papi/v2/ramp/connect/buy/payment-method-list ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | --------- | -------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | language | string | No | Language code, which determines the multi-language of the content(if any, such as "payment method name") in the response data. If not passed, English is the default. The format is "[LanguageCode](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes)-[RegionCode](https://en.wikipedia.org/wiki/ISO_3166-1)", RegionCode is optional. | ### Response Body ##### Data: PaymentMethodV2Object array | **Field** | **Type** | **Remarks** | | -------------- | ------------ | ------------------------------------------------------------ | | fiatCurrency | string | Fiat currency | | paymentMethods | object array | Payment method details. Refer to PaymentMethodV2DetailObject | ##### PaymentMethodV2DetailObject | **Field** | **Type** | **Remarks** | | --------------------- | -------- | ---------------------------------------------------------- | | payMethodCode | string | payment method code | | payMethodSubCode | string | payment method sub code | | paymentMethod | string | payment method display name | | p2p | bool | Indicate whether the payment method belongs to Binance P2P | | withdrawRestriction\* | int | 0: no restriction

1: T+1 restriction | > \*_Please refer to > [What Are the "T+1", "T+2", and "T+3" Withdrawal Limits?](https://www.binance.com/en/support/faq/what-are-the-t-1-t-2-and-t-3-withdrawal-limits-360037261532)_ # ### Example Request Parameters: ```json { "language": "zh-CN" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": [ { "fiat": "AED", "paymentMethods": [ { "paymentMethodCode": "BUY_APPLE_PAY", "channelCode": "APPLE_PAY", "paymentMethod": "Apple Pay (VISA)", "p2p": false, "withdrawRestriction": 0 }, { "paymentMethodCode": "BUY_P2P", "channelCode": "BANK", "paymentMethod": "Bank", "p2p": true, "withdrawRestriction": 0 }, { "paymentMethodCode": "BUY_P2P", "channelCode": "Paypal", "paymentMethod": "PayPal", "p2p": true, "withdrawRestriction": 0 } ] }, { "fiat": "EUR", "paymentMethods": [ { "paymentMethodCode": "BUY_WALLET", "channelCode": "Wallet", "paymentMethod": "Spot Wallet", "p2p": false, "withdrawRestriction": 0 }, { "paymentMethodCode": "BUY_CARD", "channelCode": "card", "paymentMethod": "Card (VISA/Mastercard)", "p2p": false, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_REVOLUT", "payMethodSubCode": "REVOLUT", "paymentMethod": "REVOLUT", "p2p": false, "withdrawRestriction": 0 }, { "paymentMethodCode": "BUY_P2P", "channelCode": "SEPA", "paymentMethod": "SEPA (EU) bank transfer", "p2p": true, "withdrawRestriction": 0 } ] }, { "fiat": "CNY", "paymentMethods": [ { "paymentMethodCode": "BUY_P2P", "channelCode": "ALIPAY", "paymentMethod": "Alipay English", "p2p": true, "withdrawRestriction": 1 }, { "paymentMethodCode": "BUY_P2P", "channelCode": "BANK", "paymentMethod": "Bank", "p2p": true, "withdrawRestriction": 1 }, { "paymentMethodCode": "BUY_P2P", "channelCode": "WECHAT", "paymentMethod": "WeChat", "p2p": true, "withdrawRestriction": 1 } ] }, { "fiatCurrency": "BRL", "paymentMethods": [ { "payMethodCode": "BUY_WALLET", "payMethodSubCode": "Wallet", "paymentMethod": "Spot Account", "p2p": false, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_LATAM_GATEWAY_ONLINE_BANKING_PIX", "payMethodSubCode": "LATAM_GATEWAY", "paymentMethod": "Bank Transfer (PIX)", "p2p": false, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_APPLE_PAY", "payMethodSubCode": "APPLE_PAY", "paymentMethod": "Apple Pay (VISA)", "p2p": false, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_CARD", "payMethodSubCode": "card", "paymentMethod": "Card (VISA/Mastercard)", "p2p": false, "withdrawRestriction": 0 } ] } ] } ``` ##### About payment method "BUY_WALLET" "BUY_WALLET" is a special payment method that allows users to buy crypto using the user's fiat currency balance in Binance wallet. For example, in some countries or regions, users can deposit fiat currency (such as euro - EUR) to Binance. When the user has EUR balance in the Binance wallet, he can use EUR to buy crypto. We call this payment method as "BUY_WALLET". --- ## Document: /products/connect-2.0/on-ramp-buy-apis/6.query-order-details URL: /zh-CN/docs/products/connect-2.0/on-ramp-buy-apis/6.query-order-details # Query order details ``` POST /papi/v1/ramp/connect/order ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | --------------- | -------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | externalOrderId | string | Yes | The unique order id from the partner side. | | language | string | No | Language code, which determines the multi-language of the content(if any, such as "payment method name") in the response data. If not passed, English is the default. The format is "[LanguageCode](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes)-[RegionCode](https://en.wikipedia.org/wiki/ISO_3166-1)", RegionCode is optional. | ### Response Body | **Field** | **Type** | **Remarks** | | -------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | externalOrderId | string | The unique order id from the partner side. | | type | int | 1: buy, 2: sell, 3: send\* | | status | int | Please refer to "[Order status](../basics/7.order-status.md)" | | fiatCurrency | string | fiat currency | | cryptoCurrency | string | crypto currency | | openUserId | string | OpenUserId represents a Binance user ID that has been securely hashed. This field is provided to merchants to facilitate the identification of whether multiple orders originate from the same user. | | fiatAmount | string | fiat amount | | cryptoAmount | string | crypto amount | | paymentMethod | object | payment method | | feeAmount | string | total fee amount | | feeCurrency | string | fee currency, fiat currency or crypto | | revenueAmount | string | partner revenue amount | | revenueCurrency | string | partner revenue currency, fiat currency or crypto | | networkFee | string | network fee amount | | withdrawWalletAddress | string | withdraw wallet address | | withdrawNetwork | string | withdraw network | | withdrawMemo | string | withdraw network memo | | withdrawTxHash | string | withdraw tx hash | | orderDetailLink | string | order detail link | | orderTime | timestamp | order time | | completionTime | timestamp | completion time | | convertInfo | object | Convert information. This field is only present for Convert orders. Refer to **ConvertInfo** | | swapDetailInfoVo.fromCryptoCurrencyContractAddress | string | swap information. The from crypto currency contract address. Basically, it's stable coin and same with cryptoCurrecny field | | swapDetailInfoVo.toCryptoCurrencyContractAddress | string | swap information. The to crypto currency contract address. The target token that user want to buy | | swapDetailInfoVo.toCryptoCurrencyAmount | string | swap information. The amount of the target token the user purchased. | | userData | string | AES-encrypted JSON string (see details below). Disabled by default; contact us to enable | #### ConvertInfo | **Field** | **Type** | **Remarks** | | -------------- | -------- | --------------------------------------------------- | | fromCoin | string | The source cryptocurrency being converted from | | fromCoinAmount | string | The amount of source cryptocurrency being converted | #### userData field - Type: string - Remarks: When enabled, `userData` contains a JSON object (serialized to a string) that is encrypted with AES. The field value is the AES-encrypted ciphertext encoded as a string. This field is disabled by default — please contact us if you need it enabled and for access to the AES key and configuration. - Decryption reference: follow the AES decryption instructions described in [Binance documentation](/products/binance-pay-merchant/authentication#decryption-instructions-for-merchant-data-sharing) - JSON structure (plaintext before AES encryption): | Field | Type | Remarks | | ---------------- | ------ | ------------------------------- | | firstName | string | User's first name | | middleName | string | User's middle name (optional) | | lastName | string | User's last name | | residenceCountry | string | Country code of residence (ISO) | | birthday | string | Birthday in YYYY-MM-DD format | | country | string | Country code (ISO) | | refundAddress | string | Refund crypto address (if any) | | refundNetwork | string | Network of refund (e.g., ETH) | | refundMemo | string | Refund memo/memo field (if any) | Notes: - Field names and types above show the expected JSON keys that will be present after decrypting `userData`. - The concrete AES parameters (mode, IV, padding) and key delivery method will be provided when the field is enabled; see the decryption reference link above for an example. # ### Example 1 Request Parameters: ```json { "externalOrderId": "180401941923045", "language": "zh-CN" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "externalOrderId": "180401941923045", "type": 1, "status": 11, "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "openUserId": "f47ac10b58cc4372a5670e02b2c3d479", "fiatAmount": "100", "cryptoAmount": "889.35", "paymentMethod": { "payMethodCode": "BUY_CARD", "payMethodSubCode": "card", "paymentMethod": "Card (VISA/Mastercard)", "p2p": false, "withdrawRestriction": 0 }, "feeAmount": "1", "feeCurrency": "EUR", "revenueAmount": "0.3", "revenueCurrency": "EUR", "networkFee": "0.5", "withdrawWalletAddress": "0xbb4CdB98Bd36B01bD1cBaEA52De08d9173bc095c", "withdrawNetwork": "ETH", "withdrawMemo": "", "withdrawTxHash": "0xcb163e2e6322cd6aa7bc4d45306029e846c0c06e9cdee45a06e88801d1231e71", "orderDetailLink": "https://www.binance.com/en/my/wallet/exchange/buysell-history?type=buy", "orderTime": "1723186761000", "completionTime": "1723189981000" } } ``` ### Example 2 Request Parameters: ```json { "externalOrderId": "13402681029896", "language": "en" } ``` Response: ```json { "code": "000000", "message": "success", "data": { "externalOrderId": "13402681029896", "type": 1, "status": 20, "fiatCurrency": "EUR", "cryptoCurrency": "USDC", "openUserId": "f47ac10b58cc4372a5670e02b2c3d479", "fiatAmount": "15", "cryptoAmount": "16.78903899", "paymentMethod": { "payMethodCode": "BUY_WALLET", "payMethodSubCode": "Wallet", "paymentMethod": "Spot Account", "p2p": false, "withdrawRestriction": 0 }, "feeAmount": "1.001", "feeCurrency": "EUR", "networkFee": null, "withdrawWalletAddress": "3WZVn9cY4x8BBdpPsLEDG7LpthoDov4bUT11FvPCqvAA", "withdrawNetwork": "SOL", "withdrawMemo": "", "withdrawTxHash": null, "orderDetailLink": "https://www.binance.com/en/my/wallet/exchange/buysell-history?type=buy", "orderTime": 1746788679000, "completionTime": 1746788688982, "swapDetailInfoVo": { "fromCryptoCurrencyContractAddress": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "toCryptoCurrencyContractAddress": "38PgzpJYu2HkiYvV8qePFakB8tuobPdGm2FFEn7Dpump", "toCryptoCurrencyAmount": 605.496926 } }, "success": true } ``` ### Example 3 (Convert Order) Request Parameters: ```json { "externalOrderId": "830315252102", "language": "en" } ``` Response: ```json { "code": "000000", "message": "success", "data": { "externalOrderId": "830315252102", "type": 1, "status": 11, "openUserId": "09e03149752da10be5471c0c74f2811a", "fiatCurrency": "", "cryptoCurrency": "USDT", "fiatAmount": "0", "cryptoAmount": "1.03", "paymentMethod": { "payMethodCode": "SPOT", "payMethodSubCode": "CUMBERLAND", "paymentMethod": null, "p2p": false, "withdrawRestriction": null }, "feeAmount": "0", "feeCurrency": "USDT", "networkFee": "0.03000000", "withdrawWalletAddress": "0xbb4CdB98Bd36B01bD1cBaEA52De08d9173bc095c", "withdrawNetwork": "ETH", "withdrawMemo": "", "withdrawTxHash": "", "orderDetailLink": null, "orderTime": 1753344231742, "completionTime": null, "swapDetailInfoVo": null, "convertInfo": { "fromCoin": "BNB", "fromCoinAmount": 0.00137386 } }, "success": true } ``` --- ## Document: /products/connect-2.0/on-ramp-buy-apis/5.pre-order URL: /zh-CN/docs/products/connect-2.0/on-ramp-buy-apis/5.pre-order # Pre order ``` POST /papi/v1/ramp/connect/buy/pre-order ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | -------------------- | -------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | externalOrderId | string | Yes | The unique order id from the partner side. Supports only letters and numbers. | | fiatCurrency | string | No | Fiat currency. If you don't want to specify it or cannot specify it, you can leave it null and Binance Connect will automatically select/recommend a default fiat currency. | | cryptoCurrency | string | No | Crypto currency. If you don't want to specify it or cannot specify it, you can leave it null and Binance Connect will automatically select/recommend a default crypto currency. (But for `SEND_PRIMARY` it's mandatory) | | amountType | int | Yes | Specify whether the requested amount is in fiat:1 or crypto:2 | | requestedAmount | string | No | Requested amount. Fraction is 8 | | payMethodCode | string | No | The payment method code is from payment method list API. If you don't want to specify it or cannot specify it, you can leave it null and Binance Connect will automatically select/recommend a default payment method. | | payMethodSubCode | string | No | The payment method subcode is from payment method list API. If you don't want to specify it or cannot specify it, you can leave it null and Binance Connect will automatically select/recommend a default payment method. | | network | string | Yes | crypto network | | address | string | Yes | wallet address | | memo | string | No | If blockchain required | | redirectUrl | string | No | The redirectUrl is for redirecting to your website if order is completed | | failRedirectUrl | string | No | The redirectUrl is for redirecting to your website if order is failed | | redirectDeepLink | string | No | The redirectDeepLink is for redirecting to your APP if order is completed | | failRedirectDeepLink | string | No | The failRedirectDeepLink is for redirecting to your APP if order is failed | | clientIp | string | No | The original client IP | | clientType | string | No | The original client type: web/mobile | | customization | object | No | Customization settings for the current order. Please refer to "[Customization](../basics/9.customization.md)". | | contractAddress | string | No | Crypto contract address. required if buying a token that is not listed on Binance spot | | gtrTemplateCode | string | No | GTR (Global travel rule) template code. When users need to submit GTR questionnaire, this field can be used to specify the corresponding template answers for pre-filling the questionnaire form. | | affiliateCode | string | No | The Binance referral code that you can use to earn revenue share from registered users. Note: this feature is disabled by default. Please contact us for more detail. | ### Response Body | **Field** | **Type** | **Remarks** | | -------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | link | string | The landing page link of Binance Connect. For information on how to use it, please refer to "[Landing page and redirection](../basics/8.landing-page-and-redirection.md)". | | linkExpireTime | timestamp | The expiration time of link | # ### Example 1 Request Parameters: ```json { "externalOrderId": "946972922319", "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "amountType": 1, "requestedAmount": "100", "payMethodCode": "BUY_P2P", "payMethodSubCode": "BANK", "network": "ETH", "address": "0xbb4CdB9CBd3AB01bD10BaEBF2De08d9173bc095c", "redirectUrl": "https://test.examplepartner.com/buy/home", "failRedirectUrl": "https://test.examplepartner.com/buy/order/failure", "redirectDeepLink": "examplepartner://buy/home", "failRedirectDeepLink": "examplepartner://buy/order/failure", "clientIp": "154.55.51.218", "customization": { "SKIP_CASHIER": false, "AUTO_REDIRECTION": true } } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "link": "https://app.binance.com/uni-qr/qccnt?amount=800&channel=card&cryptoCurrency=USDT&externalOrderId=676972925203314539&fiatCurrency=EUR&merchantCode=example-partner&paymentMethodCode=BUY_CARD&sign=a6fdb970954b3407e63c2518307bd42b8b1de3fb128914a9f5b926077efcec5f&utm_campaign=connect_open_api&utm_source=test", "linkExpireTime": 1742222863560 } } ``` ### Example 2 Request Parameters: ```json { "externalOrderId": "599518801876", "contractAddress": "0x09f4eBB8567ea0e969f10799CA678F9A172DC2Bb", "fiatCurrency": "EUR", "fiatAmount": "150", "address": "0x41B2E5C72cZB21fB69de8243244AF6F124b2673a", "network": "BSC", "gtrTemplateCode": "TRAVEL_001", "affiliateCode": "test" } ``` Response: ```json { "code": "000000", "message": "success", "data": { "link": "https://app.binance.com/uni-qr/ccnt?amount=150&baseCurrency=EUR&channel&cryptoCurrency=USDT&externalOrderId=599518801876&fiatCurrency=EUR&merchantCode=example-partner&paymentMethodCode®isterChannel=example-partner&sign=dd0a9e3e646d2ce3910d64811a9db46535d756a20650d56e190793a94d03727b&type=1&utm_campaign=connect_open_api&utm_source=test", "linkExpireTime": 1747128070729 }, "success": true } ``` ### Example - lock crypto amount & NET_RECEIVE Request Parameters: ```json { "externalOrderId": "946972922319", "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "amountType": 2, "requestedAmount": "200", "payMethodCode": "BUY_CARD", "payMethodSubCode": "card", "network": "BSC", "address": "0xbb4CdB9CBd3AB01bD10BaEBF2De08d9173bc095c", "redirectUrl": "https://test.examplepartner.com/buy/home", "failRedirectUrl": "https://test.examplepartner.com/buy/order/failure", "redirectDeepLink": "examplepartner://buy/home", "failRedirectDeepLink": "examplepartner://buy/order/failure", "clientIp": "154.55.51.218", "customization": { "LOCK_ORDER_ATTRIBUTES": [6], "SEND_PRIMARY": true, "NET_RECEIVE": true } } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "link": "https://app.binance.com/uni-qr/qccnt?amount=800&channel=card&cryptoCurrency=USDT&externalOrderId=676972925203314539&fiatCurrency=EUR&merchantCode=example-partner&paymentMethodCode=BUY_CARD&sign=a6fdb970954b3407e63c2518307bd42b8b1de3fb128914a9f5b926077efcec5f&utm_campaign=connect_open_api&utm_source=test", "linkExpireTime": 1742222863560 } } ``` --- ## Document: /products/connect-2.0/on-ramp-buy-apis/4.get-estimated-quote URL: /zh-CN/docs/products/connect-2.0/on-ramp-buy-apis/4.get-estimated-quote # Get estimated quote ``` POST /papi/v1/ramp/connect/buy/estimated-quote ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | ---------------- | -------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | fiatCurrency | string | Yes | fiat currency | | cryptoCurrency | string | No | crypto currency. Either `cryptoCurrency` or `contractAddress` must be provided. | | requestedAmount | string | Yes | Requested amount. Fraction is 8 | | amountType | int | Yes | Specify whether the total amount is in fiat:1 or crypto:2 | | payMethodCode | string | No | The payment method code is from payment method list API. If no value is provided for payMethodCode, the API will return the best price along with its corresponding payMethodCode, refer to example 5&6. | | payMethodSubCode | string | No | The payment method sub code is from payment method list API. If no value is provided for both payMethodCode and payMethodSubCode, the API will return the best price along with its corresponding payMethodCode and payMethodSubCode, refer to example 5&6. If only a value of payMethodCode is provided, but no value of payMethodSubCode is provided, the best price and its corresponding payMethodSubCode returned will be the best quote and payment method within the category of the specified payMethodCode. | | network | string | No | crypto network. required if contractAddress has value | | address | string | No | the user wallet address, required if contractAddress has value | | contractAddress | string | No | crypto contract address. required if buying a token that is not listed on Binance spot | ### Response Body | **Field** | **Type** | **Remarks** | | ---------------- | -------- | ------------------------------------------------------------------------------- | | totalAmount | string | total amount in crypto (when amountType is 1) or in fiat (when amountType is 2) | | quotePrice | string | quote price | | feeAmount | string | fee amount | | feeCurrency | string | fee currency, fiat currency or crypto | | networkFee | string | network fee amount | | payMethodCode | string | The payment method code supported by this quote | | payMethodSubCode | string | The payment method sub code supported by this quote | # ### Example 1 Request Parameters: ```json { "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "requestedAmount": "100", "amountType": 1, "payMethodCode": "BUY_CARD", "payMethodSubCode": "card", "network": "ETH" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "totalAmount": "93.64179386", "quotePrice": "1.04654125", "feeAmount": "2", "feeCurrency": "EUR", "networkFee": "0.03", "payMethodCode": "BUY_CARD", "payMethodSubCode": "card" } } ``` User selects to buy crypto with Card (VISA/Mastercard), and prefers "specify fiat currency amount" (amountType: 1) to buy USDT with 100 EUR (requestedAmount). The estimated quote (quotePrice) is 1.04654125 EUR/USDT. After deducting the estimated total fees (feeAmount) of 2 EUR, the estimated final amount of USDT received (totalAmount) is 93.64179386 USDT. Here, totalAmount is calculated as "(requestedAmount - feeAmount) / quotePrice", that is, (100 - 2) / 1.04654125 = 93.64179386. In addition, the blockchain network fee (networkFee) is 0.03 USDT, which will be deducted from the withdrawal amount when processing withdrawal. ### Example 2 Request Parameters: ```json { "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "requestedAmount": 100, "amountType": 2, "payMethodCode": "BUY_CARD", "payMethodSubCode": "card", "network": "ETH" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "totalAmount": "106.79", "quotePrice": "1.04654125", "feeAmount": "2.14", "feeCurrency": "EUR", "networkFee": "0.03", "payMethodCode": "BUY_CARD", "payMethodSubCode": "card" } } ``` User selects to buy crypto with Card (VISA/Mastercard), and prefers "specify crypto amount" (amountType: 2) to buy 100 USDT (requestedAmount) with EUR. The estimated quote (quotePrice) is 1.04654125 EUR/USDT. After adding the estimated total fees (feeAmount) of 2.14 EUR, the estimated final amount of fiat currency to be paid (totalAmount) is 106.79 EUR. Here, totalAmount is calculated as "requestedAmount _ quotePrice + feeAmount", that is, 100 _ 1.04654125 + 2.14 = 106.79. In addition, the blockchain network fee (networkFee) is 0.03 USDT, which will be deducted from the withdrawal amount when processing withdrawal. ### Example 3 Request Parameters: ```json { "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "requestedAmount": 100, "amountType": 1, "payMethodCode": "BUY_P2P", "payMethodSubCode": "BANK", "network": "ETH" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "totalAmount": "107.6923", "quotePrice": "0.91", "feeAmount": "2.1978", "feeCurrency": "USDT", "networkFee": "0.03", "payMethodCode": "BUY_P2P", "payMethodSubCode": "BANK" } } ``` User selects to buy crypto with P2P bank transfer, and prefers "specify fiat currency amount" (amountType: 1) to buy USDT with 100 EUR (requestedAmount). The estimated quote (quotePrice) is 0.91 EUR/USDT. After deducting the estimated total fees (feeAmount) of 2.1978 USDT, the estimated final amount of USDT received (totalAmount) is 107.6923 USDT. Here, totalAmount is calculated as "requestedAmount / quotePrice - feeAmount", that is, 100 / 0.91 - 2.1978 = 107.6923. In addition, the blockchain network fee (networkFee) is 0.03 USDT, which will be deducted from the withdrawal amount when processing withdrawal. ### Example 4 Request Parameters: ```json { "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "requestedAmount": 100, "amountType": 2, "payMethodCode": "BUY_P2P", "payMethodSubCode": "BANK", "network": "ETH" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "totalAmount": "92.857", "quotePrice": "0.91", "feeAmount": "2.04081", "feeCurrency": "USDT", "networkFee": "0.03", "payMethodCode": "BUY_P2P", "payMethodSubCode": "BANK" } } ``` User selects to buy crypto with P2P bank transfer, and prefers "specify crypto amount" (amountType: 2) to buy 100 USDT (requestedAmount) with EUR. The estimated quote (quotePrice) is 0.91 EUR/USDT. After adding the estimated total fees (feeAmount) of 2.04081 USDT, the estimated final amount of fiat currency to be paid (totalAmount) is 92.857 EUR. Here, totalAmount is calculated as "(requestedAmount + feeAmount) _ quotePrice", that is, (100 + 2.04081) _ 0.91 = 92.857. In addition, the blockchain network fee (networkFee) is 0.03 USDT, which will be deducted from the withdrawal amount when processing withdrawal. ### Example 5 Request Parameters: ```json { "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "requestedAmount": 100, "amountType": 1, "network": "ETH" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "totalAmount": "93.64179386", "quotePrice": "1.04654125", "feeAmount": "2", "feeCurrency": "EUR", "networkFee": "0.03", "payMethodCode": "BUY_CARD", "payMethodSubCode": "card" } } ``` User selects to buy crypto and prefers "specify fiat currency amount" (amountType: 1) to buy USDT with 100 EUR (requestedAmount), but does not specify any payment method. The estimated quote (quotePrice) is 1.04654125 EUR/USDT, and the corresponding payment method is Card (VISA/Mastercard). After deducting the estimated total fees (feeAmount) of 2 EUR, the estimated final amount of USDT received (totalAmount) is 93.64179386 USDT. Here, totalAmount is calculated as "(requestedAmount - feeAmount) / quotePrice", that is, (100 - 2) / 1.04654125 = 93.64179386. In addition, the blockchain network fee (networkFee) is 0.03 USDT, which will be deducted from the withdrawal amount when processing withdrawal. ### Example 6 Request Parameters: ```json { "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "requestedAmount": 100, "amountType": 2, "network": "ETH" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "totalAmount": "92.857", "quotePrice": "0.91", "feeAmount": "2.04081", "feeCurrency": "USDT", "networkFee": "0.03", "payMethodCode": "BUY_P2P", "payMethodSubCode": "BANK" } } ``` User selects to buy crypto and prefers "specify crypto amount" (amountType: 2) to buy 100 USDT (requestedAmount) with EUR, but does not specify any payment method. The estimated quote (quotePrice) is 0.91 EUR/USDT, and the corresponding payment method is P2P bank transfer. After adding the estimated total fees (feeAmount) of 2.04081 USDT, the estimated final amount of fiat currency to be paid (totalAmount) is 92.857 EUR. Here, totalAmount is calculated as "(requestedAmount + feeAmount) _ quotePrice", that is, (100 + 2.04081) _ 0.91 = 92.857. In addition, the blockchain network fee (networkFee) is 0.03 USDT, which will be deducted from the withdrawal amount when processing withdrawal. ### Example 7 Request Parameters: ```json { "fiatCurrency": "EUR", "requestedAmount": 150, "amountType": 1, "network": "BSC", "contractAddress": "0x09f4eBB8567ea0e969f10799CA678F9A172DC2Bb", "address": "0x123457890abcdef1234567890a12e4ef12345678" } ``` Response: ```json { "code": "000000", "message": "success", "data": { "totalAmount": "1498537.975596644425339737", "quotePrice": "10091.27354635904781021", "feeAmount": "1.67", "feeCurrency": "USDT", "networkFee": "0.02982442", "payMethodCode": "BUY_CARD", "payMethodSubCode": "card" }, "success": true } ``` User opts to purchase meme crypto without specifying a payment method and chooses "specify fiat currency amount" (amountType: 1) to buy meme crypto worth 150 EUR (requestedAmount). --- ## Document: /products/connect-2.0/on-ramp-buy-apis/3.get-payment-method-list URL: /zh-CN/docs/products/connect-2.0/on-ramp-buy-apis/3.get-payment-method-list # Get payment method list ``` POST /papi/v1/ramp/connect/buy/payment-method-list ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | --------------- | -------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | fiatCurrency | string | Yes | fiat currency | | cryptoCurrency | string | No | crypto currency. Either `cryptoCurrency` or `contractAddress` must be provided. | | totalAmount | string | Yes | Requested amount | | amountType | int | Yes | Specify whether the total amount is in fiat:1 or crypto:2 | | language | string | No | Language code, which determines the multi-language of the content(if any, such as "payment method name") in the response data. If not passed, English is the default. The format is "[LanguageCode](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes)-[RegionCode](https://en.wikipedia.org/wiki/ISO_3166-1)", RegionCode is optional. | | network | string | No | crypto network. Different networks will have different `cryptoMinLimit` fields. required if contractAddress has value | | contractAddress | string | No | crypto contract address. required if buying a token that is not listed on Binance spot | ### Response Body ##### Data | **Field** | **Type** | **Remarks** | | -------------- | ------------ | --------------------------------------------- | | paymentMethods | object array | Payment methods. Refer to PaymentMethodObject | ##### PaymentMethodObject | **Field** | **Type** | **Remarks** | | --------------------- | -------- | ---------------------------------------------------------- | | payMethodCode | string | payment method code | | payMethodSubCode | string | payment method sub code | | paymentMethod | string | payment method display name | | fiatMinLimit | string | fiat min amount limit | | fiatMaxLimit | string | fiat max amount limit | | cryptoMinLimit | string | crypto min amount limit | | cryptoMaxLimit | string | crypto max amount limit | | p2p | bool | Indicate whether the payment method belongs to Binance P2P | | withdrawRestriction\* | int | 0: no restriction

1: T+1 restriction | > \*_Please refer to > [What Are the "T+1", "T+2", and "T+3" Withdrawal Limits?](https://www.binance.com/en/support/faq/what-are-the-t-1-t-2-and-t-3-withdrawal-limits-360037261532)_ # ### Example 1 Request Parameters: ```json { "fiatCurrency": "EUR", "cryptoCurrency": "USDC", "totalAmount": "100", "amountType": 1, "language": "en-US", "network": "BSC" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "paymentMethods": [ { "payMethodCode": "BUY_WALLET", "payMethodSubCode": "Wallet", "paymentMethod": "Spot Account", "fiatMinLimit": "12.73251855", "fiatMaxLimit": "12500", "cryptoMinLimit": "10", "cryptoMaxLimit": "14669.77658106", "p2p": false, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_REVOLUT", "payMethodSubCode": "REVOLUT", "paymentMethod": "Revolut Pay", "fiatMinLimit": "12.73251855", "fiatMaxLimit": "5000", "cryptoMinLimit": "11.61208147", "cryptoMaxLimit": "5806.04073251", "p2p": false, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_CARD", "payMethodSubCode": "card", "paymentMethod": "Card (VISA/Mastercard)", "fiatMinLimit": "12.73251855", "fiatMaxLimit": "5000", "cryptoMinLimit": "11.6112052", "cryptoMaxLimit": "5805.60260158", "p2p": false, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_GOOGLE_PAY", "payMethodSubCode": "GOOGLE_PAY", "paymentMethod": "Google Pay (VISA/Mastercard)", "fiatMinLimit": "12.73251855", "fiatMaxLimit": "5000", "cryptoMinLimit": "11.6112052", "cryptoMaxLimit": "5805.60260158", "p2p": false, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_APPLE_PAY", "payMethodSubCode": "APPLE_PAY", "paymentMethod": "Apple Pay (VISA/Mastercard)", "fiatMinLimit": "12.73251855", "fiatMaxLimit": "5000", "cryptoMinLimit": "11.6112052", "cryptoMaxLimit": "5805.60260158", "p2p": false, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_P2P", "payMethodSubCode": "BANK", "paymentMethod": "Bank Transfer", "fiatMinLimit": "12.73251855", "fiatMaxLimit": "69116", "cryptoMinLimit": "10.7066", "cryptoMaxLimit": "74079.77696577", "p2p": true, "withdrawRestriction": 1 }, { "payMethodCode": "BUY_P2P", "payMethodSubCode": "Cash", "paymentMethod": "Cash Payment", "fiatMinLimit": "10", "fiatMaxLimit": "1009", "cryptoMinLimit": "0.8543", "cryptoMaxLimit": "940.87", "p2p": true, "withdrawRestriction": 1 }, { "payMethodCode": "BUY_P2P", "payMethodSubCode": "ALIPAY", "paymentMethod": "Alipay", "fiatMinLimit": "10", "fiatMaxLimit": "1009", "cryptoMinLimit": "0.8543", "cryptoMaxLimit": "940.87", "p2p": true, "withdrawRestriction": 1 }, { "payMethodCode": "BUY_P2P", "payMethodSubCode": "Paypal", "paymentMethod": "PayPal", "fiatMinLimit": "10", "fiatMaxLimit": "1009", "cryptoMinLimit": "0.8543", "cryptoMaxLimit": "940.87", "p2p": true, "withdrawRestriction": 1 } ] } } ``` ### Example 2 Request Parameters: ```json { "fiatCurrency": "EUR", "totalAmount": 100, "amountType": 1, "contractAddress": "0x09f4eBB8567ea0e969f10799CA678F9A172DC2Bb", "network": "BSC" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "paymentMethods": [ { "payMethodCode": "BUY_WALLET", "payMethodSubCode": "Wallet", "paymentMethod": "Spot Wallet", "fiatMinLimit": "15", "fiatMaxLimit": "10000", "cryptoMinLimit": "16.10699996", "cryptoMaxLimit": "10737.99997363", "p2p": false, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_CARD", "payMethodSubCode": "card", "paymentMethod": "Card (VISA/Mastercard)", "fiatMinLimit": "15", "fiatMaxLimit": "5000", "cryptoMinLimit": "16.10699996", "cryptoMaxLimit": "5368.99998681", "p2p": false, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_GOOGLE_PAY", "payMethodSubCode": "GOOGLE_PAY", "paymentMethod": "Google Pay", "fiatMinLimit": "15", "fiatMaxLimit": "5000", "cryptoMinLimit": "16.10699996", "cryptoMaxLimit": "5368.99998681", "p2p": false, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_APPLE_PAY", "payMethodSubCode": "APPLE_PAY", "paymentMethod": "Apple Pay", "fiatMinLimit": "15", "fiatMaxLimit": "5000", "cryptoMinLimit": "16.10699996", "cryptoMaxLimit": "5368.99998681", "p2p": false, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_P2P", "payMethodSubCode": "BANK", "paymentMethod": "Bank Transfer", "fiatMinLimit": "10", "fiatMaxLimit": "1009", "cryptoMinLimit": "0.8543", "cryptoMaxLimit": "940.87", "p2p": true, "withdrawRestriction": 1 }, { "payMethodCode": "BUY_P2P", "payMethodSubCode": "Cash", "paymentMethod": "Cash Payment", "fiatMinLimit": "10", "fiatMaxLimit": "1009", "cryptoMinLimit": "0.8543", "cryptoMaxLimit": "940.87", "p2p": true, "withdrawRestriction": 1 }, { "payMethodCode": "BUY_P2P", "payMethodSubCode": "ALIPAY", "paymentMethod": "Alipay", "fiatMinLimit": "10", "fiatMaxLimit": "1009", "cryptoMinLimit": "0.8543", "cryptoMaxLimit": "940.87", "p2p": true, "withdrawRestriction": 1 }, { "payMethodCode": "BUY_P2P", "payMethodSubCode": "Paypal", "paymentMethod": "PayPal", "fiatMinLimit": "10", "fiatMaxLimit": "1009", "cryptoMinLimit": "0.8543", "cryptoMaxLimit": "940.87", "p2p": true, "withdrawRestriction": 1 } ] } } ``` ### Example 3 Request Parameters: ```json { "fiatCurrency": "BRL", "cryptoCurrency": "USDC", "totalAmount": 100, "amountType": 1, "network": "BSC" } ``` Response: ```json { "code": "000000", "message": "success", "data": { "paymentMethods": [ { "payMethodCode": "BUY_WALLET", "payMethodSubCode": "Wallet", "paymentMethod": "Spot Account", "fiatMinLimit": "81.1467441", "fiatMaxLimit": "86000", "cryptoMinLimit": "10", "cryptoMaxLimit": "15707.36039127", "p2p": false, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_LATAM_GATEWAY_ONLINE_BANKING_PIX", "payMethodSubCode": "LATAM_GATEWAY", "paymentMethod": "Bank Transfer (PIX)", "fiatMinLimit": "81.1467441", "fiatMaxLimit": "63000", "cryptoMinLimit": "10", "cryptoMaxLimit": "11437.74266192", "p2p": false, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_CARD", "payMethodSubCode": "card", "paymentMethod": "Card (VISA/Mastercard)", "fiatMinLimit": "100", "fiatMaxLimit": "60000", "cryptoMinLimit": "17.52411339", "cryptoMaxLimit": "10514.46803156", "p2p": false, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_P2P", "payMethodSubCode": "Pix", "paymentMethod": "Pix", "fiatMinLimit": "81.1467441", "fiatMaxLimit": "16674", "cryptoMinLimit": "10", "cryptoMaxLimit": "2880.84020217", "p2p": true, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_P2P", "payMethodSubCode": "BankBrazil", "paymentMethod": "Bank Transfer (Brazil)", "fiatMinLimit": "81.1467441", "fiatMaxLimit": "16674", "cryptoMinLimit": "10", "cryptoMaxLimit": "2880.84020217", "p2p": true, "withdrawRestriction": 0 }, { "payMethodCode": "BUY_P2P", "payMethodSubCode": "PicPay", "paymentMethod": "PicPay", "fiatMinLimit": "81.1467441", "fiatMaxLimit": "16674", "cryptoMinLimit": "10", "cryptoMaxLimit": "2880.84020217", "p2p": true, "withdrawRestriction": 0 } ] }, "success": true } ``` ##### About payment method "BUY_WALLET" "BUY_WALLET" is a special payment method that allows users to buy crypto using the user's fiat currency balance in Binance wallet. For example, in some countries or regions, users can deposit fiat currency (such as euro - EUR) to Binance. When the user has EUR balance in the Binance wallet, he can use EUR to buy crypto. We call this payment method as "BUY_WALLET". --- ## Document: /products/connect-2.0/on-ramp-buy-apis/2.get-crypto-networks URL: /zh-CN/docs/products/connect-2.0/on-ramp-buy-apis/2.get-crypto-networks # Get supported crypto networks ``` POST /papi/v1/ramp/connect/crypto-network ``` ### Request Body No request body ### Response Body ##### Data: CryptoNetworkObject array ###### CryptoNetworkObject | **Field** | **Type** | **Remarks** | | -------------- | ------------ | -------------------------------------------- | | cryptoCurrency | string | fiat currency list | | networks | object array | Network detail. Refer to NetworkDetailObject | ###### NetworkDetailObject | **Field** | **Type** | **Remarks** | | ----------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | network | string | Network name. E.g ETH, BSC, ARBITRUM, SOL, OPTIMISM, BASE | | addressRegex | string array | Network address regex | | memoRegex | string | Memo regex | | withdrawFee | string | Withdraw fee | | withdrawMinAmount | string | Withdraw min amount | | withdrawMaxAmount | string | Withdraw max amount | | contractAddress | string | Contract address | | withdrawEnable | boolean | is withdraw enabled | | depositEnable | boolean | is deposit enabled | | depositDust | string | Minimum deposit amount for this network. Deposits below this amount may not be credited. Used by the [Deposit](../deposit/0.typical-flow.md) feature | # ### Example Response: ```json { "success": true, "code": "000000", "message": "success", "data": [ { "cryptoCurrency": "ETH", "networks": [ { "network": "BSC", "addressRegex": "^(0x)[0-9A-Fa-f]{40}$", "memoRegex": "", "withdrawFee": 115.0, "withdrawMinAmount": 230.0, "withdrawMaxAmount": 555.0, "contractAddress": "0x2170ed0880ac9a755fd29b2688956bd959f933f8", "withdrawEnable": false, "depositEnable": false, "depositDust": "0.00001" }, { "network": "ETH", "addressRegex": "^(0x)[0-9A-Fa-f]{40}$", "memoRegex": "", "withdrawFee": 0.0, "withdrawMinAmount": 1e-8, "withdrawMaxAmount": 9999999.0, "contractAddress": "0x7190ed0880ac9a755fd29b26f8956bd959f933f2", "withdrawEnable": true, "depositEnable": true, "depositDust": "0.00001" } ] }, { "cryptoCurrency": "ORDI", "networks": [ { "network": "ORDIBTC", "addressRegex": "^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^[(bc1q)|(bc1p)][0-9A-Za-z]{37,62}$", "memoRegex": "", "withdrawFee": 0.0, "withdrawMinAmount": 0.01, "withdrawMaxAmount": 9999999.0, "contractAddress": "b61b0172d95e266c18aea0c624db987e971a5d6d4ebc2aaed85da4642d635735i0", "withdrawEnable": true, "depositEnable": true, "depositDust": "0.01" } ] } ] } ``` --- ## Document: /products/connect-2.0/on-ramp-buy-apis/1.get-trading-pairs URL: /zh-CN/docs/products/connect-2.0/on-ramp-buy-apis/1.get-trading-pairs # Get supported trading pairs ``` POST /papi/v1/ramp/connect/buy/trading-pairs ``` ### Request Body No request body ### Response Body | **Field** | **Type** | **Remarks** | | ---------------- | ------------ | -------------------- | | fiatCurrencies | string array | fiat currency list | | cryptoCurrencies | string array | crypto currency list | # ### Example Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "fiatCurrencies": ["USD", "EUR", "VND", "AUD", "TWD", "DEFAULT"], "cryptoCurrencies": ["BTC", "ETH", "BNB", "USDT", "USDC", "DAI"] } } ``` --- ## Document: /products/connect-2.0/on-ramp-buy-apis/0.typical-flow URL: /zh-CN/docs/products/connect-2.0/on-ramp-buy-apis/0.typical-flow # Typical Buy Flow ## Overview This document describes the standard cryptocurrency purchase flow using Binance Connect's on-ramp service. The sequence diagram below illustrates the interaction between partner systems and Binance Connect APIs throughout the purchase process. ## Flow Steps ### 1. Initialize - Partner frontend renders the buy interface for users - Backend provides necessary configuration and settings (when applicable) ### 2. Query Options - Fetch supported blockchain networks for crypto delivery - Retrieve available trading pairs - Get supported payment methods - Return data to the frontend - You can be done in parallel. Depending on your UI/UX design, you may choose to call these APIs in different sequences. ### 3. Get Quote - Request real-time price quote for the selected trading pair, payment method and amount - Display quote information to the user ### 4. Create PreOrder - Submit pre-order request to Binance Connect with user's selection - Receive a redirect URL for payment processing ### 5. Payment - Redirect user to Binance - User completes the purchase using their preferred payment method - Binance processes the transaction ### 6. Confirmation - Receive webhook notifications for order status updates - Query order details to confirm final transaction status - Update user interface with purchase results and crypto delivery details ![buy-flow.png](../images/buy-flow.png) --- ## Document: /products/connect-2.0/off-ramp-sell-apis/5.get-payment-method-list-v2 URL: /zh-CN/docs/products/connect-2.0/off-ramp-sell-apis/5.get-payment-method-list-v2 # Get payment method list v2 ``` POST /papi/v2/ramp/connect/sell/payment-method-list ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | --------- | -------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | language | string | No | Language code, which determines the multi-language of the content(if any, such as "payment method name") in the response data. If not passed, English is the default. The format is "[LanguageCode](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes)-[RegionCode](https://en.wikipedia.org/wiki/ISO_3166-1)", RegionCode is optional. | ### Response Body ##### Data: PaymentMethodV2Object array | **Field** | **Type** | **Remarks** | | -------------- | ------------ | ------------------------------------------------------------ | | fiatCurrency | string | Fiat currency | | paymentMethods | object array | Payment method details. Refer to PaymentMethodV2DetailObject | ##### PaymentMethodV2DetailObject | **Field** | **Type** | **Remarks** | | ---------------- | -------- | ---------------------------------------------------------- | | payMethodCode | string | payment method code | | payMethodSubCode | string | payment method sub code | | paymentMethod | string | payment method display name | | p2p | bool | Indicate whether the payment method belongs to Binance P2P | # ### Example Request Parameters: ```json { "language": "zh-CN" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": [ { "fiat": "AED", "paymentMethods": [ { "paymentMethodCode": "SELL_APPLE_PAY", "channelCode": "APPLE_PAY", "paymentMethod": "Apple Pay (VISA)", "p2p": false }, { "paymentMethodCode": "SELL_P2P", "channelCode": "BANK", "paymentMethod": "Bank", "p2p": true }, { "paymentMethodCode": "SELL_P2P", "channelCode": "Paypal", "paymentMethod": "PayPal", "p2p": true } ] }, { "fiat": "EUR", "paymentMethods": [ { "paymentMethodCode": "SELL_WALLET", "channelCode": "Wallet", "paymentMethod": "Spot Wallet", "p2p": false }, { "paymentMethodCode": "SELL_CARD", "channelCode": "card", "paymentMethod": "Card (VISA/Mastercard)", "p2p": false }, { "paymentMethodCode": "SELL_P2P", "channelCode": "SEPA", "paymentMethod": "SEPA (EU) bank transfer", "p2p": true } ] }, { "fiat": "CNY", "paymentMethods": [ { "paymentMethodCode": "SELL_P2P", "channelCode": "ALIPAY", "paymentMethod": "Alipay English", "p2p": true }, { "paymentMethodCode": "SELL_P2P", "channelCode": "BANK", "paymentMethod": "Bank", "p2p": true }, { "paymentMethodCode": "SELL_P2P", "channelCode": "WECHAT", "paymentMethod": "WeChat", "p2p": true } ] } ] } ``` ##### About payment method "SELL_WALLET" "SELL_WALLET" is a special payment method that allows users to sell crypto for fiat currency balances in their Binance wallets. For example, in some countries or regions, Binance supports users to deposit and withdraw fiat currencies (such as euro - EUR) directly. At this time, users can sell crypto for EUR (in Binance wallet). We call this payment method as "SELL_WALLET". --- ## Document: /products/connect-2.0/off-ramp-sell-apis/4.pre-order URL: /zh-CN/docs/products/connect-2.0/off-ramp-sell-apis/4.pre-order # Pre order ``` POST /papi/v1/ramp/connect/sell/pre-order ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | -------------------- | -------- | ------------- | -------------------------------------------------------------------------------------------------------------- | | externalOrderId | string | Yes | The unique order id from the partner side. Supports only letters and numbers. | | fiatCurrency | string | Yes | fiat currency | | cryptoCurrency | string | Yes | crypto currency | | amountType | int | Yes | Specify whether the requested amount is in fiat:1 or crypto:2 | | requestedAmount | string | Yes | Requested amount. Fraction is 8 | | payMethodCode | string | Yes | The payment method code is from payment method list API | | payMethodSubCode | string | Yes | The payment method subcode is from payment method list API | | network | string | Yes | crypto network | | redirectUrl | string | No | The redirectUrl is for redirecting to your website if order is completed | | failRedirectUrl | string | No | The redirectUrl is for redirecting to your website if order is failed | | redirectDeepLink | string | No | The redirectDeepLink is for redirecting to your APP if order is completed | | failRedirectDeepLink | string | No | The failRedirectDeepLink is for redirecting to your APP if order is failed | | clientIp | string | No | The original client IP | | clientType | string | No | The original client type: web/mobile | | customization | object | No | Customization settings for the current order. Please refer to "[Customization](../basics/9.customization.md)". | ### Response Body | **Field** | **Type** | **Remarks** | | -------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | link | string | The landing page link of Binance Connect. For information on how to use it, please refer to "[Landing page and redirection](../basics/8.landing-page-and-redirection.md)". | | linkExpireTime | timestamp | The expiration time of link | # ### Example Request Parameters: ```json { "externalOrderId": "8746972922319", "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "amountType": 1, "requestedAmount": "100", "payMethodCode": "SELL_P2P", "payMethodSubCode": "BANK", "network": "ETH", "redirectUrl": "https://test.examplepartner.com/sell/home", "failRedirectUrl": "https://test.examplepartner.com/sell/order/failure", "redirectDeepLink": "examplepartner://sell/home", "failRedirectDeepLink": "examplepartner://sell/order/failure", "clientIp": "154.55.51.218", "customization": { "LOCK_ORDER_ATTRIBUTES": [2, 3], "SKIP_CASHIER": false, "AUTO_REDIRECTION": true } } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "link": "https://app.binance.com/uni-qr/qccnt?amount=1300&baseCurrency=EUR&channel=P2P&cryptoCurrency=USDT&externalOrderId=946972925243314539&fiatCurrency=EUR&merchantCode=example-partner&paymentMethodCode=SELL_P2P&paymentmethod=BANK&sign=c267bcfe69d5e263u9ee6e5cdc374e3a958a1d00a06b9efcdf19e33dca3407e4&type=2&utm_campaign=connect_open_api&utm_source=test", "linkExpireTime": 1742222312058 } } ``` --- ## Document: /products/connect-2.0/off-ramp-sell-apis/3.get-estimated-quote URL: /zh-CN/docs/products/connect-2.0/off-ramp-sell-apis/3.get-estimated-quote # Get estimated quote ``` POST /papi/v1/ramp/connect/sell/estimated-quote ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | ---------------- | -------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | fiatCurrency | string | Yes | fiat currency | | cryptoCurrency | string | Yes | crypto currency | | requestedAmount | string | Yes | Requested amount. Fraction is 8 | | amountType | int | Yes | Specify whether the total amount is in fiat:1 or crypto:2 | | payMethodCode | string | No | The payment method code is from payment method list API. If no value is provided for payMethodCode, the API will return the best price along with its corresponding payMethodCode, refer to example 5&6. | | payMethodSubCode | string | No | The payment method sub code is from payment method list API. If the payMethodCode is SELL_P2P, you must provide a value for payMethodSubCode. Otherwise, there is no need to provide a value for payMethodSubCode. | | network | string | No | crypto network | ### Response Body | **Field** | **Type** | **Remarks** | | ---------------- | -------- | ------------------------------------------------------------------------------- | | totalAmount | string | total amount in crypto (when amountType is 1) or in fiat (when amountType is 2) | | quotePrice | string | quote price | | feeAmount | string | fee amount | | feeCurrency | string | fee currency, fiat currency or crypto | | payMethodCode | string | The payment method code supported by this quote | | payMethodSubCode | string | The payment method sub code supported by this quote | # ### Example 1 Request Parameters: ```json { "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "requestedAmount": "100", "amountType": 1, "payMethodCode": "SELL_CARD", "payMethodSubCode": "card", "network": "ETH" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "totalAmount": "109.24891691", "quotePrice": "0.9336477", "feeAmount": "2", "feeCurrency": "EUR", "payMethodCode": "SELL_CARD", "payMethodSubCode": "card" } } ``` User selects to sell crypto with Card (VISA/Mastercard), and prefers "specify fiat currency amount" (amountType: 1) to sell USDT for 100 EUR (requestedAmount). The estimated quote (quotePrice) is 0.9336477 EUR/USDT. After adding the estimated total fees (feeAmount) of 2 EUR, the estimated final amount of crypto to be deducted (totalAmount) is 109.24891691 USDT. Here, totalAmount is calculated as "(requestedAmount + feeAmount) / quotePrice", that is, (100 + 2) / 0.9336477 = 109.24891691. ### Example 2 Request Parameters: ```json { "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "requestedAmount": 100, "amountType": 2, "payMethodCode": "SELL_CARD", "payMethodSubCode": "card", "network": "ETH" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "totalAmount": "91.56", "quotePrice": "0.93368279", "feeAmount": "1.8", "feeCurrency": "EUR", "payMethodCode": "SELL_CARD", "payMethodSubCode": "card" } } ``` User selects to sell crypto with Card (VISA/Mastercard), and prefers "specify crypto amount" (amountType: 2) to sell 100 USDT (requestedAmount) with EUR. The estimated quote (quotePrice) is 0.93368279 EUR/USDT. After deducting the estimated total fees (feeAmount) of 1.8 EUR, the estimated final amount of fiat currency received (totalAmount) is 91.56 EUR. Here, totalAmount is calculated as "requestedAmount _ quotePrice - feeAmount", that is, 100 _ 0.93368279 - 1.8 = 91.56. ### Example 3 Request Parameters: ```json { "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "requestedAmount": 100, "amountType": 1, "payMethodCode": "SELL_P2P", "payMethodSubCode": "BANK", "network": "ETH" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "totalAmount": "104.91278351", "quotePrice": "0.97", "feeAmount": "1.82", "feeCurrency": "USDT", "payMethodCode": "SELL_P2P", "payMethodSubCode": "BANK" } } ``` User selects to sell crypto with P2P bank transfer, and prefers "specify fiat currency amount" (amountType: 1) to sell USDT for 100 EUR (requestedAmount). The estimated quote (quotePrice) is 0.97 EUR/USDT. After adding the estimated total fees (feeAmount) of 1.82 USDT, the estimated final amount of crypto to be deducted (totalAmount) is 104.91278351 USDT. Here, totalAmount is calculated as "requestedAmount / quotePrice + feeAmount”, that is, 100 / 0.97 + 1.82 = 104.91278351. ### Example 4 Request Parameters: ```json { "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "requestedAmount": 100, "amountType": 2, "payMethodCode": "SELL_P2P", "payMethodSubCode": "BANK", "network": "ETH" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "totalAmount": "95.2346", "quotePrice": "0.97", "feeAmount": "1.82", "feeCurrency": "USDT", "payMethodCode": "SELL_P2P", "payMethodSubCode": "BANK" } } ``` User selects to sell crypto with P2P bank transfer, and prefers "specify crypto amount" (amountType: 2) to sell 100 USDT (requestedAmount) with EUR. The estimated quote (quotePrice) is 0.97 EUR/USDT. After deducting the estimated total fees (feeAmount) of 1.82 USDT, the estimated final amount of fiat currency received (totalAmount) is 95.2346 EUR. Here, totalAmount is calculated as “(requestedAmount - feeAmount) _ quotePrice”, that is, (100 - 1.82) _ 0.97 = 95.2346. ### Example 5 Request Parameters: ```json { "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "requestedAmount": 100, "amountType": 1, "network": "ETH" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "totalAmount": "109.24891691", "quotePrice": "0.9336477", "feeAmount": "2", "feeCurrency": "EUR", "payMethodCode": "SELL_CARD", "payMethodSubCode": "card" } } ``` User selects to sell crypto and prefers "specify fiat currency amount" (amountType: 1) to sell USDT for 100 EUR (requestedAmount), but does not specify any payment method. The estimated quote (quotePrice) is 0.9336477 EUR/USDT, and the corresponding payment method is Card (VISA/Mastercard). After adding the estimated total fees (feeAmount) of 2 EUR, the estimated final amount of crypto to be deducted (totalAmount) is 109.24891691 USDT. Here, totalAmount is calculated as "(requestedAmount + feeAmount) / quotePrice", that is, (100 + 2) / 0.9336477 = 109.24891691. ### Example 6 Request Parameters: ```json { "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "requestedAmount": 100, "amountType": 2, "network": "ETH" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "totalAmount": "95.2346", "quotePrice": "0.97", "feeAmount": "1.82", "feeCurrency": "USDT", "payMethodCode": "SELL_P2P", "payMethodSubCode": "BANK" } } ``` User selects to sell crypto and prefers "specify crypto amount" (amountType: 2) to sell 100 USDT (requestedAmount) with EUR, but does not specify any payment method. The estimated quote (quotePrice) is 0.97 EUR/USDT, and the corresponding payment method is P2P bank transfer. After deducting the estimated total fees (feeAmount) of 1.82 USDT, the estimated final amount of fiat currency received (totalAmount) is 95.2346 EUR. Here, totalAmount is calculated as “(requestedAmount - feeAmount) _ quotePrice”, that is, (100 - 1.82) _ 0.97 = 95.2346. --- ## Document: /products/connect-2.0/off-ramp-sell-apis/2.get-payment-method-list URL: /zh-CN/docs/products/connect-2.0/off-ramp-sell-apis/2.get-payment-method-list # Get payment method list ``` POST /papi/v1/ramp/connect/sell/payment-method-list ``` ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | -------------- | -------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | fiatCurrency | string | Yes | fiat currency | | cryptoCurrency | string | Yes | crypto currency | | totalAmount | string | Yes | Requested amount | | amountType | int | Yes | Specify whether the total amount is in fiat:1 or crypto:2 | | language | string | No | Language code, which determines the multi-language of the content(if any, such as "payment method name") in the response data. If not passed, English is the default. The format is "[LanguageCode](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes)-[RegionCode](https://en.wikipedia.org/wiki/ISO_3166-1)", RegionCode is optional. | ### Response Body ##### Data | **Field** | **Type** | **Remarks** | | -------------- | ------------ | --------------------------------------------- | | paymentMethods | object array | Payment methods. Refer to PaymentMethodObject | ##### PaymentMethodObject | **Field** | **Type** | **Remarks** | | ---------------- | -------- | ---------------------------------------------------------- | | payMethodCode | string | payment method code | | payMethodSubCode | string | payment method sub code | | paymentMethod | string | payment method display name | | fiatMinLimit | string | fiat min amount limit | | fiatMaxLimit | string | fiat max amount limit | | cryptoMinLimit | string | crypto min amount limit | | cryptoMaxLimit | string | crypto max amount limit | | p2p | bool | Indicate whether the payment method belongs to Binance P2P | # ### Example Request Parameters: ```json { "fiatCurrency": "EUR", "cryptoCurrency": "USDT", "totalAmount": "100", "amountType": 1, "language": "zh-CN" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "paymentMethods": [ { "payMethodCode": "SELL_WALLET", "payMethodSubCode": "Wallet", "paymentMethod": "Spot Wallet", "fiatMinLimit": "15", "fiatMaxLimit": "10000", "cryptoMinLimit": "16.10699996", "cryptoMaxLimit": "10737.99997363", "p2p": false }, { "payMethodCode": "SELL_CARD", "payMethodSubCode": "card", "paymentMethod": "Card (VISA/Mastercard)", "fiatMinLimit": "15", "fiatMaxLimit": "5000", "cryptoMinLimit": "16.10699996", "cryptoMaxLimit": "5368.99998681", "p2p": false }, { "payMethodCode": "SELL_GOOGLE_PAY", "payMethodSubCode": "GOOGLE_PAY", "paymentMethod": "Google Pay", "fiatMinLimit": "15", "fiatMaxLimit": "5000", "cryptoMinLimit": "16.10699996", "cryptoMaxLimit": "5368.99998681", "p2p": false }, { "payMethodCode": "SELL_APPLE_PAY", "payMethodSubCode": "APPLE_PAY", "paymentMethod": "Apple Pay", "fiatMinLimit": "15", "fiatMaxLimit": "5000", "cryptoMinLimit": "16.10699996", "cryptoMaxLimit": "5368.99998681", "p2p": false }, { "payMethodCode": "SELL_P2P", "payMethodSubCode": "BANK", "paymentMethod": "Bank Transfer", "fiatMinLimit": "10", "fiatMaxLimit": "1009", "cryptoMinLimit": "0.8543", "cryptoMaxLimit": "940.87", "p2p": true }, { "payMethodCode": "SELL_P2P", "payMethodSubCode": "Cash", "paymentMethod": "Cash Payment", "fiatMinLimit": "10", "fiatMaxLimit": "1009", "cryptoMinLimit": "0.8543", "cryptoMaxLimit": "940.87", "p2p": true }, { "payMethodCode": "SELL_P2P", "payMethodSubCode": "ALIPAY", "paymentMethod": "Alipay", "fiatMinLimit": "10", "fiatMaxLimit": "1009", "cryptoMinLimit": "0.8543", "cryptoMaxLimit": "940.87", "p2p": true }, { "payMethodCode": "SELL_P2P", "payMethodSubCode": "Paypal", "paymentMethod": "PayPal", "fiatMinLimit": "10", "fiatMaxLimit": "1009", "cryptoMinLimit": "0.8543", "cryptoMaxLimit": "940.87", "p2p": true } ] } } ``` ##### About payment method "SELL_WALLET" "SELL_WALLET" is a special payment method that allows users to sell crypto for fiat currency balances in their Binance wallets. For example, in some countries or regions, Binance supports users to deposit and withdraw fiat currencies (such as euro - EUR) directly. At this time, users can sell crypto for EUR (in Binance wallet). We call this payment method as "SELL_WALLET". --- ## Document: /products/connect-2.0/off-ramp-sell-apis/1.get-trading-pairs URL: /zh-CN/docs/products/connect-2.0/off-ramp-sell-apis/1.get-trading-pairs # Get supported trading pairs ``` POST /papi/v1/ramp/connect/sell/trading-pairs ``` ### Request Body No request body ### Response Body | **Field** | **Type** | **Remarks** | | ---------------- | ------------ | -------------------- | | fiatCurrencies | string array | fiat currency list | | cryptoCurrencies | string array | crypto currency list | # ### Example Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "fiatCurrencies": ["USD", "EUR", "VND", "AUD", "TWD", "DEFAULT"], "cryptoCurrencies": ["BTC", "ETH", "BNB", "USDT", "USDC", "DAI"] } } ``` --- ## Document: /products/connect-2.0/deposit/6.deposit-status URL: /zh-CN/docs/products/connect-2.0/deposit/6.deposit-status # Deposit authorization status | **Code** | **Status** | **Description** | **Remarks** | | -------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | | 0 | INIT | The deposit session has been created via `/deposit/initiate`, but the user has not yet opened the Binance App or taken any action. | Partner should continue polling `/deposit/authorization`. | | 1 | AUTHORIZED | The user has authorized in the Binance App. Deposit addresses for all requested networks are available. | Terminal state. `depositAddresses` will be populated in the response. | | 2 | REJECTED | The user explicitly rejected the authorization request in the Binance App. | Terminal state. Partner may call `/deposit/initiate` again with a new `externalOrderId`. | | 3 | EXPIRED | The authorization window has expired without any user action. | Terminal state. Partner should call `/deposit/initiate` again with a new `externalOrderId`. | # ### How deposit authorization status transitions ``` +---> AUTHORIZED (1) --- terminal | INIT (0) -----> user action | +---> REJECTED (2) --- terminal | (no action, time passes) | +---> EXPIRED (3) --- terminal ``` > **Notes**: > > - All transitions from `INIT` are one-way. Once a deposit session reaches `AUTHORIZED`, > `REJECTED`, or `EXPIRED`, it cannot be changed. > - If the deposit session is `REJECTED` or `EXPIRED`, the Partner should create a new deposit > session by calling `/deposit/initiate` with a **new** `externalOrderId`. > - The `AUTHORIZED` state is permanent — deposit addresses for a given user + coin + network > combination do not change. Multiple authorization sessions for the same user and network will > return the same address. --- ## Document: /products/connect-2.0/deposit/5.deposit-webhook URL: /zh-CN/docs/products/connect-2.0/deposit/5.deposit-webhook # Deposit Webhook Whenever the deposit authorization status changes (user authorizes or rejects), Binance Connect will send a webhook message to the Partner's configured webhook callback URL. The Partner can receive this message and react accordingly, such as displaying the deposit addresses or notifying the user of a rejection. > **Note**: Webhook is the **primary** delivery mechanism for deposit status changes. Polling via > `/deposit/authorization` is available as a fallback in case the webhook is missed or not yet > integrated. See [Query deposit authorization](3.query-authorization.md). ### Request Headers | **Field** | **Type** | **Remarks** | | ---------------------- | --------- | -------------------------------------------------------- | | X-BN-Connect-Timestamp | timestamp | Timestamp | | X-BN-Connect-Signature | string | SHA256withRSA(**requestBody** + **X-Connect-Timestamp**) | | X-BN-Connect-For | string | Same with your client id (X-Tesla-ClientId) | > **How signature works**: The signature verification process is the same as the > [existing Connect webhook](../webhook/webhook.md). Binance signs the webhook payload with its > private key, and the Partner verifies using Binance's public key. ### Request Body | **Field** | **Type** | **Remarks** | | ---------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------ | | webhookEventType | string | Fixed value: `deposit_status_event` | | externalOrderId | string | Partner's unique order ID (same as the one used in `/deposit/initiate`). | | status | int | Authorization status: 1 = AUTHORIZED, 2 = REJECTED. Please refer to "[Deposit authorization status](6.deposit-status.md)". | | cryptoCurrency | string | Crypto currency | | depositAddresses | object array | Deposit addresses per network. Present when `status` = 1 (AUTHORIZED), empty array when REJECTED. Refer to **DepositAddressObject**. | | updateTime | timestamp | Status change time (epoch milliseconds) | ###### DepositAddressObject | **Field** | **Type** | **Remarks** | | -------------- | -------- | ------------------------------------------------------------------------- | | depositAddress | string | Deposit address for this network | | network | string | Blockchain network. E.g. "BSC", "ETH", "SOL" | | addressTag | string | Address memo/tag (for networks like XRP, XLM, etc.). Null if not required | ### Response Body - HTTP status code should be 200 - Response body is in JSON format. | **Field** | **Type** | **Remarks** | | ------------- | -------- | ----------------------------------------------------------- | | returnCode | string | SUCCESS or other code you wish to return to Binance Connect | | returnMessage | string | The message you wish to return to Binance Connect | # ### Example - AUTHORIZED (with deposit addresses) Request Body: ```json { "webhookEventType": "deposit_status_event", "externalOrderId": "dep-20260421-001", "status": 1, "cryptoCurrency": "USDT", "depositAddresses": [ { "depositAddress": "0x1234567890abcdef1234567890abcdef12345678", "network": "BSC", "addressTag": null }, { "depositAddress": "0x1234567890abcdef1234567890abcdef12345678", "network": "ETH", "addressTag": null }, { "depositAddress": "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH", "network": "SOL", "addressTag": null } ], "updateTime": 1745350200000 } ``` ### Example - REJECTED Request Body: ```json { "webhookEventType": "deposit_status_event", "externalOrderId": "dep-20260421-001", "status": 2, "cryptoCurrency": "USDT", "depositAddresses": [], "updateTime": 1745350200000 } ``` --- ## Document: /products/connect-2.0/deposit/4.report-deposit URL: /zh-CN/docs/products/connect-2.0/deposit/4.report-deposit # Report deposit ``` POST /papi/v1/ramp/connect/deposit/report ``` Optionally report the on-chain transaction hash after the Partner has executed the deposit transfer. This is for reconciliation and audit purposes only — no downstream action is triggered by this call. > **Note**: This API is idempotent. Calling it multiple times with the same `externalOrderId` will > only update the transaction hash on the first call; subsequent calls are ignored. ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | --------------- | -------- | ------------- | ------------------------------------------------------------------------ | | externalOrderId | string | Yes | Partner's unique order ID (same as the one used in `/deposit/initiate`). | | txHash | string | Yes | On-chain transaction hash of the deposit transfer. | | amount | string | No | Actual deposited amount. | | cryptoCurrency | string | No | Crypto currency. E.g. "USDT" | | network | string | No | Blockchain network. E.g. "BSC", "ETH", "SOL" | ### Response Body No data returned. A successful response indicates the transaction hash has been recorded. # ### Example Request Parameters: ```json { "externalOrderId": "dep-20260421-001", "txHash": "0xabc123def456789012345678901234567890abcdef1234567890abcdef123456", "amount": "100.5", "cryptoCurrency": "USDT", "network": "BSC" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": null } ``` --- ## Document: /products/connect-2.0/deposit/3.query-authorization URL: /zh-CN/docs/products/connect-2.0/deposit/3.query-authorization # Query deposit authorization ``` POST /papi/v1/ramp/connect/deposit/authorization ``` Query the authorization status of a deposit session. After the user opens the Binance App via the universal link, this API returns the current status and, once authorized, the deposit addresses for all requested networks. > **Polling contract**: Poll this API every 2-3 seconds. Stop polling when the status transitions > from `0` (INIT) to a terminal state: `1` (AUTHORIZED), `2` (REJECTED), or `3` (EXPIRED). > > **Note**: Webhook is the primary delivery mechanism for authorization results. Polling is > available as a fallback. See [Deposit Webhook](5.deposit-webhook.md) for details. ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | --------------- | -------- | ------------- | ------------------------------------------------------------------------ | | externalOrderId | string | Yes | Partner's unique order ID (same as the one used in `/deposit/initiate`). | ### Response Body | **Field** | **Type** | **Remarks** | | ---------------- | ------------ | -------------------------------------------------------------------------------------------------------------- | | status | int | Authorization status. Please refer to "[Deposit authorization status](6.deposit-status.md)". | | depositAddresses | object array | Deposit addresses per network. Only present when `status` = 1 (AUTHORIZED). Refer to **DepositAddressObject**. | | cryptoCurrency | string | Crypto currency | | expireTime | timestamp | Authorization expiry time (epoch milliseconds) | ###### DepositAddressObject | **Field** | **Type** | **Remarks** | | -------------- | -------- | --------------------------------------------------------------------------------------- | | depositAddress | string | Deposit address for this network | | network | string | Blockchain network. E.g. "BSC", "ETH", "SOL" | | addressTag | string | Address memo/tag (for networks like XRP, XLM, etc.). Null if not required | | minAmount | string | Minimum deposit amount for this network. Deposits below this amount may not be credited | # ### Example - INIT (waiting for user authorization) Request Parameters: ```json { "externalOrderId": "dep-20260421-001" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "status": 0, "depositAddresses": null, "cryptoCurrency": "USDT", "expireTime": 1745352000000 } } ``` ### Example - AUTHORIZED (deposit addresses obtained) Request Parameters: ```json { "externalOrderId": "dep-20260421-001" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "status": 1, "depositAddresses": [ { "depositAddress": "0x1234567890abcdef1234567890abcdef12345678", "network": "BSC", "addressTag": null, "minAmount": "0.01" }, { "depositAddress": "0x1234567890abcdef1234567890abcdef12345678", "network": "ETH", "addressTag": null, "minAmount": "0.01" }, { "depositAddress": "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH", "network": "SOL", "addressTag": null, "minAmount": "0.01" } ], "cryptoCurrency": "USDT", "expireTime": 1745352000000 } } ``` ### Example - REJECTED (user rejected authorization) Request Parameters: ```json { "externalOrderId": "dep-20260421-001" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "status": 2, "depositAddresses": null, "cryptoCurrency": "USDT", "expireTime": 1745352000000 } } ``` ### Example - EXPIRED (authorization window expired) Request Parameters: ```json { "externalOrderId": "dep-20260421-001" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "status": 3, "depositAddresses": null, "cryptoCurrency": "USDT", "expireTime": 1745352000000 } } ``` --- ## Document: /products/connect-2.0/deposit/2.initiate-deposit URL: /zh-CN/docs/products/connect-2.0/deposit/2.initiate-deposit # Initiate deposit ``` POST /papi/v1/ramp/connect/deposit/initiate ``` Create a deposit session. Returns a universal link for opening the Binance App authorization page where the user can authorize the Partner to access their deposit addresses. > The `externalOrderId` serves as an idempotency key. Calling this API multiple times with the same > `externalOrderId` will return the same universal link. ### Request Body | **Field** | **Type** | **Mandatory** | **Remarks** | | ---------------- | ------------ | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | cryptoCurrency | string | Yes | Crypto currency. E.g. "USDT", "ETH" | | networks | string array | Yes | Blockchain networks (one or more). E.g. `["BSC", "ETH", "SOL"]`. Use `depositEnable` from the crypto-network API to check which networks support deposit. | | externalOrderId | string | Yes | Partner's unique order ID (idempotency key). Supports only letters, numbers, hyphens and underscores. | | amount | string | No | Expected deposit amount (display only, not enforced). This is shown to the user on the authorization page for reference. | | redirectUrl | string | No | Partner web redirect URL. The user will be redirected to this URL after authorization in the Binance App. | | redirectDeepLink | string | No | Partner native app deeplink. The user will be redirected to this deeplink after authorization in the Binance App. | ### Response Body | **Field** | **Type** | **Remarks** | | -------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------- | | link | string | Binance App universal link. Redirect the user to this link to open the deposit authorization page in the Binance App. | | linkExpireTime | timestamp | The expiration time of the link (epoch milliseconds). After this time, the user can no longer authorize this deposit session. | # ### Example Request Parameters: ```json { "cryptoCurrency": "USDT", "networks": ["BSC", "ETH", "SOL"], "externalOrderId": "dep-20260421-001", "amount": "100.5", "redirectUrl": "https://trustwallet.com/deposit-callback", "redirectDeepLink": "trustwallet://deposit-callback" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "link": "https://app.binance.com/mp/web?appId=VzUjjQ&startPagePath=cGFnZXMvb24tY2hhaW4tZGVwb3NpdC9pbmRleA&merchantCode=connect-trustwallet&externalOrderId=dep-20260421-001", "linkExpireTime": 1745352000000 } } ``` ### Example - Single network Request Parameters: ```json { "cryptoCurrency": "ETH", "networks": ["ETH"], "externalOrderId": "dep-20260422-002" } ``` Response: ```json { "success": true, "code": "000000", "message": "success", "data": { "link": "https://app.binance.com/mp/web?appId=VzUjjQ&startPagePath=cGFnZXMvb24tY2hhaW4tZGVwb3NpdC9pbmRleA&merchantCode=connect-trustwallet&externalOrderId=dep-20260422-002", "linkExpireTime": 1745438400000 } } ``` --- ## Document: /products/connect-2.0/deposit/1.get-crypto-networks URL: /zh-CN/docs/products/connect-2.0/deposit/1.get-crypto-networks # Get supported crypto networks ``` POST /papi/v1/ramp/connect/crypto-network ``` > This is the same API used by On-ramp and Off-ramp. For deposit use cases, refer to the > `depositEnable` and `depositDust` fields to determine which networks support deposit and the > minimum deposit amount. ### Request Body No request body ### Response Body ##### Data: CryptoNetworkObject array ###### CryptoNetworkObject | **Field** | **Type** | **Remarks** | | -------------- | ------------ | -------------------------------------------- | | cryptoCurrency | string | Crypto currency, e.g. "USDT", "ETH" | | networks | object array | Network detail. Refer to NetworkDetailObject | ###### NetworkDetailObject | **Field** | **Type** | **Remarks** | | ----------------- | -------- | --------------------------------------------------------------------------------------- | | network | string | Network name. E.g. ETH, BSC, ARBITRUM, SOL, OPTIMISM, BASE | | addressRegex | string | Network address regex | | memoRegex | string | Memo regex | | withdrawFee | string | Withdraw fee | | withdrawMinAmount | string | Withdraw min amount | | withdrawMaxAmount | string | Withdraw max amount | | contractAddress | string | Contract address | | withdrawEnable | boolean | Is withdraw enabled | | depositEnable | boolean | Is deposit enabled. Use this to filter networks available for deposit | | depositDust | string | Minimum deposit amount for this network. Deposits below this amount may not be credited | # ### Example Response: ```json { "success": true, "code": "000000", "message": "success", "data": [ { "cryptoCurrency": "USDT", "networks": [ { "network": "BSC", "addressRegex": "^(0x)[0-9A-Fa-f]{40}$", "memoRegex": "", "withdrawFee": 0.29, "withdrawMinAmount": 10.0, "withdrawMaxAmount": 9999999.0, "contractAddress": "0x55d398326f99059ff775485246999027b3197955", "withdrawEnable": true, "depositEnable": true, "depositDust": "0.01" }, { "network": "ETH", "addressRegex": "^(0x)[0-9A-Fa-f]{40}$", "memoRegex": "", "withdrawFee": 3.22, "withdrawMinAmount": 10.0, "withdrawMaxAmount": 9999999.0, "contractAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7", "withdrawEnable": true, "depositEnable": true, "depositDust": "0.01" }, { "network": "SOL", "addressRegex": "^[1-9A-HJ-NP-Za-km-z]{32,44}$", "memoRegex": "", "withdrawFee": 1.0, "withdrawMinAmount": 10.0, "withdrawMaxAmount": 9999999.0, "contractAddress": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", "withdrawEnable": true, "depositEnable": true, "depositDust": "0.01" } ] }, { "cryptoCurrency": "ETH", "networks": [ { "network": "ETH", "addressRegex": "^(0x)[0-9A-Fa-f]{40}$", "memoRegex": "", "withdrawFee": 0.0, "withdrawMinAmount": 1e-8, "withdrawMaxAmount": 9999999.0, "contractAddress": "", "withdrawEnable": true, "depositEnable": true, "depositDust": "0.00001" } ] } ] } ``` --- ## Document: /products/connect-2.0/deposit/0.typical-flow URL: /zh-CN/docs/products/connect-2.0/deposit/0.typical-flow # Typical Deposit Flow ## Overview This document describes the standard deposit flow using Binance Connect's Deposit service. The deposit feature allows users of Partner Apps (e.g., Trust Wallet) to authorize disclosure of their Binance deposit addresses, so that the Partner App can send crypto to the user's Binance account on their behalf. > **Key distinction**: Connect Deposit is an **address authorization coordinator**, NOT a payment > processor. It never moves funds — the Partner App executes the actual on-chain transfer > independently. ## Flow Steps ### 1. Query Supported Networks - Partner backend queries available coin + network combinations for deposit via `POST /papi/v1/ramp/connect/crypto-network`. - This returns supported networks with deposit-specific metadata (e.g., `depositDust` for minimum deposit amounts). ### 2. Initiate Deposit Session - Partner backend calls `POST /papi/v1/ramp/connect/deposit/initiate` with the selected crypto currency and one or more blockchain networks. - Binance Connect returns a **universal link** (`link`) for opening the Binance App authorization page, along with the link's `linkExpireTime`. ### 3. User Authorization in Binance App - Partner frontend redirects the user to Binance App using the universal link. - User sees the authorization page showing the Partner name, requested crypto currency, and networks. - User taps **"Authorize"** to grant the Partner access to their deposit addresses. ### 4. Receive Deposit Addresses - **Primary (webhook)**: Binance Connect pushes a `deposit_status_event` webhook to the Partner's callback URL with the authorization status and deposit addresses for all requested networks. - **Fallback (polling)**: Partner backend polls `POST /papi/v1/ramp/connect/deposit/authorization` every 2-3 seconds until the status transitions from `INIT` to a terminal state (`AUTHORIZED`, `REJECTED`, or `EXPIRED`). ### 5. Execute On-Chain Transfer - Partner App displays the deposit addresses to the user. - User confirms the deposit amount and the Partner App executes the on-chain transfer to the corresponding deposit address. ### 6. Report Transaction (Optional) - Partner backend optionally calls `POST /papi/v1/ramp/connect/deposit/report` to report the on-chain transaction hash for reconciliation and audit purposes. ## Sequence Diagram ``` Partner App Binance Connect Binance App | | | | 1. Query supported networks | | |------------------------------->| | | networks + coin details | | |<-------------------------------| | | | | | 2. Initiate deposit | | | (coin, networks[], ...) | | |------------------------------->| | | { link, linkExpireTime } | | |<-------------------------------| | | | | | 3. Open universal link ------|------------------------------>| | | | | | User taps "Authorize" | | |<------------------------------| | | | | 4a. Webhook: deposit_status_event (status, depositAddresses) | |<-------------------------------| | | | | | 4b. (fallback) Poll /authorization | |------------------------------->| | | { status, depositAddresses } | | |<-------------------------------| | | | | | 5. Execute on-chain transfer | | | (Partner sends crypto to | | | the deposit address) | | | | | | 6. Report txHash (optional) | | |------------------------------->| | | 200 OK | | |<-------------------------------| | ``` --- ## Document: /products/connect-2.0/convert/1.convert URL: /zh-CN/docs/products/connect-2.0/convert/1.convert # Convert Binance Connect provides a flexible and powerful Convert capability as part of the On-ramp (Buy) functionality, through which you can quickly convert one cryptocurrency to another with competitive rates! The Convert capability is a branch of the On-ramp flow that allows users to exchange their existing cryptocurrency holdings directly without going through fiat currency. This is particularly useful for: - Converting between different cryptocurrencies - Portfolio rebalancing - Taking advantage of market opportunities As a partner (client), the conversion process is seamless and uses the same On-ramp APIs with specific parameters. There are no separate Convert APIs - it utilizes the existing On-ramp infrastructure. ## Key Differences for Convert Operations When using the On-ramp APIs for Convert operations, there are some key differences: ### 1. Fiat Fields For Convert operations, the following fields will be empty since no fiat currency is involved: - `fiat` - This field will be empty - `fiatAmount` - This field will be 0 ### 2. Additional Response Fields The [Get order detail](../on-ramp-buy-apis/6.query-order-details.md) API and webhook payload will include an additional object field when processing Convert orders: **For API responses:** ```json { "convertInfo": { "fromCoin": "BTC", "fromCoinAmount": "0.01" } } ``` **For webhook payloads:** ```json { "convertInfo": { "fromCoin": "BTC", "fromCoinAmount": "0.01" } } ``` #### ConvertInfo Fields: - `fromCoin`: The source cryptocurrency being converted from - `fromCoinAmount`: The amount of source cryptocurrency being converted ### 3. Order Status Flow Convert operations will use the following order statuses: - `CONVERT_PROCESSING` (3): In the process of converting crypto - `CONVERT_COMPLETED` (4): Successfully converted crypto. The converted crypto is in the user's Binance wallet, but the withdrawal has not been initiated yet For detailed order status information, refer to [Order Status](../basics/7.order-status.md). --- ## Document: /products/connect-2.0/buy-any-token/1.buy-any-token URL: /zh-CN/docs/products/connect-2.0/buy-any-token/1.buy-any-token # Buy any token (Swap) For crypto currencies not listed on Binance spot (such as popular memecoins), Binance Connect provides a suite of flexible and powerful APIs, through which you can quickly buy any token with one click! Its implementation principle is as follows, there are two steps: 1. First buy the bridge token with fiat currency, such as USDT, USDC, BNB, SOL, etc. The bridge token is automatically selected based on the liquidity of different networks and providers, and it may be the native token of the current chain or stable coins; 2. Then swap the target token (such as memecoins) by the bridge token; As a partner (client), you don't need to pay much attention to these implementation details. These two steps are happened automatically in Binance Connect, and users will not realize any unsmooth of this process. The whole user experience is to buy any token with one click. # If you are going to integrate the "Buy any token" capability, it's quite easy. You only need to call the APIs in the following: - [Get payment method list](../on-ramp-buy-apis/3.get-payment-method-list.md). If there is success response and results of the API, it means that Binance Connect supports this token (contract address); - [Get estimated quote](../on-ramp-buy-apis/4.get-estimated-quote.md). If there is success response and result of the API, it means that there is quote and liquidity of this token (contract address), and it's fine to call the pre-order API to place an order; - [Pre order](../on-ramp-buy-apis/5.pre-order.md). In fact, these APIs are no different from the APIs in the On-ramp (Buy) section. The only difference is that On-ramp (Buy) requires the parameter `cryptoCurrency`, while the parameter for Buy any token is `contractAddress`. --- ## Document: /products/connect-2.0/basics/9.customization URL: /zh-CN/docs/products/connect-2.0/basics/9.customization # Customization While providing a set of standardized process, Binance Connect also offers some capabilities for customizing interaction details, through which the partner (client) can customize the on/off ramp process according to their needs. For example, lock transaction pairs/payment methods to prevent users from making changes after entering Binance Connect page, skip the cashier page to make the process simpler, automatically redirect to the partner's (client's) platform when the on/off ramp is completed without the user manually clicking the "Back to X" button, etc. **Please note that the customization capabilities are not enabled by default**, as they are only customized for the special needs of few of our partners, and they are not applied for most partners, usually you don't need to enable these customization capabilities, the standard process is sufficient to meet your needs. If you really need these capabilities, **please contact Binance Connect team to enable them for you** (the customization parameter of the pre-order API will be ignored if these capabilities are not enabled and the customization will not work). If the existing capabilities do not meet your needs, feel free to give any suggestions. Binance Connect will add more and more customization capabilities in the future. # ### Customization types If Binance Connect has enabled the customization capabilities for you, you can pass the customization settings for the current order in the `customization` parameter of the pre-order API. Currently, Binance Connect supports the following customization capabilities: | **Key** | **Value Type** | **Description** | **Remarks** | | --------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | LOCK_ORDER_ATTRIBUTES | int array | An array of integers, filled with all the parameters you want to lock. When the user enters the cashier page of Binance Connect, the corresponding information will be locked and cannot be edited. Please refer to “Subtypes for LOCK_ORDER_ATTRIBUTES”. | | | SKIP_CASHIER | boolean | skip cashier page (and show order confirmation page directly) or not | Cannot work together with `SEND_PRIMARY`. | | AUTO_REDIRECTION | boolean | Automatically redirect or not. When the user completes the buy crypto and withdrawal process, there will be a "Back to X" button on the page, clicking it will redirect the user back to the partner's platform. If you enable the `AUTO_REDIRECTION` capability, a countdown will be displayed on the button, and the page will automatically redirect without clicking after the countdown ends. | If `redirectUrl` and `redirectDeepLink ` are not provided in pre-order API, it will not work. | | HIDE_SEND | boolean | Hide send crypto option or not. When user is on the cashier page of the on-ramp (buy) flow, if the user has enough crypto in his Binance wallet, Binance Connect will prompt him whether to send crypto (i.e. transfer) directly. If the user choose this option, Binance connect will skip the purchase process and directly withdraw crypto to the user’s crypto wallet. If you want to disable this prompt and only enable buy, you can use the `HIDE_SEND` customization. | On-ramp only.
Cannot work together with `SEND_PRIMARY`. | | SEND_PRIMARY | boolean | promote send as the first priority (and downgrade buy) or not | On-ramp only.
Cannot work together with `HIDE_SEND`.
Should work together with `amountType: 2` .
Please refer to "[Send primary mode](../send-primary-mode/send-primary-mode.md)". | | SEND_PRIMARY_FLEXIBLE | boolean | promote send as the first priority (and downgrade buy) or not, and allows users to freely input the amount on Binance Connect page | On-ramp only.
Cannot work together with `HIDE_SEND`.
Must work together with `SEND_PRIMARY`.
The amount specified in pre-order API will be used as the default value but users can modify it.
Please refer to "[Send primary mode](../send-primary-mode/send-primary-mode.md)". | | MERCHANT_DISPLAY_NAME | string | customize the partner name displayed on the order pages | On-ramp only. | | NET_RECEIVE | boolean | Normally, since the withdrawal fee will be deducted when withdrawing, the actual amount of crypto received by the user will be less than the amount of crypto purchased. If you want the actual amount of crypto received by the user to be equal to the amount of crypto specified in the pre-order API, please use `NET_RECEIVE`. Binance Connect will purchase more crypto automatically to cover the withdrawal fee deduction at the time of withdrawal. | On-ramp only.
Should work together with `LOCK_ORDER_ATTRIBUTES: CRYPTO_AMOUNT`.
Should work together with `SEND_RPIMARY`. | | P2P_EXPRESS | boolean | When a user lands on Binance Connect, this value can redirect them to the P2P order confirmation page. | On-ramp only.
Cannot work together with `SEND_PRIMARY`. | #### Subtypes for LOCK_ORDER_ATTRIBUTES | **Subtype** | **Value** | **Remarks** | | --------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------- | | ALL | 1 | lock all parameters | | TRADING_PAIR | 2 | lock transaction pair | | NETWORK | 3 | lock crypto network | | PAYMENT_METHOD | 4 | lock payment method | | FIAT_AMOUNT | 5 | lock the fiat amount as specified in the pre-order API. Should work together with `amountType: 1` . Should work together with `HIDE_SEND `. | | CRYPTO_AMOUNT | 6 | lock the crypto amount as specified in the pre-order API. Should work together with `amountType: 2` . | | FIAT_CURRENCY | 7 | lock fiat currency | | CRYPTO_CURRENCY | 8 | lock crypto currency | # ### Example Request Parameters: ```json { // Other parameters... "customization": { "LOCK_ORDER_ATTRIBUTES": [2, 3], "SKIP_CASHIER": false, "AUTO_REDIRECTION": true, "HIDE_SEND": false, "SEND_PRIMARY": true, "MERCHANT_DISPLAY_NAME": "Super Merchant", "NET_RECEIVE": true } } ``` > \*_Please note that the above code is only an example. You don't have to pass in all the > customization attributes, you only need to pass in the attributes you need. If the permission for > a customization attribute is not enabled, the passed parameter will be ignored and the > customization will not work._ --- ## Document: /products/connect-2.0/basics/8.landing-page-and-redirection URL: /zh-CN/docs/products/connect-2.0/basics/8.landing-page-and-redirection # Landing page and redirection ### About landing page link The landing page link in the response of the pre-order API is a [universal link](https://developer.apple.com/documentation/xcode/allowing-apps-and-websites-to-link-to-your-content/) starting with `https://app.binance.com/`. When parter (client) opens this universal link, the system's behaviors should be as follows: - Desktop: the system redirects the link to the system browser and opens Binance Connect's webpage; - Mobile (Binance App installed): the system redirects the link to Binance App and opens Binance Connect's mini app; - Mobile (None Binance App installed): the system redirects the link to the system browser and opens Binance Connect's mobile webpage; Regarding the method of opening or loading the landing page link, Binance Connect requires the following requirements: - System browser or Binance App: the only highly recommended method that ensures the best security, product performance, and user experience; - Embedded browser: not a recommended approach, and we cannot guarantee the security, product performance, and user experience. If you have special needs that require you to do this, please contact Binance Connect so that we can customize a solution for you; - iframe: not allowed, we cannot guarantee the security, product performance, and user experience. If you use iframe to load the landing page link, Binance Connect reserves the right to terminate the partnership; ### Best way to load Universal Links in code For iOS native, please code like this: ```swift let connectUrl = URL(string: "https://app.binance.com/...")! UIApplication.shared.open(connectUrl, options: [:]) ``` For Android native, please code like this: ```kotlin val connectUrl = "https://app.binance.com/..." val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(connectUrl)) startActivity(browserIntent) ``` For web side, the following normal page redirect methods are all working: - HTML `` tag ```html Buy with Binance Connect ``` - Window `open()` Method ```javascript window.open("https://app.binance.com/..."); ``` - JavaScript Window Location ```javascript window.location.href = "https://app.binance.com/..."; ``` If you are using frameworks such as React Native that do not apply platform native redirection, which result in unable to redirect to the Binance App normally with Universal Links, please contact Binance Connect to seek a solution. --- ## Document: /products/connect-2.0/basics/7.order-status URL: /zh-CN/docs/products/connect-2.0/basics/7.order-status # Order status | **Code** | **Type** | **Description** | **Remarks** | | -------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | | 0 | INIT | The pre-order API has been called and the order was created, but no Fiat or P2P order has been matched (the user may be logging in or staying on the Binance Connect landing page at this time). | | | 1 | ON_RAMP_PROCESSING | In the process of buying crypto with Fiat or P2P. | On-ramp only | | 2 | ON_RAMP_COMPLETED | Successfully bought crypto through Fiat or P2P. The crypto is in the user's Binance wallet, but the withdrawal has not been initiated yet. | On-ramp only | | 3 | CONVERT_PROCESSING | In the process of converting crypto. | Convert only | | 4 | CONVERT_COMPLETED | Successfully converted crypto. The converted crypto is in the user's Binance wallet, but the withdrawal has not been initiated yet. | Convert only | | 6 | OFF_RAMP_PROCESSING | In the process of selling crypto with Fiat or P2P. | Off-ramp only | | 10 | WITHDRAW_INIT | Withdrawal has been initiated. | On-ramp and Send crypto | | 11 | WITHDRAW_PROCESSING | Withdrawal in progress, Binance or blockchain is processing. | On-ramp and Send crypto | | 15 | SWAP_PROCESSING | Swap action in progress, Binance or blockchain is processing. | On-ramp (buy any token) | | 20 | COMPLETED | For on-ramp, it means that the buying crypto and the withdrawal have been both completed; For off-ramp, it means that the selling crypto has been completed; For send crypto, it means that the withdrawal has been completed. This is one of the final states of an order. | | | 93 | SWAP_ABANDONED | Buying crypto successfully but the user voluntarily abandoned the swap action (e.g. clicking the Cancel button). The crypto will be stored in the user's Binance wallet. This is one of the final states of an order. | On-ramp (buy any token) only | | 94 | SWAP_FAILED | Swap action failed. This is one of the final states of an order. | On-ramp (buy any token) only | | 95 | OFF_RAMP_FAILED | Selling crypto failed. This is one of the final states of an order. | Off-ramp only | | 96 | WITHDRAW_ABANDONED | Buying crypto successfully but the user voluntarily abandoned the withdrawal process (e.g. clicking the Abandon button). The crypto will be stored in the user's Binance wallet. This is one of the final states of an order. | On-ramp and Send crypto | | 97 | ON_RAMP_FAILED | Buying crypto failed. This is one of the final states of an order. | On-ramp only | | 98 | WITHDRAW_FAILED | Buying crypto successfully but the withdrawal failed, the crypto will be stored in the user's Binance wallet. This is one of the final states of an order. | On-ramp and Send crypto | | 99 | FAILED | The reserved final failure state of an order, not yet enabled. | | # ### How order status transforms The following flow diagrams indicate how the order status flows during the life cycle of an order. ##### On-ramp (Buy) ![flow-state-buy](../images/flow-state-buy.jpg) ##### On-ramp (Convert) ![flow-state-convert](../images/flow-state-convert.jpg) ##### Buy any token (Swap) ![flow-state-buy](../images/flow-state-buy-any-token.jpg) ##### Send crypto (Normal send & Send primary mode) ![flow-state-send](../images/flow-state-send.jpg) ##### Off-ramp (Sell) ![flow-state-sell](../images/flow-state-sell.jpg) --- ## Document: /products/connect-2.0/basics/6.apply-developer-account URL: /zh-CN/docs/products/connect-2.0/basics/6.apply-developer-account # How to apply partner developer account If you are a partner (client) who wants to integrate Binance Connect’s Open API. Please contact Binance Connect team and provide the following items: - [Public key](3.request-signing.md) for API requests (private key kept by the partner/client safely); - IP addresses used to config whitelist; - Webhook callback url; - The domains of the URL/Universal Link that you will pass to the `redirectUrl` and `failRedirectUrl` parameters of the pre-order API, as well as the schema of the Deeplink of the `redirectDeepLink` and `failRedirectDeepLink` parameters. Which are used to config whitelist for redirecting users back to your platform when on/off ramp completed; - A logo image in format of 80 x 80 pixel png, which will be displayed on the Binance Connect page. Once Binance Connect receives these items and completes the configuration, Binance Connect will provide the following items to the partner (client): - Client id; - Sign access token; - Public key and partner code for webhook (private key kept by Binance Connect safely); Then the partner (client) will be able to call all Open APIs. > \*_Regarding to different environments, please refer to > “[Environments and API base URLs](4.base-urls.md)”. It‘s recommended to start with the QA > environment first._ --- ## Document: /products/connect-2.0/basics/5.error-code URL: /zh-CN/docs/products/connect-2.0/basics/5.error-code # Error code | **Code** | **Type** | **Message** | | -------- | ------------------------------------ | ---------------------------------------------- | | 1130101 | SYS_ERROR | System error | | 1130102 | SYS_BUSY | System busy. Please try again later | | 1130303 | ILLEGAL_PARAMETERS | The parameter {param} is illegal | | 1130304 | MISSING_CLIENT_ID | Missing client id from request | | 1130305 | PARTNER_IS_DISABLED | The partner is disabled | | 1130306 | ORDER_NOT_FOUND | Can not find the order | | 1130307 | UNSUPPORTED_ORDER_TYPE | Unsupported order type | | 1130314 | PARTNER_IS_NOT_FOUND | Can not find the partner | | 1130320 | NOT_SUPPORT_QUOTE_FOR_PAYMENT_METHOD | Not support quote for this payment method | | 1130326 | ILLEGAL_CUSTOMIZATION_VALUE | The value of customization {param} is illegal. | | 1130327 | SWAP_TOKEN_NOT_FOUND | Swap token not found. | | 1130329 | SWAP_NETWORK_NOT_SUPPORT | Swap network not support | | 1130330 | SWAP_TOKEN_NOT_MATCHED | Swap token not matched {0} | # ### Example Response: ```json { "success": false, "code": "1130306", "message": "Can not find the order", "data": null } ``` --- ## Document: /products/connect-2.0/basics/4.base-urls URL: /zh-CN/docs/products/connect-2.0/basics/4.base-urls # Environments and API base URLs According to different environments, please use the following base URLs for API requests: | Environment | URL | | ----------- | ---------------------------------------------- | | QA | Please ask for Binance Connect team | | Sandbox | Sandbox environment is not supported currently | | Production | Please ask for Binance Connect team | --- ## Document: /products/connect-2.0/basics/3.request-signing URL: /zh-CN/docs/products/connect-2.0/basics/3.request-signing # API request signing The private key and public key are generated by the partner (client). The partner (client) should keep the private key securely and privately, and inform Binance Connect of the public key, then Binance Connect will be able to verify the API requests from the partner (client). # ### Generating key pairs You can use code or the OpenSSL tool to generate key pairs, depending on which one you prefer. #### Generating key pairs with code The example code below shows how to generate public and private keys: ```java import org.apache.commons.codec.binary.Base64; import java.security.KeyPairGenerator; import java.security.KeyPair; KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA"); generator.initialize(1024); KeyPair kp = generator.generateKeyPair();   String privateK = Base64.encodeBase64String(kp.getPrivate().getEncoded()); String publicK = Base64.encodeBase64String(kp.getPublic().getEncoded()); System.out.println("-----Generating private key-----"); System.out.println(privateK); System.out.println("\n\n-----Generating public key-----"); System.out.println(publicK); ``` #### Generating key pairs with OpenSSL tool Please follow the steps below: 1. Generate private key with command: ``` openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:1024 ``` 2. Extract the DER encoding of the private key with command: ``` openssl rsa -in private_key.pem -outform DER -out private_key.der ``` 3. Convert the DER-encoded private key to Base64 encoding with command: ``` openssl base64 -in private_key.der -out private_key.base64 -A | tr -d '\n' | sed 's/\//\//g' ``` > \*_Please keep the file "private_key.base64" generated by this command securely and privately. The > private key will be used to generate the signature._ 4. Generate public key with command: ``` openssl rsa -in private_key.pem -pubout -outform DER -out public_key.der ``` 5. Convert the DER-encoded public key to Base64 encoding with command: ``` openssl base64 -in public_key.der -out public_key.base64 -A | tr -d '\n' | sed 's/\//\//g' ``` > \*_Please send the file "public_key.base64" generated by this command to Binance Connect for use > in verifying API requests._ # ### Generating signature and set HTTP headers The signature is generated by request body (json string), timestamp and partner (client) private key, the following is the example code: ```java import org.apache.commons.codec.binary.Base64; import java.security.KeyFactory; import java.security.PrivateKey; import java.security.Signature; import java.security.spec.PKCS8EncodedKeySpec; import org.springframework.http.HttpHeaders; import org.springframework.util.MultiValueMap; public class TestRequestSigning {     public static void main(String[] args) throws Exception {         MultiValueMap httpHeaders = new HttpHeaders();         String clientPrivateKey = "Your client private key";         String jsonBody = "{\n" +                 "\t\"id\": \"10000001\",\n" +                 "\t\"name\": Jack\n" +                 "}";// Please use utf-8 encoding if body contains special characters such as emoticons.         Long timestamp = System.currentTimeMillis();         PrivateKey cPrivateKey = generatePrivateKey(clientPrivateKey);         String signature = sign(jsonBody + timestamp.toString(), cPrivateKey);         httpHeaders.add("X-Tesla-Signature", signature);     }     public static PrivateKey generatePrivateKey(String privateKey) throws Exception {         PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKey));         KeyFactory keyFactory = KeyFactory.getInstance("RSA");         return keyFactory.generatePrivate(privateKeySpec);     }     public static String sign(String srcData, PrivateKey privateKey) throws Exception {         Signature signature = Signature.getInstance("SHA256withRSA");         signature.initSign(privateKey);         signature.update(srcData.getBytes());         return new String(Base64.encodeBase64(signature.sign()));     } } ``` # ### How signature works #### The signature flow is as follows: ![signature-flow](../images/signature-API.png) # ### Use [Postman](https://www.postman.com/) to sign and test API requests 1. Configure environment variables Create an environment (such as QA) in Postman and add these environment variables for subsequent reference: `base_url`, `client_id`, `access_token`, `private_key`. Please note that the format of the value of `private_key` should be like this: ```javascript -----BEGIN PRIVATE KEY----- MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANAAMnEOR1NIBIbwnDwHu19L/Jv0s4eEDHEjQ24OHjkHQ3CHWj4Ik4iFZyX9MvQsmZEzkDx8mJkkgAmIGjYkkZhEny1z6GPW55+ruo4dLYIRurESYRufZxI49BtIeLOOwL9ZFOnVfxBh8T7xyCvMmMcF93Suv6RcbTWXk8EC0pkXAgMBAAECgYA2cXbChNxCfj1BHMWoKNXwkbEjGR/MvtGK45IIwoVCpBYQ5DzIs/H58AEZvnaR1wKzMO32Bx7iJt2koQ1LUrMQ0UB9ydxhP2BogHvt9ZDI49+UPkTS92HMgPixi6O1HE6nOOu4rHR+6j7pdGcB+dneTwgPngWdk71VsbX8ZzPZsQJBAOGPmztuIpgXCxPlyLWCuEa9zTKc9lHiBe65ZN1jvUq1GCLClVcx/oEtEb9CCo7u1vacr/1sGFPxgBdvzv2y8HMCQQDsEfGEhp/79keDnjvJZ+TLfP4r+u1Gw0gAuj4Cay316K3f3q2OEqNm9lMNzg5dVYb78sVRd+guZ88u9etRBX/NAkAheIrjdcNiaED3keiHrr8jmDSj5xDSM8UHmLEz/QHw3RCYz+ETUFLg3kw84lLoxN5XOAcRhwHRKwwD7k577RqrAkEAhBiGTOIII7Vrzvp7+fdoz3ThxTpkC3S6la2hhTj0PuY0ZVD1TMqhJLwxPUhQQWnaXqE6SJwQD+eGx4BUbMHnAQJBAKomO+rK7ycU9OSRpEbPt2yQskwCcY2fiLgDy0Sy1hWmp/e5Cowt2Uyzp6uk/4QwMkfFApYzWtvjrnRkru19rMw= -----END PRIVATE KEY----- ``` 2. Set up library [postman-util-lib](https://joolfe.github.io/postman-util-lib/) for Postman Add a Postman global variable named `pmlib_code`, and set the value of it as the source code in the [library bundle content](https://joolfe.github.io/postman-util-lib/dist/bundle.js). 3. Configure HTTP headers: add Pre-request scripts to collection or request of Postman Add the following code to the Pre-request script: ```javascript eval(pm.globals.get("pmlib_code")); pm.request.headers.add({ key: "Content-Type", value: "application/json", }); pm.request.headers.add({ key: "X-Tesla-ClientId", value: pm.environment.get("client_id"), }); pm.request.headers.add({ key: "X-Tesla-SignAccessToken", value: pm.environment.get("access_token"), }); const timestamp = new Date().getTime(); let jsonBody = new String(); if (pm.request.body.raw) { jsonBody = pm.request.body.raw; } const dataToSign = jsonBody + timestamp.toString(); const privateKey = pm.environment.get("private_key"); const sha256withRSA = new pmlib.rs.KJUR.crypto.Signature({ alg: "SHA256withRSA" }); sha256withRSA.init(privateKey); sha256withRSA.updateString(dataToSign); const signature = pmlib.rs.hextob64(sha256withRSA.sign()); pm.request.headers.add({ key: "X-Tesla-Signature", value: signature, }); pm.request.headers.add({ key: "X-Tesla-Timestamp", value: timestamp.toString(), }); ``` 4. Everything is ready, feel free to test the API requests! --- ## Document: /products/connect-2.0/basics/2.common-response URL: /zh-CN/docs/products/connect-2.0/basics/2.common-response # Common API response | Field | Type | Mandatory | Remarks | | ------- | ------ | --------- | ------------------------------------------------------------------------------------------ | | success | bool | Yes | true means success. | | code | string | Yes | “000000” means success. Other error codes please refer to “[error code](5.error-code.md)”. | | data | object | No | A json object of returned data. | | message | string | No | Error message, please refer to “[error code](5.error-code.md)”. | --- ## Document: /products/connect-2.0/basics/10.restricted-industries URL: /zh-CN/docs/products/connect-2.0/basics/10.restricted-industries # Pay Onchain — Restricted / Unsupported Industries Binance Pay Onchain (Connect) cannot support merchants, businesses, products, services and/or use cases involving any of the following restricted industries: - Child sexual abuse material, pornography, adult industry and/or any sale of sexual services; - Arms, ammunition, weapons, military goods and/or related accessories; - Unlicensed financial services and/or any financial services that require licensing, registration or regulatory approval but do not have the required authorization in the relevant territory; - Illegal and/or unlicensed casinos, gaming, betting, gambling and/or other activities related to these industries; - Cryptocurrency exchanges, coin swap services and/or exchange-like services, as determined by Binance in its sole discretion; - Prepaid card, debit card, credit card, card issuing, card top-up, card balance funding and/or other card-related services; - High-risk crypto financial services, as determined by Binance in its sole discretion; - Non-custodial wallets that do not meet the required approved flow, including the required two-way deposit flow requirement; - Payment processors, aggregators, technical service providers and/or sub-merchant models that cannot provide sufficient merchant transparency, restricted industry controls, payer country controls and/or other required compliance controls; - Such other businesses, products, services and/or activities which would be considered illegal, restricted or sensitive in the relevant territory, or that could expose Binance, its affiliates, partners, users or any other party to legal, regulatory, sanctions, compliance or reputational risk, as determined by Binance in its sole discretion. If you require additional information about the specific onboarding requirements of merchants and restrictions applicable to your business, please reach out to [binanceconnect@binance.com](mailto:binanceconnect@binance.com). --- ## Document: /products/connect-2.0/basics/1.common-request-headers URL: /zh-CN/docs/products/connect-2.0/basics/1.common-request-headers # Common API request headers | Parameter | Description | Mandatory | Remarks | | ----------------------- | ----------------------------------------------------------------------------------- | --------- | ------------------------------------------------------ | | Content-Type | application/json | Yes | | | X-Tesla-ClientId | Partner (client) id provided by Binance Connect | Yes | | | X-Tesla-SignAccessToken | Access token provided by Binance Connect | Yes | | | X-Tesla-Signature | A signature generated by request body, timestamp and partner (client) private key\* | Yes | Refer to “[API Request signing](3.request-signing.md)” | | X-Tesla-Timestamp | Timestamp in millisecond | Yes | | > \*_The private key and public key are generated by the partner (client). Please refer to > “[API Request signing](3.request-signing.md)” for the generation method._ --- ## Document: /products/common/sapi/quick-start URL: /zh-CN/docs/products/common/sapi/quick-start # 快速开始 ## API Key 权限设置 - 新创建的API的默认权限是 `只读`。 - 如果需要通过API提款, 需要在UI修改权限, 选中 `允许提现`。 ## 账户 ### 现货账户 新注册的币安账号都会有一个现货(`SPOT`)账号。 ### 杠杆账户 为了开设杠杆(`MARGIN`)账户, 可以参考[Binance杠杆交易账户设置指南](https://www.binance.vision/zh/tutorials/binance-margin-trading-guide) ## API 代码库 ### Connectors 以下有一些轻量级的代码库,使不同语言的用户能够直接调用现货的 Binance 公共 API: - Python [https://github.com/binance/binance-connector-python](https://github.com/binance/binance-connector-python) - JavaScript [https://github.com/binance/binance-connector-js](https://github.com/binance/binance-connector-js) - Ruby [https://github.com/binance/binance-connector-ruby](https://github.com/binance/binance-connector-ruby) - DotNET C# [https://github.com/binance/binance-connector-dotnet](https://github.com/binance/binance-connector-dotnet) - Java [https://github.com/binance/binance-connector-java](https://github.com/binance/binance-connector-java) - Rust [https://github.com/binance/binance-spot-connector-rust](https://github.com/binance/binance-spot-connector-rust) - PHP [https://github.com/binance/binance-connector-php](https://github.com/binance/binance-connector-php) - Go [https://github.com/binance/binance-connector-go](https://github.com/binance/binance-connector-go) ### Postman Collections Postman 集合现已推出。推荐给寻求快速和轻松地开始使用 API 的新用户。 [https://github.com/binance/binance-api-postman](https://github.com/binance/binance-api-postman) ### Swagger 以下有提供包含 RESTful API 的 OpenAPI 规范的 YAML 文件,以及可供参考的 Swagger UI 页面。 [https://github.com/binance/binance-api-swagger](https://github.com/binance/binance-api-swagger) --- ## Document: /products/common/sapi/general-info URL: /zh-CN/docs/products/common/sapi/general-info # 基本信息 ## API 基本信息 - 接口可能需要用户的 API Key,如何创建API-KEY请参考[这里](https://www.binance.com/cn/support/articles/360002502072) - 本篇列出接口的 base URL 有: - **https://api.binance.com** - **https://api-gcp.binance.com** - **https://api1.binance.com** - **https://api2.binance.com** - **https://api3.binance.com** - **https://api4.binance.com** - 上述列表的最后4个接口 (`api1`-`api4`) 可能会提供更好的性能,但其稳定性略为逊色。因此,请务必使用最适合您现有配置的那款。 - 所有接口的响应都是 JSON 格式。 - 响应中如有数组,数组元素以时间**升序**排列,越早的数据越提前。 - 所有时间、时间戳均为UNIX时间,单位为**毫秒**。 ### HTTP 返回代码 - HTTP `4XX` 错误码用于指示错误的请求内容、行为、格式。问题在于请求者。 - HTTP `403` 错误码表示违反WAF限制(Web应用程序防火墙)。 - HTTP `409` 错误码表示重新下单(cancelReplace)的请求部分成功。(比如取消订单失败,但是下单成功了) - HTTP `429` 错误码表示警告访问频次超限,即将被封IP。 - HTTP `418` 表示收到429后继续访问,于是被封了。 - HTTP `5XX` 错误码用于指示Binance服务侧的问题。 ### 接口错误代码 - 使用接口 `/api/v3`, 以及 `/sapi/v1/margin`时, 每个接口都有可能抛出异常; > API 与 SAPI 的错误代码返回形式如下: ```javascript { "code": -1121, "msg": "Invalid symbol." } ``` - 具体的错误码及其解释在 [错误代码](./error-code). ### 接口的基本信息 - `GET` 方法的接口, 参数必须在 `query string`中发送。 - `POST`, `PUT`, 和 `DELETE` 方法的接口,参数可以在内容形式为`application/x-www-form-urlencoded`的 `query string` 中发送,也可以在 `request body` 中发送。 如果你喜欢,也可以混合这两种方式发送参数。 - 对参数的顺序不做要求。 - 但如果同一个参数名在query string和request body中都有,query string中的会被优先采用。 --- ## 访问限制 ### 访问限制基本信息 - 以下 是`intervalLetter` 作为头部值: - SECOND => S - MINUTE => M - HOUR => H - DAY => D - 在 `/api/v3/exchangeInfo` `rateLimits` 数组中包含与交易的有关RAW_REQUESTS,REQUEST_WEIGHT和ORDERS速率限制相关的对象。这些在 `限制种类 (rateLimitType)` 下的 `枚举定义` 部分中进一步定义。 - 违反任何一个速率限制时(访问频次限制或下单速率限制),将返回429。 ### IP 访问限制 - 每个请求将包含一个`X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,其中包含当前IP所有请求的已使用权重。 - 每一个接口均有一个相应的权重(weight),有的接口根据参数不同可能拥有不同的权重。越消耗资源的接口权重就会越大。 - 收到429时,您有责任停止发送请求,不得滥用API。 - **收到429后仍然继续违反访问限制,会被封禁IP,并收到418错误码** - 频繁违反限制,封禁时间会逐渐延长,**从最短2分钟到最长3天**。 - `Retry-After`的头会与带有418或429的响应发送,并且会给出**以秒为单位**的等待时长(如果是429)以防止禁令,或者如果是418,直到禁令结束。 - **访问限制是基于IP的,而不是API Key** ###下单频率限制 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - 当下单数超过限制时,会收到带有429但不含`Retry-After`头的响应。请检查 `GET api/v3/exchangeInfo` 的下单频率限制 (rateLimitType = ORDERS) 并等待封禁时间结束。 - 被拒绝或不成功的下单并不保证回报中包含以上头内容。 - **下单频率限制是基于每个账户计数的。** - 用户可以通过接口 `GET api/v3/rateLimit/order` 来查询当前的下单量. ### WEB SOCKET 连接限制 - Websocket服务器每秒最多接受5个消息。消息包括: - PING帧 - PONG帧 - JSON格式的消息, 比如订阅, 断开订阅. - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。 - 单个连接最多可以订阅 **1024** 个Streams。 - 每IP地址、每5分钟最多可以发送300次连接请求。 ### /api/ 与 /sapi/ 接口限频说明 `/api/*`接口和 `/sapi/*`接口采用两套不同的访问限频规则, 两者互相独立。 - `/api/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以 `/api/*`开头的接口按IP限频,**且所有接口共用每分钟6,000限制**。 - 每个请求将包含一个 `X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)`的头,包含当前IP所有请求的已使用权重。 - 每个成功的下单回报将包含一个`X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`的头,其中包含当前账户已用的下单限制数量。 - `/sapi/*`的接口相关: - 按IP和按UID(account)两种模式分别统计, 两者互相独立。 - 以`/sapi/*`开头的接口采用**单接口限频模式**。按IP统计的权重单接口权重总额为每分钟12000;按照UID统计的单接口权重总额是每分钟180000。 - 每个接口会标明是按照IP或者按照UID统计, 以及相应请求一次的权重值。 - 按照IP统计的接口, 请求返回头里面会包含`X-SAPI-USED-IP-WEIGHT-1M=`或`X-SAPI-USED-IP-WEIGHT-1S=`, 包含当前IP所有请求已使用权重。 - 按照UID统计的接口, 请求返回头里面会包含`X-SAPI-USED-UID-WEIGHT-1M=`或`X-SAPI-USED-UID-WEIGHT-1S=`, 包含当前账户所有已用的UID权重。 --- ## 数据来源 - 因为API系统是异步的, 所以返回的数据有延时很正常, 也在预期之中。 - 在每个接口中,都列出了其数据的来源,可以用于理解数据的时效性。 系统一共有3个数据来源,按照更新速度的先后排序。排在前面的数据最新,在后面就有可能存在延迟。 - **撮合引擎** - 表示数据来源于撮合引擎 - **缓存** - 表示数据来源于内部或者外部的缓存 - **数据库** - 表示数据直接来源于数据库 ## 请求鉴权类型 - 每个接口都有一个鉴权类型,指示所需的 API 密钥权限,显示在接口名称旁边(例如,[下新订单 (TRADE)](#place-new-order-trade))。 - 如果未指定,则鉴权类型为 `NONE`。 - 除了为 `NONE` 外,所有具有鉴权类型的接口均视为 `SIGNED` 请求(即包含 `signature`),[listenKey 管理](#user-data-stream-requests) 除外。 - 具有鉴权类型的接口需要提供有效的 API 密钥并验证通过。 - API 密钥可在您的 Binance 账户的 [API 管理](https://www.binance.com/en/support/faq/360002502072) 页面创建。 - **API 密钥和密钥对均为敏感信息,切勿与他人分享。** 如果发现账户有异常活动,请立即撤销所有密钥并联系 Binance 支持。 - API 密钥可配置为仅允许访问某些鉴权接口。 - 例如,您可以拥有具有 `TRADE` 权限的 API 密钥用于交易,同时使用具有 `USER_DATA` 权限的另一个 API 密钥来监控订单状态。 - 默认情况下,API 密钥无法进行 `TRADE`,您需要先在 API 管理中启用交易权限。 | 鉴权类型 | 描述 | | ----------- | ------------------------- | | NONE | 不需要鉴权的接口 | | TRADE | 需要有效的 API-Key 和签名 | | MARGIN | 需要有效的 API-Key 和签名 | | USER_DATA | 需要有效的 API-Key 和签名 | | USER_STREAM | 需要有效的 API-Key | | MARKET_DATA | 需要有效的 API-Key | ### 需要签名的接口 - 调用`SIGNED` 接口时,除了接口本身所需的参数外,还需要在 `query string` 或 `request body` 中传递 `signature`, 即签名参数。 #### 签名是否是大小写敏感的 - **HMAC:** 使用 HMAC 生成的签名**不区分大小写**。这意味着无论字母大小写如何,签名字符串都可以被验证。 - **RSA:** 使用 RSA 生成的签名是**大小写敏感的**。 - **Ed25519:** 使用 Ed25519 生成的签名也是**大小写敏感的**。 请参阅[已签名请求示例 (HMAC)](#hmac-keys)、[已签名请求示例 (RSA)](#rsa-keys) 和[已签名请求示例 (Ed25519)](#ed25519-keys),了解如何根据您使用的 API 密钥类型计算签名。 ### 时间同步安全 - `SIGNED` 请求还需要一个 `timestamp` 参数,该参数应为当前时间戳,单位为毫秒或微秒。(参见 [通用 API 信息](#general-api-information)) - 另一个可选参数 `recvWindow`,用以指定请求的有效期,只能以毫秒为单位。 - `recvWindow` 扩展为三位小数(例如 6000.346),以便可以指定微秒。 - 如果未发送 `recvWindow`,则 **默认值为 5000 毫秒**。 - `recvWindow` 的最大值为 60000 毫秒。 - 请求处理逻辑如下: ```javascript serverTime = getCurrentTime() if (timestamp < (serverTime + 1 second) && (serverTime - timestamp) <= recvWindow) { // 开始处理请求 serverTime = getCurrentTime() if (serverTime - timestamp) <= recvWindow { // 将请求转发到撮合引擎 } else { // 拒绝请求 } // 结束处理请求 } else { // 拒绝请求 } ``` **关于交易时效性** 互联网状况并不100%可靠,不可完全依赖,因此你的程序本地到币安服务器的时延会有抖动. 这是我们设置`recvWindow`的目的所在,如果你从事高频交易,对交易时效性有较高的要求,可以灵活设置`recvWindow`以达到你的要求。 **不推荐使用5秒以上的recvWindow。最大值不能超过60秒!** ### POST /api/v3/order 的签名示例 #### HMAC Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 以下示例分步演示如何使用 `echo`、`openssl` 和 `curl` 从 Linux 命令行发送有效的签名 payload。其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 API 密钥和密钥示例: | Key | Value | | ----------- | ---------------------------------------------------------------- | | `apiKey` | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A | | `secretKey` | NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j | **警告:请勿与任何人分享您的 API 密钥和秘钥。** 此处提供的示例密钥仅用于示范说明目的。 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | LTCBTC | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | BUY | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.1 | | `recvWindow` | 5000 | | `timestamp` | 1499827319559 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559 ``` **第二步: 计算签名。** 1. 使用 API 密钥中的 `secretKey` 作为 HMAC-SHA-256 算法的签名密钥。 2. 对步骤 1 中构建的签名 payload 进行签名。 3. 将 HMAC-SHA-256 的输出编码为十六进制字符串。 请注意,`secretKey` 和 payload 是**大小写敏感的**,而生成的签名值是不区分大小写的。 **示例命令** 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71 ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n "symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3 ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71" ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -s -v -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=e1353ec6b14d888f1164ae9af8228a3dbd508bc82eb867db8ab6046442f33ef3" ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash apiKey="vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" secretKey="NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" payload="symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" # 对请求进行签名 signature=$(echo -n "$payload" | openssl dgst -sha256 -hmac "$secretKey") signature=${signature#*= } # Keep only the part after the "= " # 发送请求 curl -H "X-MBX-APIKEY: $apiKey" -X POST "https://api.binance.com/api/v3/order?$payload&signature=$signature" ``` #### RSA Keys 不使用分隔符,把查询字符串与 `HTTP body` 连接在一起将生成请求的签名 payload。任何非 ASCII 字符在签名前都必须进行百分比编码(percent-encoded)。 要获取 API 密钥,您需要将 RSA 公钥上传到您的帐户中,系统将为您提供相应的 API 密钥。 仅支持 `PKCS#8` 密钥。 在以下示例中,其中一个例子中的交易对名称完全由 ASCII 字符组成,另一个例子中的交易对名称则包含非 ASCII 字符。 这些示例假设私钥存储在文件 `./test-prv-key.pem` 中。 | Key | Value | | -------- | ---------------------------------------------------------------- | | `apiKey` | CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ | 交易对名称完全由 ASCII 字符组成的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | BTCUSDT | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | 交易对名称包含非 ASCII 字符的请求示例: | 参数 | 取值 | | ------------- | ------------- | | `symbol` | 123456 | | `side` | SELL | | `type` | LIMIT | | `timeInForce` | GTC | | `quantity` | 1 | | `price` | 0.2 | | `timestamp` | 1668481559918 | | `recvWindow` | 5000 | **第一步: 构建签名 payload。** 1. 将参数格式化为 `参数=取值` 对并用 `&` 分隔每个参数对。 2. 对字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符), `parameter=value` 字符串将如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对于第二组示例参数(包含一些 Unicode 字符),`parameter=value` 字符串将如下所示: ```console symbol=123456=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` 对字符串进行百分比编码(percent-encoded)后,签名 payload 如下所示: ```console symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000 ``` **第二步: 计算签名。** 1. 使用 RSASSA-PKCS1-v1_5 算法和 SHA-256 哈希函数对步骤 1 中构建的签名 payload 进行签名。 2. 将输出结果编码为 base64 格式。 请注意,payload 和生成的`签名值`是**大小写敏感的**。 对于第一组示例参数(仅限 ASCII 字符): ```console $ echo -n 'symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' HZ8HOjiJ1s/igS9JA+n7+7Ti/ihtkRF5BIWcPIEluJP6tlbFM/Bf44LfZka/iemtahZAZzcO9TnI5uaXh3++lrqtNonCwp6/245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH+XxaCmR0WcvlKjNQnp12/eKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang/1WOq+Jaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT/fNnMRxFc7u+j3qI//5yuGuu14KR0MuQKKCSpViieD+fIti46sxPTsjSemoUKp0oXA== ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console $ echo -n 'symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000' | openssl dgst -sha256 -sign ./test-prv-key.pem | openssl enc -base64 -A | tr -d '\n' qJtv66wyp/1mZE+mIFAAMUoTe8xkmLN7/eAZjuC9x1ocxovItHLl/sNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M+JNIMz5UFxfeA53rXjFlvsyH1Sig+OuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C/QMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt/GuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng== ``` 3. 对 base64 格式的字符串进行百分比编码(percent-encoded)。 对于第一组示例参数(仅限 ASCII 字符): ```console HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D ``` **第三步: 为请求添加签名** 通过在查询字符串中添加 `signature` 参数来完成请求。 对于第一组示例参数(仅限 ASCII 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=HZ8HOjiJ1s%2FigS9JA%2Bn7%2B7Ti%2FihtkRF5BIWcPIEluJP6tlbFM%2FBf44LfZka%2FiemtahZAZzcO9TnI5uaXh3%2B%2BlrqtNonCwp6%2F245UFWkiW1elpgtVAmJPbogcAv6rSlokztAfWk296ZJXzRDYAtzGH0gq7CgSJKfH%2BXxaCmR0WcvlKjNQnp12%2FeKXJYO4tDap8UCBLuyxDnR7oJKLHQHJLP0r0EAVOOSIbrFang%2F1WOq%2BJaq4Efc4XpnTgnwlBbWTmhWDR1pvS9iVEzcSYLHT%2FfNnMRxFc7u%2Bj3qI%2F%2F5yuGuu14KR0MuQKKCSpViieD%2BfIti46sxPTsjSemoUKp0oXA%3D%3D' ``` 对于第二组示例参数(包含一些 Unicode 字符): ```console curl -H "X-MBX-APIKEY: CAvIjXy3F44yW6Pou5k8Dy1swsYDWJZLeoK2r8G4cFDnE9nosRppc2eKc1T8TRTQ" -X POST 'https://api.binance.com/api/v3/order?symbol=%EF%BC%91%EF%BC%92%EF%BC%93%EF%BC%94%EF%BC%95%EF%BC%96&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=0.2×tamp=1668481559918&recvWindow=5000&signature=qJtv66wyp%2F1mZE%2BmIFAAMUoTe8xkmLN7%2FeAZjuC9x1ocxovItHLl%2FsNK7Wq8QjgiHqGn0bb8P7yVvGBEd1gFe71NQ8aM0M%2BJNIMz5UFxfeA53rXjFlvsyH1Sig%2BOuO9Nz5nhCaJ6bEfj2iuv7w27pB3L8MVqmoCi6D9C%2FQMiLxtPaR70CxtnvoOlIgPmpv2bQy029A31NEK19ieVLkoyp1EUkXRaX3v0mohx8yMnUG1dhX9nUg3Oy8TYZ03DQy7kHDGkMKisNX7rt%2FGuGx1HIgjFclDGLsbAFIodvSLjm9FbseasMELoxlAJDlwRnW8zo5sQmL0Fz7ao935QBynrng%3D%3D' ``` 以下是一个执行上述所有步骤的 Bash 脚本示例: ```bash function rawurlencode { local string="${1}" local strlen=${#string} local encoded="" local pos c o for (( pos=0 ; pos 错误JSON格式: ```javascript { "code":-1121, "msg":"Invalid symbol." } ``` 错误由两部分组成:错误代码和消息。 代码是通用的,但是消息可能会有所不同。 ## 10xx -常规服务器或网络问题 ### -1000 UNKNOWN - 处理请求时发生未知错误。 - 处理请求时发生未知错误。[%s] ### -1001 DISCONNECTED - 内部错误; 无法处理您的请求。 请再试一次. ### -1002 UNAUTHORIZED - 您无权执行此请求。 ### -1003 TOO_MANY_REQUESTS - 排队的请求过多。 - 请求权重过多; 当前限制是 %s 每 %s 的请求权重。 请使用 Websocket Streams 进行实时更新,以避免轮询API。 - 请求权重过多; IP被禁止,直到%s。 请使用 Websocket Streams 进行实时更新,以免被禁。 ### -1004 SERVER_BUSY - 服务器正忙,请稍候再试。 ### -1006 UNEXPECTED_RESP - 从消息总线收到意外的响应。 执行状态未知。 ### -1007 TIMEOUT - 等待后端服务器响应超时。 发送状态未知; 执行状态未知。 ### -1008 SERVER_BUSY - 现货交易服务器当前因其他请求而过载。 请在几分钟后重试。 ### -1014 UNKNOWN_ORDER_COMPOSITION - 不支持的订单组合。 ### -1015 TOO_MANY_ORDERS - 新订单太多。 - 新订单太多; 当前限制为每%s %s个订单。 ### -1016 SERVICE_SHUTTING_DOWN - 该服务不可用。 ### -1020 UNSUPPORTED_OPERATION - 不支持此操作。 ### -1021 INVALID_TIMESTAMP - 此请求的时间戳在recvWindow之外。 - 此请求的时间戳比服务器时间提前1000毫秒。 ### -1022 INVALID_SIGNATURE - 此请求的签名无效。 ### -1099 Not found, authenticated, or authorized - 替换错误代码-1999 ## 11xx - 2xxx Request issues ### -1100 ILLEGAL_CHARS - 在参数中发现非法字符。 - 在参数中发现非法字符。`%s` - 在参数`%s`中发现非法字符; 合法范围是`%s`。 ### -1101 TOO_MANY_PARAMETERS - 为此端点发送的参数太多。 - 参数太多; 预期为`%s`并收到了`%s`。 - 检测到的参数值重复。 ### -1102 MANDATORY_PARAM_EMPTY_OR_MALFORMED - 未发送强制性参数,该参数为空/空或格式错误。 - 强制参数`%s`未发送,为空/空或格式错误。 - 必须发送参数`%s`或`%s`,但两者均为空! ### -1103 UNKNOWN_PARAM - 发送了未知参数。 ### -1104 UNREAD_PARAMETERS - 并非所有发送的参数都被读取。 - 并非所有发送的参数都被读取; 读取了`%s`参数,但被发送了`%s`。 ### -1105 PARAM_EMPTY - 参数为空。 - 参数`%s`为空。 ### -1106 PARAM_NOT_REQUIRED - 不需要时已发送参数。 - 不需要时发送参数`%s`。 ### -1111 BAD_PRECISION - 精度超过为此资产定义的最大值。 ### -1112 NO_DEPTH - 交易对没有挂单。 ### -1114 TIF_NOT_REQUIRED - 不需要时发送了TimeInForce参数。 ### -1115 INVALID_TIF - 无效 timeInForce. ### -1116 INVALID_ORDER_TYPE - 无效订单类型。 ### -1117 INVALID_SIDE - 无效买卖方向。 ### -1118 EMPTY_NEW_CL_ORD_ID - 新的客户订单ID为空。 ### -1119 EMPTY_ORG_CL_ORD_ID - 客户自定义的订单ID为空。 ### -1120 BAD_INTERVAL - 无效时间间隔。 ### -1121 BAD_SYMBOL - 无效的交易对。 ### -1125 INVALID_LISTEN_KEY - 该listenKey不存在。 ### -1127 MORE_THAN_XX_HOURS - 查询间隔太大。 - 从开始时间到结束时间之间超过%s小时。 ### -1128 OPTIONAL_PARAMS_BAD_COMBO - 可选参数组合无效。 ### -1130 INVALID_PARAMETER - 发送的参数为无效数据。 - 发送参数`%s`的数据无效。 ### -1131 BAD_RECV_WINDOW - `recvWindow` 必须小于 60000 ### -1134 BAD_STRATEGY_TYPE - `strategyType` 必须小于 1000000 #### -1145 INVALID_CANCEL_RESTRICTIONS - `cancelRestrictions` 必须是 `ONLY_NEW` 或者 `ONLY_PARTIALLY_FILLED`。 #### -1151 重复的交易对 - Symbol is present multiple times in the list. ### -2010 NEW_ORDER_REJECTED - 新订单被拒绝 ### -2011 CANCEL_REJECTED - 取消订单被拒绝 ### -2013 NO_SUCH_ORDER - 订单不存在。 ### -2014 BAD_API_KEY_FMT - API-key 格式无效。 ### -2015 REJECTED_MBX_KEY - 无效的API密钥,IP或操作权限。 ### -2016 NO_TRADING_WINDOW - 找不到该交易对的交易窗口。 尝试改为24小时自动报价。 #### -2026 ORDER_ARCHIVED - 订单已被存档因为此订单被取消或过期,无交易数量而最后的更新已超过 90 天前。 ## 3xxx-5xxx SAPI 具体问题 ### -3000 INNER_FAILURE - 内部服务器错误。 ### -3001 NEED_ENABLE_2FA - 请先启用2FA。 ### -3002 ASSET_DEFICIENCY - 此资产不存在。 ### -3003 NO_OPENED_MARGIN_ACCOUNT - 杠杆账户不存在。 ### -3004 TRADE_NOT_ALLOWED - 禁止交易。 ### -3005 TRANSFER_OUT_NOT_ALLOWED - 不允许转账。 ### -3006 EXCEED_MAX_BORROWABLE - 您的已借金额已超过最高可借金额。 ### -3007 HAS_PENDING_TRANSACTION - 您有待处理的交易,请稍后再试。 ### -3008 BORROW_NOT_ALLOWED - 不允许借款。 ### -3009 ASSET_NOT_MORTGAGEABLE - 此资产目前不允许转入杠杆账户。 ### -3010 REPAY_NOT_ALLOWED - 不允许还款。 ### -3011 BAD_DATE_RANGE - 您输入的日期无效。 ### -3012 ASSET_ADMIN_BAN_BORROW - 此资产禁止借款。 ### -3013 LT_MIN_BORROWABLE - 借入金额少于最低借入金额。 ### -3014 ACCOUNT_BAN_BORROW - 此帐户禁止借款。 ### -3015 REPAY_EXCEED_LIABILITY - 还款额超过借款额。 ### -3016 LT_MIN_REPAY - 还款额少于最低还款额。 ### -3017 ASSET_ADMIN_BAN_MORTGAGE - 此资产目前不允许转入保证金账户。 ### -3018 ACCOUNT_BAN_MORTGAGE - 此帐户已禁止转入。 ### -3019 ACCOUNT_BAN_ROLLOUT - 此帐户禁止转出。 ### -3020 EXCEED_MAX_ROLLOUT - 转出金额超过上限。 ### -3021 PAIR_ADMIN_BAN_TRADE - 杠杆账户无法交易此交易对。 ### -3022 ACCOUNT_BAN_TRADE - 账号被禁止交易。 ### -3023 WARNING_MARGIN_LEVEL - 无法在当前杠杆倍数下转出资金或者下单 ### -3024 FEW_LIABILITY_LEFT - 付款之后未付款的债务太小 ### -3025 INVALID_EFFECTIVE_TIME - 输入时间有误。 ### -3026 VALIDATION_FAILED - 输入参数有误。 ### -3027 NOT_VALID_MARGIN_ASSET - 无效的杠杆资产。 ### -3028 NOT_VALID_MARGIN_PAIR - 无效的杠杆交易对。 ### -3029 TRANSFER_FAILED - 转账失败。 ### -3036 ACCOUNT_BAN_REPAY - 此账号无法还款。 ### -3037 PNL_CLEARING - `PNL`正在清帐,请稍等。 ### -3038 LISTEN_KEY_NOT_FOUND - 找不到`Listen key` ### -3041 BALANCE_NOT_CLEARED - 余额不足 ### -3042 PRICE_INDEX_NOT_FOUND - 该杠杆交易对无可用价格指数。 ### -3043 TRANSFER_IN_NOT_ALLOWED - 不允许转入。 ### -3044 SYSTEM_BUSY - 系统繁忙。 ### -3045 SYSTEM - 系统目前没有足够可借的资产。 ### -3999 NOT_WHITELIST_USER - 此功能只面向邀请的用户。 ### -4001 CAPITAL_INVALID - 非法操作 ### -4002 CAPITAL_IG - 非法获取 ### -4003 CAPITAL_IEV - 非法邮箱验证 ### -4004 CAPITAL_UA - 未登录或者认证。 ### -4005 CAPAITAL_TOO_MANY_REQUEST - 请求太频繁。 ### -4006 CAPITAL_ONLY_SUPPORT_PRIMARY_ACCOUNT - 只支持主账号。 ### -4007 CAPITAL_ADDRESS_VERIFICATION_NOT_PASS - 地址的没有通过校验。 ### -4008 CAPITAL_ADDRESS_TAG_VERIFICATION_NOT_PASS - 地址的标记信息(`tag`)没有通过校验。 ### -4010 CAPITAL_WHITELIST_EMAIL_CONFIRM - 确认电子邮件已经列入白名单。 ### -4011 CAPITAL_WHITELIST_EMAIL_EXPIRED - 列入白名单的电子邮件无效。 ### -4012 CAPITAL_WHITELIST_CLOSE - 白名单未打开。 ### -4013 CAPITAL_WITHDRAW_2FA_VERIFY - 2FA未打开。 ### -4014 CAPITAL_WITHDRAW_LOGIN_DELAY - 在登录后的2分钟之内不允许提款。 ### -4015 CAPITAL_WITHDRAW_RESTRICTED_MINUTE - 暂停提款 ### -4016 CAPITAL_WITHDRAW_RESTRICTED_PASSWORD - 在密码修改后的24小时之内不允许提款。 ### -4017 CAPITAL_WITHDRAW_RESTRICTED_UNBIND_2FA - 在2FA发行后的24小时之内不允许提款。 ### -4018 CAPITAL_WITHDRAW_ASSET_NOT_EXIST - 此资产不存在。 ### -4019 CAPITAL_WITHDRAW_ASSET_PROHIBIT - 此资产不允许提款。 ### -4021 CAPITAL_WITHDRAW_AMOUNT_MULTIPLE - 资产的提款数量必须是%s的%s倍。 ### -4022 CAPITAL_WITHDRAW_MIN_AMOUNT - 不须少于最低的提款数量%s。 ### -4023 CAPITAL_WITHDRAW_MAX_AMOUNT - 在24小时之内,不须超过最高的提款数量。 ### -4024 CAPITAL_WITHDRAW_USER_NO_ASSET - 当前用户没有此资产。 ### -4025 CAPITAL_WITHDRAW_USER_ASSET_LESS_THAN_ZERO - 持有资产的数量小于零。 ### -4026 CAPITAL_WITHDRAW_USER_ASSET_NOT_ENOUGH - 此资产余额不足。 ### -4027 CAPITAL_WITHDRAW_GET_TRAN_ID_FAILURE - 无法获取tranId。 ### -4028 CAPITAL_WITHDRAW_MORE_THAN_FEE - 提款金额必须多于佣金额。 ### -4029 CAPITAL_WITHDRAW_NOT_EXIST - 此提款记录不存在。 ### -4030 CAPITAL_WITHDRAW_CONFIRM_SUCCESS - 提款资产成功。 ### -4031 CAPITAL_WITHDRAW_CANCEL_FAILURE - 取消提款失败。 ### -4032 CAPITAL_WITHDRAW_CHECKSUM_VERIFY_FAILURE - 验证提款失败。 ### -4033 CAPITAL_WITHDRAW_ILLEGAL_ADDRESS - 提款地址不合法。 ### -4034 CAPITAL_WITHDRAW_ADDRESS_CHEAT - 当前地址有异常。 ### -4035 CAPITAL_WITHDRAW_NOT_WHITE_ADDRESS - 此地址不在白名单上。请加入然后重试。 ### -4036 CAPITAL_WITHDRAW_NEW_ADDRESS - 新地址在{0}小时后才可以提款。 ### -4037 CAPITAL_WITHDRAW_RESEND_EMAIL_FAIL - 重新发送邮件失败。 ### -4038 CAPITAL_WITHDRAW_RESEND_EMAIL_TIME_OUT - 请5分钟后重试。 ### -4039 CAPITAL_USER_EMPTY - 用户不存在。 ### -4041 CAPITAL_MINUTE_TOO_SMALL - 请一分钟后重试。 ### -4042 CAPITAL_CHARGE_NOT_RESET - 资产无法重新获取存款地址。 ### -4043 CAPITAL_ADDRESS_TOO_MUCH - 在24小时之内充值超过100多个地址。 ### -4044 CAPITAL_BLACKLIST_COUNTRY_GET_ADDRESS - 此国家在黑名单上。 ### -4045 CAPITAL_GET_ASSET_ERROR - 获得资产失败。 ### -4046 CAPITAL_AGREEMENT_NOT_CONFIRMED - 协议未确认。 ### -4047 CAPITAL_DATE_INTERVAL_LIMIT - 时间间隔必须在0-90天之内 ### -4060 CAPITAL_WITHDRAW_USER_ASSET_LOCK_DEPOSIT - 体现仍在区块确认中,暂时锁定部分资产 ### -4106 TAG_NOT_SUPPORTED_FOR_NETWORK - 该网络不支持 memo/tag。请移除 `addressTag` 字段后重试。 ### -5001 ASSET_DRIBBLET_CONVERT_SWITCH_OFF - 不允许转移到微型资产。 ### -5002 ASSET_ASSET_NOT_ENOUGH - 此余额不足。 ### -5003 ASSET_USER_HAVE_NO_ASSET - 此资产不存在。 ### -5004 USER_OUT_OF_TRANSFER_FLOAT - 剩余余额已超过0.001BTC,请重新选择。 - %s的剩余余额已超过0.001BTC,请重新选择。 ### -5005 USER_ASSET_AMOUNT_IS_TOO_LOW - BTC的剩余余额太低,请重新选择。 - %s的剩余余额太低,请重新选择。 ### -5006 USER_CAN_NOT_REQUEST_IN_24_HOURS - 24小时内只能转账一次。 ### -5007 AMOUNT_OVER_ZERO - 数量必须大于零。 ### -5008 ASSET_WITHDRAW_WITHDRAWING_NOT_ENOUGH - 可退回资产的金额不足。 ### -5009 PRODUCT_NOT_EXIST - 产品不存在。 ### -5010 TRANSFER_FAIL - 资产转移失败。 ### -5011 FUTURE_ACCT_NOT_EXIST - 合约帐户不存在。 ### -5012 TRANSFER_PENDING - 资产转移正在进行中。 ### -5021 PARENT_SUB_HAVE_NO_RELATION - 当前的子账户和母账户没有从属关系。 ### -5012 FUTURE_ACCT_OR_SUBRELATION_NOT_EXIST - 合约帐户或子账户关系不存在。 ## 6XXX - 币安宝相关 ### -6001 DAILY_PRODUCT_NOT_EXIST - 理财产品不存在. ### -6003 DAILY_PRODUCT_NOT_ACCESSIBLE - 产品不存在或者没有权限。 ### -6004 DAILY_PRODUCT_NOT_PURCHASABLE - 产品无法购买。 ### -6005 DAILY_LOWER_THAN_MIN_PURCHASE_LIMIT - 低于可以购买的最小限额。 ### -6006 DAILY_REDEEM_AMOUNT_ERROR - 赎回额度有误。 ### -6007 DAILY_REDEEM_TIME_ERROR - 不在赎回的时间内。 ### -6008 DAILY_PRODUCT_NOT_REDEEMABLE - 产品暂时无法赎回。 ### -6009 REQUEST_FREQUENCY_TOO_HIGH - 发送请求太频繁。 ### -6011 EXCEEDED_USER_PURCHASE_LIMIT - 超购每个月用户可以申购的最大次数。 ### -6012 BALANCE_NOT_ENOUGH - 余额不足。 ### -6013 PURCHASING_FAILED - 申购失败。 ### -6014 UPDATE_FAILED - 超过可以申购的最大上限。 ### -6015 EMPTY_REQUEST_BODY - 请求的`body`为空。 ### -6016 PARAMS_ERR - 请求的参数有误。 ### -6017 NOT_IN_WHITELIST - 不在白名单里面。 ### -6018 ASSET_NOT_ENOUGH - 资产不足。 ### -6019 PENDING - 需要进一步确认。 ### -6020 PROJECT_NOT_EXISTS - 此项目不存在。 ## 70xx - 期货 ### -7001 FUTURES_BAD_DATE_RANGE - 此日期范围不支持。 ### -7002 FUTURES_BAD_TYPE - 此数据请求类型不支持。 ## 20xxx - 合约/现货策略交易 ### -20121 Invalid symbol - 无效交易对。 ### -20124 Invalid algo id or it has been completed - 无效的策略订单ID或者它已经被执行。 ### -20130 Invalid data sent for a parameter - 无效数据。 ### -20132 The client algo id is duplicated - 用户自定义策略订单ID重复。 ### -20194 Duration is too short to execute all required quantity - Duration 时间太短不足以执行用户选择的订单数量。 ### -20195 The total size is too small - 下单数量太小。 ### -20196 The total size is too large - 下单数量太大。 ### -20198 Reach the max open orders allowed - 达到了最大挂单上限。 ### -20204 The notional of USD is less or more than the limit - 订单小于最小USD名义价值 ## 过滤器故障 | 报错信息 | 描述 | | ------------------------------------------ | ---------------------------------------------------------------------------------- | | "Filter failure: PRICE_FILTER" | "价格"过高,过低和/或不遵循交易对的最小价格规则。 | | "Filter failure: PERCENT_PRICE" | "价格"比最近Y分钟的平均加权价格高X%或X%太低。 | | "Filter failure: PERCENT_PRICE_BY_SIDE" | `price` 在当前方向上(`BUY`或者`SELL`)比`lastPrice`价格超过X%或者低于Y%。 | | "Filter failure: LOT_SIZE" | "数量"太高,太低和/或不遵循该交易对的步长规则。 | | "Filter failure: MIN_NOTIONAL" | 价格\*数量太低,无法成为该交易对的有效订单。 | | "Filter failure: ICEBERG_PARTS" | `ICEBERG` 订单会分成太多部分; icebergQty太小。 | | "Filter failure: MARKET_LOT_SIZE" | "MARKET"订单的"数量"过高,过低和/或未遵循交易对的步长规则。 | | "Filter failure: MAX_POSITION" | 达到账户的最大仓位限制。这包括了账户的余额总额,以及所有处于open的买单的数量总和。 | | "Filter failure: MAX_NUM_ORDERS" | 客户在交易对上有太多挂单。 | | "Filter failure: MAX_ALGO_ORDERS" | 账户有太多未平仓止损和/或在交易对上执行获利指令。 | | "Filter failure: MAX_NUM_ICEBERG_ORDERS" | 客户在交易对上有太多 iceberg 挂单。 | | "Filter failure: TRAILING_DELTA" | `trailingDelta` 值不在限定的范围内. | | "Filter failure: EXCHANGE_MAX_NUM_ORDERS" | 帐户上的交易所有太多挂单。 | | "Filter failure: EXCHANGE_MAX_ALGO_ORDERS" | 帐户有太多止损挂单和/或在交易所收取获利指令。 | ## 10xxx - 质押借币 ### -10001 SYSTEM_MAINTENANCE - 系统维护中,请稍后再试 ### -10002 INVALID_INPUT - 无效的输入参数 ### -10005 NO_RECORDS - 暂无记录 ### -10007 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10008 COIN_NOT_LOANABLE - 该币种暂不支持借贷 ### -10009 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10010 COIN_NOT_COLLATERAL - 该币种暂不支持抵押 ### -10011 INSUFFICIENT_ASSET - 现货资产不足 ### -10012 INVALID_AMOUNT - 无效的还款金额 ### -10013 INSUFFICIENT_AMOUNT - 抵押资产不足 ### -10015 DEDUCTION_FAILED - 抵押资产扣款失败 ### -10016 LOAN_FAILED - 放贷失败 ### -10017 REPAY_EXCEED_DEBT - 还款金额超过负债金额 ### -10018 INVALID_AMOUNT - 无效的还款金额 ### -10019 CONFIG_NOT_EXIST - 配置不存在 ### -10020 UID_NOT_EXIST - 用户ID不存在 ### -10021 ORDER_NOT_EXIST - 订单不存在 ### -10022 INVALID_AMOUNT - 无效的调整金额 ### -10023 ADJUST_LTV_FAILED - 调整质押率失败 ### -10024 ADJUST_LTV_NOT_SUPPORTED - 暂不支持调整质押率 ### -10025 REPAY_FAILED - 还款失败 ### -10026 INVALID_PARAMETER - 无效的参数 ### -10028 INVALID_PARAMETER - 无效的参数 ### -10029 AMOUNT_TOO_SMALL - 借贷金额过小 ### -10030 AMOUNT_TOO_LARGE - 借贷金额过大 ### -10031 QUOTA_REACHED - 已达到个人借贷限额 ### -10032 REPAY_NOT_AVAILABLE - 暂不支持换款 ### -10034 REPAY_NOT_AVAILABLE - 抵押物还款暂时不支持,请尝试用借贷币还款。 ### -10039 AMOUNT_TOO_SMALL - 还款金额过小 ### -10040 AMOUNT_TOO_LARGE - 还款金额过大 ### -10041 INSUFFICIENT_AMOUNT - 由于借贷需求过多,系统剩余可借{0}额度不足。请调整借贷金额或明天再试。 ### -10042 ASSET_NOT_SUPPORTED - 暂不支持%s币种 ### -10043 ASSET_NOT_SUPPORTED - 暂不支持{0} 借贷 ### -10044 QUOTA_REACHED - 抵押物数量已达到限额,请调整抵押金额或使用其他抵押资产。 ### -10045 COLLTERAL_REPAY_NOT_SUPPORTED - 该借贷币种暂不支持抵押物还款,请稍后再试。 ### -10046 EXCEED_MAX_ADJUSTMENT - 调整抵押物超过最大限额,请重试。 ### -10047 REGION_NOT_SUPPORTED - 受当地法规管制,您所在地区暂不支持该币种。 ## 13xxx - 杠杆代币 ### -13000 BLVT_FORBID_REDEEM - 当前该杠杆代币关闭赎回 ### -13001 BLVT_EXCEED_DAILY_LIMIT - 超过该代币个人24小时赎回金额上限 ### -13002 BLVT_EXCEED_TOKEN_DAILY_LIMIT - 超过该代币全局24小时赎回金额上限 ### -13003 BLVT_FORBID_PURCHASE - 当前该杠杆代币关闭申购 ### -13004 BLVT_EXCEED_DAILY_PURCHASE_LIMIT - 超过该代币个人24小时申购金额上限 ### -13005 BLVT_EXCEED_TOKEN_DAILY_PURCHASE_LIMIT - 超过该代币全局24小时申购金额上限 ### -13006 BLVT_PURCHASE_LESS_MIN_AMOUNT - 申购金额低于规定下限 ### -13007 BLVT_PURCHASE_AGREEMENT_NOT_SIGN - 没有签署开通交易协议 ## 12xxx - 流动性挖矿 ### -12014 TOO MANY REQUESTS - 2秒内接收的请求数量多于1条 ## 18xxx - 币安码 ### -18002 - The total amount of codes you created has exceeded the 24-hour limit, please try again after UTC 0 - 24小时内制码总金额已超过限额,请UTC0点后再尝试 ### -18003 - Too many codes created in 24 hours, please try again after UTC 0 - 24小时内制码总次数已超过限额,请UTC0点后再尝试 ### -18004 - Too many invalid redeem attempts in 24 hours, please try again after UTC 0 - 24小时内兑现币安码输错次数已超过限额,请UTC0点后再尝试 ### -18005 - Too many invalid verify attempts, please try later - 参考号输错次数过多,请稍后再试 ### -18006 - The amount is too small, please re-enter - 金额过小,请重新输入 ### -18007 - This token is not currently supported, please re-enter - 尚未支持该币种,请重新输入 ## 21xxx - 統一帳戶 ### -21001 USER_IS_NOT_UNIACCOUNT - 尚未开通统一账户。 ### -21002 UNI_ACCOUNT_CANT_TRANSFER_FUTURE - 统一账户禁用margin向futures转账。 ### -21003 NET_ASSET_MUST_LTE_RATIO - margin资产更新失败。 ### -21004 USER_NO_LIABILITY - 用户不存在统一账户穿仓负债 ### -21005 NO_ENOUGH_ASSET - 用户现货钱包BUSD资产不足以偿还统一账户穿仓负债 ### -21006 HAD_IN_PROCESS_REPAY - 用户存在正在偿还的统一账户穿仓负债 ### -21007 IN_FORCE_LIQUIDATION - 强平进行中,用户偿还统一账户穿仓负债失败 ## 订单拒绝错误 以下错误代码表示撮合引擎返回的订单相关错误: - `-1010 ERROR_MSG_RECEIVED` - `-2010 NEW_ORDER_REJECTED` - `-2011 CANCEL_REJECTED` 结合以下消息将指示特定的错误: | 错误信息 | 描述 | | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | "Unknown order sent." | 找不到订单(通过"orderId","clientOrderId","origClientOrderId") | | "Duplicate order sent." | `clientOrderId`已经被使用 | | "Market is closed." | 该交易对不在交易范围 | | "Account has insufficient balance for requested action." | 没有足够的资金来完成行动 | | "Market orders are not supported for this symbol." | 交易对上未启用"MARKET" | | "Iceberg orders are not supported for this symbol." | 交易对上未启用`icebergQty` | | "Stop loss orders are not supported for this symbol." | 交易对上未启用 `STOP_LOSS` | | "Stop loss limit orders are not supported for this symbol." | 交易对上未启`STOP_LOSS_LIMIT` | | "Take profit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT` | | "Take profit limit orders are not supported for this symbol." | 交易对上未启用`TAKE_PROFIT_LIMIT` | | "Price \* QTY is zero or less." | `price` \* `quantity`太小 | | "IcebergQty exceeds QTY." | `icebergQty` 必须少于订单数量 | | "This action is disabled on this account." | 联系客户支持; 该账户已禁用了某些操作。 | | "This account may not place or cancel orders." | 联系客户支持: 该账户已被禁用了交易操作。 | | "Unsupported order combination" | 不允许组合`orderType`, `timeInForce`, `stopPrice`, 和/或 `icebergQty` 。 | | "Order would trigger immediately." | 与最后交易价格相比,订单的止损价无效。 | | "Cancel order is invalid. Check origClientOrderId and orderId." | 未发送`origClientOrderId` 或`orderId` 。 | | "Order would immediately match and take." | `LIMIT_MAKER` 订单类型将立即匹配并进行交易,而不是纯粹的生成订单。 | | "The relationship of the prices for the orders is not correct." | `OCO`订单中设置的价格不符合报价规则:

The rules are:

`SELL Orders`: Limit Price > Last Price > Stop Price

`BUY Orders`: Limit Price < Last Price < Stop Price | | "OCO orders are not supported for this symbol" | `OCO`订单不支持该交易对 | | "Quote order qty market orders are not support for this symbol." | 这个交易对,市价单不支持参数`quoteOrderQty` | | "Trailing stop orders are not supported for this symbol." | 此symbol不支持 `trailingDelta` | | | "Order cancel-replace is not supported for this symbol." | 此symbol不支持 `POST /api/v3/order/cancelReplace` 或者 `order.cancelReplace` (WebSocket API) | | | "This symbol is not permitted for this account." | 账户和交易对的权限不一致 (比如 `SPOT`, `MARGIN` 等)。| | | "This symbol is restricted for this account." | 账户没有权限在此交易对交易 (比如账户只拥有 `ISOLATED_MARGIN`权限,则无法下`SPOT` 订单)。 | | | "Order was not canceled due to cancel restrictions." | `cancelRestrictions` 设置为 `ONLY_NEW` 但订单状态不是 `NEW`

`cancelRestrictions` 设置为 `ONLY_PARTIALLY_FILLED` 但订单状态不是 `PARTIALLY_FILLED`。 | | ## 关于 POST /api/v3/order/cancelReplace 的错误 ### -2021 Order cancel-replace partially failed 收到该错误码代表撤单**或者**下单失败。 ### -2022 Order cancel-replace failed. 收到该错误码代表撤单**和**下单都失败。 --- ## Document: /products/common/sapi/contact-us URL: /zh-CN/docs/products/common/sapi/contact-us # 联系我们 - [币安API电报群](https://t.me/Binance_api_Chinese) - 咨询关于API或者Websockets性能方面的问题. - 咨询文档中没有提及的API问题. - [币安开发者社区](https://dev.binance.vision/) - 咨询关于API/Websockets代码实现,或者任何API/Websockets的问题. - [币安客服](https://www.binance.com/cn/support-center) - 咨询关于账户,钱包,2FA等. --- ## Document: /products/common/sapi/change-log URL: /zh-CN/docs/products/common/sapi/change-log # Change Log ## 2023-05-26 **Notice:** The change below are being rolled out, and will take approximately a week to complete. - The following base endpoints may give better performance but have less stability than **https://api.binance.com**: - **https://api1.binance.com** - **https://api2.binance.com** - **https://api3.binance.com** - **https://api4.binance.com** --- ## 2023-05-24 - **The previous market data URLs have been deprecated. Please update your code immediately to prevent interruption of our services.** - API Market data from `data.binance.com` can now be accessed from `data-api.binance.vision`. - Websocket Market Data from `data-stream.binance.com` can now be accessed from `data-stream.binance.vision`. - New endpoints for Classic Portfolio Margin: - `POST /sapi/v1/portfolio/auto-collection`: classic portfolio Margin fund collection - `POST /sapi/v1/portfolio/bnb-transfer`: classic portfolio margin BNB transfer - `GET /sapi/v1/portfolio/interest-rate` has be deprecated, users can query the Classic Portfolio Margin Negative Balance Interest Rate by using `GET /sapi/v1/margin/interestRateHistory`. --- ## 2023-05-18 - New endpoints for Wallet: - `POST /sapi/v1/capital/deposit/credit-apply`: apply deposit credit for expired address --- ## 2023-05-09 - New endpoints for Portfolio Margin: - `GET /sapi/v1/portfolio/asset-index-price`: query portfolio margin asset index price - Update endpoints for Wallet: - `POST /sapi/v1/asset/transfer`: add enum `MAIN_PORTFOLIO_MARGIN` and `PORTFOLIO_MARGIN_MAIN` --- ## 2023-04-20 - New endpoints for Sub-Account: - `GET /sapi/v1/managed-subaccount/deposit/address`: get managed sub-account deposit address - Update endpoints for VIP Loans: - `GET /sapi/v1/loan/vip/ongoing/orders`: add fields `totalCollateralValueAfterHaircut` and `lockedCollateralValue` --- ## 2023-04-18 - New endpoints for Spot Algo: - `POST /sapi/v1/algo/spot/newOrderTwap` to support new order - `DELETE /sapi/v1/algo/spot/order` to support cancel Algo order - `GET /sapi/v1/algo/spot/openOrders` to support query Algo open orders - `GET /sapi/v1/algo/spot/historicalOrders` to support query Algo historical orders - `GET /sapi/v1/algo/spot/subOrders` to support query Algo sub orders for a specified algoId --- ## 2023-03-23 - Update endpoints for Sub-Account: - `GET /sapi/v1/managed-subaccount/queryTransLogForInvestor`: Add response field `tranId` - `GET /sapi/v1/managed-subaccount/queryTransLogForTradeParent`: Add response field `tranId` - New endpoints for Sub-Account: - `GET /sapi/v1/managed-subaccount/info`: query investor's managed sub-account list - `GET /sapi/v1/sub-account/transaction-statistics`: Query sub-account transaction tatistics --- ## 2023-03-13 **Notice:** All changes are being rolled out gradually to all our servers, and may take a week to complete. GENERAL CHANGES - The error messages for certain issues have been improved for easier troubleshooting.
Situation Old Error Message New Error Message
An account cannot place or cancel an order, due to trading ability disabled. This action is disabled on this account. This account may not place or cancel orders.
When the permissions configured on the symbol do not match the permissions on the account. This symbol is not permitted for this account.
When the account tries to place an order on a symbol it has no permissions for. This symbol is restricted for this account.
Placing an order when symbol is not TRADING. Unsupported order combination. This order type is not possible in this trading phase.
Placing an order with timeinForce=IOC or FOK on a trading phase that does not support it. Limit orders require GTC for this phase.
- Fixed error message for querying archived orders: - Previously, If an archived order (i.e. order with status `CANCELED` or `EXPIRED` where `executedQty` == 0 that occurred more than 90 days in the past.) is queried, the error message would be: - `{"code": -2013,"msg": "Order does not exist."}` - Now, the error message is: - `{"code": -2026,"msg": "Order was canceled or expired with no executed qty over 90 days ago and has been archived."}` - Behavior for API requests with `startTime` and `endTime`: - Previously some requests failed if the `startTime` == `endTime`. - Now, all API requests that accept `startTime` and `endTime` allow the parameters to be equal. This applies to the following requests: - Rest API - `GET /api/v3/aggTrades` - `GET /api/v3/klines` - `GET /api/v3/allOrderList` - `GET /api/v3/allOrders` - `GET /api/v3/myTrades` The following changes will take effect **approximately a week from the release date**, but the rest of the documentation has been updated to reflect the future changes: - Changes to Filter Evaluation: - Previous behavior: `LOT_SIZE` and `MARKET_LOT_SIZE` required that (`quantity` - `minQty`) % `stepSize` == 0. - New behavior: This has now been changed to (`quantity` % `stepSize`) == 0. - Bug fix with reverse `MARKET` orders (i.e., `MARKET` using `quoteOrderQty`): - Previous behavior: Reverse market orders would always have the status `FILLED` even if the order did not fully fill due to low liquidity. - New behavior: If the reverse market order did not fully fill due to low liquidity the order status will be `EXPIRED`, and `FILLED` only if the order was completely filled. SPOT API - Changes to `DELETE /api/v3/order` and `POST /api/v3/order/cancelReplace`: - A new optional parameter `cancelRestrictions` that determines whether the cancel will succeed if the order status is `NEW` or `PARTIALLY_FILLED`. - If the order cancellation fails due to `cancelRestrictions`, the error will be: - `{"code": -2011,"msg": "Order was not canceled due to cancel restrictions."}` --- ## 2023-02-27 - New endpoints for Margin: - `/sapi/v1/margin/next-hourly-interest-rate`: Get user the next hourly estimate interest - New endpoints for Porfolio Margin: - `GET /sapi/v1/portfolio/interest-history`: get user's portfolio margin interest history - `GET /sapi/v1/portfolio/interest-rate`: get portfolio margin interest rate --- ## 2023-02-21 - Adjusted endpoints for Crypto Loan: - `POST /sapi/v1/loan/borrow`: paramater `loanTerm` is restricted to 7 or 30 --- ## 2023-02-17 The Websocket Stream now only allows 300 connections requests every 5 minutes. This limit is **per IP address**. Please be careful when trying to open multiple connections or reconnecting to the Websocket API. --- ## 2023-02-13 - New endpoints for Sub-Account: - `GET /sapi/v4/sub-account/assets`: Fetch sub-account assets --- ## 2023-02-02 - New endpoints for Margin: - `GET /sapi/v1/margin/exchange-small-liability`: Query the coins which can be small liability exchange - `POST /sapi/v1/margin/exchange-small-liability`: Cross Margin Small Liability Exchange - `GET /sapi/v1/margin/exchange-small-liability-history`: Get Small liability Exchange History - Update endpoints for Wallet: - Universal Transfer `POST /sapi/v1/asset/transfer` support option transfer --- ## 2023-01-26 As per the [announcement](https://www.binance.com/en/support/announcement/binance-spot-launches-self-trade-prevention-stp-function-on-api-312fd0112fb44635b397c116e56d8f84), Self Trade Prevention will be enabled at **2023-01-26 08:00 UTC**. Please refer to `GET /api/v3/exchangeInfo` from the Rest API or `exchangeInfo` from the Websocket API on the default and allowed modes. --- ## 2023-01-23 New API cluster has been added. Note that all endpoints are functionally equal, but may vary in performance. - https://api4.binance.com --- ## 2023-01-19 **ACTUAL RELEASE DATE TBD** SPOT API **New Feature**: Self-Trade Prevention (aka STP) will be added to the system at a later date. This will prevent orders from matching with orders from the same account, or accounts under the same `tradeGroupId`. Please refer to `GET /api/v3/exchangeInfo` from the SPOT API or `exchangeInfo` from the Websocket API on the status. ```javascript "defaultSelfTradePreventionMode": "NONE", //If selfTradePreventionMode not provided, this will be the value passed to the engine "allowedSelfTradePreventionModes": [ //What the allowed modes of selfTradePrevention are "NONE", "EXPIRE_TAKER", "EXPIRE_BOTH", "EXPIRE_MAKER" ] ``` - New order status: `EXPIRED_IN_MATCH` - This means that the order expired due to STP being triggered. - New endpoint: - `GET /api/v3/myPreventedMatches` - This queries the orders that expired due to STP being triggered. - New optional parameter `selfTradePreventionMode` has been added to the following endpoints: - `POST /api/v3/order` - `POST /api/v3/order/oco` - `POST /api/v3/cancelReplace` - New responses that will appear for all order placement endpoints if there was a prevented match (i.e. if an order could have matched with an order of the same account, or the accounts are in the same `tradeGroupId`): - `tradeGroupId` - This will only appear if account is configured to a `tradeGroupId` and if there was a prevented match. - `preventedQuantity` - Only appears if there was a prevented match. - An array `preventedMatches` with the following fields: - `preventedMatchId` - `makerOrderId` - `price` - `takerPreventedQuantity` - This will only appear if `selfTradePreventionMode` set is `EXPIRE_TAKER` or `EXPIRE_BOTH`. - `makerPreventedQuantity` - This will only appear if `selfTradePreventionMode` set is `EXPIRE_MAKER` or `EXPIRE_BOTH`. - New fields `preventedMatchId` and `preventedQuantity` that can appear in the order query endpoints if the order had expired due to an STP trigger: - `GET /api/v3/order` - `GET /api/v3/openOrders` - `GET /api/v3/allOrders` USER DATA STREAM - New execution Type: `TRADE_PREVENTION` - New fields for `executionReport` (These fields will only appear if the order has expired due to STP trigger) - `u` - `tradeGroupId` - `v` - `preventedMatchId` - `U` - `counterOrderId` - `A` - `preventedQuantity` - `B` - `lastPreventedQuantity` --- ## 2023-01-13 - The following endpoints will be discontinued on January 13, 2023 6:00 AM UTC: - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction` to support master account enable and disable IP restriction for a sub-account API Key - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList` to support master account add IP list for a sub-account API Key - New endpoints for Sub-Account: - `GET /sapi/v1/managed-subaccount/fetch-future-asset`: Investor can use this api to query managed sub account futures asset details - `GET /sapi/v1/managed-subaccount/marginAsset`: Investor can use this api to query managed sub account margin asset details - New endpoin for Margin: - `GET /sapi/v1/margin/crossMarginCollateralRatio`: Get cross margin collateral ratio --- ## 2023-01-05 - New endpoints for Sub-Account: - `GET /sapi/v1/managed-subaccount/queryTransLogForInvestor`: Investor can use this api to query managed sub account transfer log - `GET /sapi/v1/managed-subaccount/queryTransLogForTradeParent`: Trading team can use this api to query managed sub account transfer log --- ## 2022-12-26 - New endpoints for wallet: - `GET /sapi/v1/capital/contract/convertible-coins`: Get a user's auto-conversion settings in deposit/withdrawal - `POST /sapi/v1/capital/contract/convertible-coins`: User can use it to turn on or turn off the BUSD auto-conversion from/to a specific stable coin. --- ## 2022-12-15 - New RSA signature - Documentation has been updated to show how to sign a request using an RSA key. - For security reasons, we recommend to use RSA keys instead of HMAC keys when generating an API key. - We accept `PKCS#8` (BEGIN PUBLIC KEY). - More details on how to upload your RSA public key will be added at a later date. --- ## 2022-12-13 REST API Some error messages on error code `-1003` have changed: - Previous error message: `Too much request weight used; current limit is %s request weight per %s %s. Please use the websocket for live updates to avoid polling the API.` has been updated to: `Too much request weight used; current limit is %s request weight per %s. Please use WebSocket Streams for live updates to avoid polling the API.` - Previous error message `Way too much request weight used; IP banned until %s. Please use the websocket for live updates to avoid bans.` has been updated to: `Way too much request weight used; IP banned until %s. Please use WebSocket Streams for live updates to avoid bans.` --- ## 2022-12-05 **Notice:** These changes are being rolled out gradually to all our servers, and will take approximately a week to complete. WEBSOCKET - `!bookTicker` will be removed by **December 7, 2022**. Please use the Individual Book Ticker Streams instead. (<symbol>@bookTicker). - Multiple <symbol>@bookTicker streams can be subscribed to over one connection. (E.g. `wss://stream.binance.com:9443/stream?streams=btcusdt@bookTicker/bnbbtc@bookTicker`) SPOT API - New error code `-1135` - This error code will occur if a parameter requiring a JSON object is invalid. - New error code `-1108` - This error will occur if a value to a parameter being sent was too large, potentially causing overflow. - This error code can occur in the following endpoints: - `POST /api/v3/order` - `POST /api/v3/order/cancelReplace` - `POST /api/v3/order/oco` - Changes to `GET /api/v3/aggTrades` - Previous behavior: `startTime` and `endTime` had to be used in combination and could only be an hour apart. - New behavior: `startTime` and `endTime` can be used individually and the 1 hour limit has been removed. - When using `startTime` only, this will return trades from that time, up to the `limit` provided. - When using `endTime` only, this will return trades starting from the `endTime` including all trades before that time, up to the limit provided. - If `limit` not provided, regardless of used in combination or sent individually, the endpoint will use the default limit. - Changes to `GET /api/v3/myTrades` - Fixed a bug where `symbol` + `orderId` combination would return all trades even if the number of trades went beyond the `500` default limit. - Previous behavior: The API would send specific error messages depending on the combination of parameters sent. E.g: ` { "code": -1106, "msg": "Parameter X was sent when not required." } ` - New behavior: If the combinations of optional parameters to the endpoint were not supported, then the endpoint will respond with the generic error: ` { "code": -1128, "msg": "Combination of optional parameters invalid." } ` - Added a new combination of supported parameters: `symbol` + `orderId` + `fromId`. - The following combinations of parameters were previously supported but no longer accepted, as these combinations were only taking `fromId` into consideration, ignoring `startTime` and `endTime`: - `symbol` + `fromId` + `startTime` - `symbol` + `fromId` + `endTime` - `symbol` + `fromId` + `startTime` + `endTime` - Thus, these are the supported combinations of parameters: - `symbol` - `symbol` + `orderId` - `symbol` + `startTime` - `symbol` + `endTime` - `symbol` + `fromId` - `symbol` + `startTime` + `endTime` - `symbol`+ `orderId` + `fromId` **Note:** These new fields will appear approximately a week from the release date. - Changes to `GET /api/v3/exchangeInfo` - New fields `defaultSelfTradePreventionMode` and `allowedSelfTradePreventionModes` - Changes to the Order Placement Endpoints/Order Query/Order Cancellation Endpoints: - New field `selfTradePreventionMode` will appear in the response. - Affects the following endpoints: - `POST /api/v3/order` - `POST /api/v3/order/oco` - `POST /api/v3/order/cancelReplace` - `GET /api/v3/order` - `DELETE /api/v3/order` - `DELETE /api/v3/orderList` - Changes to `GET /api/v3/account` - New field `requireSelfTradePrevention` will appear in the response. - New field `workingTime`, indicating when the order started working on the order book, will appear in the following endpoints: - `POST /api/v3/order` - `GET /api/v3/order` - `POST /api/v3/order/cancelReplace` - `POST /api/v3/order/oco` - `GET /api/v3/order` - `GET /api/v3/openOrders` - `GET /api/v3/allOrders` - Field `trailingTime`, indicating the time when the trailing order is active and tracking price changes, will appear for the following order types (`TAKE_PROFIT`, `TAKE_PROFIT_LIMIT`, `STOP_LOSS`, `STOP_LOSS_LIMIT` if `trailingDelta` parameter was provided) for the following endpoints: - `POST /api/v3/order` - `GET /api/v3/order` - `GET /api/v3/openOrders` - `GET /api/v3/allOrders` - `POST /api/v3/order/cancelReplace` - `DELETE /api/v3/order` - Field `commissionRates` will appear in the `GET /api/v3/acccount` response USER DATA STREAM - eventType `executionReport` has new fields - `V` - `selfTradePreventionMode` - `D` - `trailing_time` (Appears if the trailing stop order is active) - `W` - `workingTime` (Appears if `isWorking`=`true`) --- ## 2022-12-02 - Added a new market data base URL `https://data.binance.com`. - Added a new WebSocket URL `wss://data-stream.binance.com`. --- ## 2022-11-29 - New endpoint for VIP Loan: - `GET /sapi/v1/loan/vip/collateral/account: Check Locked Value of VIP Collateral Account --- ## 2022-11-22 - New endpoints for Convert: - `GET /sapi/v1/convert/exchangeInfo`: Query for all convertible token pairs and the tokens’ respective upper/lower limits - `GET /sapi/v1/convert/assetInfo`: Query for supported asset’s precision information - `POST /sapi/v1/convert/getQuote`: Request a quote for the requested token pairs - `POST /sapi/v1/convert/acceptQuote`: Accept the offered quote by quote ID. - `GET /sapi/v1/convert/orderStatus`: Query order status by order ID. --- ## 2022-11-18 - New endpoint for Wallet: - `GET /sapi/v1/asset/ledger-transfer/cloud-mining/queryByPage`: The query of Cloud-Mining payment and refund history - New endpoints for Sub-account: - `GET /sapi/v1/sub-account/apiRestrictions/ipRestriction/thirdPartyList`: To query Sub-Account API key Third Party IP whitelist - `POST /sapi/v2/sub-account/subAccountApi/ipRestriction`: To support master account update IP Restriction for Sub-Account API key --- ## 2022-11-14 - New endpoints for VIP Loan: - `GET /sapi/v1/loan/vip/ongoing/orders`: Get VIP Loan Ongoing Orders - `POST /sapi/v1/loan/vip/repay`: VIP Loan Repay - `GET /sapi/v1/loan/vip/repay/history`: Get VIP Loan Repayment History --- ## 2022-11-02 - Update endpoints for Wallet: - `POST /sapi/v1/capital/withdraw/apply`: Weight changed to Weight(UID): 600 --- ## 2022-11-01 - New endpoints for Crypto Loan: - `GET /sapi/v1/loan/loanable/data`: Get interest rate and borrow limit of loanable assets. The borrow limit is shown in USD value. - `GET /sapi/v1/loan/collateral/data`: Get LTV information and collateral limit of collateral assets. The collateral limit is shown in USD value. - `GET /sapi/v1/loan/repay/collateral/rate`: Get the the rate of collateral coin / loan coin when using collateral repay, the rate will be valid within 8 second. - `POST /sapi/v1/loan/customize/margin_call`: Customize margin call for ongoing orders only. --- ## 2022-10-28 - Update endpoints for Wallet: - `POST /sapi/v1/asset/convert-transfer`: New parameter `accountType` - `POST /sapi/v1/asset/convert-transfer/queryByPage`: request method is changed to `GET`, new parameter `clientTranId` --- ## 2022-10-15 - New endpoints for Binance Code: - `POST /sapi/v1/giftcard/buyCode`: For buying a fixed-value Binance Code. - `GET /sapi/v1/giftcard/buyCode/token-limit`: To verify which tokens are available for you to purchase fixed-value gift cards as mentioned in section 2 and its’ limitation. --- ## 2022-09-30 - Delete endpoints for Futures Cross Collateral: - `POST /sapi/v1/futures/loan/borrow` - `POST /sapi/v1/futures/loan/repay` - `GET /sapi/v1/futures/loan/configs` - `GET /sapi/v2/futures/loan/configs` - `GET /sapi/v1/futures/loan/calcAdjustLevel` - `GET /sapi/v2/futures/loan/calcAdjustLevel` - `GET /sapi/v1/futures/loan/calcMaxAdjustAmount` - `GET /sapi/v2/futures/loan/calcMaxAdjustAmount` - `POST /sapi/v1/futures/loan/adjustCollateral` - `POST /sapi/v2/futures/loan/adjustCollateral` - `GET /sapi/v1/futures/loan/collateralRepayLimit` - `GET /sapi/v1/futures/loan/collateralRepay` - `POST /sapi/v1/futures/loan/collateralRepay` - `GET /sapi/v1/futures/loan/collateralRepayResult` --- ## 2022-09-30 Scheduled changes to the removal of `!bookTicker` around November 2022. - The All Book Tickers stream (`!bookTicker`) is set to be removed in **November 2022** - More details of the actual removal date will be announced at a later time. - Please use the Individual Book Ticker Streams instead. (`@bookTicker`). - Multiple `@bookTicker` streams can be subscribed to over one connection. - Example: wss://stream.binance.com:9443/stream?streams=btcusdt@bookTicker/bnbbtc@bookTicker --- ## 2022-09-29 - New endpoints for Wallet: - `POST /sapi/v1/asset/convert-transfer`: Convert transfer, convert between BUSD and stablecoins. - `POST /sapi/v1/asset/convert-transfer/queryByPage`: Query convert transfer --- ## 2022-09-22 - Update endpoint for Sub-Account: - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction`: Add new param `thirdParty` - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList`: Add new param `thirdPartyName` - `DELETE /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList`: Add new param `thirdPartyName` - Add Rate Limit for following endpoints: - `GET /sapi/v1/bswap/liquidity`: 3/1s per account and per pool - `GET /sapi/v1/bswap/quote`: 3/1s per account and per pool - `POST /sapi/v1/lending/daily/purchase`: 1/3s per account - `POST /sapi/v1/lending/customizedFixed/purchase`: 1/3s per account - `POST /sapi/v1/staking/purchase`: 1/3s per account --- ## 2022-09-16 - New endpoint for Margin: - `GET /sapi/v1/margin/tradeCoeff`: Get personal margin level information --- ## 2022-09-15 - New endpoints for Crypto Loan - `POST /sapi/v1/loan/borrow`: Borrow - Crypto Loan Borrow - `GET /sapi/v1/loan/borrow/history`: Borrow - Get Loan Borrow History - `GET/sapi/v1/loan/ongoing/orders`: Borrow - Get Loan Ongoing Orders - `POST/sapi/v1/loan/repay`: Repay - Crypto Loan Repay - `GET/sapi/v1/loan/repay/history`: Repay - Get Loan Repayment History - `POST/sapi/v1/loan/adjust/ltv`: Adjust LTV - Crypto Loan Adjust LTV - `GET/sapi/v1/loan/ltv/adjustment/history`: Adjust LTV - Get Loan LTV Adjustment History --- ## 2022-09-15 Note that these are rolling changes, so it may take a few days for it to rollout to all our servers. - Changes to `GET /api/v3/exchangeInfo` - New optional parameter `permissions` added to display all symbols with the permissions matching the parameter provided. (eg.`SPOT`, `MARGIN`, `LEVERAGED`) - If not provided, the default value will be `["SPOT","MARGIN", "LEVERAGED"]`. - This means the request `GET /api/v3/exchangeInfo` without any parameters will show all symbols that can be used for `SPOT`,`MARGIN` and/or `LEVERAGED` trading. - To search for symbols that can be traded on other permissions (e.g. `TRD_GRP_004`, etc), then this needs to be searched for explicitly. (e.g.`permissions`=`TRD_GRP_004`) - Cannot be combined with `symbol` or `symbols` --- ## 2022-09-12 - Update endpoint for Sub-account: \* `GET /sapi/v1/sub-account/subAccountApi/ipRestriction`: To support master account query Third party IP list name for a sub account API key --- ## 2022-09-05 - Delete endpoint for Futures: - `GET /sapi/v1/futures/loan/wallet` --- ## 2022-08-23 SPOT API Note that these are rolling changes, so it may take a few days for it to rollout to all our servers. - Changes to `GET /api/v3/ticker` and `GET /api/v3/ticker/24hr` - New optional parameter `type` added - Supported values for parameter `type` are `FULL` and `MINI` - `FULL` is the default value and the response that is currently being returned from the endpoint - `MINI` omits the following fields from the response: `priceChangePercent`, `weightedAvgPrice`, `bidPrice`, `bidQty`, `askPrice`, `askQty`, and `lastQty` - New error code `-1008` - This is sent whenever the servers are overloaded with requests. - This error code only appears for the SPOT API. - New field `brokered` has been added to `GET /api/v3/account` - New endpoint: `GET /api/v3/uiKlines` - New kline interval: `1s` --- ## 2022-08-18 - Update endpoint for Convert: - `GET /sapi/v1/convert/tradeFlow`: Update weight from Weight(IP) 3000 to Weight(UID) 3000. --- ## 2022-08-08 SPOT API - Changes to `POST /api/v3/order` and `POST /api/v3/order/cancelReplace` - New optional field `strategyId` is a parameter used to identify an order as part of a strategy. - New optional field `strategyType` is a parameter used to identify what strategy was running. (E.g. If all the orders are part of spot grid strategy, it can be set to `strategyType=1000000`) - **Note:** `strategyType` cannot be less than `1000000`. - Changes to `POST /api/v3/order/oco` - New optional fields `limitStrategyId`, `limitStrategyType`. `stopStrategyId`, `stopStrategyType` - These are the strategy metadata parameters for both legs of the OCO orders. - `limitStrategyType` and `stopStrategyType` both cannot be less than `1000000`. - Changes to `GET /api/v3/order`, `GET /api/v3/openOrders`, and `GET /api/v3/allOrders` - New fields `strategyId` and `strategyType` will appear in the response JSON for orders that had these fields populated upon order placement. - Changes to `DELETE /api/v3/order` and `DELETE /api/v3/openOrders` - New fields `strategyId` and `strategyType` will appear in the response JSON for cancelled orders that had these fields populated upon order placement. USER DATA STREAM - New fields to eventType `executionReport` - `j` for `strategyId` - `J` for `strategyType` - Note that these fields only appear if these were populated upon order placement. --- ## 2022-08-05 - Update endpoint for Convert: - `GET /sapi/v1/convert/tradeFlow`: Update weight from Weight(IP) 100 to Weight(IP) 3000. --- ## 2022-07-21 - New endpoint for Portfolio Margin: - `GET /sapi/v1/portfolio/pmLoan` Query Portfolio Margin Bankruptcy Loan Record - `POST /sapi/v1/portfolio/repay` Portfolio Margin Bankruptcy Loan Repay --- ## 2022-07-18 - New endpoint for Portfolio Margin: - `GET /sapi/v1/portfolio/collateralRate` to get Portfolio Margin Collateral Rate. --- ## 2022-07-01 - New endpoint for Wallet: - `POST /sapi/v3/asset/getUserAsset` to get user assets. - New endpoint for Margin: - `GET /sapi/v1/margin/dribblet` to query the historical information of user's margin account small-value asset conversion BNB. - Update endpoint for Convert: - `GET /sapi/v1/convert/tradeFlow`: Update weight from 3000 to 100. - Update endpoint for Margin: - `GET /sapi/v1/margin/repay`: Add response field rawAsset. --- ## 2022-06-20 SPOT API: Changes to `GET /api/v3/ticker` - Weight has been reduced from 5 to 2 per symbol, regardless of `windowSize`. - The max number of symbols that can be processed in a request is 100. - If the number of `symbols` sent is more than 100, the error will be as follows: ```json { "code": -1101, "msg": "Too many values sent for parameter 'symbols', maximum allowed up to 100." } ``` - The max Weight(IP) for this endpoint will cap at 100. - I.e. If the request has more than 50 symbols, the Weight will still be 100, regardless of `windowSize`. --- ## 2022-06-15 **Note:** The update is being rolled out over the next few days, so these changes may not be visible right away. - `GET /api/v3/ticker` added - Rolling window price change statistics based on `windowSize` provided. - Contrary to `GET /api/v3/ticker/24hr` the list of symbols cannot be omitted. - If `windowSize` not specified, the value will default to `1d`. - Response is similar to `GET /api/v3/ticker/24hr`, minus the following fields: `prevClosePrice`, `lastQty`, `bidPrice`, `bidQty`, `askPrice`, `askQty` - `POST /api/v3/order/cancelReplace` added - Cancels an existing order and places a new order on the same symbol. - The filters are evaluated **before** the cancel order is placed. - e.g. If the `MAX_NUM_ORDERS` filter is 10, and the total number of open orders on the account is also 10, when using `POST /api/v3/order/cancelReplace` both the cancel order placement and new order will fail because of the filter. - The change is being rolled out in the next few days, thus this feature will be enabled once the upgrade is completed. - `GET /api/v3/exchangeInfo` returns new field `cancelReplaceAllowed` in `symbols` list. - New filter `NOTIONAL` has been added. - Defines the allowed notional value (`price * quantity`) based on a configured `minNotional` and `maxNotional` - New exchange filter `EXCHANGE_MAX_NUM_ICEBERG_ORDERS` has been added. - Defines the limit of open iceberg orders on an account WEBSOCKETS - New symbol ticker streams with 1h and 4h windows: - Individual symbol ticker streams - `@ticker_` - All market ticker streams - `!ticker_@arr` --- ## 2022-06-02 - Update endpoint for Subaccount: - `GET /sapi/v1/sub-account/sub/transfer/history`: fromEmail and toEmail can be master email. --- ## 2022-05-31 - Update endpoint for Fiat: - `GET /sapi/v1/fiat/orders`: Weight changes from UID(3000) to UID(90000) - Update endpoint for Pay: - `GET /sapi/v1/pay/transactions`: Param names changed: startTimestamp -> startTime; endTimestamp -> endTime. --- ## 2022-05-26 - Update endpoint for Fiat: - `GET /sapi/v1/fiat/orders`: Weight changes from IP(1) to UID(3000) - Update info for the following margin account endpoints: The max interval between `startTime` and `endTime` is 30 days.: - `GET /sapi/v1/margin/transfer` - `GET /sapi/v1/margin/loan` - `GET /sapi/v1/margin/repay` - `GET /sapi/v1/margin/isolated/transfer` - `GET /sapi/v1/margin/interestHistory` --- ## 2022-05-23 - Changes to Order Book Depth Levels - Quantities in the Depth levels were returning negative values in situations where they were exceeding the max value, resulting in an overflow. - Going forward depth levels will not overflow, but will be capped at the max value based on the precision of the base asset. This means that the depth level is at max value _or more_. - E.g. If the precision is 8, then the max value for quantity will be at 92,233,720,368.54775807. - When the fix has been applied, a change in the order book at the affected price level is required for the changes to be visible. - What does this affect? - SPOT API - `GET /api/v3/depth` - Websocket Streams - `@depth` - `@depth@100ms` - `@depth` - `@depth@100ms` - Updates to `MAX_POSITION` - If an order's `quantity` can cause the position to overflow, this will now fail the `MAX_POSITION` filter. --- ## 2022-05-19 - Update endpoint for Mining: - `GET /sapi/v1/mining/pub/algoList` and `GET /sapi/v1/mining/pub/coinList`: Need no paramter. - Add error codes (21xxx) for Portfolio Margin Account: -21001, -21002, -21003 --- ## 2022-05-17 SPOT API - Changes to `GET api/v3/aggTrades` - When providing `startTime` and `endTime`, the oldest items are returned. - Changed error messaging on `GET /api/v3/myTrades` where parameter `symbol` is not provided: ```json { "code": -1102, "msg": "Mandatory parameter 'symbol' was not sent, was empty/null, or malformed." } ``` - The following endpoints now support multi-symbol querying using the parameter `symbols`. - `GET /api/v3/ticker/24hr` - `GET /api/v3/ticker/price` - `GET /api/v3/ticker/bookTicker` - In the above, the request weight will depend on the number of symbols provided in `symbols`.

Please refer to the table below: | Endpoint | Number of Symbols | Weight | | ------------------------------- | ----------------- | ------ | | `GET /api/v3/ticker/price` | Any | 2 | | `GET /api/v3/ticker/bookTicker` | Any | 2 | | `GET /api/v3/ticker/24hr` | 1-20 | 1 | | `GET /api/v3/ticker/24hr` | 21-100 | 20 | | `GET /api/v3/ticker/24hr` | 101 or more | 40 | --- ## 2022-05-05 - New endpoint for Binance Code: - `GET /sapi/v1/giftcard/cryptography/rsa-public-key` to fetch RSA public key. - Update endpoint for Binance Code: - `POST /sapi/v1/giftcard/redeemCode`: new optional parameter `externalUid`. Each external unique ID represents a unique user on the partner platform. The function helps you to identify the redemption behavior of different users. --- ## 2022-04-28 - New endpoints for Staking: - `GET /sapi/v1/staking/productList` to get Staking product list - `POST /sapi/v1/staking/purchase` to stake product - `POST /sapi/v1/staking/redeem` to redeem product - `GET /sapi/v1/staking/position` to get Staking product holding position - `GET /sapi/v1/staking/stakingRecord` to inquiry Staking history records - `POST /sapi/v1/staking/setAutoStaking` to set Auto Staking function - `GET /sapi/v1/staking/personalLeftQuota` to inquiry Staking left quota --- ## 2022-04-27 - New endpoint for Futures Algo: - `POST /sapi/v1/algo/futures/newOrderTwap` to support Twap new order FAQ: [Time-Weighted Average Price(Twap) Introduction](https://www.binance.com/en/support/faq/093927599fd54fd48857237f6ebec0b0) --- ## 2022-04-26 - `GET /sapi/v1/margin/rateLimit/order` added - The endpoint will display the user's current margin order count usage for all intervals. --- ## 2022-04-20 - New endpoint for Portfolio Margin: - `GET /sapi/v1/portfolio/account` to support query portfolio margin account info FAQ: [Portfolio Margin Program](https://www.binance.com/en/support/faq/5054378212d240cca17ecd6006c11f23) Only Portfolio Margin Account is accessible to this endpoint. To enroll, kindly refer to: [How to Enroll into the Binance Portfolio Margin Program](https://www.binance.com/en/support/faq/a7834b9bc03140728583a90bcb469144) --- ## 2022-04-13 - New endpoints for Futures Algo: - `POST /sapi/v1/algo/futures/newOrderVp` to support VP new order - `DELETE /sapi/v1/algo/futures/order` to support cancel Algo order - `GET /sapi/v1/algo/futures/openOrders` to support query Algo open orders - `GET /sapi/v1/algo/futures/historicalOrders` to support query Algo historical orders - `GET /sapi/v1/algo/futures/subOrders` to support query Algo sub orders for a specified algoId FAQ: [Volume Participation(VP) Introduction](https://www.binance.com/en/support/faq/b0b94dcc8eb64c2585763b8747b60702) --- ## 2022-04-13 **Information on Trailing Stops** SPOT API - Trailing Stops have been enabled. - This is a type of algo order where the activation is based on a percentage of a price change in the market using the new parameter `trailingDelta`. - This can only used with any of the following order types: `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, `TAKE_PROFIT_LIMIT`. - The `trailingDelta` parameter will be done in Basis Points or BIPS. - For example: a STOP_LOSS SELL order with a `trailingDelta` of 100 will trigger after a price decrease of 1%. (100 / 10,000 => 0.01 => 1%) - When used in combination with OCO Orders, the `trailingDelta` will determine when the contingent leg of the OCO will trigger. - When `trailingDelta` is used in combination with `stopPrice`, once the `stopPrice` condition is met, the trailing stop starts tracking the price change from the `stopPrice` based on the `trailingDelta` provided. - When no `stopPrice` is sent, the trailing stop starts tracking the price changes from the last price based on the `trailingDelta` provided. - Changes to POST `/api/v3/order` - New optional field `trailingDelta` - Changes to POST `/api/v3/order/test` - New optional field `trailingDelta` - Changes to POST `/api/v3/order/oco` - New optional field `trailingDelta` - A new filter `TRAILING_DELTA` has been added. - This filter is defined by the minimum and maximum values for the `trailingDelta` value. USER DATA STREAM - New field in `executionReport` - "d" for `trailingDelta` --- ## 2022-04-12 **Note:** The changes are being rolled out during the next few days, so these will not appear right away. - Error message changed on `GET api/v3/allOrders` where `symbol` is not provided:

``` { "code": -1102, "msg": "Mandatory parameter 'symbol' was not sent, was empty/null, or malformed." } ``` - Fixed a typo with an error message when an account has disabled permissions (e.g. to withdraw, to trade, etc)

``` "This action is disabled on this account." ``` - During a market data audit, we detected some issues with the Spot aggregate trade data. - Missing aggregate trades were recovered. - Duplicated records were marked invalid with the following values: - p = '0' // price - q = '0' // qty - f = -1 // first_trade_id - l = -1 // last_trade_id --- ## 2022-04-08 - Update WEBSOCKET for BLVT:\* Base url changed to `wss://nbstream.binance.com/lvt-p` for BLVT streams `@tokenNav` and `@nav_Kline_` More details: [Websocket BLVT Info Streams](#websocket-blvt-info-streams) and [Websocket BLVT NAV Kline/Candlestick Streams](#websocket-blvt-nav-kline-candlestick-streams) --- ## 2022-3-29 The following updates will take effect on **March 31, 2022 08:00 AM UTC** - Update endpoint for Sub-account: - `GET /sapi/v1/sub-account/universalTransfer` The query time period must be less then 30 days; If `startTime` and `endTime` not sent, return records of the last 30 days by default --- ## 2022-03-25 - Update endpoint for Sub-Account: - New endpoint`GET /sapi/v1/managed-subaccount/accountSnapshot` to support investor master account query asset snapshot of managed sub-account --- ## 2022-03-08 - Update endpoint for Sub-Account: - New transfer types`MARGIN`,`ISOLATED_MARGIN` and parameter`symbol`added in`POST /sapi/v1/sub-account/universalTransfer` to support transfer to sub-account cross margin account and isolated margin account --- ## 2022-02-28 - New field `allowTrailingStop` has been added to `GET /api/v3/exchangeInfo` --- ## 2022-02-22 SPOT API - `(price-minPrice) % tickSize == 0` rule in `PRICE_FILTER` has been changed to `price % tickSize == 0`. - A new filter `PERCENT_PRICE_BY_SIDE` has been added. - Changes to GET `api/v3/depth` - The `limit` value can be outside of the previous values (i.e. 5, 10, 20, 50, 100, 500, 1000,5000) and will return the correct limit. (i.e. if limit=3 then the response will be the top 3 bids and asks) - The limit still cannot exceed 5000. If the limit provided is greater than 5000, then the response will be truncated to 5000. - Due to the changes, these are the updated request weights based on the limit value provided: | Limit | Request Weight | | --------- | -------------- | | 1-100 | 1 | | 101-500 | 5 | | 501-1000 | 10 | | 1001-5000 | 50 | - Changes to GET `api/v3/aggTrades` - When providing `startTime` and `endTime`, the oldest items are returned. --- ## 2022-2-18 - Update endpoint for Sub-Account: - New fields `isManagedSubAccount`and `isAssetManagementSubAccount` added in`GET /sapi/v1/sub-account/list`to support query whether the sub-account is a managed sub-account or a asset management sub-account --- ## 2022-2-17 The following updates will take effect on **February 24, 2022 08:00 AM UTC** - Update endpoint for Wallet: - `GET /sapi/v1/accountSnapshot` The time limit of this endpoint is shortened to only support querying the data of the latest month --- ## 2022-2-09 - New endpoint for Wallet: - `POST /sapi/v1/asset/dust-btc` to get assets that can be converted into BNB --- ## 2022-1-25 - From **January 28, 2022 4:00 AM UTC**, You need to open`Enable Spot & Margin Trading`permission for the API key which requests these endpoints as following: - `POST /sapi/v1/asset/dust` Dust transfer - `POST /sapi/v1/lending/daily/purchase` Purchase Savings flexible product - `POST /sapi/v1/lending/daily/redeem` Redeem Savings flexible product - `POST /sapi/v1/lending/customizedFixed/purchase` Purchase Savings Fixed/Activity project - `POST /sapi/v1/lending/positionChanged` Change Savings Fixed/Activity position to Daily position - `POST /sapi/v1/bswap/liquidityAdd` Bswap add liquidity - `POST /sapi/v1/bswap/liquidityRemove` Bswap remove liquidity - `POST /sapi/v1/bswap/swap` Bswap swap - `POST /sapi/v1/bswap/claimRewards` Bswap claim rewards --- ## 2022-1-21 - New endpoints for Binance Code: - `POST /sapi/v1/giftcard/createCode` to create a Binance Code. - `POST /sapi/v1/giftcard/redeemCode` to redeem a Binance Code. - `GET /sapi/v1/giftcard/verify` to verify a Binance Code. --- ## 2022-1-4 - New endpoint for Mining: - `GET /sapi/v1/mining/payment/uid` to get Mining account earning. - New endpoints for BSwap: - `GET /sapi/v1/bswap/unclaimedRewards` to get unclaimed rewards record. - `POST /sapi/v1/bswap/claimRewards` to claim swap rewards or liquidity rewards. - `GET /sapi/v1/bswap/claimedHistory` to get history of claimed rewards. --- ## 2021-12-30 - Update endpoint for Margin: - Removed out `limit` from`GET /sapi/v1/margin/interestRateHistory`; The max interval between startTime and endTime is 30 days. - Update endpoint for Wallet: - As the Mining account is merged into Funding account, transfer types MAIN_MINING, MINING_MAIN, MINING_UMFUTURE, MARGIN_MINING, and MINING_MARGIN will be discontinued in Universal Transfer endpoint `POST /sapi/v1/asset/transfer` on **January 05, 2022 08:00 AM UTC** --- ## 2021-12-29 - Removed out dated "Symbol Type" enum; added "Permissions" enum. --- ## 2021-12-24 - Update endpoints for Sub-Account: - New parameter`clientTranId`added in`POST /sapi/v1/sub-account/universalTransfer` and `GET /sapi/v1/sub-account/universalTransfer` to support custom transfer id --- ## 2021-12-03 - New endpoints for Margin: - `GET /sapi/v1/margin/crossMarginData` to get cross margin fee data collection - `GET /sapi/v1/margin/isolatedMarginData` to get isolated margin fee data collection - `GET /sapi/v1/margin/isolatedMarginTier` to get isolated margin tier data collection - New endpoints for NFT: - `GET /sapi/v1/nft/history/transactions` to get NFT transaction history - `GET /sapi/v1/nft/history/deposit` to get NFT deposit history - `GET /sapi/v1/nft/history/withdraw` to get NFT withdraw history - `GET /sapi/v1/nft/user/getAsset` to get NFT asset --- ## 2021-11-30 - New endpoint for Convert: - `GET /sapi/v1/convert/tradeFlow` to support user query convert trade history records - New endpoint for Rebate: - `GET /sapi/v1/rebate/taxQuery` to support user query spot rebate history records --- ## 2021-11-19 - New endpoint for Pay: - `GET /sapi/v1/pay/transactions`to support user query Pay trade history - Update endpoint for Wallet: - New field`info`added in`GET /sapi/v1/capital/withdraw/history`to show the reason for withdrawal failure --- ## 2021-11-18 The following updates will take effect on **November 25, 2021 08:00 AM UTC** - Update endpoint for Wallet: - `GET /sapi/v1/accountSnapshot` The query time range of both endpoints are shortened to support data query within the last 6 months only, where startTime does not support selecting a timestamp beyond 6 months. If you do not specify startTime and endTime, the data of the last 7 days will be returned by default. --- ## 2021-11-17 - The following endpoints will be discontinued on **November 17, 2021 13:00 PM UTC**: - `POST /sapi/v1/account/apiRestrictions/ipRestriction` to support user enable and disable IP restriction for an API Key - `POST /sapi/v1/account/apiRestrictions/ipRestriction/ipList` to support user add IP list for an API Key - `GET /sapi/v1/account/apiRestrictions/ipRestriction` to support user query IP restriction for an API Key - `DELETE /sapi/v1/account/apiRestrictions/ipRestriction/ipList` to support user delete IP list for an API Key --- ## 2021-11-16 - New endpoints for Sub-Account: - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction` to support master account enable and disable IP restriction for a sub-account API Key - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList` to support master account add IP list for a sub-account API Key - `GET /sapi/v1/sub-account/subAccountApi/ipRestriction` to support master account query IP restriction for a sub-account API Key - `DELETE /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList` to support master account delete IP list for a sub-account API Key --- ## 2021-11-09 - New endpoints for Wallet: - `POST /sapi/v1/account/apiRestrictions/ipRestriction` to support user enable and disable IP restriction for an API Key - `POST /sapi/v1/account/apiRestrictions/ipRestriction/ipList` to support user add IP list for an API Key - `GET /sapi/v1/account/apiRestrictions/ipRestriction` to support user query IP restriction for an API Key - `DELETE /sapi/v1/account/apiRestrictions/ipRestriction/ipList` to support user delete IP list for an API Key --- ## 2021-11-08 - New endpoint for Crypto Loans: - New endpoint`GET /sapi/v1/loan/income`to support user query crypto loans income history --- ## 2021-11-05 - Update endpoint for Wallet: - New parameter `walletType `added in `POST /sapi/v1/capital/withdraw/apply` to support user choose wallet type `spot wallet` and `funding wallet` when withdraw crypto. --- ## 2021-11-04 The following updates will take effect on **November 11, 2021 08:00 AM UTC** - Update endpoints for Wallet and Futures: - `GET /sapi/v1/asset/transfer` - `GET /sapi/v1/futures/transfer` The query time range of both endpoints are shortened to support data query within the last 6 months only, where startTime does not support selecting a timestamp beyond 6 months. If you do not specify startTime and endTime, the data of the last 7 days will be returned by default. --- ## 2021-11-01 - `GET /api/v3/rateLimit/order` added - The endpoint will display the user's current order count usage for all intervals. - This endpoint will have a request weight of 20. --- ## 2021-10-22 - Update endpoint for Wallet: - New transfer types `MAIN_FUNDING`,`FUNDING_MAIN`,`FUNDING_UMFUTURE`,`UMFUTURE_FUNDING`,`MARGIN_FUNDING`,`FUNDING_MARGIN`,`FUNDING_CMFUTURE`and `CMFUTURE_FUNDING` added in Universal Transfer endpoint `POST /sapi/v1/asset/transfer` and `GET /sapi/v1/asset/transfer` to support transfer assets among funding account and other accounts - As the C2C account, Binance Payment, Binance Card and other business account are merged into a Funding account, transfer types `MAIN_C2C`,`C2C_MAIN`,`C2C_UMFUTURE`,`C2C_MINING`,`UMFUTURE_C2C`,`MINING_C2C`,`MARGIN_C2C`,`C2C_MARGIN`,`MAIN_PAY`and `PAY_MAIN` will be discontinued in Universal Transfer endpoint `POST /sapi/v1/asset/transfer` and `GET /sapi/v1/asset/transfer` on **November 04, 2021 08:00 AM UTC** --- ## 2021-10-14 - Update the time range of the response data for the following margin account endpoints, `startTime` and `endTime` time span will not exceed 30 days, without time parameter sent the system will return the last 7 days of data by default, while the `archived` parameter is `true`, the system will return the last 7 days of data 6 months ago by default: - `GET /sapi/v1/margin/transfer` - `GET /sapi/v1/margin/loan` - `GET /sapi/v1/margin/repay` - `GET /sapi/v1/margin/isolated/transfer` - `GET /sapi/v1/margin/interestHistory` --- ## 2021-09-18 - New endpoints for BSwap: - `GET /sapi/v1/bswap/poolConfigure` to get pool configure - `GET /sapi/v1/bswap/addLiquidityPreview` to get add liquidity preview - `GET /sapi/v1/bswap/removeLiquidityPreview` to get remove liquidity preview --- ## 2021-09-17 - Add`/api/*`and`/sapi/*` limit introduction in General Info --- ## 2021-09-08 - Add endpoints for enabled isolated margin account limit: - `DELETE /sapi/v1/margin/isolated/account` to disable isolated margin account for a specific symbol - `POST /sapi/v1/margin/isolated/account` to enable isolated margin account for a specific symbol - `GET /sapi/v1/margin/isolated/accountLimit` to query enabled isolated margin account limit - New field "enabled" in response of `GET /sapi/v1/margin/isolated/account` to check if the isolated margin account is enabled --- ## 2021-09-03 - Update endpoint for Wallet: _ New fields `sameAddress`,`depositDust` and `specialWithdrawTips`added in `GET /sapi/v1/capital/config/getall` `sameAddress` means if the coin needs to provide memo to withdraw `depositDust` means minimum creditable amount `specialWithdrawTips` means special tips for withdraw _ New field `confirmNo`added in `GET /sapi/v1/capital/withdraw/history` to support query confirm times for withdraw history --- ## 2021-08-27 - Update endpoint for Wallet: - New parameter `withdrawOrderId`added in `GET /sapi/v1/capital/withdraw/history` to support user query withdraw history by withdrawOrderId - New field `unlockConfirm`added in `GET /sapi/v1/capital/deposit/hisrec` to support query network confirm times for unlocking --- ## 2021-08-23 - New endpoints for Margin Account OCO: - `POST /sapi/v1/margin/order/oco` - `DELETE /sapi/v1/margin/orderList` - `GET /sapi/v1/margin/orderList` - `GET /sapi/v1/margin/allOrderList` - `GET /sapi/v1/margin/openOrderList` Same usage as spot account OCO --- ## 2021-08-20 - Update endpoint for Wallet: - New parameters`fromSymbol`,`toSymbol`and new transfer types `ISOLATEDMARGIN_MARGIN`, `MARGIN_ISOLATEDMARGIN`and `ISOLATEDMARGIN_ISOLATEDMARGIN` added in `POST /sapi/v1/asset/transfer` and `GET /sapi/v1/asset/transfer` to support user transfer assets between Margin(cross) account and Margin(isolated) account --- ## 2021-08-12 - GET `api/v3/myTrades` has a new optional field `orderId` --- ## 2021-08-05 - New endpoint for C2C: - `GET /sapi/v1/c2c/orderMatch/listUserOrderHistory` to query user C2C trade history --- ## 2021-08-05 - Update endpoints for Savings: - `GET /sapi/v1/lending/union/purchaseRecord` - `GET /sapi/v1/lending/union/redemptionRecord` - `GET /sapi/v1/lending/union/interestHistory` The time between `startTime` and `endTime` cannot be longer than 30 days. If `startTime` and `endTime` are both not sent, then the last 30 days' data will be returned --- ## 2021-07-29 - Update endpoint for Sub-Account: - `GET /sapi/v1/sub-account/transfer/subUserHistory` if `startTime`and`endTime`are not sent, the recent 30-day data will be returned by default --- ## 2021-07-27 - New endpoint for Fiat: - `GET /sapi/v1/fiat/orders` to query user fiat deposit and withdraw history - `GET /sapi/v1/fiat/payments` to query user fiat payments history --- ## 2021-07-16 - New endpoint for Wallet: - `GET /sapi/v1/account/apiRestrictions` to query user API Key permission --- ## 2021-07-09 - New endpoint for Wallet: - `POST /sapi/v1/asset/get-funding-asset` to query funding wallet, includes Binance Pay, Binance Card, Binance Gift Card, Stock Token --- ## 2021-06-24 - Update endpoints for Wallet: - `GET /sapi/v1/capital/withdraw/history` added default value 1000, max value 1000 for the parameter`limit` - `GET /sapi/v1/capital/deposit/hisrec` added default value 1000, max value 1000 for the parameter`limit` --- ## 2021-06-17 - Update endpoint for Savings: - `GET /sapi/v1/lending/daily/product/list` to include new parameters `current` and `size` --- ## 2021-06-15 - New endpoints for Sub-Account: - `POST /sapi/v1/managed-subaccount/deposit ` to deposit assets into the managed sub-account (only for investor master account) - `GET /sapi/v1/managed-subaccount/asset` to query managed sub-account asset details (only for investor master account) - `POST /sapi/v1/managed-subaccount/withdraw` to withdrawal assets from the managed sub-account (only for investor master account) --- ## 2021-06-04 On **August 01, 2021 02:00 AM UTC** the WAPI endpoints will be discontinued: - `GET /wapi/v3/systemStatus.html` - `POST /wapi/v3/withdraw.html` - `GET /wapi/v3/depositHistory.html` - `GET /wapi/v3/withdrawHistory.html` - `GET /wapi/v3/depositAddress.html` - `GET /wapi/v3/accountStatus.html` - `GET /wapi/v3/apiTradingStatus.html` - `GET /wapi/v3/userAssetDribbletLog.html` - `GET /wapi/v3/assetDetail.html` - `GET /wapi/v3/tradeFee.html` - `GET /wapi/v3/sub-account/list.html` - `GET /wapi/v3/sub-account/transfer/history.html` - `POST /wapi/v3/sub-account/transfer.html` - `GET /wapi/v3/sub-account/assets.html` The WAPI endpoints have been removed from Binance API Documentation.To ensure your trading strategies are not affected, all API users are encouraged to upgrade trading bots to SAPI endpoints as soon as possible. --- ## 2021-05-26 - Update endpoint for Wallet: - New transfer types `MAIN_PAY` ,`PAY_MAIN` added in Universal Transfer endpoint `POST /sapi/v1/asset/transfer` and `GET /sapi/v1/asset/transfer` to support trasnfer assets between spot account and pay account --- ## 2021-05-12 - Added `Data Source` in the documentation to explain where each endpoint is retrieving its data - Added field `Data Source` to each Spot API endpoint in the documentation - GET `api/v3/exchangeInfo` now supports single or multi-symbol query --- ## 2021-04-28 On **May 15, 2021 08:00 UTC** the SAPI Create Margin Account endpoint will be discontinued: - `POST /sapi/v1/margin/isolated/create` Isolated Margin account creation and trade preparation can be completed directly through Isolated Margin funds transfer `POST /sapi/v1/margin/isolated/transfer` --- ## 2021-04-26 On **April 28, 2021 00:00 UTC** the weights to the following endpoints will be adjusted: - `GET /api/v3/order` weight increased to 2 - `GET /api/v3/openOrders` weight increased to 3 - `GET /api/v3/allOrders` weight increased to 10 - `GET /api/v3/orderList` weight increased to 2 - `GET /api/v3/openOrderList` weight increased to 3 - `GET /api/v3/account` weight increased to 10 - `GET /api/v3/myTrades` weight increased to 10 - `GET /api/v3/exchangeInfo` weight increased to 10 --- ## 2021-04-08 - Update endpoint for Sub-Account: - `GET /sapi/v1/sub-account/futures/accountSummary` and `GET /sapi/v2/sub-account/futures/accountSummary` the unit of field `asset` changed to USD valued summary of sub-account assets --- ## 2021-04-02 - New endpoints for Wallet: - `GET /sapi/v1/system/status` to query system status - `GET /sapi/v1/account/status` to query account status - `GET /sapi/v1/account/apiTradingStatus` to query account API trading status - `GET /sapi/v1/asset/dribblet` to query dust log - `GET /sapi/v1/asset/assetDetail` to query asset detail - `GET /sapi/v1/asset/tradeFee` to query trade fee - New endpoint for Sub-Account: - `GET /sapi/v3/sub-account/assets` to query sub-account assets --- ## 2021-04-01 - Update endpoint for Sub-Account: - `GET /sapi/v1/sub-account/transfer/subUserHistory` new fields `fromAccountType` and `toAccountType` added in response --- ## 2021-03-31 - Update endpoint for Sub-Account: - `GET /wapi/v3/sub-account/transfer/history.html` added new parameters `fromEmail` and `toEmail`, the original parameter`email` is equal to`fromEmail`by default --- ## 2021-03-08 - New endpoint for Sub-Account: - `POST /sapi/v1/sub-account/virtualSubAccount` to support create a virtual sub-account - `GET /sapi/v1/sub-account/list` to support query sub-account list - `POST /sapi/v1/sub-account/blvt/enable` to support enable blvt for sub-account --- ## 2021-03-05 - New endpoints for Margin: - `GET /sapi/v1/margin/interestRateHistory` to support margin interest rate history query --- ## 2021-02-08 - New endpoints for Futures: - `GET /sapi/v2/futures/loan/wallet` to support BUSD loan query - `GET /sapi/v2/futures/loan/configs` to support BUSD loan query - `GET /sapi/v2/futures/loan/calcAdjustLevel` to support BUSD loan - `GET /sapi/v2/futures/loan/calcMaxAdjustAmount` to support adjustment of BUSD loan - `POST /sapi/v2/futures/loan/adjustCollateral` to support adjustment of BUSD loan - Update endpoints for Futures - `GET /sapi/v1/futures/loan/adjustCollateral/history` new parameter and fields in response `loanCoin` for BUSD loan - `GET /sapi/v1/futures/loan/liquidationHistory` new parameter and fields in response `loanCoin` for BUSD loan --- ## 2021-02-04 - New transfer types `MARGIN_MINING` ,`MINING_MARGIN`, `MARGIN_C2C` ,`C2C_MARGIN`, `MARGIN_CMFUTURE`, `CMFUTURE_MARGIN` added in Universal Transfer endpoint `POST /sapi/v1/asset/transfer` and `GET /sapi/v1/asset/transfer`. --- ## 2021-01-15 - New endpoint `DELETE /sapi/v1/margin/openOrders` for Margin Trade - This will allow a user to cancel all open orders on a single symbol for margin account. - This endpoint will cancel all open orders including OCO orders for margin account. --- ## 2021-01-10 - New parameter `pageSize` for Mining endpoint `GET /sapi/v1/mining/payment/list` - New fields in response to Mining endpoint `GET /sapi/v1/mining/payment/list`: - "type" for income type - "hashTransfer" for resale Hashrate - "transferAmount" for transferred Income - New Mining endpoints: - `GET /sapi/v1/mining/payment/other` - `GET /sapi/v1/mining/hash-transfer/config/details` - `GET /sapi/v1/mining/hash-transfer/config/details/list` - `GET /sapi/v1/mining/hash-transfer/profit/details` - `POST /sapi/v1/mining/hash-transfer/config` - `POST /sapi/v1/mining/hash-transfer/config/cancel` --- ## 2021-01-01 USER DATA STREAM - `outboundAccountInfo` has been removed. --- ## 2020-12-30 - New endpoint for Wallet: - `POST /sapi/v1/asset/transfer` to support user universal transfer among Spot, Margin, Futures, C2C, MINING accounts. - `GET /sapi/v1/asset/transfer` to get user universal transfer history. --- ## 2020-12-22 - New endpoint for Sub-Account: - `GET /sapi/v1/sub-account/sub/transfer/history` to get spot asset transfer history. --- ## 2020-12-11 - Update endpoints for Futures Cross-Collateral: - `GET /sapi/v1/futures/loan/wallet` new fields in response `interestFreeLimit` for total interest free limit, `interestFreeLimitUsed` for interest free limit used. - `GET /sapi/v1/futures/loan/interestHistory` new fields in response `interestFreeLimitUsed` for interest free limit used. --- ## 2020-12-04 - Update endpoint for BLVT: - `GET /sapi/v1/blvt/tokenInfo` new fields in response `currentBaskets`(include `symbol`, `amount` , `notionalValue` ),`purchaseFeePct`,`dailyPurchaseLimit`,`redeemFeePct`,`dailyRedeemLimit`. - New endpoint for BLVT: - `GET /sapi/v1/blvt/userLimit` to get BLVT user limit info. --- ## 2020-12-02 - New endpoints for Sub-Account: - `GET /sapi/v2/sub-account/futures/account` to get detail on sub-account's USDT margined futures account and COIN margined futures account. - `GET /sapi/v2/sub-account/futures/accountSummary` to get summary of sub-account's USDT margined futures account and COIN margined futures account. - `GET /sapi/v2/sub-account/futures/positionRisk` to get position risk of sub-account's USDT margined futures account and COIN margined futures account. --- ## 2020-12-01 - Update Margin Trade Endpoint: - `POST /sapi/v1/margin/order` new parameter `quoteOrderQty` allow a user to specify the total `quoteOrderQty` spent or received in the `MARKET` order. --- ## 2020-11-27 New API clusters have been added in order to improve performance. Users can access any of the following API clusters, in addition to `api.binance.com` If there are any performance issues with accessing `api.binance.com` please try any of the following instead: - https://api1.binance.com/api/v3/* - https://api2.binance.com/api/v3/* - https://api3.binance.com/api/v3/* --- ## 2020-11-16 - Updated endpoints for Margin, new parameter `archived` to query data from 6 months ago: - `GET /sapi/v1/margin/loan` - `GET /sapi/v1/margin/repay` - `GET /sapi/v1/margin/interestHistory` --- ## 2020-11-13 - New endpoints for Sub-Account: - `POST /sapi/v1/sub-account/universalTransfer` to transfer spot and futures asset between master account and sub accounts. - `GET /sapi/v1/sub-account/universalTransfer` to search transfer records. --- ## 2020-11-10 - New endpoint to toggle BNB Burn: - `POST /sapi/v1/bnbBurn` to toggle BNB Burn on spot trade and margin interest. - `GET /sapi/v1/bnbBurn` to get BNB Burn status. --- ## 2020-11-09 - New field `tranId` is available from endpoints: - `GET /sapi/v1/sub-account/futures/internalTransfer` - `GET /sapi/v1/sub-account/transfer/subUserHistory` --- ## 2020-11-03 - Update endpoints for Futures Cross-Collateral: - `GET /sapi/v1/futures/loan/repay/history` new fields in response `repayType`(`NORMAL` for normal repayment, `COLLATERAL` for collateral repayment), `price` (collateral repayment rate), `repayCollateral`(collateral amount for collateral repayment). - `GET /sapi/v1/futures/loan/wallet` new fields in response `totalInterest` (total interest for cross-collateral), `principalForInterest`(cross-collateral principal for interest), `interest`(cross-collateral interest). - `GET /sapi/v1/futures/loan/configs` new fields in response `interestRate` (interest rate for cross-collateral), `interestGracePeriod` (interest grace period for cross-collateral). - New endpoints for Futures Cross-Collateral: - `GET /sapi/v1/futures/loan/collateralRepayLimit` to check the maximum and minimum limit when repay with collateral. - `GET /sapi/v1/futures/loan/collateralRepay` to get quote for collateral repayment. - `POST /sapi/v1/futures/loan/collateralRepay` to repay with collateral. - `GET /sapi/v1/futures/loan/collateralRepayResult` to check collateral repayment result. - `GET /sapi/v1/futures/loan/interestHistory` to get cross-collateral interest history. --- ## 2020-10-14 - Update endpoints for Futures Cross-Collateral: - `POST /sapi/v1/futures/loan/borrow` and `GET /sapi/v1/futures/loan/borrow/history` new field `borrowId` in response for ID of Cross-Collateral borrow operation. - `POST /sapi/v1/futures/loan/repay` and `GET /sapi/v1/futures/loan/repay/history` new field `repayId` in response for ID of Cross-Collateral repay operation. --- ## 2020-10-10 - New `type` added in the endpoint `POST /sapi/v1/sub-account/futures/transfer`to support transfer asset from subaccount's spot account to its COIN-margined futures account and transfer asset from subaccount's COIN-margined futures account to its spot account. --- ## 2020-09-30 - Update endpoints for Margin Account: - `GET /sapi/v1/margin/maxBorrowable` new field `borrowLimit` in response for account borrow limit. --- ## 2020-09-28 - New endpoints for Binance Savings: - `POST /sapi/v1/lending/positionChanged` to change fixed/activity position to daily position. - New parameter `ACTIVITY` replace `REGULAR`in the following Binance Savings endpoints: - `GET /sapi/v1/lending/project/list` - `POST /sapi/v1/lending/customizedFixed/purchase` - `GET /sapi/v1/lending/project/position/list` - `GET /sapi/v1/lending/union/purchaseRecord` - `GET /sapi/v1/lending/union/interestHistory` --- ## 2020-09-23 - New SAPI endpoints for BSwap: - `GET /sapi/v1/bswap/pools` to list all swap pools. - `GET /sapi/v1/bswap/liquidity` to get liquidity information of a pool. - `POST /sapi/v1/bswap/liquidityAdd` to add liquidity. - `POST /sapi/v1/bswap/liquidityRemove` to remove liquidity. - `GET /sapi/v1/bswap/liquidityOps` to get liquidity operation record. - `GET /sapi/v1/bswap/quote` to request quotes. - `POST /sapi/v1/bswap/swap` to swap. - `GET /sapi/v1/bswap/swap` to get swap history. --- ## 2020-09-16 - New SAPI endpoints for BLVT: - `GET /sapi/v1/blvt/tokenInfo` to get BLVT info. - `POST /sapi/v1/blvt/subscribe (HMAC SHA256)` to subscribe BLVT. - `GET /sapi/v1/blvt/subscribe/record (HMAC SHA256)` to get subscription record。 - `POST /sapi/v1/blvt/redeem (HMAC SHA256)` to redeem BLVT. - `GET /sapi/v1/blvt/redeem/record (HMAC SHA256` to get redemption record. - The BLVT NAV system is working relatively with Binance Futures, so some endpoints are based on futures system: - New endpoint to get historical BLVT Kline. - New WebSocket streams for BLVT Info and BLVT NAV Kline: ## 2020-09-09 USER DATA STREAM - `outboundAccountInfo` has been deprecated. - `outboundAccountInfo` will be removed in the future. (Exact date unknown) **Please use `outboundAccountPosition` instead.** - `outboundAccountInfo` will now only show the balance of non-zero assets and assets that have been reduced to 0. --- ## 2020-09-03 - New endpoint `POST /sapi/v1/sub-account/futures/internalTransfer` to transfer futures asset between master account and subaccount. - New endpoint`GET /sapi/v1/sub-account/futures/internalTransfer` to get futures transfer history of subaccount. --- ## 2020-09-01 - New parameter `masterAccountTotalAsset` added in the endpoint `GET /sapi/v1/sub-account/spotSummary` to get BTC valued asset summary of master account. --- ## 2020-08-27 - New endpoint `GET /sapi/v1/sub-account/spotSummary` to get BTC valued asset summary of subaccout. --- ## 2020-08-26 - New parameter `symbols` added in the endpoint `GET /sapi/v1/margin/isolated/account`. --- ## 2020-07-28 ISOLATED MARGIN - New parameters "isIsolated" and "symbol" added for isolated margin in the following endpoints: - `POST /sapi/v1/margin/loan` - `POST /sapi/v1/margin/repay` - New parameter "isIsolated" and new response field "isIsolated" added for isolated margin in the following endpoints: - `POST /sapi/v1/margin/order` - `DELETE /sapi/v1/margin/order` - `GET /sapi/v1/margin/order` - `GET /sapi/v1/margin/openOrders` - `GET /sapi/v1/margin/allOrders` - `GET /sapi/v1/margin/myTrades` - New parameter "isolatedSymbol" and new response field "isolatedSymbol" added for isolated margin in the following endpoints: - `GET /sapi/v1/margin/loan` - `GET /sapi/v1/margin/repay` - `GET /sapi/v1/margin/interestHistory` - New parameter "isolatedSymbol" and new response field "isIsolated" added for isolated margin in the following endpoint `GET /sapi/v1/margin/forceLiquidationRec` - New parameter "isolatedSymbol" added for isolated margin in the following endpoints: - `GET /sapi/v1/margin/maxBorrowable` - `GET /sapi/v1/margin/maxTransferable` - New endpoints for isolated margin: - `POST /sapi/v1/margin/isolated/create` - `POST /sapi/v1/margin/isolated/transfer` - `GET /sapi/v1/margin/isolated/transfer` - `GET /sapi/v1/margin/isolated/account` - `GET /sapi/v1/margin/isolated/pair` - `GET /sapi/v1/margin/isolated/allPairs` - New endpoints for listenKey management of isolated margin account: - `POST /sapi/v1/userDataStream/isolated` - `PUT /sapi/v1/userDataStream/isolated` - `DELETE /sapi/v1/userDataStream/isolated` --- ## 2020-07-20 - The max value of parameter "limit" in `GET /sapi/v1/margin/allOrders` has been changed as 500. --- ## 2020-07-17 - There is now a request limit specifically for the sapi/v1/margin/allOrders endpoint at 60 raw requests per minute for a single IP address. --- ## 2020-07-13 - New SAPI Endpoints for futures Cross-Collateral: - `POST /sapi/v1/futures/loan/borrow` - `GET /sapi/v1/futures/loan/borrow/history` - `POST /sapi/v1/futures/loan/repay` - `GET /sapi/v1/futures/loan/repay/history` - `GET /sapi/v1/futures/loan/wallet` - `GET /sapi/v1/futures/loan/configs` - `GET /sapi/v1/futures/loan/calcAdjustLevel` - `GET /sapi/v1/futures/loan/calcMaxAdjustAmount` - `POST /sapi/v1/futures/loan/adjustCollateral` - `GET /sapi/v1/futures/loan/adjustCollateral/history` - `GET /sapi/v1/futures/loan/liquidationHistory` --- ## 2020-06-28 - SAPI Endpoints for futures: - `POST /sapi/v1/futures/transfer` - `GET /sapi/v1/futures/transfer` --- ## 2020-05-06 - New endpoints for Mining: - `GET /sapi/v1/mining/pub/algoList` - `GET /sapi/v1/mining/pub/coinList` - `GET /sapi/v1/mining/worker/detail` - `GET /sapi/v1/mining/worker/list` - `GET /sapi/v1/mining/payment/list` - `GET /sapi/v1/mining/statistics/user/status` - `GET /sapi/v1/mining/statistics/user/list` --- ## 2020-05-01 - From 2020-05-01 UTC 00:00, all symbols will have a limit of 200 open orders using the [MAX_NUM_ORDERS](https://binance-docs.github.io/apidocs/spot/en/#filters) filter. - No existing orders will be removed or canceled. - Accounts that have 200 or more open orders on a symbol will not be able to place new orders on that symbol until the open order count is below 200. - OCO orders count as 2 open orders before the `LIMIT` order is touched or the `STOP_LOSS` (or `STOP_LOSS_LIMIT`) order is triggered; once this happens the other order is canceled and will no longer count as an open order. --- ## 2020-04-25 SPOT API - New field `permissions` - Defines the trading permissions that are allowed on accounts and symbols. - `permissions` is an enum array; values: - `SPOT` - `MARGIN` - `permissions` will replace `isSpotTradingAllowed` and `isMarginTradingAllowed` on `GET api/v3/exchangeInfo` in future API versions (v4+). - For an account to trade on a symbol, the account and symbol must share at least 1 permission in common. - Updates to GET `api/v3/exchangeInfo` - New field `permissions` added. - New field `quoteAssetPrecision` added; a duplicate of the `quotePrecision` field. `quotePrecision` will be removed in future API versions (v4+). - Updates to GET `api/v3/account` - New field `permissions` added. - New endpoint DELETE `api/v3/openOrders` - This will allow a user to cancel all open orders on a single symbol. - This endpoint will cancel all open orders including OCO orders. - Orders can be canceled via the API on symbols in the `BREAK` or `HALT` status. USER DATA STREAM - `OutboundAccountInfo` has new field `P` which shows the trading permissions of the account. --- ## 2020-04-23 WEB SOCKET STREAM - WebSocket connections have a limit of 5 incoming messages per second. A message is considered: - A PING frame - A PONG frame - A JSON control message (e.g. subscribe, unsubscribe) - A connection that goes beyond the limit will be disconnected; IPs that are repeatedly disconnected may be banned. - A single connection can listen to a maximum of 1024 streams. ## 2020-04-16 - New fields in response to endpoint`GET /sapi/v1/lending/daily/token/position`: - `todayPurchasedAmount` for user's purchased amount today - New lending endpoints for customized fixed projects: - `GET /sapi/v1/lending/project/list` - `POST /sapi/v1/lending/customizedFixed/purchase` - `GET /sapi/v1/lending/project/position/list` --- ## 2020-04-02 - New fields in response to endpoint`GET /sapi/v1/capital/config/getall`: - `minConfirm` for min number for balance confirmation - `unLockConfirm` for confirmation number for balance unlock --- ## 2020-03-24 - `MAX_POSITION` filter added. - This filter defines the allowed maximum position an account can have on the base asset of a symbol. An account's position defined as the sum of the account's: - free balance of the base asset - locked balance of the base asset - sum of the qty of all open BUY orders - `BUY` orders will be rejected if the account's position is greater than the maximum position allowed. --- ## 2020-03-13 - New parameter `transactionFeeFlag` is available in endpoint: - `POST /sapi/v1/capital/withdraw/apply` and - `POST /wapi/v3/withdraw.html` --- ## 2020-02-05 - New sub account endpoints: - `POST /sapi/v1/sub-account/futures/transfer` to transfer between futures and spot accout of sub-account. - `POST /sapi/v1/sub-account/margin/transfer` to transfer between margin and spot accout of sub-account. - `POST /sapi/v1/sub-account/transfer/subToSub` to transfer to another account by sub-account. - `POST /sapi/v1/sub-account/transfer/subToMaster` to transfer to same master by sub-account. - `GET /sapi/v1/sub-account/transfer/subUserHistory` to get transfer history of sub-account. --- ## 2020-01-15 - New parameter `withdrawOrderId` for client customized withdraw id for endpoint `POST /wapi/v3/withdraw.html`. - New field `withdrawOrderId` in response to `GET /wapi/v3/withdrawHistory.html` --- ## 2019-12-25 - New endpoints for Binance Savings: - `GET /sapi/v1/lending/daily/product/list` - `GET /sapi/v1/lending/daily/userLeftQuota` - `POST /sapi/v1/lending/daily/purchase ` - `GET /sapi/v1/lending/daily/userRedemptionQuota` - `POST /sapi/v1/lending/daily/redeem` - `GET /sapi/v1/lending/daily/token/position` - `GET /sapi/v1/lending/union/account` - `GET /sapi/v1/lending/union/purchaseRecord` - `GET /sapi/v1/lending/union/redemptionRecord` - `GET /sapi/v1/lending/union/interestHistory` - Added time interval limit in `GET /sapi/v1/capital/withdraw/history`, `GET /wapi/v3/withdrawHistory.html`, `GET /sapi/v1/capital/deposit/hisrec` and `GET /wapi/v3/depositHistory.html`: _ The default `startTime` is 90 days from current time, and the default `endTime` is current time. _ Please notice the default `startTime` and `endTime` to make sure that time interval is within 0-90 days. \* If both `startTime` and `endTime` are sent, time between `startTime` and `endTime` must be less than 90 days. --- ## 2019-12-18 - New endpoint to get daily snapshot of account: `GET /sapi/v1/accountSnapshot` --- ## 2019-11-30 - Added parameter `sideEffectType` in `POST /sapi/v1/margin/order (HMAC SHA256)` with enums: - `NO_SIDE_EFFECT` for normal trade order; - `MARGIN_BUY` for margin trade order; - `AUTO_REPAY` for making auto repayment after order filled. - New field `marginBuyBorrowAmount` and `marginBuyBorrowAsset` in `FULL` response to `POST /sapi/v1/margin/order (HMAC SHA256)` --- ## 2019-11-28 - New SAPI endpont to disable fast withdraw switch: `POST /sapi/v1/account/disableFastWithdrawSwitch (HMAC SHA256)` - New SAPI endpont to enable fast withdraw switch: `POST /sapi/v1/account/enableFastWithdrawSwitch (HMAC SHA256)` --- ## 2019-11-22 - Quote Order Qty Market orders have been enabled on all symbols. - Quote Order Qty `MARKET` orders allow a user to specify the total `quoteOrderQty` spent or received in the `MARKET` order. - Quote Order Qty `MARKET` orders will not break `LOT_SIZE` filter rules; the order will execute a quantity that will have the notional value as close as possible to `quoteOrderQty`. - Using `BNBBTC` as an example: - On the `BUY` side, the order will buy as many BNB as `quoteOrderQty` BTC can. - On the `SELL` side, the order will sell as much BNB as needed to receive `quoteOrderQty` BTC. --- ## 2019-11-19 - `GET /sapi/v1/sub-account/margin/account` has new field: `marginTradeCoeffVo` which contains - `forceLiquidationBar` for liquidation margin ratio - `marginCallBar` for margin call margin ratio - `normalBar` for initial margin ratio --- ## 2019-11-13 Rest API - api/v3/exchangeInfo has new fields: - `quoteOrderQtyMarketAllowed` - `baseCommissionPrecision` - `quoteCommissionPrecision` - `MARKET` orders have a new optional field: `quoteOrderQty` used to specify the quote quantity to BUY or SELL. This cannot be used in combination with `quantity`. - The exact timing that `quoteOrderQty` MARKET orders will be enabled is TBD. There will be a separate announcement and further details at that time. - All order query endpoints will return a new field `origQuoteOrderQty` in the JSON payload. (e.g. GET api/v3/allOrders) ```json { "code": -1128, "msg": "Combination of optional parameters invalid. Recommendation: 'stopLimitTimeInForce' should also be sent." } ``` - Updated error messages for -1128 - Sending an `OCO` with a `stopLimitPrice` but without a `stopLimitTimeInForce` will return the error: - Updated error messages for -1003 to specify the limit is referring to the request weight, not to the number of requests. **Deprecation of v1 endpoints**: By end of Q1 2020, the following endpoints will be removed from the API. The documentation has been updated to use the v3 versions of these endpoints. - GET api/v1/depth - GET api/v1/historicalTrades - GET api/v1/aggTrades - GET api/v1/klines - GET api/v1/ticker/24hr - GET api/v1/ticker/price - GET api/v1/exchangeInfo - POST api/v1/userDataStream - PUT api/v1/userDataStream - GET api/v1/ping - GET api/v1/time - GET api/v1/ticker/bookTicker **These endpoints however, will NOT be migrated to v3. Please use the following endpoints instead moving forward.**
Old V1 Endpoints New V3 Endpoints
GET api/v1/ticker/allPrices GET api/v3/ticker/price
GET api/v1/ticker/allBookTickers GET api/v3/ticker/bookTicker
USER DATA STREAM - Changes to`executionReport` event - If the C field is empty, it will now properly return `null`, instead of `"null"`. - New field Q which represents the `quoteOrderQty`. - `balanceUpdate` event type added - This event occurs when funds are deposited or withdrawn from your account. WEB SOCKET STREAM - WSS now supports live subscribing/unsubscribing to streams. --- ## 2019-11-08 - New sapi for subaccount management on margin and futures: - `GET /sapi/v1/sub-account/status (HMAC SHA256)` - `POST /sapi/v1/sub-account/margin/enable (HMAC SHA256)` - `GET /sapi/v1/sub-account/margin/account (HMAC SHA256)` - `GET /sapi/v1/sub-account/margin/accountSummary (HMAC SHA256)` - `POST /sapi/v1/sub-account/futures/enable (HMAC SHA256)` - `GET /sapi/v1/sub-account/futures/account (HMAC SHA256)` - `GET /sapi/v1/sub-account/futures/accountSummary (HMAC SHA256)` - `GET /sapi/v1/sub-account/futures/positionRisk (HMAC SHA256)` --- ## 2019-11-04 - New sapi endpoints for subaccount wallet. - `GET /sapi/v1/capital/deposit/subAddress (HMAC SHA256))`: fetch subaccount deposit address. - `GET /sapi/v1/capital/deposit/subHisrec (HMAC SHA256))`: fetch subaccount deposit history. --- ## 2019-10-29 - New sapi endpoints for wallet. - `POST /sapi/v1/capital/withdraw/apply (HMAC SHA256)`: withdraw. - `Get /sapi/v1/capital/withdraw/history (HMAC SHA256)`: fetch withdraw history with network. --- ## 2019-10-14 - New sapi endpoints for wallet. - `GET /sapi/v1/capital/config/getall (HMAC SHA256)`: get all coins' information for user. - `GET /sapi/v1/capital/deposit/hisrec (HMAC SHA256)`: fetch deposit history with network. - `GET /sapi/v1/capital/deposit/address (HMAC SHA256)`: fetch deposit address with network. --- ## 2019-10-11 - Added parameter `network` in `POST /wapi/v3/withdraw.html` so that asset can be withdrawed with specific network. --- ## 2019-09-09 - New WebSocket streams for bookTickers added: `@bookTicker` and `!bookTicker`. --- ## 2019-09-03 - Faster order book data with 100ms updates: `@depth@100ms` and `@depth#@100ms` - Added "Update Speed:" to `Websocket Market Streams` - Removed deprecated v1 endpoints as per previous announcement: - GET api/v1/order - GET api/v1/openOrders - POST api/v1/order - DELETE api/v1/order - GET api/v1/allOrders - GET api/v1/account - GET api/v1/myTrades --- ## 2019-08-16 - GET api/v1/depth `limit` of 10000 has been temporarily removed - In Q4 2017, the following endpoints were deprecated and removed from the API documentation. They have been permanently removed from the API as of this version. We apologize for the omission from the original changelog: - GET api/v1/order - GET api/v1/openOrders - POST api/v1/order - DELETE api/v1/order - GET api/v1/allOrders - GET api/v1/account - GET api/v1/myTrades - Streams, endpoints, parameters, payloads, etc. described in the documents in this repository are **considered official** and **supported**. The use of any other streams, endpoints, parameters, or payloads, etc. is **not supported; use them at your own risk and with no guarantees.** --- ## 2019-09-15 Rest API - New order type: OCO ("One Cancels the Other") - An OCO has 2 orders: (also known as legs in financial terms) - `STOP_LOSS` or `STOP_LOSS_LIMIT` leg - `LIMIT_MAKER` leg - Price Restrictions: - `SELL Orders` : Limit Price > Last Price > Stop Price - `BUY Orders` : Limit Price < Last Price < Stop Price - As stated, the prices must "straddle" the last traded price on the symbol. EX: If the last price is 10: - A SELL OCO must have the limit price greater than 10, and the stop price less than 10. - A BUY OCO must have a limit price less than 10, and the stop price greater than 10. - Quantity Restrictions: - Both legs must have the **same quantity**. - `ICEBERG` quantities however, do not have to be the same. - Execution Order: - If the `LIMIT_MAKER` is touched, the limit maker leg will be executed first BEFORE canceling the Stop Loss Leg. - if the Market Price moves such that the `STOP_LOSS` or `STOP_LOSS_LIMIT` will trigger, the Limit Maker leg will be cancelled BEFORE executing the `STOP_LOSS` Leg. - Cancelling an OCO - Cancelling either order leg will cancel the entire OCO. - The entire OCO can be canceled via the `orderListId` or the `listClientOrderId`. - New Enums for OCO: 1. `ListStatusType` - `RESPONSE` - used when ListStatus is responding to a failed action. (either order list placement or cancellation) - `EXEC_STARTED` - used when an order list has been placed or there is an update to a list's status. - `ALL_DONE` - used when an order list has finished executing and is no longer active. 2. `ListOrderStatus` - `EXECUTING` - used when an order list has been placed or there is an update to a list's status. - `ALL_DONE` - used when an order list has finished executing and is no longer active. - `REJECT` - used when ListStatus is responding to a failed action. (either order list placement or cancellation) 3. `ContingencyType` - `OCO` - specifies the type of order list. - New Endpoints: - POST api/v3/order/oco - DELETE api/v3/orderList - GET api/v3/orderList - `recvWindow` cannot exceed 60000. - New `intervalLetter` values for headers: - SECOND => S - MINUTE => M - HOUR => H - DAY => D - New Headers `X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)` will give your current used request weight for the (intervalNum)(intervalLetter) rate limiter. For example, if there is a one minute request rate weight limiter set, you will get a `X-MBX-USED-WEIGHT-1M` header in the response. The legacy header `X-MBX-USED-WEIGHT` will still be returned and will represent the current used weight for the one minute request rate weight limit. - New Header `X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)`that is updated on any valid order placement and tracks your current order count for the interval; rejected/unsuccessful orders are not guaranteed to have `X-MBX-ORDER-COUNT-**` headers in the response. - Eg. `X-MBX-ORDER-COUNT-1S` for "orders per 1 second" and `X-MBX-ORDER-COUNT-1D` for orders per "one day" - GET api/v1/depth now supports `limit` 5000 and 10000; weights are 50 and 100 respectively. - GET api/v1/exchangeInfo has a new parameter `ocoAllowed`. USER DATA STREAM - `executionReport` event now contains "g" which has the `orderListId`; it will be set to -1 for non-OCO orders. - New Event Type `listStatus`; `listStatus` is sent on an update to any OCO order. - New Event Type `outboundAccountPosition`; `outboundAccountPosition` is sent any time an account's balance changes and contains the assets that could have changed by the event that generated the balance change (a deposit, withdrawal, trade, order placement, or cancelation). NEW ERRORS - **-1131 BAD_RECV_WINDOW** - `recvWindow` must be less than 60000 - **-1099 Not found, authenticated, or authorized** - This replaces error code -1999 NEW -2011 ERRORS - **OCO_BAD_ORDER_PARAMS** - A parameter for one of the orders is incorrect. - **OCO_BAD_PRICES** - The relationship of the prices for the orders is not correct. - **UNSUPPORTED_ORD_OCO** - OCO orders are not supported for this symbol. --- ## 2019-03-12 Rest API - X-MBX-USED-WEIGHT header added to Rest API responses. - Retry-After header added to Rest API 418 and 429 responses. - When canceling the Rest API can now return `errorCode` -1013 OR -2011 if the symbol's `status` isn't `TRADING`. - `api/v1/depth` no longer has the ignored and empty `[]`. - `api/v3/myTrades` now returns `quoteQty`; the price \* qty of for the trade. Websocket streams - `@depth` and `@depthX` streams no longer have the ignored and empty `[]`. System improvements - Matching Engine stability/reliability improvements. - Rest API performance improvements. --- ## 2018-11-13 Rest API - Can now cancel orders through the Rest API during a trading ban. - New filters: `PERCENT_PRICE`, `MARKET_LOT_SIZE`, `MAX_NUM_ICEBERG_ORDERS`. - Added `RAW_REQUESTS` rate limit. Limits based on the number of requests over X minutes regardless of weight. - /api/v3/ticker/price increased to weight of 2 for a no symbol query. - /api/v3/ticker/bookTicker increased weight of 2 for a no symbol query. - DELETE /api/v3/order will now return an execution report of the final state of the order. - `MIN_NOTIONAL` filter has two new parameters: `applyToMarket` (whether or not the filter is applied to MARKET orders) and `avgPriceMins` (the number of minutes over which the price averaged for the notional estimation). - `intervalNum` added to /api/v1/exchangeInfo limits. `intervalNum` describes the amount of the interval. For example: `intervalNum` 5, with `interval` minute, means "every 5 minutes". Explanation for the average price calculation: 1. (qty \* price) of all trades / sum of qty of all trades over previous 5 minutes. 2. If there is no trade in the last 5 minutes, it takes the first trade that happened outside of the 5min window. For example if the last trade was 20 minutes ago, that trade's price is the 5 min average. 3. If there is no trade on the symbol, there is no average price and market orders cannot be placed. On a new symbol with `applyToMarket` enabled on the `MIN_NOTIONAL` filter, market orders cannot be placed until there is at least 1 trade. 4. The current average price can be checked here: `https://api.binance.com/api/v3/avgPrice?symbol=` For example: https://api.binance.com/api/v3/avgPrice?symbol=BNBUSDT User data stream - `Last quote asset transacted quantity` (as variable `Y`) added to execution reports. Represents the `lastPrice` _ `lastQty` (`L` _ `l`). --- ## 2018-07-18 Rest API - New filter: `ICEBERG_PARTS` - `POST api/v3/order` new defaults for `newOrderRespType`. `ACK`, `RESULT`, or `FULL`; `MARKET` and `LIMIT` order types default to `FULL`, all other orders default to `ACK`. - POST api/v3/order `RESULT` and `FULL` responses now have `cummulativeQuoteQty` - GET api/v3/openOrders with no symbol weight reduced to 40. - GET api/v3/ticker/24hr with no symbol weight reduced to 40. - Max amount of trades from GET /api/v1/trades increased to 1000. - Max amount of trades from GET /api/v1/historicalTrades increased to 1000. - Max amount of aggregate trades from GET /api/v1/aggTrades increased to 1000. - Max amount of aggregate trades from GET /api/v1/klines increased to 1000. - Rest API Order lookups now return `updateTime` which represents the last time the order was updated; `time` is the order creation time. - Order lookup endpoints will now return `cummulativeQuoteQty`. If `cummulativeQuoteQty` is < 0, it means the data isn't available for this order at this time. - `REQUESTS` rate limit type changed to `REQUEST_WEIGHT`. This limit was always logically request weight and the previous name for it caused confusion. User data stream - `cummulativeQuoteQty` field added to order responses and execution reports (as variable `Z`). Represents the cummulative amount of the `quote` that has been spent (with a `BUY` order) or received (with a `SELL` order). Historical orders will have a value < 0 in this field indicating the data is not available at this time. `cummulativeQuoteQty` divided by `cummulativeQty` will give the average price for an order. - `O` (order creation time) added to execution reports --- ## 2018-01-23 - GET /api/v1/historicalTrades weight decreased to 5 - GET /api/v1/aggTrades weight decreased to 1 - GET /api/v1/klines weight decreased to 1 - GET /api/v1/ticker/24hr all symbols weight decreased to number of trading symbols / 2 - GET /api/v3/allOrders weight decreased to 5 - GET /api/v3/myTrades weight decreased to 5 - GET /api/v3/account weight decreased to 5 - GET /api/v1/depth limit=500 weight decreased to 5 - GET /api/v1/depth limit=1000 weight decreased to 10 - -1003 error message updated to direct users to websockets --- ## 2018-01-20 - GET /api/v1/ticker/24hr single symbol weight decreased to 1 - GET /api/v3/openOrders all symbols weight decreased to number of trading symbols / 2 - GET /api/v3/allOrders weight decreased to 15 - GET /api/v3/myTrades weight decreased to 15 - GET /api/v3/order weight decreased to 1 - myTrades will now return both sides of a self-trade/wash-trade --- ## 2018-01-14 - GET /api/v1/aggTrades weight changed to 2 - GET /api/v1/klines weight changed to 2 - GET /api/v3/order weight changed to 2 - GET /api/v3/allOrders weight changed to 20 - GET /api/v3/account weight changed to 20 - GET /api/v3/myTrades weight changed to 20 - GET /api/v3/historicalTrades weight changed to 20 --- ## Document: /products/common/derivatives-trading/quick-start URL: /zh-CN/docs/products/common/derivatives-trading/quick-start # 快速开始 ## API Key 权限设置 - 新创建的API的默认权限是 `只读`。 - 如果需要通过API提款, 需要在UI修改权限, 选中 `允许提现`。 - 如果需要通过API交易, 需要在UI修改权限, 选中对应交易权限 ## 账户 ### 现货账户 新注册的币安账号都会有一个现货(`SPOT`)账号。 ### 期货账户 为了开设期货(`FUTURES`)账户, 可以参考[币安期权介绍](https://www.binance.com/zh-CN/support/faq/%E6%95%B0%E5%AD%97%E8%B4%A7%E5%B8%81%E8%A1%8D%E7%94%9F%E5%93%81?c=4&navId=4#18-36) ### 期货测试网 用户可以使用期货的测试网来体验`FUTURES`交易. 现在只能通过API来交易。 更多信息请参考[期货模拟交易](https://demo.binance.com/en/futures/BTCUSDT)。 ### 期权账户 为了开设期权(`OPTION`)账户, 可以参考[Binance期权概览](https://www.binance.com/zh-CN/support/faq/%E5%B9%A3%E5%AE%89%E6%9C%9F%E6%AC%8A%E6%A6%82%E8%A6%BD-374321c9317c473480243365298b8706) ## API 代码库 ### Python connector 一个轻量级的Python代码库,提供让用户直接调用API的方法。支持所有合约的接口。 [https://github.com/binance/binance-connector-python](https://github.com/binance/binance-connector-python) ### Java connector 一个轻量级的代码库,提供Java用户直接调用API的方法。支持所有合约的接口。 [https://github.com/binance/binance-connector-java](https://github.com/binance/binance-connector-java) --- ## Document: /products/common/derivatives-trading/change-log URL: /zh-CN/docs/products/common/derivatives-trading/change-log # 更新日志 ## 2026-06-20 U 本位合约 - `POST /fapi/v1/algoOrder`(下条件单) - 请求权重调整为下单限频:10s order rate limit(`X-MBX-ORDER-COUNT-10S`) 为 `1`;1min order rate limit(`X-MBX-ORDER-COUNT-1M`) 为 `1`。IP 权重维持为 `0`。 --- ## 2026-06-16 **时效性通知** - **更新:** 币本位合约 demo 交易停机维护窗口延长。新的窗口为 2026-06-16 02:00:00 至 2026-06-23 10:00:00 (UTC)。感谢您的耐心与理解。 --- ## 2026-06-10 **生效日期: 2026-06-30** 币本位合约与 U 本位合约架构整合 — 涉及 REST 接口、WebSocket Stream、以及账户层行为的变更。完整的受影响接口清单与行动项请见 [币本位/U本位整合迁移公告](/products/derivatives-trading-coin-futures/Important-CM-UM-Integration-Notice)。 --- ## 2026-06-02 **生效日期: 2026-06-02** U 本位合约 - `GET /fapi/v1/tradingSchedule`(交易时段) - 时间范围从查询时间前一日起算的“往后 7 天”扩展为**“往前 7 天 + 往后 7 天”**。 - 新增韩国股票市场(`KR_EQUITY`)支持。韩国股票市场时段类型:`REGULAR` 和 `NO_TRADING`。 - WebSocket Stream `tradingSession`(当前交易时段) - 新增韩国股票市场支持。 - 新增事件类型 `KR_EquityUpdate`。韩国股票市场时段类型:`REGULAR` 和 `NO_TRADING`。 --- ## 2026-05-11 **生效日期: 2026-05-13** USDⓈ-M期货 - `POST /fapi/v1/positionSide/dual` - 新增错误码 `-4531`:在修改 UM 的 `dualSidePosition` 时,系统会自动同步 CM 的 `dualSidePosition`。如果 CM 账户有任何持仓或挂单,则无法进行同步,UM 持仓模式的修改将被拒绝并返回错误码 `-4531`。 - 错误信息: ```json { "code": -4531, "msg": "Position mode change requires syncing UM and CM. Please close any open positions or orders in CM and try again." } ``` - **注意**: 此错误码是临时的,仅在 CM 进入 Guard 之前有效(约 1 个月)。CM 进入 Guard 后,将不再出现此错误。 --- ## 2026-04-17 统一账户Pro - Websocket账户信息推送更新: - 新增 `PM_PRO_ACCOUNT_UPDATE` 消息,每 5 秒推送一次账户资产状态。 --- ## 2026-04-15 欧式期权 - 交易接口 - 批量撤销订单 - 修正请求权重,从 1 更正为 5。 --- ## 2026-04-14 统一账户 - 将在2026-04-28启用以下REST接口和WebSocket用户数据推送: - REST: - POST `/papi/v1/um/algo/order` - DELETE `/papi/v1/um/algo/order` - DELETE `/papi/v1/um/algo/allOpenOrders` - GET `/papi/v1/um/algo/algoOrder` - GET `/papi/v1/um/algo/openAlgoOrders` - GET `/papi/v1/um/algo/allAlgoOrders` - Websocket: - `ALGO_UPDATE`: 条件订单交易更新推送 - 将在2026-04-28弃用以下REST接口: - REST: - POST `/papi/v1/um/conditional/order` - DELETE `/papi/v1/um/conditional/order` - DELETE `/papi/v1/um/conditional/allOpenOrders` - GET `/papi/v1/um/conditional/allOrders` - GET `/papi/v1/um/conditional/openOrders` - GET `/papi/v1/um/conditional/openOrder` - GET `/papi/v1/um/conditional/orderHistory` 请参考以下[公告](https://www.binance.com/en/support/announcement/detail/13980e4145ee41259d32f985161d81b6)进行接口替换和调整 --- ## 2026-04-13 统一账户和统一账户Pro REST API新增: - `POST /sapi/v1/portfolio/margin-call-level` : 设置统一保证金账户的强平预警线。当账户的 uniMMR 降至指定水平时,系统将通过邮件和短信发送通知。 - `GET /sapi/v1/portfolio/margin-call-level` : 查询统一保证金账户的强平预警线。 - `DELETE /sapi/v1/portfolio/margin-call-level` : 删除统一保证金账户的强平预警线。 --- ## 2026-04-10 **生效日期: 2026-04-14** COIN-M期货 / 统一账户和统一账户Pro - `POST /dapi/v1/positionSide/dual` 和 `POST /papi/v1/cm/positionSide/dual` - CM 的 `dualSidePosition` 必须与 UM 保持一致。如果 CM 的 `dualSidePosition` 已经与 UM 相同,则修改会被拒绝。 USDⓈ-M期货 - 强平订单 (`@forceOrder`) 和全市场强平订单 (`!forceOrder@arr`) - 更新描述:将"最近的强平订单"改为"最大的强平订单"。 --- ## 2026-04-09 统一账户 - User Data Stream - [杠杆账户订单事件](pm/user-data-streams/Event-Margin-Order-Update_zh-CN) - `executionReport` 事件新增字段: `Cs`, `pl`, `pL`, `pY`, `eR`。 --- ## 2026-04-08 统一账户 REST API新增: - `POST /papi/v1/um/stock/contract` : 签署传统金融合约协议 --- ## 2026-04-06 USDⓈ-M期货 / COIN-M期货 / 统一账户和统一账户Pro - `GET /fapi/v1/forceOrders`、`GET /dapi/v1/forceOrders`、`GET /papi/v1/um/forceOrders` 和 `GET /papi/v1/cm/forceOrders` - 新增说明:本接口仅支持最近90天数据的查询。 --- ## 2026-04-02 USDⓈ-M期货 - Websocket - 更新 [WebSocket Base URL 迁移公告](/products/derivatives-trading-usds-futures/websocket-market-streams/Important-WebSocket-Change-Notice),新增旧 URL 下线日期:**2026-04-23**。 --- ## 2026-03-19 USDⓈ-M期货 / COIN-M期货 - `GET /fapi/v1/historicalTrades` 和 `GET /dapi/v1/historicalTrades` - 数据查询范围从最近3个月调整为最近1个月。 ## 2026-03-16 USDⓈ-M期货 - 市场数据连接 - `Mark-Price-Stream`和`Mark-Price-Stream-for-All-market`中新增字段`ap`显示标记价格移动平均 ## 2026-03-11 欧式期权 - 自2026-03-19起 - 自成交保护 - 和USDⓈ-M期货一样,期权已经支持 Self-Trade Prevention(STP)自成交保护。此功能将阻止订单与来自同一账户或者同一tradeGroupId 账户的订单交易(当前仅支持同一账户)。 - 期权所有交易对支持通过下单时设置selfTradePreventionMode为下面之一的 STP 模式: - EXPIRE_MAKER: 自成交过期 maker 订单 - EXPIRE_TAKER: 自成交过期 taker 订单 - EXPIRE_BOTH: 自成交过期 taker 和 maker 订单 - REST 更新: - 新的订单状态:EXPIRED_IN_MATCH - 订单由于 STP 触发而过期 - 以下接口新增可选参数selfTradePreventionMode以设置该订单的自成交保护模式: - POST /eapi/v1/order - POST /eapi/v1/batchOrders - 以下接口新增响应字段selfTradePreventionMode以显示订单的自成交保护模式: - POST /eapi/v1/order - POST /eapi/v1/batchOrders - GET /eapi/v1/order - GET /eapi/v1/openOrders - PUT /eapi/v1/order - PUT /eapi/v1/batchOrders - DELETE /eapi/v1/order - DELETE /eapi/v1/batchOrders - WEBSOCKET 账户信息推送更新: - ORDER_TRADE_UPDATE中新增字段V显示用户订单的自成交保护模式 ## 2026-03-05 USDⓈ-M期货 - Websocket - [WebSocket Base URL 迁移公告](usds-margined-futures/websocket-market-streams/Important-WebSocket-Change-Notice_zh-CN) - 所有 WebSocket 行情推送页面新增 `URL PATH` 字段,标注新的 Base URL 路径(`/public`、`/market`)。 - 所有用户数据推送事件页面新增 `URL PATH` 字段,标注新的 Base URL 路径(`/private`)。 ## 2026-01-09 统一账户: - Rest API新增Delta中性账户新接口: - `POST /sapi/v1/portfolio/delta-mode`: 切换当前统一账户到Delta中性账户 - `GET /sapi/v1/portfolio/delta-mode`: 查询当前账户到Delta中性状态 ## 2026-01-07 期权 - REST API新增: - `GET /eapi/v1/commission`: 获取用户手续费率 ## 2025-12-29 USDⓈ-M期货 - "filterType": "MAX_NUM_ALGO_ORDERS" 返回已从接口 `GET /fapi/v1/exchangeInfo`移除。所有币对的未平仓条件单上限为 200 笔。 - 自2025-12-31起,归集交易数据流`@aggTrade`增加字段`nq`,其聚合普通订单成交量,不包含RPI订单数据。 ## 2025-12-11 USDⓈ-M期货 - REST API新增: - `GET /fapi/v1/tradingSchedule`: 获取一周交易时段信息 - `POST /fapi/v1/stock/contract`: 签署传统金融合约协议 - Websocket API新增: - `tradingSession`: 获取当前交易时段信息 ## 2025-12-10 - 由于条件订单已迁移至Algo服务,事件 `CONDITIONAL_ORDER_TRIGGER_REJECT` 将于2025年12月15日起废止。所有条件订单的拒绝原因已通过 `ALGO_UPDATE` 事件提供。 ## 2025-12-09 COIN-M期货 - 自2025-12-10起,订单交易更新推送事件`ORDER_TRADE_UPDATE`增加订单过期原因字段`er`。 ## 2025-11-25 USDⓈ-M期货 - 自 **2025-11-26** 起,用户手续费率接口支持查询RPI手续费率 - REST - `GET /fapi/v1/commissionRate` - 提供如下新接口,获取RPI深度信息 - REST - `GET /fapi/v1/rpiDepth` - WebSocket - `@rpiDepth@500ms` ## 2025-11-19 USDⓈ-M期货 - REST API更新: - `GET /fapi/v1/symbolAdlRisk`: 查询自动减仓风险评级 ## 2025-11-18 USDⓈ-M期货 - 支持RPI订单 - 有效方式 (timeInForce)新增“RPI”枚举值 - REST - `POST /fapi/v1/order` - `POST /fapi/v1/batchOrders` - WebSocket - `order.place` - 新响应字段"IsRPITrade"(布尔) - REST - `GET /fapi/v1/trades` - `GET /fapi/v1/historicalTrades` - RPI订单不包含在订单簿 - REST - `GET /fapi/v1/depth` - `GET /fapi/v1/ticker/bookTicker` - WebSocket - `ticker.book` - `@bookTicker` - `!bookTicker` - `@depth` - `@depth` - 更多详细信息,请阅读 - ## 2025-11-12 币安衍生品正在重建期权系统,以提升整体的稳定性、性能与可扩展性,并引入更多新功能。 作为第一步,我们已上线全新的期权 Demo API 环境,以便现有用户能够提前调整代码,适配新系统。相关文档可在 “Options Demo Trading” 标签页中查看。 请前往 创建新的 API Key,该 Key 可用于访问全新的期权 Demo 交易环境。 ## 2025-11-10 - BFUSD 已于 2025-08-13 迁移至 Binance Earn,以下接口已被废弃: - `POST sapi/v1/portfolio/mint` - `POST sapi/v1/portfolio/redeem` ## 2025-11-06 - USDT-M合约将在 **2025-12-09** 起将条件订单迁移到Algo服务, 以下订单类型将会受到影响: `STOP_MARKET`/`TAKE_PROFIT_MARKET`/`STOP`/`TAKE_PROFIT`/`TRAILING_STOP_MARKET`. - REST API 将提供如下新接口进行条件订单的下单、撤单和查询: - `POST fapi/v1/algoOrder`: 条件单下单 - `DELETE /fapi/v1/algoOrder`: 条件单撤单 - `DELETE fapi/v1/algoOpenOrders`: 撤销所有条件单 - `GET /fapi/v1/algoOrder`: 查询条件订单 - `GET /fapi/v1/openAlgoOrders`: 查询条件订单挂单 - `GET /fapi/v1/allAlgoOrders`: 查询所有条件单 - 切换后以下接口下 `STOP_MARKET`/`TAKE_PROFIT_MARKET`/`STOP`/`TAKE_PROFIT`/`TRAILING_STOP_MARKET`类型订单会被拦截。请求接口会遇到错误码 `-4120` STOP_ORDER_SWITCH_ALGO 。 - `POST /fapi/v1/order` - `POST /fapi/v1/batchOrders` - 用户数据更新 - 条件单新增事件: `ALGO_UPDATE` - Websocket API 更新 - 条件单下单 : `algoOrder.place` - 条件单撤单: `algoOrder.cancel` - 本次迁移的影响点如下: - 条件单在触发前不会进行保证金校验 - GTE_GTC 订单不再依赖于对手方的未平仓订单,而仅依赖于持仓情况 - 订单触发不会增加延迟 - 条件单暂不支持改单 ## 2025-10-21 - 自 **2025-10-23** 起,下单/改单接口中的 `priceMatch` 枚举 **`OPPONENT_10`**、**`OPPONENT_20`** 暂时移除,其余枚举不受影响。影响接口如下: **USDT-M 合约 (`/fapi`)** - `POST /fapi/v1/order` - `POST /fapi/v1/batchOrders` - `PUT /fapi/v1/order` - `PUT /fapi/v1/batchOrders` **COIN-M 合约 (`/dapi`)** - `POST /dapi/v1/order` - `POST /dapi/v1/batchOrders` - `PUT /dapi/v1/order` - `PUT /dapi/v1/batchOrders` **Portfolio Margin (`/papi`)** - `POST /papi/v1/um/order` - `PUT /papi/v1/um/order` - `POST /papi/v1/um/conditional/order` - `POST /papi/v1/cm/order` - `PUT /papi/v1/cm/order` - `POST /papi/v1/cm/conditional/order` ## 2025-10-20 USDⓈ-M期货 - 自2025-10-23起,订单交易更新推送事件`ORDER_TRADE_UPDATE`增加订单过期原因字段`er`。 ## 2025-10-14 - 自 2025-10-23 起,下列错误码的提示信息将更新: ```javascript { "code": -1008, "msg": "Request throttled by system-level protection. Reduce-only/close-position orders are exempt. Please try again." } ``` ## 2025-10-09 - 合约系统新增:支持中文交易对名称(`symbol` 可为中文)。`exchangeInfo` 返回示例:`"symbol": "测试USDT"`。 - 通过 API 下单时,若 `symbol` 含中文,必须进行 URL 编码(UTF-8 百分号编码)。示例: `https://fapi.binance.com/fapi/v1/order?symbol=%E6%B5%8B%E8%AF%95USDT&side=BUY&type=TAKE_PROFIT_MARKET&timeInForce=GTE_GTC&quantity=1&stopPrice=30×tamp=1760000007980` - 推送消息(WebSocket/用户数据流)中的 `symbol` 也可能为中文,请确保客户端/下游系统对中文解析、解码与显示的兼容性。 - 未对中文 `symbol` 进行编码可能导致请求失败或参数解析错误。 ## 2025-08-11 - BFUSD 将于 2025-08-13 迁移至 Binance Earn。迁移完成后,以下接口将被废弃: - `POST sapi/v1/portfolio/mint` - `POST sapi/v1/portfolio/redeem` - 调用上述接口可能会遇到错误码 `-21015`(ENDPOINT_GONE)。 - Portfolio Margin 和 Portfolio Margin Pro 用户可切换至 Binance Earn 进行 BFUSD 的铸造和赎回。迁移后,Portfolio Margin 钱包中的现有 BFUSD 可先通过资产归集接口(`POST /sapi/v1/portfolio/asset-collection`)进行资金归集,然后将BFUSD资产从 Portfolio Margin 钱包转至现货钱包进行赎回。 ## 2025-07-25 - fapi新增下列错误码: - `-4109`: _This account is inactive, please activate the account first._ 这表示该账户因长期未使用而被归档。要激活账户,请向USDM合约账户转入任意金额的资产。 ## 2025-07-02 USDⓈ-M期货 - REST API更新: - `GET /futures/data/openInterestHist`: 响应增加`CMCCirculatingSupply` - 市场数据连接: - 单个连接最多可以订阅Streams个数从200增加到1024。 ## 2025-04-23 USDⓈ-M期货 - REST API更新: - `GET /fapi/v1/insuranceBalance`: 查询保险基金余额快照 - `GET /fapi/v1/constituents`: 响应增加`price`和`weight` ## 2025-04-15 Portfolio Margin and Portfolio Margin Pro - 统一账户支持Earn资产作为抵押物相关接口: - `POST /sapi/v1/portfolio/earn-asset-transfer`: 统一账户转入LDUSDT资产 - `GET /sapi/v1/portfolio/earn-asset-balance`: 查询统一账户LDUSDT可转金额 ## 2025-02-28 Portfolio Margin Pro - 统一账户专业版新增穿仓借贷偿还记录查询(将于2025-02-28生效): - `GET /sapi/v1/portfolio/pmloan-history` ## 2025-02-20 币本位合约 WEBSOCKET API - Websocket API 将于2025-02-25,可通过以下 URL 访问:“wss://ws-dapi.binance.com/ws-dapi/v1” - WebSocket API 允许通过 WebSocket 连接下单、取消订单等。 - WebSocket API 是独立于 WebSocket 市场数据流的服务。也就是说,下订单和收听市场数据需要两个独立的 WebSocket 连接。 - WebSocket API 受与 REST API 相同的过滤器和速率限制规则的约束。 - WebSocket API 和 REST API 在功能上是等效的:它们提供相同的功能,接受相同的参数,返回相同的状态和错误代码。 ## 2025-01-20 Portfolio Margin - 统一账户新增查询用户负余额自动兑换记录(将于2025-01-22生效): - `GET /papi/v1/portfolio/negative-balance-exchange-record` ## 2025-01-13 USDⓈ-M Futures & COIN-M Futures - 下列接口将在2024-01-14被调整: - `GET /fapi/v1/historicalTrades` - `GET /dapi/v1/historicalTrades` 接口请求参数`limit`调整内容为: - 最大值从1000改为500 - 默认值从500改为100 ## 2025-01-06 Portfolio Margin - 统一账户新增查询用户下单限频接口: - `GET papi/v1/rateLimit/order` ## 2024-12-19 Portfolio Margin Pro & Portfolio Margin - 统一账户新增BFUSD申购和赎回接口(将于2024-12-20生效): - `POST sapi/v1/portfolio/mint` - `POST sapi/v1/portfolio/redeem` ## 2024-12-17 期权 - REST API: 新增 `GET /eapi/v1/blockTrades`以查询最近的大宗交易 - Websocket行情推送: 在消息`@trade`和 `@trade`增加字段`X`显示交易类型 ## 2024-12-02 USDⓈ-M Futures - 将于2024-12-03增加下列错误码: - `-4116`: ClientOrderId is duplicated. - `-4117`: Stop order is in triggering process. Please try again later. ## 2024-11-04 USDⓈ-M期货和币本位合约 - `GET /fapi/v1/pmExchangeInfo` 和 `GET /dapi/v1/pmExchangeInfo` 将于2024-11-15停用 ## 2024-11-01 期权 - 新增做市商大宗交易接口: - `POST eapi/v1/block/order/create` - `PUT eapi/v1/block/order/create` - `DELETE eapi/v1/block/order/create` - `GET eapi/v1/block/order/orders` - `POST eapi/v1/block/order/execute` - `GET eapi/v1/block/order/execute` - `GET eapi/v1/block/user-trades` ## 2024-10-29 Portfolio Margin Pro - 下列REST接口被调整: - `POST /sapi/v1/portfolio/repay-futures-switch`: 从2024-11-01开始, 接口限频为每天20次。 Portfolio Margin - T下列REST接口被调整: - `POST /papi/v1/repay-futures-switch`: 从2024-11-01开始, 接口限频为每天20次。 ## 2024-10-24 欧式期权 - 接口字段删除(2024-10-28生效): - `GET /eapi/v1/exchangeInfo`接口移除`optionContracts`中的`id`字段,移除`optionAssets`中的`id`字段,移除`optionSymbols`中的`contractId`和`id`字段 - 推送`option_pair`中移除`id`和`cid`字段 ## 2024-10-21 USDⓈ-M期货和币本位合约 - 币安合约预计于2024年10月30日08:00(东八区时间)更新以下接口。自2024年10月30日08:00(东八区时间)之后,以下接口仅支持查询不超过最近6个月的合约交易数据: - `GET /fapi/v1/userTrades` - `GET /dapi/v1/userTrades` 币本位合约 - 新增历史数据下载接口: - `GET /dapi/v1/order/asyn`: 获取合约订单历史下载id - `GET /dapi/v1/order/asyn/id`: 通过下载id获取合约订单历史下载链接 - `GET /dapi/v1/trade/asyn`: 获取合约交易历史下载id - `GET /dapi/v1/trade/asyn/id`: 通过下载id获取合约交易历史下载链接 ## 2024-10-15 Portfolio Margin Pro(Release date 2024-10-18) - 新增查询统一账户专业版SPAN账户信息接口(仅统一账户专业版SPAN可查): - `GET /sapi/v2/portfolio/account` - 新增查询统一账户专业版账户资产信息接口: - `GET /sapi/v1/portfolio/balance` Portfolio Margin - 新增获取统一账户UM合约交易历史下载Id: - `GET /papi/v1/um/trade/asyn` - 新增通过下载Id获取统一账户UM合约交易历史下载链接: - `GET /papi/v1/um/trade/asyn/id` - 新增获取统一账户UM合约订单历史下载Id: - `GET /papi/v1/um/order/asyn` - 新增通过下载Id获取统一账户UM合约订单历史下载链接: - `GET /papi/v1/um/order/asyn/id` - 新增获取统一账户UM合约资金流水历史下载Id: - `GET /papi/v1/um/income/asyn` - 新增通过下载Id获取统一账户UM合约资金流水历史下载链接: - `GET /papi/v1/um/income/asyn/id` ## 2024-10-14 USDⓈ-M 期货 - 下列REST接口被调整: - `POST /fapi/v1/convert/getQuote`: 从2024-10-19开始,接口限频为每小时360次,每天500次。 - `POST /fapi/v1/convert/getQuote`: `validTime`的枚举值调整为仅支持`10s` ## 2024-10-11 币本位合约 - **自成交保护** - 币本位合约系统中已经支持 Self-Trade Prevention(STP)自成交保护。此功能将阻止订单与来自同一账户或者同一`tradeGroupId` 账户的订单交易(当前仅支持同一账户)。详情请参考 [FAQ](https://www.binance.com/cn/support/faq/0941126f6413485b9a3df964a9aa2306) - 合约所有交易对支持通过下单时设置`selfTradePreventionMode`为下面之一的 STP 模式: - NONE: 不设置自成交保护 - EXPIRE_TAKER: 自成交过期 taker 订单 - EXPIRE_MAKER: 自成交过期 maker 订单 - EXPIRE_BOTH: 自成交过期 taker 和 maker 订单 - REST 更新: - 新的订单状态:`EXPIRED_IN_MATCH` - 订单由于 STP 触发而过期 - 以下接口新增可选参数`selfTradePreventionMode`以设置该订单的自成交保护模式: - `POST /dapi/v1/order` - `POST /dapi/v1/batchOrders` - 以下接口新增响应字段`selfTradePreventionMode`以显示订单的自成交保护模式: - `POST /dapi/v1/order` - `POST /dapi/v1/batchOrders` - `GET /dapi/v1/order` - `GET /dapi/v1/openOrders` - `GET /dapi/v1/allOrders` - `PUT /dapi/v1/order` - `PUT /dapi/v1/batchOrders` - `DELETE /dapi/v1/order` - `DELETE /dapi/v1/batchOrders` - WEBSOCKET 账户信息推送更新: - `ORDER_TRADE_UPDATE`中新增字段`V`显示用户订单的自成交保护模式 - **价格匹配** - 币本位合约系统中已经支持价格匹配功能(priceMatch)。此功能将允许用户的LIMIT/STOP/TAKE_PROFIT订单无需输入价格,价格匹配功能将根据订单的价格匹配模式和订单簿实时自动确定订单价格。 - 合约LIMIT/STOP/TAKE_PROFIT订单支持设置priceMatch以价格匹配模式: - NONE: 设置价格匹配 - OPPONENT: 盘口对手价 - OPPONENT_5: 盘口对手5档价 - OPPONENT_10: 盘口对手10档价 - OPPONENT_20: 盘口对手20档价 - QUEUE: 盘口同向价 - QUEUE_5: 盘口同向排队5档价 - QUEUE_10: 盘口同向排队10档价 - QUEUE_20: 盘口同向排队20档价 - 例子: - 用户下买单,设置priceMatch为QUEUE_5,则订单价格为订单薄买方向(盘口同向)第五档价格 - 用户下买单,设置priceMatch为OPPONENT,则订单价格为订单薄卖方向(盘口对手)第一档价格 - REST更新: - 以下接口新增可选参数priceMatch以设置价格匹配类型: - `POST /dapi/v1/order` - `POST /dapi/v1/batchOrders` - 以下接口新增响应字段priceMatch以显示订单的价格匹配模式: - `POST /dapi/v1/order` - `POST /dapi/v1/batchOrders` - `GET /dapi/v1/order` - `GET /dapi/v1/openOrders` - `GET /dapi/v1/allOrders` - `PUT /dapi/v1/order` - `PUT /dapi/v1/batchOrders` - `DELETE /dapi/v1/order` - `DELETE /dapi/v1/batchOrders` - Websocket账户信息推送更新: - ORDER_TRADE_UPDATE中新增字段`pm`显示用户订单的价格匹配模式 ## 2024-10-10 USDⓈ-M 期货 - 预计于2024年10月17日11:00(东八区时间)更新以下接口。自2024年10月17日11:00(东八区时间)后,以下接口将支持查询不超过1年的合约交易数据: - `GET /fapi/v1/aggTrades` - `GET /dapi/v1/aggTrades` - 预计于2024年10月16日11:00(东八区时间)更新以下接口。自2024年10月16日11:00(东八区时间)后,以下接口将支持查询不超过1个月的合约数据: - `GET /fapi/v1/positionMargin/history` ## 2024-10-08 COIN-M 期货 - 请求以下接口时,默认返回最近7天的数据。这些接口的查询时间段必须小于7天: - `获取 /dapi/v1/allOrders` - `获取 /dapi/v1/userTrades` - 以下接口将进行调整,仅保留最近三个月的数据: - `获取 /dapi/v1/order` - `获取 /dapi/v1/allOrders` ## 2024-09-27 USDⓈ-M 期货 - 下列websocket用户信息请求被停止使用: - `listenkey@account` - `listenkey@balance` - `listenkey@position` COIN-M 期货 - 下列websocket用户信息请求被停止使用: - `listenkey@account` - `listenkey@balance` - `listenkey@position` ## 2024-09-19 Portfolio Margin - 新增杠杆账户还款接口: `POST /papi/v1/margin/repay-debt` ## 2024-09-06 Portfolio Margin - Portfolio Margin/Trade接口更新(Release date 2024-09-06): - `POST /papi/v1/um/order`: 新增入参`priceMatch`以支持下单 - `POST/papi/v1/um/conditional/order`: 新增入参`priceMatch`以支持条件单下单 - `PUT /papi/v1/um/order`: 新增入参`priceMatch`以支持改单 - 以下接口新增返回 `priceMatch`: - `POST /papi/v1/um/order` - `POST/papi/v1/um/conditional/order` - `PUT /papi/v1/um/order` - `GET /papi/v1/um/orderAmendment` - `GET /papi/v1/um/order` - `GET /papi/v1/um/openOrder` - `GET /papi/v1/um/openOrders` - `GET /papi/v1/um/allOrders` - `GET /papi/v1/um/conditional/openOrder` - `GET /papi/v1/um/conditional/openOrders` - `GET /papi/v1/um/conditional/orderHistory` - `GET /papi/v1/um/conditional/allOrders` - `DELETE /papi/v1/um/order` - `DELETE /papi/v1/um/conditional/order` - WEBSOCKET - `ORDER_TRADE_UPDATE` 和 `CONDITIONAL_ORDER_TRADE_UPDATE` 新增`pm`推送以支持priceMatch ## 2024-09-05 Portfolio Margin Pro - 新增查询统一账户专业版资产阶梯质押率信息的接口: - `GET /sapi/v2/portfolio/collateralRate` ## 2024-09-03 USDⓈ-M 期货 - 账户信息推送中新增新增`TRADE_LITE`事件类型。`TRADE_LITE`旨在通过精简用户信息数据和仅推送用户已成交的TRADE数据流,从而降低用户数据推送的延迟。相比于现有的`ORDER_TRADE_UPDATE`事件类型,`TRADE_LITE`将提供更加敏捷和高效的用户体验。 ## 2024-08-26 USDⓈ-M 期货 - 新增账户内资产转换接口: - `GET /fapi/v1/convert/exchangeInfo` - `POST /fapi/v1/convert/getQuote` - `POST /fapi/v1/convert/acceptQuote` - `GET /fapi/v1/convert/orderStatus` ## 2024-08-23 Portfolio Margin - 新增查询账户信息的接口: - `POST /papi/v1/um/feeBurn`: BNB UM合约交易抵扣开关。 - `GET /papi/v1/um/feeBurn`: 获取UM合约交易 BNB 抵扣开关状态。 - 新增查询交易信息的接口: - `GET /papi/v1/um/accountConfig`: 查询用户UM账户配置。 - `GET /papi/v1/um/symbolConfig`: 查询用户UM交易对配置。 - `GET /papi/v2/um/account`: 相较于`GET /papi/v1/um/account`,此接口仅返回用户有持仓或挂单的交易对。账户/交易对配置相关字段已被移除,现在可以通过 `GET /papi/v1/um/symbolConfig` 和 `GET /papi/v1/um/accountConfig` 查询。V2接口还提供了更好的性能。 ## 2024-08-07 USDⓈ-M 期货 - 以下接口将在2024-09-03进行权重调整: - REST API: - `GET /fapi/v2/balance`: 5->10 - `GET /fapi/v2/account`: 5->10 - `GET /fapi/v2/positionRisk`: 5->10 - Websocket API: - `account.status`: 5->10 - `account.balance`: 5->10 - `account.position`: 5->10 - 将弃用以下WebSocket用户数据请求: - \@account - \@balance - \@position 请参考以下[公告](https://www.binance.com/zh-CN/support/announcement/%E5%85%B3%E4%BA%8E%E5%B0%86%E6%9B%B4%E6%96%B0%E5%B8%81%E5%AE%89api%E7%9A%84%E5%85%AC%E5%91%8A-2024-09-03-19d4e3cd0758426584dd9686eb56ec64)进行接口替换和调整 ## 2024-08-06 COIN-M 期货 因统一账户专业版移除`notionalLimit`限制,`GET /dapi/v1/pmExchangeInfo` 将于8月6日停用 ## 2024-07-24 USDⓈ-M 期货 #### REST API - 新增查询账户信息的接口: - `GET /fapi/v1/symbolConfig`: 查询用户交易对配置。 - `GET /fapi/v1/accountConfig`: 查询用户账户配置。 - `GET /fapi/v3/account`: 相较于 `GET /fapi/v2/account`,此接口仅返回用户有持仓或挂单的交易对。账户/交易对配置相关字段已被移除,现在可以通过 `GET /fapi/v1/symbolConfig` 和 `GET /fapi/v1/accountConfig` 查询。V3接口还提供了更好的性能。 - `GET /fapi/v3/balance`: 查询用户账户余额。 - 新增查询交易信息的接口: - `GET /fapi/v3/positionRisk`: 相较于 `GET /fapi/v2/positionRisk`,此接口仅返回用户有持仓或挂单的交易对。交易对配置相关字段已被移除,现在可以通过 `GET /fapi/v1/symbolConfig` 查询。V3接口还提供了更好的性能。 #### WebSocket API - 新增查询账户信息的接口: - `v2/account.status`: 相较于 `account.status`,此接口仅返回用户有持仓或挂单的交易对。配置相关字段已被移除,现在可以通过 `GET /fapi/v1/symbolConfig` 和 `GET /fapi/v1/accountConfig` 查询。V2接口还提供了更好的性能。 - `v2/account.balance`: 查询用户账户余额。 - `v2/account.position`: 相较于 `account.position`,此接口仅返回用户有持仓或挂单的接口。配置相关字段已被移除,现在可以通过 `GET /fapi/v1/symbolConfig` 查询。V2接口还提供了更好的性能。 **弃用通知:** - 以下接口将在未来几个月内弃用(具体日期待定)。请切换到上述新接口: - REST API: - `GET /fapi/v2/balance` - `GET /fapi/v2/account` - `GET /fapi/v2/positionRisk` - Websocket API: - `account.status` - `account.balance` - `account.position` --- ## 2024-07-17 统一账户 #### REST API - `GET /papi/v1/um/userTrades`的响应字段`marginAsset`将在2024-07-17被移除 --- ## 2024-06-19 U本位合约 #### REST API - `GET /fapi/v1/userTrades`的响应字段`marginAsset`将在2024-07-17被移除 --- ## 2024-05-22 U本位合约 REST API & Websocket API - 新增BNB抵扣开关接口: - `POST /fapi/v1/feeBurn` BNB 合约交易抵扣开关。 - `GET /fapi/v1/feeBurn` 获取 BNB 抵扣开关状态。 --- ## 2024-04-19 U本位合约 REST API & Websocket API - 调用`PUT /fapi/v1/listenKey`或WebSocket api `userDataStream.ping`时会增加新的返回字段listenKey以显示有效期被延长的listenkey,改动将于2024-04-25生效。 ```javascript { "listenKey": "3HBntNTepshgEdjIwSUIBgB9keLyOCg5qv3n6bYAtktG8ejcaW5HXz9Vx1JgIieg" } ``` --- ## 2024-04-09 U本位合约/币本位合约/统一账户 WEBSOCKET API - Good-Till-Cancel(GTC)订单变为仅有一年的有效期。 超过一年的GTC订单将被自动取消。改动适用于所有订单类型,包括仅减仓订单(reduceOnly),但不影响部分成交订单或策略交易或跟单交易订单。 --- ## 2024-04-01 U本位合约 WEBSOCKET API - Websocket API 现已推出,可通过以下 URL 访问:“wss://ws-fapi.binance.com/ws-fapi/v1” - WebSocket API 允许通过 WebSocket 连接下单、取消订单等。 - WebSocket API 是独立于 WebSocket 市场数据流的服务。也就是说,下订单和收听市场数据需要两个独立的 WebSocket 连接。 - WebSocket API 受与 REST API 相同的过滤器和速率限制规则的约束。 - WebSocket API 和 REST API 在功能上是等效的:它们提供相同的功能,接受相同的参数,返回相同的状态和错误代码。 --- ## 2024-03-11 U本位合约 REST - 新增账户接口: - `GET /fapi/v1/rateLimit/order`: 查询用户下单频率限制 --- ## 2024-02-09 U本位合约 币安合约在进行 Websocket 服务升级,升级影响以下逻辑: - 升级前: - 服务端每 3 分钟会发送 ping 帧,客户端应当在 10 分钟内回复 pong 帧,否则服务端会主动断开链接。允许客户端发送不成对的 pong 帧(即客户端可以以高于 10 分钟每次的频率发送 pong 帧保持链接) - 升级后 - Websocket 服务器每 3 分钟发送 Ping 消息。 - 如果 Websocket 服务器在 10 分钟之内没有收到 Pong 消息应答,连接会被断开。 - 当客户收到 ping 消息,必需尽快回复 pong 消息,同时 payload 需要和 ping 消息一致。 - 未经请求的 pong 消息是被允许的,但是不会保证连接不断开。**对于这些 pong 消息,建议 payload 为空** --- ## 2024-01-24 U本位合约 测试网 WEBSOCKET - **testnet**的 Websocket baseurl 更新为 "wss://fstream.binancefuture.com" --- ## 2024-01-19 统一账户 - REST - 新增 `PUT /papi/v1/um/order` 和 `PUT /papi/v1/cm/order` 接口以支持合约限价订单修改功能 - 新增 `GET /papi/v1/um/orderAmendment` 和 `GET /papi/v1/cm/orderAmendment` 接口以查询合约订单修改历史 --- ## 2024-01-11 统一账户 - **自成交保护(已发布)** - U 本位合约系统中将支持 Self-Trade Prevention(STP)自成交保护。此功能将阻止订单与来自同一账户或者同一 tradeGroupId 账户的订单交易。详情请参考 [FAQ](https://www.binance.com/en/support/faq/what-is-self-trade-prevention-stp-0941126f6413485b9a3df964a9aa2306) - 合约所有交易对支持通过下单时设置`selfTradePreventionMode`为下面之一的 STP 模式: - NONE: 不设置自成交保护 - EXPIRE_TAKER: 自成交过期 taker 订单 - EXPIRE_MAKER: 自成交过期 maker 订单 - EXPIRE_BOTH: 自成交过期 taker 和 maker 订单 - REST 更新: - 新的订单状态:`EXPIRED_IN_MATCH` - 订单由于 STP 触发而过期 - /papi/v1/um/account 中响应新增字段`tradeGroupId`显示用户的 tradeGroupId - 以下接口新增可选参数`selfTradePreventionMode`以设置该订单的自成交保护模式: - POST /papi/v1/um/order - POST/papi/v1/um/conditional/order - POST /papi/v1/margin/order - POST /papi/v1/margin/order/oco - 以下接口新增响应字段`selfTradePreventionMode`以显示订单的自成交保护模式: - POST /papi/v1/um/order - POST/papi/v1/um/conditional/order - GET /papi/v1/um/order - GET /papi/v1/um/openOrder - GET /papi/v1/um/openOrders - GET /papi/v1/um/allOrders - GET /papi/v1/um/conditional/openOrder - GET /papi/v1/um/conditional/openOrders - GET /papi/v1/um/conditional/orderHistory - GET /papi/v1/um/conditional/allOrders - DELETE /papi/v1/um/order - DELETE /papi/v1/um/conditional/order - DELETE /papi/v1/margin/order - DELETE /papi/v1/margin/allOpenOrders - DELETE /papi/v1/margin/orderList - GET /papi/v1/margin/order - GET /papi/v1/margin/allOrders - GET /papi/v1/margin/orderList - GET /papi/v1/margin/allOrderList - GET /papi/v1/margin/openOrderList - WEBSOCKET 账户信息推送更新: - `ORDER_TRADE_UPDATE`和`CONDITIONAL_ORDER_TRADE_UPDATE`中新增字段`V`显示用户订单的自成交保护模式 - `executionReport`中新增以下字段 - `u` - `tradeGroupId` - `v` - `preventedMatchId` - `U` - `counterOrderId` - `A` - `preventedQuantity` - `B` - `lastPreventedQuantity` - **有效方式 GTD(已发布)** - U 本位合约系统中将支持有效方式 GTD(Good Till Date)。有效方式(TIF)为 GTD 的订单到`goodTillDate`时间仍未完结会被自动取消 - REST 更新: - 以下接口新增响应字段`goodTillDate`以配置 GTD 订单过期时间: _POST /papi/v1/um/order_ POST/papi/v1/um/conditional/order - 以下接口新增响应字段`goodTillDate`以显示 GTD 订单过期时间: _POST /papi/v1/um/order_ POST/papi/v1/um/conditional/order _GET /papi/v1/um/order_ GET /papi/v1/um/openOrder _GET /papi/v1/um/openOrders_ GET /papi/v1/um/allOrders _GET /papi/v1/um/conditional/openOrder_ GET /papi/v1/um/conditional/openOrders _GET /papi/v1/um/conditional/orderHistory_ GET /papi/v1/um/conditional/allOrders _DELETE /papi/v1/um/order_ DELETE /papi/v1/um/conditional/order - Websocket 账户信息推送更新: `ORDER_TRADE_UPDATE`和 `CONDITIONAL_ORDER_TRADE_UPDATE`中新增字段 `goodTillDate`` 显示用户 GTD 订单的自动取消时间 - **盈亏平衡价(已发布)** - REST 更新 - 以下接口返回新增`breakEvenPrice`字段代表仓位盈亏平衡价: _GET /papi/v1/um/account_ GET /papi/v1/um/positionRisk _GET /papi/v1/cm/account_ GET /papi/v1/cm/positionRisk - WEBSOCKET 更新 - Position 更新推送 payloadACCOUNT_UPDATE 中 P 新增 bep 字段代表仓位盈亏平衡价 --- ## 2024-01-08 U本位合约 REST - 账号与交易接口更新(将于 2023-01-11 更新): - `PUT /fapi/v1/order`: 新增入参`priceMatch`以支持改单价格保护 - `PUT /fapi/v1/batchOrders`: 新增入参`priceMatch`以支持改单价格保护 - 改单会保留该订单原有的`selfTradePreventionMode` --- ## 2023-12-12 U本位合约 WEBSOCKET - 行情推送`!bookTicker`的更新速度将从实时更改为每 5 秒一次,该更改将从 2023 年 12 月 20 日开始。单个交易对的 Book Ticker 流`@bookticker`不会受到此次更新的影响。 --- ## 2023-11-15 U本位合约 REST - 新增市场数据接口: - `GET /fapi/v2/ticker/price`: 查询最新价格 v2 接口。与`GET /fapi/v1/ticker/price`相比,v2 接口入参和响应相同,但接口延迟更低且占用限频更少。`GET /fapi/v1/ticker/price`将在未来被弃用,时间待定 WEBSOCKET - 币安合约将于 2023-12-15 06:00 停用`wss://fstream-auth.binance.com`域名,建议 API 用户在此时间前迁移 websocket 连接到`wss://fstream.binance.com`。需要特别注意的是,`wss://fstream.binance.com`的连接方法与`wss://fstream-auth.binance.com`不同,例如: - `wss://fstream-auth.binance.com/ws/?listenKey=` should change to `wss://fstream.binance.com/ws/` --- ## 2023-11-01 币本位合约 REST - `GET dapi/v1/fundingRate`更新: - 增加返回字段`markPrice`以显示特定资金费对应的标记价格 --- ## 2023-11-01 U本位合约 REST - 新增市场数据接口: - `GET /futures/data/basis`: 查询基差 - `GET /fapi/v1/fundingRate`更新: - 增加返回字段`markPrice`以显示特定资金费对应的标记价格 --- ## 2023-10-19 币本位合约 REST - 新增行情接口: - `GET /futures/data/delivery-price`: 查询季度合约历史交割价格 - 调整下列接口限频为 1000/5min/IP: - `GET /futures/data/openInterestHist` - `GET /futures/data/topLongShortAccountRatio` - `GET /futures/data/topLongShortPositionRatio` - `GET /futures/data/globalLongShortAccountRatio` - `GET /futures/data/takerlongshortRatio` --- ## 2023-10-19 欧式期权 币安期权在进行 Websocket 服务升级,升级影响以下逻辑: - 升级前: - 服务端每 5 分钟会发送 ping 帧,客户端应当在 15 分钟内回复 pong 帧,否则服务端会主动断开链接。允许客户端发送不成对的 pong 帧(即客户端可以以高于 15 分钟每次的频率发送 pong 帧保持链接) - 无信息流订阅连接 Websocket 服务: - 升级前, 用户可以用以下方式连接: - `wss://nbstream.binance.com/eoptions/ws` - `wss://nbstream.binance.com/eoptions/stream` - `wss://nbstream.binance.com/eoptions/ws/` - `wss://nbstream.binance.com/eoptions/stream/` - 升级后 - 服务端每 3 分钟会发送 ping 帧,客户端应当在 10 分钟内回复 pong 帧,否则服务端会主动断开链接。允许客户端发送不成对的 pong 帧(即客户端可以以高于 10 分钟每次的频率发送 pong 帧保持链接) - 无信息流订阅连接 Websocket 服务: - 升级后,用户可以用以下方式连接: - `wss://nbstream.binance.com/eoptions/ws` - `wss://nbstream.binance.com/eoptions/stream` - `/` 在 url 结尾不再支持 - 带信息流订阅连接 Websocket 服务: - 不支持如下类型的 stream:`wss://nbstream.binance.com/eoptions/illegal_parameter/stream?steams=`或`wss://nbstream.binance.com/eoptions/illegal_parameter/ws/`,请移除 `/ws` 和 `/stream`前的`illegal_parameter/` --- ## 2023-10-19 U本位合约 REST - 新增行情接口: - `GET /futures/data/delivery-price`: 查询季度合约历史交割价格 - 调整下列接口限频为 1000/5min/IP: - `GET /futures/data/openInterestHist` - `GET /futures/data/topLongShortAccountRatio` - `GET /futures/data/topLongShortPositionRatio` - `GET /futures/data/globalLongShortAccountRatio` - `GET /futures/data/takerlongshortRatio` - 调整下列接口限频为 500/5min/IP: - `GET /fapi/v1/fundingRate` - `GET /fapi/v1/fundingInfo` --- ## 2023-10-16 币本位合约 REST - 新增行情接口: - `GET /dapi/v1/constituents`: 查询指数成分 --- ## 2023-10-16 U本位合约 REST - 新增行情接口: - `GET /fapi/v1/constituents`: 查询指数成分 --- ## 2023-10-11 U本位合约 REST - 账户接口 IP 权重调整: - `GET /fapi/v1/income/asyn`: 5->1000 - `GET /fapi/v1/order/asyn`: 5->1000 - `GET /fapi/v1/trade/asyn`: 5->1000 - `GET /fapi/v1/income/asyn/id`: 5->10 - `GET /fapi/v1/order/asyn/id`: 5->10 - `GET /fapi/v1/trade/asyn/id`: 5->10 --- ## 2023-09-25 币本位合约 REST - 新增行情接口: - `GET /dapi/v1/fundingInfo`: 查询有调整的资金费率信息 --- ## 2023-09-25 U本位合约 REST - 新增行情接口: - `GET /fapi/v1/fundingInfo`: 查询有调整的资金费率信息 --- ## 2023-09-20 币本位合约 REST - `GET /dapi/v1/ticker/bookTicker`更新: - 增加返回字段`lastUpdateId` - `GET /dapi/v1/account`更新: - 在`assets`中增加返回字段`updateTime` --- ## 2023-09-20 U本位合约 REST - `GET /fapi/v1/ticker/bookTicker`更新: - 增加返回字段`lastUpdateId` --- ## 2023-09-19 U本位合约 ```javascript { "code": -1008, "msg": "Server is currently overloaded with other requests. Please try again in a few minutes." } ``` - 新增 HTTP`503`可能的错误响应及错误码,下列接口在请求高峰期可能出现此响应: - `POST /fapi/v1/order` - `PUT /fapi/v1/order` - `DELETE /fapi/v1/order` - `POST /fapi/v1/batchOrder` - `PUT /fapi/v1/batchOrder` - `DELETE /fapi/v1/batchOrder` - `POST /fapi/v1/order/test` - `DELETE /fapi/v1/allOpenOrders` - 此响应表示本次 API 请求失败。这种情况下您如果需要的话可以选择立即重试。 --- ## 2023-09-07 币本位合约 REST - 新增接口`GET /dapi/v1/income/asyn` 获取合约资金流水下载 id - 新增接口`GET /dapi/v1/income/asyn/id` 通过下载 id 获取合约资金流水下载链接 --- ## 2023-09-05 U本位合约 - 根据此[公告](https://www.binance.com/zh-CN/support/announcement/%E5%B8%81%E5%AE%89%E5%90%88%E7%BA%A6%E6%8E%A8%E5%87%BAapi-u%E6%9C%AC%E4%BD%8D%E5%90%88%E7%BA%A6%E8%87%AA%E6%88%90%E4%BA%A4%E9%A2%84%E9%98%B2-stp-%E5%8A%9F%E8%83%BD-32916877372243d69154c345200e34b8),自成交保护(Self-Trade Prevention)已于 **2023-09-05** 发布。 - 价格匹配/有效方式 GTD/盈亏平衡价等功能(详情见 2023-08-29 更新日志)已于**2023-09-05** 发布。 --- ## 2023-09-04 统一账户 - 接口字段更新: - `GET /papi/v1/um/positionRisk`: 新增响应字段`liquidationPrice` - `GET /papi/v1/cm/positionRisk`: 新增响应字段 `liquidationPrice` - `GET /papi/v1/um/leverageBracket`: 新增响应字段 `notionalCoef` - `GET /papi/v1/cm/leverageBracket`: 新增响应字段 `notionalCoef` - Websocket 账户信息推送字段更新: - `outboundAccountPosition`事件新增字段更新 Id`U` - `balanceUpdate`事件新增字段更新 Id`U` --- ## 2023-09-04 统一账户 **2023-09-07 发布** - papi 的 order ratelimit 从 2400 orders/min 降低为 1200 orders/min,受影响的接口: - POST `/papi/v1/um/order` - POST `/papi/v1/cm/order` - POST `/papi/v1/margin/order` - POST `/papi/v1/margin/order/oco` - POST `/papi/v1/um/conditional/order` - POST `/papi/v1/cm/conditional/order` --- ## 2023-08-31 币本位合约 币安合约在进行 Websocket 服务升级,升级影响以下逻辑: - 升级前: - 服务端每 5 分钟会发送 ping 帧,客户端应当在 15 分钟内回复 pong 帧,否则服务端会主动断开链接。允许客户端发送不成对的 pong 帧(即客户端可以以高于 15 分钟每次的频率发送 pong 帧保持链接) - 升级后 - 服务端每 3 分钟会发送 ping 帧,客户端应当在 10 分钟内回复 pong 帧,否则服务端会主动断开链接。允许客户端发送不成对的 pong 帧(即客户端可以以高于 10 分钟每次的频率发送 pong 帧保持链接) --- ## 2023-08-31 U本位合约 币安合约在进行 Websocket 服务升级,升级影响以下逻辑: - 升级前: - 服务端每 5 分钟会发送 ping 帧,客户端应当在 15 分钟内回复 pong 帧,否则服务端会主动断开链接。允许客户端发送不成对的 pong 帧(即客户端可以以高于 15 分钟每次的频率发送 pong 帧保持链接) - 升级后 - 服务端每 3 分钟会发送 ping 帧,客户端应当在 10 分钟内回复 pong 帧,否则服务端会主动断开链接。允许客户端发送不成对的 pong 帧(即客户端可以以高于 10 分钟每次的频率发送 pong 帧保持链接) --- ## 2023-08-29 欧式期权 REST - `GET /eapi/v1/account`: 新增字段`riskLevel`显示账户风险等级 - `GET /eapi/v1/marginAccount`: 新增字段`riskLevel`显示账户风险等级 Websocket 用户信息流 - 新增更新时间`RISK_LEVEL_CHANGE`以显示账户风险等级变化 --- ## 2023-08-29 U本位合约 - **自成交保护(发布时间待定)** - U 本位合约系统中将支持 Self-Trade Prevention(STP)自成交保护。此功能将阻止订单与来自同一账户或者同一 `tradeGroupId` 账户的订单交易。详情请参考 [FAQ](https://www.binance.com/cn/support/faq/0941126f6413485b9a3df964a9aa2306) - 合约所有交易对支持通过下单时设置`selfTradePreventionMode`为下面之一的 STP 模式: - NONE: 不设置自成交保护 - EXPIRE_TAKER: 自成交过期 taker 订单 - EXPIRE_MAKER: 自成交过期 maker 订单 - EXPIRE_BOTH: 自成交过期 taker 和 maker 订单 - REST 更新: - 新的订单状态:`EXPIRED_IN_MATCH` - 订单由于 STP 触发而过期 - `GET /fapi/v2/account`中响应新增字段`tradeGroupId`显示用户的 tradeGroupId - 以下接口新增可选参数`selfTradePreventionMode`以设置该订单的自成交保护模式: - `POST /fapi/v1/order` - `POST /fapi/v1/batchOrders` - 以下接口新增响应字段`selfTradePreventionMode`以显示订单的自成交保护模式: - `POST /fapi/v1/order` - `POST /fapi/v1/batchOrders` - `POST /fapi/v1/order` - `POST /fapi/v1/order` - `GET /fapi/v1/order` - `GET /fapi/v1/openOrders` - `GET /fapi/v1/allOrders` - `PUT /fapi/v1/order` - `PUT /fapi/v1/batchOrders` - `DELETE /fapi/v1/order` - `DELETE /fapi/v1/batchOrders` - WEBSOCKET 账户信息推送更新: - `ORDER_TRADE_UPDATE`中新增字段`V`显示用户订单的自成交保护模式 --- ## 2023-08-25 币本位合约 - 币安合约在进行 Websocket 服务升级,升级影响以下连接方式: - 无信息流订阅连接 Websocket 服务: - 升级前, 用户可以用以下方式连接: - `wss://dstream.binance.com/ws` - `wss://dstream.binance.com/stream` - `wss://dstream.binance.com/ws/` - `wss://dstream.binance.com/stream/` - 升级后,用户可以用以下方式连接: - `wss://dstream.binance.com/ws` - `wss://dstream.binance.com/stream` - `/` 在 url 结尾不再支持 - 带信息流订阅连接 Websocket 服务: - 不支持如下类型的 stream:`wss://fstream.binance.com/illegal_parameter/stream?steams=`或`wss://fstream.binance.com/illegal_parameter/ws/`,请移除 `/ws` 和 `/stream`前的`illegal_parameter/` --- ## 2023-08-19 U本位合约 - 币安合约在进行 Websocket 服务升级,升级影响以下连接方式: - 无信息流订阅连接 Websocket 服务: - 升级前, 用户可以用以下方式连接: - `wss://fstream.binance.com/ws` - `wss://fstream.binance.com/stream` - `wss://fstream.binance.com/ws/` - `wss://fstream.binance.com/stream/` - 升级后,用户可以用以下方式连接: - `wss://fstream.binance.com/ws` - `wss://fstream.binance.com/stream` - `/` 在 url 结尾不再支持 - 带信息流订阅连接 Websocket 服务: - 不支持如下类型的 stream:`wss://fstream.binance.com/illegal_parameter/stream?steams=`或`wss://fstream.binance.com/illegal_parameter/ws/`,请移除 `/ws` 和 `/stream`前的`illegal_parameter/` --- ## 2023-08-18 统一账户 - 新增查询接口: - `GET /papi/v1/margin/order`: 杠杆下单 - `GET /papi/v1/margin/openOrders`: 查询杠杆账户挂单记录 - `GET /papi/v1/margin/allOrders`: 查询杠杆账户的所有订单 - `GET /papi/v1/margin/orderList`: 查询杠杆账户 OCO - `GET /papi/v1/margin/allOrderList`: 查询特定杠杆账户所有 OCO - `GET /papi/v1/margin/openOrderList`: 查询杠杆账户 OCO 挂单 - `GET /papi/v1/margin/myTrades`: 查询杠杆账户交易历史 --- ## 2023-08-14 币本位合约 - 更新账户和交易接口: - `GET /dapi/v1/income`:增加字段`page`用以分页 --- ## 2023-08-14 U本位合约 - 更新账户和交易接口: - `GET /fapi/v1/income`:增加字段`page`用以分页 --- ## 2023-07-28 统一账户 - 新增账户接口: - `POST /papi/v1/asset-collection`: 特定资产资金归集 --- ## 2023-07-21 欧式期权 REST - 新增接口`GET /eapi/v1/income/asyn` 获取期权流水历史下载 id - 新增接口`GET /eapi/v1/income/asyn/id` 通过下载 id 获取期权流水历史下载链接 --- ## 2023-07-20 统一账户 - 新增账户接口: - `GET /papi/v1/um/adlQuantile`: UM 持仓 ADL 队列估算 - `GET /papi/v1/cm/adlQuantile`: CM 持仓 ADL 队列估算 --- ## 2023-07-19 币本位合约 REST - `GET /dapi/v2/leverageBracket` 新增字段`notionalCoef`显示用户相对默认 bracket 的调整倍数 --- ## 2023-07-18 统一账户 - 新增统一账户账户接口: - `POST /papi/v1/repay-futures-switch`: 更改自动清还合约负余额模式 - `GET /papi/v1/repay-futures-switch`: 查询自动清还合约负余额模式 - `POST /papi/v1/repay-futures-negative-balance`: 清还合约负余额 --- ## 2023-07-18 U本位合约 REST - `GET /fapi/v1/leverageBracket` 新增字段`notionalCoef`显示用户相对默认 bracket 的调整倍数 --- ## 2023-07-13 欧式期权 Websocket Market Streams - 下面更新将在 2023-7-14 生效: - 在数据流`@ticker`, `@ticker@`新增参数`T`显示交易时间 - 在数据流`@depth`新增参数`E`显示事件时间 --- ## 2023-07-13 统一账户 - 新增用户数据推送`riskLevelChange`(2023-7-14 生效) --- ## 2023-07-12 币本位合约 REST - 以下接口返回新增`breakEvenPrice`字段代表仓位盈亏平衡价: - GET /dapi/v1/account (HMAC SHA256) - GET /dapi/v1/positionRisk (HMAC SHA256) WEBSOCKET - Position 更新推送 payload `ACCOUNT_UPDATE`中"P"新增`bep`字段代表仓位盈亏平衡价 --- ## 2023-07-11 统一账户 REST - 增加新接口`POST /papi/v1/ping` 测试服务器连通性 --- ## 2023-07-04 U本位合约 REST - 以下接口将改为仅保留最近 3 个月数据: - `GET /fapi/v1/order`(2023-07-27 生效) - `GET /fapi/v1/allOrders`(2023-07-27 生效) - `GET /fapi/v1/userTrades`(具体时间待定) - 请自行维护和保留 3 个月之前的历史数据或使用以下新接口获得历史订单/交易信息: - 新增接口`GET /fapi/v1/order/asyn` 获取合约订单历史下载 id - 新增接口`GET /fapi/v1/order/asyn/id` 通过下载 id 获取合约订单历史下载链接 - 新增接口`GET /fapi/v1/trade/asyn` 获取合约交易历史下载 id - 新增接口`GET /fapi/v1/trade/asyn/id` 通过下载 id 获取合约交易历史下载链接 --- ## 2023-06-28 U本位合约 **注意:** REST - 以下接口将于 2023-07-15 后不再支持: - `GET /fapi/v1/account` - `GET /fapi/v1/balance` - `GET /fapi/v1/positionRisk` - 请及时替换为对应的 v2 接口: - `GET /fapi/v2/account` - `GET /fapi/v2/balance` - `GET /fapi/v2/positionRisk` --- ## 2023-06-22 币本位合约 **注意:** WEBSOCKET - 订阅格式 **/ws?\** 不被支持, 如`wss://dstream.binance.com/ws?btcusd@depth` 会被认为是非法请求. - 发送带有不合法 JSON 格式的 websocket 消息将导致连接断开,返回错误`{"error":{"code":3,"msg":"Invalid JSON: expected value at line 1 column 1"}}` --- ## 2023-06-22 U本位合约 **注意:** WEBSOCKET - 订阅格式 **/ws?\** 不被支持, 如`wss://fstream.binance.com/ws?btcusdt@depth` 会被认为是非法请求. - 发送带有不合法 JSON 格式的 websocket 消息将导致连接断开,返回错误`{"error":{"code":3,"msg":"Invalid JSON: expected value at line 1 column 1"}}` --- ## 2023-06-19 统一账户 REST - 在 `POST /papi/v1/um/conditional/order`和`POST/papi/v1/cm/conditional/order`新增参数`CONTRACT_PRICE`,`priceProtect` --- ## 2023-06-16 U本位合约 **注意:** - 建议使用标准的 HTTP 请求格式,fapi 中将不支持非标准请求格式。以下是一些正确的代码实践示例: - 不再支持使用 '\x22' 进行转义("),请改用标准的 '%22',需要对中括号[]和中括号内部的双引号进行 URL encode DELETE /fapi/v1/batchOrders?origClientOrderIdList= 不支持: [\x229151944646313025900\x22] 建议: ["9151944646313025900"] --经过 URL 编码后-- DELETE /fapi/v1/batchOrders?origClientOrderIdList=%5B%229151944646313025900%22%5D - 不支持非标准嵌套 JSON 格式 POST /fapi/v1/batchOrders?batchOrders= 不支持: ["{\"type\":\"LIMIT\",\"timeInForce\":\"GTC\"}"] 建议: [{"type":"LIMIT","timeInForce":"GTC"}] --经过 URL 编码后-- POST /fapi/v1/batchOrders?batchOrders=%5B%7B%22type%22%3A%22LIMIT%22%2C%22timeInForce%22%3A%22GTC%22%7D%5D - 不支持使用不正确的数据类型 DELETE /fapi/v1/batchOrders?orderIdList= 由于 'orderIdList' 参数的数据类型为 LIST\ 不支持: ["159856286502","159856313662"] 建议: [159856286502,159856313662] --经过 URL 编码后-- DELETE /fapi/v1/batchOrders?orderIdList=%5B159856286502%2C159856313662%5D - 不支持从请求参数中的无效空白字符 不支持: POST symbol=BTCUSDT& price= 40000.0 & signature=2d24a314 建议: POST symbol=BTCUSDT&&price=40000.0&signature=2d24a314 - 不支持请求参数传空值 不支持: GET symbol=BTCUSDT&orderId=&signature=2d24a314 建议: GET symbol=BTCUSDT&signature=2d24a314 --- ## 2023-06-14 币本位合约 WEBSOCKET - 在`@markPrice` and `@markPrice`中新增指数`i`字段 --- ## 2023-06-14 U本位合约 **注意:** - 新增市场信息流 `!assetIndex@arr`OR`@assetIndex`推送多资产模式资产指数价格 --- ## 2023-06-01 统一账户 REST - 下列接口将于 2023-06-02 生效: - New endpoints `GET /papi/v1/um/income` and `GET /papi/v1/cm/income` to query portfolio margin UM/CM income history - New endpoints `GET /papi/v1/um/account` and `GET /papi/v1/cm/account` to query portfolio margin UM/CM account history --- ## 2023-05-31 U本位合约 WEBSOCKET - 新增账户信息流: - 新增推送 `CONDITIONAL_ORDER_TRIGGER_REJECT` 以显示被触发的止盈止损单被拒绝原因 --- ## 2023-05-30 欧式期权 General Information on Endpoints - `GET`方法的接口, 参数必须在`query string`中发送且 HTTP 头中不设置 content type. --- ## 2023-05-05 U本位合约 REST - 新增 `PUT /fapi/v1/order` 和 `PUT /fapi/v1/batchOrders` 接口以支持限价订单修改功能 - 新增 `GET /fapi/v1/orderAmendment` 接口以查询订单修改历史 WEBSOCKET - 订单/交易 更新推送 `ORDER_TRADE_UPDATE` 中本次事件的具体执行类型 `x` 新增 "AMENDMENT" 代表订单修改 --- ## 2023-05-04 统一账户 - 新增统一账户文档 --- ## 2023-04-17 币本位合约 **发布日期待确定** `recvWindow` 校验也将在订单到达撮合后进行。`recvWindow` 校验在下单相关接口更加精确。 ```javascript { "code": -4188, "msg": "Timestamp for this request is outside of the ME recvWindow" } ``` **发布前 recvWindow 逻辑:** - 下单类请求在 `recvWindow` + `timestamp` => REST API 服务器`timestamp`时有效 **发布后 recvWindow 逻辑:** - 新增校验:下单类请求在 `recvWindow` + `timestamp` => 撮合`timestamp`时有效 - 受影响接口: - POST /dapi/v1/order (HMAC SHA256) - PUT /dapi/v1/order (HMAC SHA256) - POST /dapi/v1/batchOrders (HMAC SHA256) - PUT /dapi/v1/batchOrders (HMAC SHA256) --- ## 2023-04-17 U本位合约 **发布日期 2023-04-18** `recvWindow` 校验也将在订单到达撮合后进行。`recvWindow` 校验在下单相关接口更加精确。 ```javascript { "code": -5028, "msg": "Timestamp for this request is outside of the ME recvWindow" } ``` **发布前 recvWindow 逻辑:** - 下单类请求在 `recvWindow` + `timestamp` => REST API 服务器`timestamp`时有效 **发布后 recvWindow 逻辑:** - 新增校验:下单类请求在 `recvWindow` + `timestamp` => 撮合`timestamp`时有效 - 受影响接口: - POST /fapi/v1/order - PUT /fapi/v1/order - POST /fapi/v1/batchOrders - PUT /fapi/v1/batchOrders --- ## 2023-03-28 U本位合约 **发布前推荐返佣逻辑:** - 每笔交易实时返佣,用户会在 USER-DATA-STREAM 的 `ACCOUNT_UPDATE` 事件中收到如下推送: ```javascript { "e": "ACCOUNT_UPDATE", "T": 1679974782150, "E": 1679974782155, "a": { "B": [ { "a": "USDT", "wb": "685.31478079", "cw": "677.17212454", "bc": "0.00258637" } ], "P": [], "m": "ADMIN_DEPOSIT" } } ``` **发布后推荐返佣逻辑:** - 每 20 分钟聚合一次计算返佣上账,用户会在 USER-DATA-STREAM 的 `ACCOUNT_UPDATE` 事件中收到相同推送,余额变化为聚合后的返佣加总。 --- ## 2023-03-08 U本位合约 **发布日期 2023-03-22** **发布前订单逻辑:** - 下单时传参 `timeInForce`为 `FOK` 或 `GTX`(Post-only),用户会收到订单返回 `status` = “NEW” 并收到推送 `order_trade_update`消息`x` = “NEW”, `X` = “NEW”。 如果订单不满足执行条件,用户会收到另一条 `order_trade_update` 消息,其`x` = “EXPIRED”, `X` = “EXPIRED”。 该订单可以在`GET /fapi/v1/order`或`GET /fapi/v1/allOrders`查到。 ```javascript { "code": -5021, "msg": "Due to the order could not be filled immediately, the FOK order has been rejected. The order will not be recorded in the order history" } ``` **发布后订单逻辑:** - 下单时传参 `timeInForce`为 `FOK` 或 `GTX`(Post-only),如果该订单不满足执行条件,订单会被直接拒绝并收到报错信息,`order_trade_update`不会推送此订单的消息。该订单不能在`GET /fapi/v1/order`或`GET /fapi/v1/allOrders`中查到。 ```javascript { "code": -5022, "msg": "Due to the order could not be executed as maker, the Post Only order will be rejected. The order will not be recorded in the order history" } ``` - 受影响接口: - POST /fapi/v1/order - POST /fapi/v1/batchOrders - GET /fapi/v1/order - GET /fapi/v1/allOrders --- ## 2023-02-02 欧式期权 REST - 接口`POST /eapi/v1/transfer`不再使用. --- ## 2023-01-11 欧式期权 REST - 增加`GET /eapi/v1/order`以查询单个订单状态 --- ## 2023-01-04 U本位合约 WEBSOCKET - Order Update: 订单状态中删除`NEW_INSURANCE`风险保障基金(强平)与`NEW_ADL`自动减仓序列(强平) --- ## 2022-12-16 币本位合约 WEBSOCKET - 新增订阅信息流 `!contractInfo` 获取交易对信息更新 --- ## 2022-12-16 U本位合约 WEBSOCKET - 新增订阅信息流 `!contractInfo` 获取交易对信息更新 --- ## 2022-12-13 欧式期权 WEBSOCKET - 在`@depth1000`中新增字段`u`和`pu`以获取增量 orderbook 更新 --- ## 2022-12-09 欧式期权 REST - 在`GET /eapi/v1/depth`中新增更新 id 字段`u` - 在`GET /eapi/v1/exerciseHistory`中增加入参`underlying` --- ## 2022-11-29 币本位合约 WEB SOCKET USER DATA STREAM - USER-DATA-STREAM 中新增事件`STRATEGY_UPDATE`: 在策略交易创建、取消、失效等等时候更新。 - USER-DATA-STREAM 中新增事件`GRID_UPDATE`: 在网格子订单有部份或是完全成交时更新。 --- ## 2022-11-29 U本位合约 WEB SOCKET USER DATA STREAM - USER-DATA-STREAM 中新增事件`STRATEGY_UPDATE`: 在策略交易创建、取消、失效等等时候更新。 - USER-DATA-STREAM 中新增事件`GRID_UPDATE`: 在网格子订单有部份或是完全成交时更新。 --- ## 2022-11-18 欧式期权 REST - 新增接口`GET /eapi/v1/openInterest`用来获取特定标的资产特定到期日的期权持仓量 WEBSOCKET - 增加数据流`@openInterest@`用来获取特定标的资产期权持仓量 --- ## 2022-11-16 欧式期权 WEBSOCKET - 增加交易数据流`@trade`用来获取特定标的资产的所有期权交易 - 调整数据流`option_pair`输出格式 --- ## 2022-11-03 欧式期权 REST - 将于 2022-11-07 日新增做市商倒计时自动取消接口: - `POST /eapi/v1/countdownCancelAll`:设置倒计时取消所有订单配置 - `GET /eapi/v1/countdownCancelAll`:获得倒计时自动取消所有订单配置 - `POST /eapi/v1/countdownCancelAllHeartBeat`:重置倒计时取消所有订单心跳 --- ## 2022-10-13 币本位合约 **注意:** 此变动会在 2022-10-17 生效 REST RATE LIMIT WEIGHT 接口 `GET /dapi/v1/ticker/bookTicker` **权重更新:** - 单交易对`2` - 无交易对`5` --- ## 2022-10-13 U本位合约 **注意:** 此变动会在 2022-10-17 生效 REST RATE LIMIT WEIGHT 接口 `GET /fapi/v1/ticker/bookTicker` **权重更新:** - 单交易对`2` - 无交易对`5` --- ## 2022-09-22 币本位合约 - 新增统一账户接口: - `GET /dapi/v1/pmAccountInfo`:查询统一账户当前账户信息。 --- ## 2022-09-22 U本位合约 - 更新账户和交易接口: - `GET /fapi/v1/income`:支持更多收益类型 - 新增统一账户接口: - `GET /fapi/v1/pmAccountInfo`:查询统一账户当前账户信息。 --- ## 2022-09-20 欧式期权 WEBSOCKET - 新增数据流 `@markPrice` 和 `@ticker@` - 数据流 `` 将于 2022/10/30 弃用 --- ## 2022-09-14 欧式期权 REST - 修改`GET /eapi/v1/exchangeInfo`中`strikePrice`,`makerFeeRate`,`takerFeeRate`,`minQty`,`maxQty`,`initialMargin`,`maintenanceMargin`,`minInitialMargin`,`minMaintenanceMargin`为 string - `GET /eapi/v1/historyOrders`中仅保留最近 5 天订单 --- ## 2022-09-05 欧式期权 REST - 修改`DELETE /eapi/v1/allOpenOrdersByUnderlying`中 response 的格式 --- ## 2022-07-27 币本位合约 REST RATE LIMIT WEIGHT - 接口 `GET /dapi/v1/trades` 的请求权重更新为 5 --- ## 2022-07-27 U本位合约 REST RATE LIMIT WEIGHT - 接口 `GET /fapi/v1/trades` 的请求权重更新为 5 --- ## 2022-06-28 币本位合约 REST - 新增接口 `GET /dapi/v1/pmExchangeInfo` 获取统一账户交易规则 --- ## 2022-06-28 U本位合约 REST - 新增接口 `GET /fapi/v1/pmExchangeInfo` 获取统一账户交易规则 --- ## 2022-04-28 币本位合约 REST - 新增 `PUT /dapi/v1/order` 和 `PUT /dapi/v1/batchOrders` 接口以支持限价订单修改功能 - 新增 `GET /dapi/v1/orderAmendment` 接口以查询订单修改历史 WEBSOCKET - 订单/交易 更新推送 `ORDER_TRADE_UPDATE` 中本次事件的具体执行类型 `x` 新增 "AMENDMENT" 代表订单修改 --- ## 2022-04-14 币本位合约 WEB SOCKET USER DATA STREAM - USER-DATA-STREAM 中新增事件`ACCOUNT_CONFIG_UPDATE`以获取交易对杠杆倍数变动更新 --- ## 2022-03-01 U本位合约 REST - 新增接口`GET /fapi/v1/income/asyn` 获取合约资金流水下载 id - 新增接口`GET /fapi/v1/income/asyn/id` 通过下载 id 获取合约资金流水下载链接 --- ## 2022-02-18 币本位合约 REST - 查询账户成交历史接口`GET /dapi/v1/userTrades`接口参数`limit`的最大值调整至 1000 --- ## 2022-02-10 U本位合约 REST - 更新`GET /fapi/v2/account`接口: - 若用户开启多资产模式,`totalInitialMargin``totalMaintMargin``totalWalletBalance``totalUnrealizedProfit``totalMarginBalance``totalPositionInitialMargin``totalOpenOrderInitialMargin``totalCrossWalletBalance``totalCrossUnPnl``availableBalance``maxWithdrawAmount` 计入各种资产并转化为其 USD 价值显示 - 若用户使用单资产模式, 仅 USDT 资产会被计入计算(和改动前一致) --- ## 2021-12-30 U本位合约 WEBSOCKET - 新增 WEBSOCKET 连接方式: - Base Url:`wss://fstream-auth.binance.com` - 订阅单一 stream 格式为 `/ws/?listenKey=` - 组合 streams 的 URL 格式为 `/stream?streams=//&listenKey=` - ``在建立连接时,必须为一个有效的 listenKey - 详细说明见 [Websocket 行情推送](#websocket)和[Websocket 账户信息推送](#websocket-2) --- ## 2021-11-02 U本位合约 REST - 新增接口`GET /fapi/v1/assetIndex`以获取多资产模式保证金资产汇率指数 --- ## 2021-08-18 币本位合约 REST - `GET /dapi/v1/account` 响应内容加入 `positionAmt` 以表示持仓数量 --- ## 2021-08-17 币本位合约 REST - 新增 `PUT /dapi/v1/order` 和 `PUT /dapi/v1/batchOrders` 接口以支持限价订单修改功能 - 新增 `GET /dapi/v1/orderAmendment` 接口以查询订单修改历史 WEBSOCKET - 订单/交易 更新推送 `ORDER_TRADE_UPDATE` 中本次事件的具体执行类型 `x` 新增 "AMENDMENT" 代表订单修改 --- ## 2021-07-23 币本位合约 REST - `GET /dapi/v1/account` 和 `GET /dapi/v1/positionRisk`响应内容加入`updateTime`以表示资产,仓位的最新更新时间 --- ## 2021-07-06 币本位合约 REST - `GET /dapi/v1/exchangeInfo` 响应内容增加以下字段: - "liquidationFee" 表示强平费率 - "marketTakeBound" 表示市价吃单(相对于标记价格)允许可造成的最大价格偏离比例 --- ## 2021-07-06 U本位合约 REST - `GET /fapi/v2/account` 和 `GET /fapi/v2/positionRisk`响应内容加入`updateTime`以表示资产,仓位的最新更新时间 - `GET /fapi/v1/exchangeInfo` 响应内容增加以下字段: - "liquidationFee" 表示强平费率 - "marketTakeBound" 表示市价吃单(相对于标记价格)允许可造成的最大价格偏离比例 --- ## 2021-06-15 U本位合约 WEBSOCKET - 综合指数交易对信息流 `@compositeIndex` 新增返回字段 "q" 表示报价资产, "i" 表示指数价格 REST - 更新以下接口: - `GET /fapi/v1/indexInfo` 响应加入`component`成分资产,`quoteAsset`报价资产字段 --- ## 2021-05-06 币本位合约 WEBSOCKET - "ACCOUNT_UPDATE" 事件新增返回字段 "bc" 表示账户余额改变量。 --- ## 2021-05-06 U本位合约 WEBSOCKET - 更新以下接口: - 原有杠杆倍数更新推送事件`ACCOUNT_CONFIG_UPDATE`扩展为账户配置更新推送事件,包含杠杆倍数与联合保证金状态更新推送 - Balance 和 Position 更新推送`ACCOUNT_UPDATE`的事件`m`枚举类型新增`AUTO_EXCHANGE`代表联合保证金自动兑换事件 REST - 新增以下接口: - `POST /fapi/v1/multiAssetsMargin` 以更改联合保证金模式 - `GET /fapi/v1/multiAssetsMargin` 以查询联合保证金模式 - 更新以下接口: - `GET /fapi/v1/exchangeInfo` 响应加入`assets`资产信息 - `GET /fapi/v2/balance`与`GET /fapi/v2/account` 响应加入`marginAvailable`字段代表是否可用作联合保证金 --- ## 2021-04-27 币本位合约 WEBSOCKET - 以下市场强平订单推送事件由实时推送调整为快照推送,即每秒最多推送一条强平订单数据: - `@forceOrder` - `!forceOrder@arr` REST - 获取市场强平订单接口 `GET /dapi/v1/allForceOrders`停止维护,不再接受请求 --- ## 2021-04-27 U本位合约 WEBSOCKET - 以下市场强平订单推送事件由实时推送调整为快照推送,即每秒最多推送一条强平订单数据: - `@forceOrder` - `!forceOrder@arr` REST - 获取市场强平订单接口 `GET /fapi/v1/allForceOrders`停止维护,不再接受请求 --- ## 2021-04-22 U本位合约 WEBSOCKET - "ACCOUNT_UPDATE" 事件新增返回字段 "bc" 表示账户余额改变量。 --- ## 2021-03-10 币本位合约 REST - 接口 `GET /dapi/v1/allForceOrders` 的查询时间范围最大为 7 天(默认查询最近 7 天内的数据) --- ## 2021-03-02 U本位合约 - 新增接口 `GET /fapi/v1/indexPriceKlines` 以获取价格指数 K 线数据。 - 新增接口 `GET /fapi/v1/markPriceKlines` 以获取标记价格 K 线数据。 --- ## 2021-02-24 U本位合约 REST RATE LIMIT WEIGHT - 接口 `GET /fapi/v2/balance` 的请求权重更新为 5 - 接口 `GET /fapi/v2/positionRisk` 的请求权重更新为 5 --- ## 2021-02-22 U本位合约 REST RATE LIMIT WEIGHT - 接口 `GET /fapi/v1/income` 的请求权重更新为 30 REST - 接口`GET /fapi/v1/allOrders` 的查询时间范围最大为 7 天. - 接口`GET /fapi/v1/allForceOrders`的查询范围仅限于最近 7 天内的数据. --- ## 2021-01-26 币本位合约 REST RATE LIMIT WEIGHT - 以下接口的权重调整为 带 symbol 20, 不带 symbol 50 - `GET /dapi/v1/allForceOrders` - `GET /dapi/v1/forceOrders` --- ## 2021-01-26 U本位合约 WEB SOCKET USER DATA STREAM - USER-DATA-STREAM 中新增事件`ACCOUNT_CONFIG_UPDATE`以获取交易对杠杆倍数变动更新 REST RATE LIMIT WEIGHT - 以下接口的权重调整为 带 symbol 20, 不带 symbol 50 - `GET /fapi/v1/allForceOrders` - `GET /fapi/v1/forceOrders` REST - 新增交易对过滤器 "MIN_NOTIONAL",定义了交易对订单所允许的最小名义价值,并在 `fapi/v1/exchangeInfo` 的响应中返回 --- ## 2021-01-21 币本位合约 合约订单用户自定义 id`newClientOrderId`更新正则规则为: `^[\.A-Z\:/a-z0-9_-]{1,36}$` --- ## 2021-01-21 U本位合约 合约订单用户自定义 id`newClientOrderId`更新正则规则为: `^[\.A-Z\:/a-z0-9_-]{1,36}$` --- ## 2021-01-04 U本位合约 REST - 以下接口的 IP 限制权重将采用基于参数 LIMIT 数值的新权重规则: - `GET /fapi/v1/klines` - `GET /fapi/v1/continuousKlines` - 以下接口的 IP 限制权重调整到 20: - `GET /fapi/v1/historicalTrades` - `GET /fapi/v1/allForceOrders` - `GET /fapi/v1/forceOrders` - `GET /fapi/v1/aggTrades` --- ## 2020-12-30 币本位合约 REST RATE LIMIT WEIGHT - 以下接口的 IP 限制权重将采用基于参数 LIMIT 数值的新权重规则: - `GET /dapi/v1/klines` - `GET /dapi/v1/continuousKlines` - `GET /dapi/v1/indexPriceKlines` - `GET /dapi/v1/markPriceKlines` - 以下接口的 IP 限制权重调整到 20: - `GET /dapi/v1/historicalTrades` - `GET /dapi/v1/allForceOrders` - `GET /dapi/v1/forceOrders` - `GET /dapi/v1/aggTrades` --- ## 2020-12-08 U本位合约 WEBSOCKET - 行情消息推送 `@bookTicker` 和 `!bookTicker` 返回内容新增字段`e` 表示事件类型 - 行情消息推送`@markPrice`, `@markPrice@1s`, `!markPrice@arr`, 和 `!markPrice@arr@1s` 返回内容新增字段`P` 表示估计结算价 - 新增行情连续合约 K 线推送 `_@continuousKline_` REST API - 接口 `GET /fapi/v1/premiumIndex` 返回内容新增字段 "estimatedSettlePrice" 表示估计结算价。 - 接口`GET /fapi/v1/exchangeInfo` 返回内容新增字段: - "pair" 标的交易对 - "contractType" 合约类型 - "deliveryDate" 交割日期 - "onboardDate" 上线日期 - 新增接口 `GET /fapi/v1/continuousKlines` 获取连续合约 K 线数据 ENUM - 合约类型: - PERPETUAL 永续合约 - CURRENT_MONTH 当月交割合约 - NEXT_MONTH 次月交割合约 - CURRENT_QUARTER 当季交割合约 - NEXT_QUARTER 次季交割合约 --- ## 2020-11-27 币本位合约 - 新增接口 `GET /dapi/v1/commissionRate` 以查询用户交易手续费率。 --- ## 2020-11-27 U本位合约 - 新增接口 `GET /fapi/v1/commissionRate` 以查询用户交易手续费率。 --- ## 2020-11-13 U本位合约 WEB SOCKET STREAM - 为了给用户提供更安全稳定的服务,`depth@0ms` and `@depth@0ms` 的更新频率调整为根据数据流量总量和其他客观情况动态调整 --- ## 2020-11-10 U本位合约 - 接口`GET /fapi/v1/exchangeInfo` 新增返回字段 "marginAsset" 表示保证金资产 - 接口`GET /fapi/v2/account`新增返回字段 "positionAmt" 表示持仓数量 --- ## 2020-11-09 U本位合约 WEB SOCKET USER DATA STREAM USER-DATA-STREAM 中的事件`ACCOUNT_UPDATE`推送规则作出了以下更新和优化: - 当用户某项资产发生变化时: - 资产项目"B"中仅会推送本次发生变化的资产及其余额 - 其他资产不会被推送,即便资产不为 0 - 如果资产变化不涉及持仓变化,持仓项目"P"将仅返回空`[]` - 当合约某 symbol 的持仓或全逐仓配置发生变动时 - "P"中会推送该 symbol 对应的"BOTH"方向上的持仓详情 - 如果是多空方向上发生持仓变动, "P"中会推送该 symbol 发生持仓变动的对应"LONG"或"SHORT"方向上的持仓详情 - 该 symbol 上被初始化过的"LONG"或"SHORT"方向的逐仓持仓, 也会被推送 - 所以该 symbol 上推送的 position 方向组合, 由具体场景决定() - 其他 symbol 的所有持仓信息都不会被推送,即使其持仓不为 0 - 简言之, 您应该通过相关的 rest 接口( `GET /fapi/v2/account` 和 `GET /fapi/v2/positionRisk`) 获取资产和头寸的**全量**信息; 通过 Websocket USER-DATA-STREAM 中的事件`ACCOUNT_UPDATE`对本地缓存的资产或头寸数据进行**增量**更新。 - 可以访问[这里](https://dev.binance.vision/t/838) 获取示例以帮助对本次优化升级的理解 --- ## 2020-10-27 U本位合约 WEB SOCKET STREAM - 单个连接可订阅的最大 stream 数量调整为 200 --- ## 2020-10-10 U本位合约 WEBSOCKET - 新增 WebSocket 综合指数交易对信息更新`@compositeIndex` 。 --- ## 2020-10-09 U本位合约 - 新增接口 `GET /fapi/v1/indexInfo` 以获取交易对为综合指数的基础成分信息。 --- ## 2020-09-18 U本位合约 - 新增 API 交易量化规则指标查询接口 `GET /fapi/v1/apiTradingStatus`。 --- ## 2020-09-16 U本位合约 - 新增杠杆代币历史净值 K 线接口 `GET /fapi/v1/lvtKlines`。 杠杆代币净值系统基于合约架构,故该接口采用 fapi。 WEBSOCKET - 新增 WebSocket 杠杆代币信息更新`@tokenNav` 和 净值 K 线更新`@nav_Kline_`。 杠杆代币净值系统基于合约架构,故该推送采用合约 WS 服务。 --- ## 2020-09-09 U本位合约 - 一些过期或者被取消的订单将在未来开始逐步不会从 API 的接口返回。 - 被移除的订单需要满足如下条件: - 订单的最终状态为 `CANCELED` 或者 `EXPIRED`, **并且** - 订单没有任何的成交记录, **并且** - 订单生成时间 + 7 天 < 当前时间 - 如下的接口会受影响: - `GET /fapi/v1/order` - `GET /fapi/v1/allOrders` --- ## 2020-08-16 币本位合约 WEBSOCKET - 新增 Websocket 账户信息请求功能, 并开放以下请求: - `@account` 请求获取账户信息 - `@balance` 请求获取账户余额 - `@balance` 请求获取持仓信息 REST - 新增接口`GET /dapi/v1/adlQuantile` 以获取持仓 ADL 队列位置估算分数 --- ## 2020-08-14 U本位合约 - 接口`GET /fapi/v1/premiumIndex` 新增返回字段 "indexPrice", 表示现货指数价格。 - 以下 websocket 行情,新增返回字段 "i" 表示现货指数价格: - `@markPrice`, - `@markPrice@1s`, - `!markPrice@arr`, - `!markPrice@arr@1s` --- ## 2020-08-12 币本位合约 - 新增接口 `GET /dapi/v1/forceOrders` 以获取用户强平订单历史. --- ## 2020-08-12 U本位合约 - 新增接口 `GET /fapi/v1/forceOrders` 以获取用户强平订单历史. --- ## 2020-08-11 币本位合约 币本位永续合约 - 新增合约类型("contractType") `PERPETUAL` 表示币本位永续合约 - 接口`GET /dapi/v1/premiumIndex`新增返回内容: - `lastFundingRate` 表示(永续合约的)最近更新的资金费率 - `nextFundingTime` 表示(永续合约的)下次资金费时间 - 新增接口`GET /dapi/v1/fundingRate` 用以获取币本位永续合约的资金费率历史 - WSS 推送`@markPrice`, `@markPrice@1s`, `@markPrice`, 和 `@markPrice@1s`新增推送内容: - `r` 表示(永续合约的)最近更新的资金费率 - `T` 表示(永续合约的)下次资金费时间 --- ## 2020-07-30 U本位合约 - 新增接口`GET /fapi/v1/adlQuantile` 以获取持仓 ADL 队列位置估算分数 --- ## 2020-07-22 币本位合约 - 新增币本位合约大数据接口: - `GET /futures/data/openInterestHist` - `GET /futures/data/topLongShortAccountRatio` - `GET /futures/data/topLongShortPositionRatio` - `GET /futures/data/globalLongShortAccountRatio` - `GET /futures/data/takerBuySellVol` - `GET /futures/data/basis` --- ## 2020-07-17 U本位合约 - 接口 `GET /fapi/v1/income` 权重调整为 20 --- ## 2020-07-02 U本位合约 WEBSOCKET - "ACCOUNT_UPDATE" 事件新增返回字段 "m" 表示事件推出缘由。 - "ORDER_TRADE_UPDATE" 事件新增返回字段 "rp" 表示该交易实现损益。 --- ## 2020-06-15 U本位合约 - 接口`GET /fapi/v2/account`,`GET /fapi/v2/balance`返回内容新增字段: - `availableBalance` - `maxWithdrawAmount` --- ## 2020-06-04 U本位合约 - 新增 `/fapi/v2/` 接口, 较 v1 对应接口性能有较大提升: - `GET /fapi/v2/account` - `GET /fapi/v2/balance` --- ## 2020-06-02 U本位合约 - 新增 `/fapi/v2/` 接口 `GET /fapi/v2/positionRisk`: - 允许用户指定 symbol 查询 - 市场上所有 symbol 都可以被查询 - 返回内容有效区分单向持仓模式和双向持仓模式 - 较 ‘/fapi/v1/positionRisk’ 性能有较大改善 --- ## 2020-05-18 U本位合约 - 新增参数 `closePosition` 于下单接口 `POST /fapi/v1/order`, 表示条件全部平仓: 如果一个`STOP_MARKET` 或 `TAKE_PROFIT_MARKET` 条简单设置了 `closePosition=true` 并被触发了,当时持有**所有**多头仓位(若为卖单)或当时持有**所有**空头仓位(若为买单)将会被平仓。 - 新增返回字段`closePosition`于以下接口表示是否为条件全平仓单: - `POST /fapi/v1/order` - `POST /fapi/v1/batchOrders` - `GET /fapi/v1/order` - `DELETE /fapi/v1/order` - `DELETE /fapi/v1/batchOrders` - `GET /fapi/v1/openOrder` - `GET /fapi/v1/openOrders` - `GET /fapi/v1/allOrders` --- ## 2020-05-18 U本位合约 - 一些过期或者被取消的订单将在未来开始逐步不会从 API 的接口返回, 但是还可以从网页端查询到。 - 被移除的订单需要满足如下条件: - 订单的最终状态为 `CANCELED` 或者 `EXPIRED`, **并且** - 订单没有任何的成交记录, **并且** - 订单生成时间 + 30 天 < 当前时间 - 如下的接口会受影响: - `GET /fapi/v1/order` - `GET /fapi/v1/allOrders` --- ## 2020-05-15 U本位合约 - Wesocket 行情消息 `@bookTicker` 和 `!bookTicker` 增加返回字段: - `E` 表示事件推出事件 - `T` 表示撮合时间 --- ## 2020-05-14 U本位合约 - 以下接口返回内容增加`time`字段,表示撮合引擎时间: - `GET /fapi/v1/ticker/price` - `GET /fapi/v1/ticker/bookTicker` - `GET /fapi/v1/openInterest` --- ## 2020-05-11 U本位合约 - 新增接口 `POST /fapi/v1/countdownCancelAll` 以实现倒计时自动撤单。 - 该接口可以被用于确保在倒计时结束时撤销指定 symbol 上的所有挂单。 - 在使用这个功能时,接口应像心跳一样在倒计时内被反复调用,以便可以取消既有的倒计时并开始新的倒数计时设置。 --- ## 2020-05-06 U本位合约 REST 接口 - 接口 `GET /fapi/v1/leverageBracket` 调整为 USER-DATA 权限访问,需要验签以及 timestamp WEBSOCKET 账户信息推送 - 请注意: 当某一持仓发生"FUNDING FEE"时,事件`ACCOUNT_UPDATE`将只会推送相关的用户资产余额信息和持仓信息,而不会推送其余无关的资产和持仓信息。 - 当用户某**全仓**持仓发生"FUNDING FEE"时,事件`ACCOUNT_UPDATE`将只会推送相关的用户资产余额信息`B`(仅推送 FUNDING FEE 发生相关的资产余额信息),而不会推送任何持仓信息`P`。 - 当用户某**逐仓**仓持仓发生"FUNGDING FEE"时,事件`ACCOUNT_UPDATE`将只会推送相关的用户资产余额信息`B`(仅推送"FUNDING FEE"所使用的资产余额信息),和相关的持仓信息`P`(仅推送这笔"FUNDING FEE"发生所在的持仓信息),其余持仓信息不会被推送 --- ## 2020-04-25 U本位合约 - 用户"订单/交易更新推送" `ORDER_TRADE_UPDATE` 新增以下字段: - `cp` 表示是否为平仓条件单 - `AP` 表示追踪止损单的追踪止损激活价格 - `cr` 表示追踪止损单的追踪止损回调比例 - 新增账户信息推送事件: "追加保证金通知"`MARGIN_CALL`. --- ## 2020-04-17 U本位合约 - 下单接口支持新的可选参数 `newOrderRespType` 表示下单响应类型。支持`ACK` 和 `RESULT`, 如果`newOrderRespType= RESULT`: - `MARKET` 订单将直接返回成交(FILLED)结果; - 配合使用特殊 `timeInForce` 的 `LIMIT` 订单将直接返回成交/过期(FILLED/EXPIRED)结果。 --- ## 2020-04-14 U本位合约 WEB SOCKET 连接限制 - Websocket 服务器每秒最多接受 10 个消息。消息包括: - PING 帧 - PONG 帧 - JSON 格式的消息, 比如订阅, 断开订阅. - 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的 IP 有可能被服务器屏蔽。 - 单个连接最多可以订阅 **200** 个 Streams。 --- ## 2020-04-09 U本位合约 - 新增接口合约大数据 `GET /futures/data/takerlongshortRatio` 以查询合约主动买卖量 --- ## 2020-04-08 U本位合约 - 新增接口 `GET /fapi/v1/positionSide/dual` 以查询用户当前持仓模式 - 新增接口 `POST /fapi/v1/batchOrders` 以实现批量下单 --- ## 2020-04-06 U本位合约 - 请注意 账户信息推送 事件 "Balance 和 Position 更新推送"(`ACCOUNT_UPDATE`)将不再未发生更新时推送,具体规则如下: - 仅当账户信息有变动时(包括资金、仓位、保证金模式等发生变化),才会推送此事件; - 订单状态变化没有引起账户和持仓变化的,不会推送此事件; - 每次推送的 position 信息,仅包含当前持仓不为 0 或逐仓仓位保证金不为 0 的 symbol position。 - 新增接口 `POST /fapi/v1/positionSide/dual` 更改持仓模式:双向或单向持仓模式。 - 以下接口新增参数 `positionSide` 用以支持单向/双向持仓模式,表示持仓方向: - `POST /fapi/v1/order` - `POST /fapi/v1/positionMargin` - 以下接口新增返回字段 `positionSide` 用以支持单向/双向持仓模式,表示持仓方向: - `POST /fapi/v1/order` - `GET /fapi/v1/order` - `DELETE /fapi/v1/order` - `DELETE /fapi/v1/batchOrders` - `GET /fapi/v1/openOrder` - `GET /fapi/v1/openOrders` - `GET /fapi/v1/allOrders` - `GET /fapi/v1/account` - `POST /fapi/v1/positionMargin` - `GET /fapi/v1/positionMargin/history` - `GET /fapi/v1/positionRisk` - `GET /fapi/v1/userTrades` - 账户信息推送 事件 "Balance 和 Position 更新推送"(`ACCOUNT_UPDATE`)和 "订单/交易更新推送"(ORDER_TRADE_UPDATE)中新增字段 `ps` 表示持仓方向。 --- ## 2020-03-30 U本位合约 - 新增接口合约大数据: - `GET /futures/data/openInterestHist` - `GET /futures/data/topLongShortAccountRatio` - `GET /futures/data/topLongShortPositionRatio` - `GET /futures/data/globalLongShortAccountRatio` --- ## 2020-02-26 U本位合约 - 新增订单类型:跟踪止损 `TRAILING_STOP_MARKET` --- ## 2020-02-20 U本位合约 - 新增接口以查询指定的当前挂单: `GET /fapi/v1/openOrder` --- ## 2020-02-17 U本位合约 - `@ticker` 与 `!ticker@arr` 更新频率提升为 1000ms - 新增 500ms 更新的增量深度信息流选项: `@depth@500ms` - 新增 500ms 更新的有限档深度信息流选项: `@depth@500ms` --- ## 2020-02-12 U本位合约 - Java [SDK 和代码示例](#sdk) 发布 - 实现每秒更新的标记价格信息流选项: `@markPrice@1s` and `!markPrice@arr@1s` --- ## 2020-02-05 U本位合约 - 新增接口`GET /fapi/v1/leverageBracket`: 查询杠杆分层标准。 --- ## 2020-01-19 U本位合约 - "cumQty" 字段将于未来几周从 `DELETE /fapi/v1/order`,`DELETE /fapi/v1/batchOrders` 等 `order` 相关接口的返回内容中去除,请使用 "executedQty" 字段予以替代。 --- ## 2019-12-19 U本位合约 - 新增接口获取市场当前未平仓合约数: `GET /fapi/v1/openInterest` --- ## 2019-12-18 U本位合约 - 新增账户信息推送事件:`listenKeyExpired`。 --- ## 2019-12-12 U本位合约 - 新增接口撤销指定 symbol 的所有订单: `DELETE /fapi/v1/allOpenOrders` - 新增接口批量撤销订单:`DELETE /fapi/v1/batchOrders` - 新增支持仅减仓`reduceOnly`的订单类型: - `TAKE_PROFIT` - `TAKE_PROFIT_MARKET` - `STOP` - `STOP_MARKET` --- ## 2019-11-29 U本位合约 - 新增接口获取市场强平订单:`GET /fapi/v1/allForceOrders` - 新增市场行情推送: - 强平订单:`@forceOrder` - 全市场强平订单:`!forceOrder@arr` --- ## 2019-11-25 U本位合约 - `GET /fapi/v1/account` 新增返回内容: `positions` - 以下接口新增返回值 `time` 表示订单创建时间: - `GET /fapi/v1/openOrders` - `GET /fapi/v1/order` - `GET /fapi/v1/allOrders` --- ## 2019-11-15 U本位合约 - Websocket 新增市场行情流: - `!miniTicker@arr`: 全市场的精简 Ticker 更新 - `!ticker@arr`: : 全市场的完整 Ticker 更新 --- ## 2019-11-12 U本位合约 - WSS 支持实时订阅和取消数据流。 --- ## 2019-11-05 U本位合约 - 新增订单类型: - `STOP_MARKET`止损市价单, - `TAKE_PROFIT_MARKET`止盈市价单 - 下单新增可选参数: `workingType` 可选`stopPrice`由 "CONTRACT_PRICE" 或 "MARK_PRICE"触发 - USER-DATA-STREAMS 新增: - `ORDER_TRADE_UPDATE`订单/交易 更新推送 增加: - "T": 撮合时间 - "wt": workingType - `ACCOUNT_UPDATE` Balance 和 Position 更新推送 增加:"T": 撮合时间 --- ## 2019-10-28 U本位合约 - 新增接口查询账户损益资金流水:`GET /fapi/v1/income` --- ## 2019-10-25 U本位合约 - 账户信息推送事件`ACCOUNT_UPDATE`增加字段 "up",表示持仓未实现盈亏。 - 账户信息推送事件`ORDER_TRADE_UPDATE`增加字段 "R",表示该成交是否作为只减仓单。 --- ## 2019-10-24 U本位合约 - 新增最优挂单信息行情流: `@bookTicker` 与`!bookTicker` - 新增有限档深度信息行情流: `@depth` 与 `@depth@100ms` - 更新频率达到 100ms 的更快的增量深度信息流选项: `@depth@100ms` - `Websocket行情推送` 增加 `Update Speed` 更新速度 --- ## 2019-10-18 U本位合约 - 新增接口 `POST /fapi/v1/leverage` 以调整开仓杠杆倍数。 - 接口 `GET /fapi/v1/positionRisk` 的返回内容中新增字段: - "leverage": 当前开仓杠杆倍数; - "maxNotionalValue": 当前开仓杠杆倍数下的名义价值上限。 - `MARKET` 市价单支持 `reduceOnly` 只减仓参数。 --- ## 2019-10-14 U本位合约 - 新增接口`GET /fapi/v1/fundingRate`: 获取资金费率历史。 --- ## 2019-10-11 U本位合约 - 账户信息推送事件`ORDER_TRADE_UPDATE`增加字段 "m",表示该成交是否作为挂单成交 --- ## 2019-10-08 U本位合约 - 新增限价指令订单参数 `reduceOnly` :只减仓 - 新增订单类型 `TAKE_PROFIT`: 止盈单 --- --- ## Document: /products/common/derivatives-trading/Introduction URL: /zh-CN/docs/products/common/derivatives-trading/Introduction 衍生品API为您的期货,期权及统一账户等衍生品交易需求提供了REST API和WebSocket推送 --- ## Document: /products/common/binance-link/change-log URL: /zh-CN/docs/products/common/binance-link/change-log **2026-05-08** - Update KYC SaaS endpoints to support KZ Entity Broker Partial Sharing mode. - POST `/bapi/ekyc/v2/public/ekyc/customer/share-kyc-data` - `basicInfo` / `identityInfo` changed from `YES` to `Conditional` (required for standard brokers; optional for KZ Entity brokers). - New optional `KycInfo` fields: `tncInfo`, `questionnaireInfo`. - New sub-sections: `TncInfo`, `QuestionnaireInfo`, `QuestionnaireAnswer`. - POST `/bapi/ekyc/v2/public/ekyc/customer/query-kyc-info` - New `KycInfoVo` response fields: `questionInfo`, `tncInfo`. - New sub-sections: `QuestionInfo`, `TncInfo` (response shape). --- **2025-11-25** - New response fields for GET `/sapi/v1/apiReferral/rebate/recentRecord` - `distributeTime` - `commissionAsset` - `commission` - `convertPrice` --- **2025-09-22** - New Futures Transfer for Link Sub-account endpoints * POST `/sapi/v1/broker/futures/accountTransfer` --- **2025-09-16** - Futures commission rebate query endpoints require to input `symbol` or `pair`. * GET `/sapi/v1/broker/subAccountApi/commission/futures` * GET `/sapi/v1/broker/subAccountApi/commission/coinFutures` --- **2025-07-02** - New endpoints for KYC SaaS Integration, KYC Querying, and Request for Information (RFI). --- **2025-04-18** - New Endpoint for delete sub account `DELETE /sapi/v1/broker/subAccount `. - Create Link sub account API key endpoint and FAST api key creation endpoint support asymmetrical key type(Ed25519 and RSA). Please see https://www.binance.com/en/support/faq/detail/6b9a63f1e3384cf48a2eedb82767a69a --- **2025-03-07** - New Endpoint for query sub account deposit by depositId `GET /sapi/v2/broker/subAccount/depositHist `. --- **2025-02-26** - Update sub account deposit history Endpoint `GET /sapi/v1/broker/subAccount/depositHist `, adding "travelRuleStatus". --- **2024-10-30** - Update the `Weight(UID)` to 60 for Endpoint `GET /sapi/v3/broker/subAccount/futuresSummary `. --- **2024-08-15** - New parameter `filterResult ` will be available on August 16, 2024 for query futures commission rebate record:`GET /sapi/v1/broker/rebate/futures/recentRecord `. If `filterResult ` = TRUE, rebates not from its own sub accounts will be filtered out in response. --- **2024-06-28** - New Endpoint for query futures assets of sub-accounts:`GET /sapi/v3/broker/subAccount/futuresSummary `. - Following endpoints will be deleted in a month: `GET /sapi/v1/broker/subAccount/futuresSummary `,`GET /sapi/v2/broker/subAccount/futuresSummary `. Please migrate the usage of legacy version(v1&v2) to the new (v3) version as soon as possible. --- **2024-06-06** - Endpoints adjustment: for internal transfers, the txid prefix has been replaced to “Off-chain transfer”on 28 May 2024. “internal transfer” flag is no longer available in the TXID field, including historical transactions, the following endpoints are impacted: `GET /sapi/v1/broker/subAccount/depositHist`. --- **2024-04-30** - Update the request limit for endpoint: `POST /sapi/v1/broker/subAccountApi`. You can only create 1 api key for each sub account per second - Update the request limit for endpoint: `DELETE /sapi/v1/broker/subAccountApi`. You can only delete 1 api key for each sub account per second --- **2024-03-05** - Remove endpoint: `POST /sapi/v1/broker/subAccount/blvt`. --- **2023-12-15** - Update the default parameter values of endpoint: `GET /sapi/v1/broker/universalTransfer`. --- **2023-11-20** - Add `depositId` and `selfReturnStatus` in response of endpoint: `GET /sapi/v1/broker/subAccount/deposit`. --- **2023-10-04** - Remove endpoint: `POST /sapi/v1/broker/subAccountApi/permission/vanillaOptions`. --- **2023-08-31** - Remove endpoint: `POST /sapi/v1/broker/subAccount/margin`. To enable the margin account, simply transfer assets into Cross Margin wallet. --- **2023-06-08** - Update weight for endpoint: `POST /sapi/v1/broker/subAccountApi`. Weight(Master Account) changed to 3000 --- **2023-01-13** - Remove 2 endpoints: `POST /sapi/v1/broker/subAccountApi/ipRestriction`, `POST /sapi/v1/broker/subAccountApi/ipRestriction/ipList`. --- **2022-12-16** - Remove "thirdPartyName" for `POST /sapi/v2/broker/subAccountApi/ipRestriction (HMAC SHA256)`, `POST /sapi/v1/broker/subAccountApi/ipRestriction`, `POST /sapi/v1/broker/subAccountApi/ipRestriction/ipList`, `DELETE /sapi/v1/broker/subAccountApi/ipRestriction/ipList`. --- **2022-11-28** - Add "the max length is 32 characters" in the description of clientTranId for endpoints `POST /sapi/v1/broker/universalTransfer`, `POST /sapi/v1/broker/transfer/futures`, `POST /sapi/v1/broker/transfer`. --- **2022-11-18** - Added new endpoint `POST /sapi/v2/sub-account/subAccountApi/ipRestriction` to support user update IP Restriction for Sub-Account API key. --- **2022-09-22** - Update `POST /sapi/v1/broker/subAccountApi/ipRestriction` to support user enable or disable Third party IP list name restriction for sub-account api key. - Update `POST /sapi/v1/broker/subAccountApi/ipRestriction/ipList` to support user update Third party IP list name restriction for sub-account api key. - Update `DELETE /sapi/v1/broker/subAccountApi/ipRestriction/ipList` to support user delete Third party IP list name restriction for sub-account api key. --- **2022-09-12** - Update `GET /sapi/v1/broker/subAccountApi/ipRestriction` to support user query third party IP list name. --- **2022-08-23** - Add 100-days query scope for `GET /sapi/v1/broker/universalTransfer` and `GET /sapi/v1/broker/transfer`. - Add requests per UID are limited to 60 requests per minute for `GET /sapi/v1/broker/subAccount/spotSummary`. --- **2022-06-27** - Added a new rebate status field in API response for endpoints `GET /sapi/v1/broker/rebate/futures/recentRecord` and `GET /sapi/v1/broker/rebate/recentRecord`. --- **2021-04-29** - Added parameter `tag` and new field `email` in endpoint `POST /sapi/v1/broker/subAccount`. --- **2021-03-26** - Added new endpoint `POST /sapi/v1/broker/subAccountApi/permission/universalTransfer` to enable the api permission for a sub account to use `POST /sapi/v1/asset/transfer`endpoint. - Added new endpoint `POST /sapi/v1/broker/subAccountApi/permission/vanillaOptions` to enable Vanilla Options permission for sub account api key. --- **2021-02-04** - Added parameter `fromId` and `toId` in endpoint `GET /sapi/v1/broker/transfer`. The parameter `subaccountId` will be removed on 02/10 16:00(UTC+8). Please adjust the program as soon as possible. --- **2021-02-04** - Added parameter showAllStatus in endpoint `GET /sapi/v1/broker/universalTransfer`. --- **2021-01-27** - Added new endpoint `GET /sapi/v2/broker/subAccount/futuresSummary` to support query subaccount Coin Margined Futures asset info. --- **2021-01-14** - Added parameter clientTranId in endpoint `POST /sapi/v1/broker/transfer/futures` and `GET /sapi/v1/broker/transfer/futures`. --- **2020-12-28** - Added parameters page and size in endpoint `GET /sapi/v1/broker/subAccountApi`. --- **2020-12-14** - The endpoint `GET /sapi/v1/broker/transfer/futures` can only get the latest history of past 30 days. --- **2020-12-10** - Added new endpoint `POST /sapi/v1/broker/universalTransfer` to transfer spot and futures asset between master account and sub accounts. - Added new endpoint `GET /sapi/v1/broker/universalTransfer` to get universal transfer history. --- **2020-11-27** - Added tranId in response of endpoint `GET /sapi/v1/broker/transfer/futures`. --- **2020-10-23** - Added parameter showAllStatus in endpoint `GET /sapi/v1/broker/transfer`. --- **2020-10-12** - Added parameter status in the response of endpoint `GET /sapi/v1/broker/transfer`. --- **2020-09-16** - Added new endpoint `POST /sapi/v1/broker/subAccountApi/commission/coinFutures` to change sub- account COIN-Ⓜ futures commission adjustment. - Added new endpoint `GET /sapi/v1/broker/subAccountApi/commission/coinFutures` query sub- account COIN-Ⓜ futures commission adjustment. - Added parameter confirmTimes in endpoint `GET /sapi/v1/broker/subAccount/depositHist`. **2020-09-11** - Added parameter email in endpoint `GET /sapi/v1/broker/subAccount`. --- **2020-09-07** - Added new endpoint `POST /sapi/v1/broker/subAccountApi/ipRestriction` to enable or disable IP restriction for sub-account api key. - Added new endpoint `POST /sapi/v1/broker/subAccountApi/ipRestriction/ipList` to add IP restricion for sub-account api key. - Added new endpoint `GET /sapi/v1/broker/subAccountApi/ipRestriction` to get IP restriction for sub-account api key. - Added new endpoint `DELETE /sapi/v1/broker/subAccountApi/ipRestriction/ipList` to delete IP restriction for sub-account api key. --- **2020-09-02** - Added new endpoint `GET /sapi/v1/broker/rebate/futures/recentRecord` to get futures commision rebate record. - Added new endpoint `POST /sapi/v1/broker/transfer/futures` to transfer futures asset directly. - Added new endpoint `GET /sapi/v1/broker/transfer/futures` to get futures transfer history. --- **2020-08-25** - Added parameters page and size in endpoint `GET /sapi/v1/broker/rebate/recentRecord`. --- **2020-07-29** - Added new endpoint `POST /sapi/v1/broker/subAccount/blvt` to enable leverage token for sub-account. --- **2020-07-21** - Added parameters page and size in endpoint `GET /sapi/v1/broker/subAccount`. --- **2020-07-10** - Added default limit 500 in endpoint `GET /sapi/v1/broker/transfer`. --- **2020-06-15** - Added new endpoint `GET /sapi/v1/broker/subAccount/spotSummary` to query sub accounts spot asset. - Added new endpoint `GET /sapi/v1/broker/subAccount/marginSummary` to query sub accounts margin asset. - Added new endpoint `GET /sapi/v1/broker/subAccount/futuresSummary` to query sub accounts futures asset. --- **2020-06-12** - Added new endpoint `GET /sapi/v1/broker/rebate/recentRecord` to query broker commission rebate recent record. --- **2020-06-11** - Added new endpoint `GET /sapi/v1/broker/subAccount/depositHist` to query sub accounts deposit history. --- **2020-04-22** - New fields in response to `GET /sapi/v1/broker/subAccountApi/commission/futures` and `POST /sapi/v1/broker/subAccountApi/commission/futures`: - `makerCommission` for current futures commission ratio for maker; - `takerCommission` for current futures commission ratio for taker; --- **2020-04-03** - Added new endpoint `POST /sapi/v1/broker/subAccount/bnbBurn/spot` to enable or disable BNB Burn for sub-account spot and margin. - Added new endpoint `POST /sapi/v1/broker/subAccount/bnbBurn/marginInterest` to enable or disable BNB Burn for sub-account margin interest. - Added new endpoint `GET /sapi/v1/broker/subAccount/bnbBurn/status` to get BNB Burn status for sub-account. --- **2020-03-27** - Added parameters `clientTranId `in endpoints: - `POST /sapi/v1/broker/transfer`, - `GET /sapi/v1/broker/transfer`. --- **2020-02-12** - The below endpoints will be released in the future: - new endpoint `GET /sapi/v1/broker/rebate/recentRecord` to query broker commission rebate recent record. - new endpoint `GET /sapi/v1/broker/rebate/historicalRecord ` to get broker commission rebate historical record. --- **2019-12-23** - Added new endpoint `POST /sapi/v1/broker/subAccountApi/commission/futures` to change sub-account futures commission adjustment. - Added new endpoint `GET /sapi/v1/broker/subAccountApi/commission/futures` to query sub-account futures commission adjustment. --- **2019-11-11** - Added parameters `marginTrade ` and `futuresTrade` in endpoints: - `POST /sapi/v1/broker/subAccountApi`, - `POST /sapi/v1/broker/subAccountApi/permission`. - Added keys `marginTrade ` and `futuresTrade` in responses to endpoints: - `POST /sapi/v1/broker/subAccountApi`, - `GET /sapi/v1/broker/subAccountApi`, - `POST /sapi/v1/broker/subAccountApi/permission`. - Added parameters `marginMakerCommission ` and `marginTakerCommission ` in endpoint `POST /sapi/v1/broker/subAccountApi/commission`. - Added keys `marginMakerCommission ` and `marginTakerCommission ` in responses to endpoints: - `POST /sapi/v1/broker/subAccountApi/commission`, - `Get /sapi/v1/broker/subAccount/`. - Added new endpoint `POST /sapi/v1/broker/subAccount/margin` for setting subaccount enable on margin. - Added new endpoint `POST /sapi/v1/broker/subAccount/futures` for setting subaccount enable on futures. --- ## Document: /products/common/advanced-earn/change-log URL: /zh-CN/docs/products/common/advanced-earn/change-log # 更新日志 ## 2026-03-23 - 双币投资 - `GET /sapi/v1/dci/product/positions` - 在响应中新增 `subscriptionTime` 字段。 --- ## 2025-12-26 ### 时效性通知 - **以下有关于REST API变更将在 2026-01-15 07:OO UTC 发生:**
调用需要签名的接口时,请在计算签名之前对 payload 进行百分比编码(percent-encode)。不符合此顺序的请求将被拒绝,并返回错误代码 [`-1022 签名不正确`](./error-code.md#-1022-invalid_signature)。请检查并相应地更新您代码中的签名逻辑部分。 ### REST API - 更新了 REST API 文档中有关于 [签名请求示例](./general-info.md#post-apiv3order-的签名示例) 的部分。 --- ## 2025-12-02 - 新增折价买币接口 --- ## 2024-02-23 - 新增双币投资接口: - `GET /sapi/v1/dci/product/list`: 获得双币产品列表 - `POST /sapi/v1/dci/product/subscribe`: 申购双币产品 - `GET /sapi/v1/dci/product/positions`: 获得双币产品持仓状态 - `GET /sapi/v1/dci/product/accounts`: 查询双币产品账户 - `POST /sapi/v1/dci/product/auto_compound/edit-status`: 改变自动复投状态 --- ## Document: /products/common/advanced-earn/Introduction URL: /zh-CN/docs/products/common/advanced-earn/Introduction 进阶赚币下的创新产品旨在驾驭各种市场状况,助力您轻松获利。 --- ## Document: 教程与使用场景 URL: /zh-CN/docs/products/agentic-wallet/quickstart/use-agentic-wallet-tutorial-and-use-cases # 教程与使用场景 完成 [安装 Agentic Wallet](/products/agentic-wallet/quickstart/install-agentic-wallet) 并登录后,你可以直接用自然语言与 AI Agent 对话,Agentic Wallet Skills 会自动解析意图并执行链上操作。 --- ## 最小教程 最小工作流:查询状态 → 获取报价 → 确认执行兑换。 **1. 确认钱包连接状态** > "我的钱包现在连接了吗?地址是什么?" AI 返回连接状态和钱包地址。 **2. 查询当前余额** > "我有多少 BNB 和 USDT?" AI 返回所有非零余额及估值。 **3. 获取兑换报价(不执行)** > "给我看看把 0.01 BNB 换成 USDT 能换多少,不要执行" AI 返回预估兑换量、滑点和 Gas 估算,不发起链上交易。 **4. 执行兑换** > "好的,执行吧" AI 请求确认后发起链上 Swap,并返回订单 ID 供跟踪。 --- ## 场景一:钱包操作 ### 查询状态 > "我的钱包连接正常吗?" > "我在哪条链上?支持哪些网络?" > "我的钱包地址是什么?" ### 查询余额 > "我现在所有代币的余额是多少?" > "我还有多少 USDT?" > "帮我看一下我的总资产估值" ### 查询交易记录 > "我最近有哪些交易记录?" > "有没有还在 pending 的交易?" > "帮我查一下这笔交易 0xabc123... 的状态" ### 查询每日限额 > "我今天还剩多少可用额度?" > "我的每日交易上限是多少,今天还能用多少?" --- ## 场景二:转账 向白名单地址转账代币。 > **前置条件:** 收款地址必须已在 Binance App 中添加(Wallet → Settings → Address Book)。 **转账原生代币:** > "发送 0.02 BNB 到 0x1234...5678" **转账 ERC-20 代币:** > "转 10 USDT 给 0x1234...5678" AI 将在执行前告知转账金额和目标地址,请求你确认。成功后返回交易哈希,可继续追问状态: > "刚那笔转账上链了吗?" --- ## 场景三:市价兑换(Swap) ### 获取报价 > "把 0.1 BNB 换成 USDT 大概能换多少?只看报价,不要执行" AI 返回预估兑换量、滑点和路由,不发起链上交易。 ### 执行市价兑换 > "把 0.1 BNB 换成 USDT" > "用 50 USDT 买 BNB,滑点控制在 2%" AI 先展示报价等待确认,你说"确认"或"执行"后发起 Swap。 ### 查询订单状态 > "我刚才那笔 Swap 完成了吗?" > "帮我看一下最近的兑换订单" > "有没有还没完成的 Swap?" | 状态 | 说明 | | ---------- | ---------- | | `PENDING` | 上链处理中 | | `FINISHED` | 执行成功 | | `FAILED` | 执行失败 | --- ## 场景四:限价单 设定目标价格,价格到达时 AI 自动执行,无需守盘。 > **注意:** > 限价单仅支持 BSC 和 Solana。买单的支付代币只支持 USDT、USDC、USD1、U、原生代币;卖单的收款代币只支持 USDT、USDC、USD1、U、原生代币。 ### 创建限价买单 > "BNB 价格跌到 $500 时,用 100 USDT 买入 BNB" > "WETH 跌到 $2800 的时候,用 200 USDT 在 BSC 上买一些" AI 创建条件单并返回 strategyId,价格触达时自动执行。 ### 创建限价卖单 > "BNB 涨到 $650 时,把我 1 个 BNB 换成 USDT" > "WETH 到 $3500 帮我在 BSC 上卖 0.5 个" ### 查询限价单 > "我现在有哪些挂单?" > "查一下还在等待触发的限价单" > "帮我看一下这个限价单 9876543210 的状态" | 状态 | 说明 | | ----------- | ---------------- | | `WORKING` | 等待触发价格 | | `TRIGGERED` | 价格达到,执行中 | | `PENDING` | 上链处理中 | | `FINISHED` | 执行成功 | | `FAILED` | 执行失败 | | `EXPIRED` | 已过期 | | `CANCELED` | 已取消 | ### 取消限价单 > "取消我的 BNB 限价买单" > "把所有挂单都取消掉" --- ## 场景五:预测市场 在预测市场中交易 — 浏览市场、下注结果、管理持仓、赎回收益。 ### 浏览市场 > "搜索体育类最热门的预测市场" > "加密货币类的预测市场有哪些?" ### 下注 > "在最近一期 BTC 15 分钟价格市场中买入'涨'" AI 获取报价后展示预期成本和回报,等待你确认后再下单。 ### 查看持仓与盈亏 > "我目前的预测持仓有哪些?" > "查看我的预测组合和未实现盈亏" > "我的预测交易历史" ### 赎回收益 > "有没有已经赢了可以领取的预测?" > "赎回我的预测收益" AI 检查 `PENDING_CLAIM` 状态的持仓并触发赎回。 ### 取消订单 > "取消我的待处理预测订单" | 状态 | 说明 | | ------------------ | -------------------- | | `PENDING` | 订单已创建,尚未提交 | | `SUBMITTED` | 已提交,等待执行 | | `FILLED` | 完全成交 | | `PARTIALLY_FILLED` | 部分成交 | | `CANCELLED` | 已被用户或系统取消 | | `FAILED` | 执行失败 | | `EXPIRED` | 市场结束导致过期 | --- ## 场景六:安全设置 安全设置仅在 Binance App 中修改,你可以随时通过 AI 查询当前配置: > "我现在的每日限额是多少?" > "我的可交易代币范围是什么?" > "异常交易是自动拒绝还是需要二次确认?" 如需修改:**Binance App → Agentic Wallet 管理页 → 右上角设置图标** --- ## 场景七:自动化交易策略 结合 Binance 已发布的 Wallet Skills(如 `meme-rush`、`trading-signal`、`query-token-info`、`query-token-audit`),你可以构建端到端的自动化交易策略。 > **提示:** 以下场景需安装对应的 Skills。从 > [binance-skills-hub](https://github.com/binance/binance-skills-hub/tree/main/skills/binance-web3) > 安装。 ### 策略一:Meme 代币狙击 利用 `meme-rush` 监控新上线或即将迁移的 Meme 代币,结合 `query-token-audit` 进行安全预检,确认安全后下单。 **示例对话:** > "Solana 上有哪些新上线的 Meme 代币?" AI 通过 `meme-rush` 返回处于 Bonding Curve 阶段的新代币列表。 > "帮我审计一下 XXX 这个代币的安全性" AI 通过 `query-token-audit` 返回风险评分、蜜罐检测、税率分析等。 > "看起来风险可控,用 50 USDT 买入" AI 确认后通过 Agentic Wallet 执行市价兑换。 --- ### 策略二:聪明钱跟单 利用 `trading-signal` 实时监控聪明钱买入信号,自动检查后跟进交易。 **基础用法:** > "最近有哪些聪明钱买入信号?" AI 通过 `trading-signal` 返回活跃信号,包括代币、触发价、当前价、最大涨幅等。 > "这个信号对应的代币安全吗?帮我查一下" AI 调用 `query-token-audit` 返回安全审计结果。 > "确认无误,用 50 USDT 买入" AI 通过 Agentic Wallet 执行交易。 **进阶用法 — 自动化跟单:** > "帮我每 5 分钟检查一次聪明钱信号,有新信号就自动审计,如果风险等级是 LOW 就用 50 USDT 买入" AI Agent 会设置定时任务,自动完成:拉取信号 → 安全审计 → 确认后交易。具体实现方式由 Agent 根据你的指令自行规划。 --- ### 策略三:热门叙事捕捉 利用 `meme-rush` 的 AI 叙事识别功能,发现当前市场热点,提前布局。 **示例对话:** > "现在什么叙事最火?资金流入最多的主题是什么?" AI 通过 `meme-rush` 返回按资金净流入排序的叙事主题。 > "这个叙事下有哪些代表性代币?" AI 返回相关代币列表及市场数据。 > "帮我查一下 XXX 的持币分布和流动性" AI 通过 `query-token-info` 返回代币详情、持币分析、流动性数据。 > "流动性够深,设置一个限价单:涨到 $1.2 时卖出 50%" AI 通过 Agentic Wallet 创建限价卖单。 --- ### 最佳实践 | 原则 | 说明 | | ------------ | --------------------------------------------------- | | **先查后买** | 任何非主流代币,交易前先用 `query-token-audit` 审计 | | **小额试水** | 新策略先用小额验证,确认流程无误后再放大 | | **设置止损** | 利用限价卖单设定止损点,避免被套 | | **分散风险** | 不要把所有资金押在单一代币或单一叙事上 | | **持续监控** | 定期检查限价单状态和持仓变化 | > ⚠️ **风险提示:** > 链上交易存在滑点、MEV 攻击、合约风险等。所有交易决策应基于你自己的研究(DYOR),Skills 仅提供信息和执行能力,不构成投资建议。 --- ## 下一步 - [Skills 参考](/products/agentic-wallet/reference/skills):Skills 能力的完整说明 - [支持的 Skills](/products/wallet-skills/supported-skills):查看所有可用的 Wallet Skills --- ## Document: 安装 Agentic Wallet URL: /zh-CN/docs/products/agentic-wallet/quickstart/install-agentic-wallet # 安装 Agentic Wallet 完成以下两步即可通过 AI 自然语言驱动链上操作。 --- ## 前置条件 **Node.js 18+**:Skills 安装程序需要 Node.js 18 或以上版本。 **Binance 账号 & MPC Wallet** 1. 您需要首先拥有一个币安账号 2. 注册登录好币安账号后,您需要先创建一个 App 端 MPC Wallet,从而拥有创建 Agentic Wallet 的权限 --- ## 第一步:安装 Skills ```bash npx skills add binance/binance-skills-hub/skills/binance-web3/binance-agentic-wallet ``` > 如果你尚未安装 `baw` CLI,Skills 会在第一次使用时自动完成安装。 --- ## 第二步:登录 安装完成后,在 AI Agent 中直接说: > "登录 Binance Agentic Wallet" Agent 会返回一个登录链接。如果您在移动端点击该链接,将直接跳转至 Binance App;如果您在网页端打开,则需要使用 Binance App 扫描二维码,并在 App 内确认登录。 如果这是您第一次登录,我们会在 Binance App 中为您走完整个标准创建流程,创建完成后,您会进入 Agentic Wallet 管理页。 如需登出,直接告诉 AI: > "退出登录" --- ## 安全设置建议 安全规则仅在 Binance App 中配置,AI 只能读取,无法修改。建议初次使用时: - 每日限额设置为较小金额(如 $50) - 可交易代币限定为有限代币范围 - 异常交易处理设为"需 App 二次确认" 如需修改:**Binance App → Agentic Wallet 管理页 → 右上角设置图标** --- ## 下一步 → [教程与使用场景](./use-agentic-wallet-tutorial-and-use-cases.md) --- ## Document: Skills 参考 URL: /zh-CN/docs/products/agentic-wallet/reference/skills # Skills 参考 `binance-agentic-wallet` Skill 通过 `baw` CLI 提供钱包管理和链上交易功能。 **支持链:** BNB Smart Chain (BSC)、Ethereum、Base、Solana --- ## Skill 文档结构 ``` binance-agentic-wallet/ ├── SKILL.md # 主文档:命令路由、安全策略、常用代币地址 └── references/ ├── preflight.md # 预检流程:Skill 版本检查、CLI 版本检查 ├── authentication.md # 登录/登出流程 ├── wallet-view.md # 钱包查询:状态、地址、余额、交易记录等 ├── wallet-setting.md # 安全设置(只读) ├── send.md # 代币转账 ├── market-order.md # 市价兑换 ├── limit-order.md # 限价单 ├── prediction.md # 预测市场交易 └── security.md # 交易前安全预检流程 ``` --- ## 主要功能 ### 钱包管理 查询钱包状态、地址、余额、交易记录、安全设置等。 ``` 我的钱包连接正常吗? 我的钱包地址是什么? 我有多少 BNB 和 USDT? 查一下我最近的交易记录 今天还剩多少可用额度? ``` ### 代币转账 向通讯录地址转账代币。收款地址须在 Binance App 通讯录中。 ``` 发送 0.02 BNB 到 0x1234...5678 转 10 USDT 给 0x1234...5678 ``` ### 市价兑换 获取报价或以当前市价执行代币兑换。支持自定义滑点和 MEV 保护。 ``` 把 0.1 BNB 换成 USDT 大概能换多少?只看报价 把 0.1 BNB 换成 USDT 用 50 USDT 买 BNB,滑点控制在 2% ``` ### 限价单 设定目标价格,价格到达时自动执行。 > **注意:** 限价单仅支持 BSC 和 Solana。 ``` BNB 价格跌到 $500 时,用 100 USDT 买入 BNB 涨到 $650 时,卖出 1 BNB 换 USDT 查看我的挂单 取消我的 BNB 限价单 ``` ### 预测市场 在预测市场中交易 — 浏览市场、下注结果、跟踪持仓、赎回收益。 ``` 搜索体育类最热门的预测市场 在最近一期 BTC 15 分钟价格市场中买入"涨" 我当前的预测持仓有哪些? 查看我的预测盈亏 赎回我的预测收益 取消我的待处理预测订单 ``` --- ## 相关页面 - [安装 Agentic Wallet](../quickstart/install-agentic-wallet.md) - [教程与使用场景](../quickstart/use-agentic-wallet-tutorial-and-use-cases.md) --- ## Document: WidgetSlot URL: /zh-CN/docs/products/mini-program/framework/components/WidgetSlot # WidgetSlot Slot for Widget **Example** bxml ```html ``` ## Props | Name | Type | Description | | ------- | -------- | ----------- | | `appid` | `string` | | | `path` | `string` | | | `props` | `object` |   | --- ## Document: WebView URL: /zh-CN/docs/products/mini-program/framework/components/WebView # WebView A container that hosts web pages. Will automatically cover the entire Mini Program page,**Personal type Mini Program is not supported for the time being.** **Example** ```js Page({ data: {}, onLoad(query) { console.log("onload", this, query); }, onShow() {}, onReady() {}, onWebViewLoad(e) { console.log("[WebView] onLoad", e.detail); }, onWebViewError(e) { console.log("[WebView] onError", e.detail); }, async onWebViewMessage(e) { await bn.showModal({ title: "Message From WebView", content: JSON.stringify(e.detail.data), }); bn.createSelectorQuery() .select(".web-view") .context((result) => { result.context.postMessage("hey!"); }) .exec(); }, }); ``` **Bug & Tip** - `tip`:Inside the page iframe The domain name also needs to be configured into the domain whitelist. - `tip`: On the developer tools, you can web-view Component by right-clicking - Debug, Open web-view Component debugging. - `tip`: Each page can have only one web-view,web-view Automatically covers the entire page and overwrites other components. - `tip`: web-view Division between web pages and Mini Programs is not supported JSSDK Provides communication beyond the interface provided by. - `tip`: Avoid Chinese characters in links, and iOS There will be a problem to open the white screen, it is recommended to add EncodeURIComponent ## Props | Name | Type | Description | Default | | ----------------- | --------- | ------------------------------------------------------------------------------------------- | ------- | | `src` | `string` | webview A link to a web page. | | | `injected` | `unknown` | js script file to be injected before jump to any pages. | | | `bounce` | `boolean` | | `true` | | `loading-bar` | `boolean` | | `true` | | `web-preferences` | `object` | | | | `hidden` | `boolean` | whether the webview is hidden | `false` | | `handle-error` | `boolean` | whether js has handled error or not. If true, native will show an error page. Default false | `false` | --- ## Document: View URL: /zh-CN/docs/products/mini-program/framework/components/View # View View container **Example** bxml ```html {{msg}} ``` js ```js Page({ data() { return { msg: "view container", }; }, touchstart() { console.log("touchstart"); }, }); ``` ## Props | Name | Type | Description | Default | | ------------------------ | --------- | -------------------------------------------------------------------------------------------------- | -------- | | `hover-class` | `string` | Specifies the style class to press down on. when hover-class="none" There is no click state effect | `"none"` | | `hover-stop-propagation` | `boolean` | Specifies whether to prevent this node's ancestor from clicking | `false` | | `hover-start-time` | `number` | How long does it take to click, in milliseconds? | `50` | | `hover-stay-time` | `number` | Click hold time after finger release, in milliseconds | `400` | | `catch-move` | `boolean` | prevent scroll event's propagation | `false` | | `no-drag-propagation` | `boolean` | prevent scroll event's propagation jssdk > 4.33.0 | `false` | ## Events | Name | Description | | ---------------- | ---------------------- | | `bindtouchstart` | Touch start event trap | --- ## Document: Video URL: /zh-CN/docs/products/mini-program/framework/components/Video # Video Video support Same-layer rendering. Related api:bn.createVideoContext **Example** ```js Page({ data: { id: "myVideo", }, onLoad(query) { console.log("onload", this, query); }, onShow() { console.log(`[LifeCycle][Textarea] useEffect`); setTimeout(() => { if (!this.videoContext) throw new Error("Missing VideoContext"); this.videoContext.play(); }, 500); }, onReady() { this.videoContext = bn.createVideoContext("myVideo"); }, onPlay(e) { console.log("[video] onPlay", e); }, onPause(e) { console.log("[video] onPause", e); }, onEnded(e) { console.log("[video] onEnded", e); }, onTimeupdate(e) { console.log("[video] onTimeupdate", e); }, onFullscreenchange(e) { console.log("[video] onFullscreenchange", e); }, onLoadedmetadata(e) { console.log("[video] onLoadedmetadata", e); }, onError(e) { console.log("[video] onError", e); }, }); ``` **Bug & Tip** - tip:video Default width 300px, altitude 225px, available via bxss Set the width and height. ## Props | Name | Type | Description | Default | | ---------------- | --------- | ----------------------------------------------------------------------------------- | ------- | | `id` | `string` | | | | `src` _required_ | `string` | Resource address to play video, support network path, local temporary path | | | `playsinline` | `boolean` | Whether to play inline | `false` | | `controls` | `boolean` | Whether to display the default playback controls/Pause on, playback progress, time) | `true` | | `autoplay` | `boolean` | Whether to autoplay | `false` | | `loop` | `boolean` | Whether to play on a loop | `false` | | `muted` | `boolean` | Mute Play | `false` | | `poster` | `string` | The image displayed before playing the video | `""` | ## Events | Name | Description | | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | | `bindplay` | When it starts/Triggers play event while continuing playback | | `bindpause` | Triggered when playback is paused pause event | | `bindended` | Triggered when playback is paused pause event | | `bindtimeupdate` | Triggered when playback progress changes, event. detail = {currentTime, duration} Trigger frequency. 250ms first | | `bindfullscreenchange` | Triggered when video enters and exits full-screen, event.detail = {fullScreen, direction},direction Valid values are vertical or horizontal | | `binderror` | Triggered when video playback goes wrong | --- ## Document: textarea URL: /zh-CN/docs/products/mini-program/framework/components/TextArea # textarea ## Props | Property | Type | Default Value | Required | Description | | ---------------------------- | ------------- | ---------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | value | String | | | The initial content in the input box. | | placeholder | String | | | The placeholder used when the input box is empty. | | placeholderStyle | String | | | Specifies the style of the placeholder. Only color, font-size, and font-weight styles are supported. | | placeholderClass | String | `textarea-placeholder` | | Specifies the style class of the placeholder. | | disabled | Boolean | `false` | | Specifies whether to disable the component. | | maxlength | Number | `140` | | The maximum length. When it is set to `-1`, the maximum length is not limited. | | autoFocus | Boolean | `false` | | (Will be discarded soon. Use the focus instead.) Auto focus. The keyboard is automatically displayed. | | focus | Boolean | `false` | | Gets focus. | | autoHeight | Boolean | `false` | | Specifies whether the height automatically increases. If this property is specified, style.height does not take effect. | | fixed | Boolean | `false` | | If the textarea is in an area of `position:fixed`, the value of the specified property should always be true. | | cursorSpacing | Number | `0` | | Specifies the distance between the cursor and the keyboard. It is either the distance between `textarea` and the bottom of the screen or the distance specified via `cursorSpacing`, whichever is smaller. | | cursor | Number | `-1` | | Specifies the cursor position during focusing. | | showConfirmBar | Boolean | `true` | | Specifies whether to display the bar containing the `Done` button above the keyboard. | | selectionStart | Number | `-1` | | The start position of the cursor. It takes effect only during auto focusing, and needs to used with selection-end. | | selectionEnd | Number | `-1` | | The end position of the cursor. It takes effect only during auto focusing, and needs to used with selection-start. | | adjustPosition | Boolean | `true` | | Specifies whether to automatically push up the page when the keyboard is displayed. | | holdKeyboard | Boolean | `false` | | Specifies whether to hide the keyboard when clicking page while the input is focused. | | disableDefaultPadding | Boolean | `false` | | Specifies whether to remove the default padding behavior on iOS. | | confirmType | String | `return` | | Sets the text on the lower-right button on the keyboard. It takes effect only when type='text'. | | confirmHold | Boolean | `false` | | Specifies whether the keyboard is not hidden when the lower-right button on the keyboard is tapped. | | onInput | Event handler | | | Triggered when the user taps the keyboard. `event.detail = { value, cursor, keyCode }`, where keyCode is the key value.box. | | onFocus | Event handler | | | Triggered when the input box is focused. `event.detail = { value, height }` | | onBlur | Event handler | | | Triggered when the input box is unfocused. `event.detail = { value, cursor }`. | | onLineChange | Event handler | | | Called when the number of lines in the input box changes. `event.detail = { height: number, heightRpx: number, lineCount: number }` | | onConfirm | Event handler | | | Triggered when the Done button is tapped. `event.detail = { value }`. | | onKeyboardHeightChange | Event handler | | | Triggered when the height of the keyboard changes. `event.detail = { height, duration}`. | | keyboardAccessoryItems | String[] | | | The array of keyboard accessory items, the items'length must be 2-5 | | onKeyboardAccessoryItemClick | Event handler | | | Triggered when the accessory item is clicked. `event.detail = { index }`. | #### Valid values of `confirm-type` | Value | Description | | -------- | -------------------------------------------------------------- | | `send` | Indicates that the button in the lower right corner is Send. | | `search` | Indicates that the button in the lower right corner is Search. | | `next` | Indicates that the button in the lower right corner is Next. | | `go` | Indicates that the button in the lower right corner is GO. | | `done` | Indicates that the button in the lower right corner is Done. | | `return` | Indicates that the button in the lower right corner is Return. | ### bug & tips - `tip`: if developer need change the caret-color of input component, developer should use css class to set it instead of inline style - `tip`: keyboardAccessoryItems's length must be 2-5 , otherwise the ui will be abnormal , and the onKeyboardAccessoryItemClick can listen the click event of the accessory item **Example** ```html ``` --- ## Document: Text URL: /zh-CN/docs/products/mini-program/framework/components/Text # Text Text component for mp **Example** bxml ```html {{text}} ``` js ```js const texts = ["2017 we created a new world", "2018 we have a group of people", "2019 we have become a family", "2020 most of us are happy"]; Page({ onShareAppMessage() { return { title: "text", path: "page/component/pages/text/text", }; }, data: { text: "", canAdd: true, canRemove: false, }, extraLine: [], add() { this.extraLine.push(texts[this.extraLine.length % 12]); this.setData({ text: this.extraLine.join("\n"), canAdd: this.extraLine.length < 12, canRemove: this.extraLine.length > 0, }); setTimeout(() => { this.setData({ scrollTop: 99999, }); }, 0); }, remove() { if (this.extraLine.length > 0) { this.extraLine.pop(); this.setData({ text: this.extraLine.join("\n"), canAdd: this.extraLine.length < 12, canRemove: this.extraLine.length > 0, }); } setTimeout(() => { this.setData({ scrollTop: 99999, }); }, 0); }, }); ``` ##### `Tips` & `Bug`: - Decode can be parsed with ` ` `<` `>` `&` `&apos` `&ensp` `&emsp` - The standard of whitespace is not consistent across operating systems. ## Props | Name | Type | Description | Default | | ------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------- | ------- | | `user-select` | `boolean` | Whether the text is optional, this property causes the text node to display as inline-block | `false` | | `decode` | `boolean` | Whether to decode | `false` | | `space` | `'ensp'` | `'emsp'` | `'nbsp'` | Display continuous spaces |   | ## Events | Name | Description | | ---------- | ----------- | | `bindcopy` |   | --- ## Document: Switch URL: /zh-CN/docs/products/mini-program/framework/components/Switch # Switch Switch selector. **Example** js ```js var pageData = { data: { switch1Checked: true, switch2Checked: false, switch1Style: "", switch2Style: "text-decoration: line-through", }, }; for (var i = 1; i <= 2; ++i) { (function (index) { pageData[`switch${index}Change`] = function (e) { console.log(`switch${index}发生change事件,携带值为`, e.detail.value); var obj = {}; obj[`switch${index}Checked`] = e.detail.value; this.setData(obj); obj = {}; obj[`switch${index}Style`] = e.detail.value ? "" : "text-decoration: line-through"; this.setData(obj); }; })(i); } Page(pageData); ``` bxml ```html switch 开关 type="switch" type="checkbox" ``` **Bug & Tip** - `tip`: When switching type comes with vibration feedback in iOS, can be set in the system -> Sound and touch -> System Tactile Feedback Shut Down ## Props | Name | Type | Description | Default | | ---------- | --------- | -------------------------------- | -------------------- | | `checked` | `boolean` | If selected | `false` | | `disabled` | `boolean` | Is it disabled? | `false` | | `color` | `string` | Switch The color of css of color | `var(--bnui-primay)` | ## Events | Name | Description | | ---------------- | ----------------------------------------------------------------------- | | `bindtap` | Tap event for the switch | | `bindtapcapture` | Tap capture event | | `bindchange` | checked Triggered when changed change Events, event.detail = `{ value}` | --- ## Document: SwiperSlide URL: /zh-CN/docs/products/mini-program/framework/components/SwiperItem # SwiperSlide Only can be placed inswiper component, width and height are automatically set to 100%. ## Props | Name | Type | Description | Default | | ------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | | `item-id` | `string` | The id flag of the swiper item | | | `skip-hidden-item-layout` | `boolean` | Whether to skip the undisplayed slider layout, set to true Improves sliding performance in complex situations, but loses layout information for hidden state sliders | `false` | --- ## Document: swiper URL: /zh-CN/docs/products/mini-program/framework/components/Swiper # swiper swiper item container. Only the swiper-item component can be placed in it, otherwise it will cause undefined problem. **Example** bxml ```html Default Style {{item}} indicatorColor: indicatorActiveColor: current: easingFunction: interval: duration: displayMultipleItems: ``` bxss: ```css .bn-swiper-item { background: red; } .options_line { width: 100%; display: flex; flex-direction: row; justify-content: space-between; } .options_btn { margin-top: 0; } .options_input { width: 100px; border: 1px solid #282828; border-radius: 4px; padding: 2px 12px; line-height: 1.6; font-size: 14px; font-weight: normal; box-sizing: border-box; } ``` js ```js Page({ data: { bgColorGroups: ['yellow', 'red', 'orange', 'green'], indicatorDots: true, isAutoplay: false, circular: true, vertical: false, indicatorColor: 'white', indicatorActiveColor: 'black', // * current: 0, easingFunction: this.easingFunction, displayMultipleItems: 1, indicatorColorInput: 'white', indicatorActiveColorInput: 'black', currentInput: 0, easingFunctionInput: 'linear', interval: 3000, intervalInput: 3000, duration: 200, durationInput: 200, displayMultipleItemsInput: 1, autoHeight: false, }, onLoad(query) { console.log('onload', this, query) }, onShow() { console.log('onShow', this.data) }, onReady() { console.log('onReady') }, onHide() { console.log('onHide') }, onTabItemTap(payload) { console.log('onTabItemTap', payload) }, // swiper page method onAutoPlayChange: function() { this.setData({ isAutoplay: !this.data.isAutoplay }) }, onCircularChange() { this.setData({ circular: !this.data.circular }) }, onVerticalChange() { this.setData({ vertical: !this.data.vertical }) }, onIndicatorDotsChange() { this.setData({ indicatorDots: !this.data.indicatorDots }) }, onIndicatorColorInput(e) { this.setData({ indicatorColorInput: e.detail.value }) }, onIndicatorColorClick() { this.setData({ indicatorColor: this.data.indicatorColorInput }) }, onIndicatorActiveColorInput(e) { this.setData({ indicatorActiveColorInput: e.detail.value }) }, onindicatorActiveColorClick() { this.setData({ indicatorActiveColor: this.data.indicatorActiveColorInput }) }, onCurrentinputInput(e) { this.setData({ currentInput: Number(e.detail.value) }) }, onCurrentinputClick() { this.setData({ current: this.data.currentInput }) }, onEasingFunctioninputInput(e) { this.setData({ easingFunctionInput: e.detail.value }) }, onEasingFunctioninputClick() { this.setData({ easingFunction: this.data.easingFunctionInput }) }, onIntervalinputInput(e) { this.setData({ intervalInput: Number(e.detail.value) }) }, onIntervalinputClick() { this.setData({ interval: this.data.intervalInput }) }, onDurationinputInput(e) { this.setData({ durationInput: Number(e.detail.value) }) }, onDurationinputClick() { this.setData({ duration: this.data.durationInput }) }, onDisplayMultipleItemsinputInput(e) { this.setData({ displayMultipleItemsInput: e.detail.value }) }, onDisplayMultipleItemsinputClick() { this.setData({ displayMultipleItems: this.data.displayMultipleItemsInput }) }, onAddBgColorGroupsClick() { const newBgColorGroups = [...this.data.bgColorGroups] newBgColorGroups.push("black") this.setData({ bgColorGroups: newBgColorGroups }) }, onRemoveBgColorGroupsClick() { const newBgColorGroups = [...this.data.bgColorGroups] newBgColorGroups.length > 0 && newBgColorGroups.pop() this.setData({ bgColorGroups: newBgColorGroups }) }, onChange(e) { console.log('[View] onClick', e) }, onTransition(e) { console.log('[View] onLongPress', e) }, onAnimationfinish(e) { console.log('[View] onTouchStart', e) }, }) ``` ## Props | Name | Type | Description | Default | | ----------------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | | `indicator-dots` | `boolean` | whether to display panel indicator points | `false` | | `indicator-color` | `string` | color of indicator | `"rgba(0, 0, 0, .3)"` | | `indicator-active-color` | `string` | color of active indicator | `"#000000"` | | `autoplay` | `boolean` | autoplay or not | `false` | | `current` | `number` | the index of current swiper | `0` | | `interval` | `number` | interval when using autoplay | `5000` | | `duration` | `number` | swipe animation duration | `500` | | `circular` | `boolean` | when last one finished, whether turn to the first one | `false` | | `vertical` | `boolean` | vertical or not(horizontal) | `false` | | `previous-margin` | `string` | exposing a small part of the previous item (child element setting width/height: 100%; set img's width/height: inherit) | `"0px"` | | `next-margin` | `string` | exposing a small part of the next item (child element setting width/height: 100%; set img's width/height: inherit) | `"0px"` | | `snap-to-edge` | `boolean` | When the number of swiper-items is greater than or equal to 2, circular is turned off and previous-margin or next-margin is turned on, you can specify that this margin is applied to the first and last element | `false` | | `display-multiple-items` | `number` | | `1` | | `easing-function` | `EasingFunctionName` | currently supported easingFunction: default,linear,easeInCubic,easeOutCubic,easeInOutCubic | `"default"` | | `rtl` | `boolean` | Right-to-left sliding mode default value is false | `false` | | `touch-start-prevent-default` | `boolean` | Whether to prevent default behavior when touch start | `true` | | `auto-height` | `boolean` | Auto height swiper - adjusts wrapper and container height to the height of the currently active slide | `false` | ## Events | Name | Description | | --------------------- | --------------------------------------------------------------------------------------------------------------- | | `bindchange` | The change event is fired when the current changes,event.detail = {current, source} | | `bindtransition` | The transition event is triggered when the position of the swiper-item changes,event.detail = {dx: dx, dy: dy} | | `bindanimationfinish` | Triggered when the animation finished,event.detail = {current, source} | --- ## Document: svg URL: /zh-CN/docs/products/mini-program/framework/components/Svg # svg builtin svg component, will render raw svg tag **Example** js ```js Page({ data: { localImage: "pages/tabbar/component/resources/pic/1.jpg", remoteImage: "https://static.devfdg.net/image/julia/pie-chart-currentcolor.svg", colorChanged: false, svgStyle: "", colorClassChanged: false, colorClass: "", boxattrsChanged: false, boxattrs: { width: "48px", height: "48px" }, }, onChangeColor(e) { console.log(`[Svg] onChangeColor `, e); if (!this.data.colorChanged) { this.setData({ colorChanged: true, svgStyle: "color: #d22f2f;" }); } else { this.setData({ colorChanged: false, svgStyle: "" }); } }, onChangeBoxAttr() { if (!this.data.boxattrsChanged) { this.setData({ boxattrsChanged: true, boxattrs: { width: "96px", height: "96px" }, }); } else { this.setData({ boxattrsChanged: false, boxattrs: { width: "48px", height: "48px" }, }); } }, }); ``` bxml ```html color change box attributes boxattrs: {{ boxattrs }} box attributes priority set width & height at attribute with 48px set width & height at style with 96px svg will be 96px; set width & height at attribute with 96px svg will be 96px; data url demo ``` ### Bug & Tip - `tip`: for keep same code between webview and flutter, recommand not use class to custom svg style - `tip`: not support fully svg feature (document not ready) - `tip`: could use data-url format and pass by `src`. supported schema `text/html`, `image/svg+xml` (don't forget encode url content) - `tip`: style `width` and `height` have more priority than attribute `width` and `height` - `tip`: for `padding` and `margin`, we recommand only use `margin` for better compatibility in webview and flutter :::warn cannot direct receive svg content as child, eg `xxxx`, use `src` instead ::: - **remark** - required jssdk >= 4.37.6 - **remark** - required bundlerversion >= 3.0.112 - **remark** - if use from uikit, need config RootProvider's `iconConfig` with `svgTag: true` ## Props | Name | Type | Description | Default | | ---------------- | --------- | ------------------------------------------------------------------ | ------- | | `style` | `string` | container style | `""` | | `svg-style` | `string` | inner svg tag style | `""` | | `src` _required_ | `string` | resource url, could be remote or local | | | `width` | `string` | fit svg tag `width` attribute, lower priority than `style.width` | | | `height` | `string` | fit svg tag `height` attribute, lower priority than `style.height` | | | `no-sanitize` | `boolean` | determine should skip sanitize |   | --- ## Document: StickySectionr URL: /zh-CN/docs/products/mini-program/framework/components/StickySection # StickySectionr StickySection container msv >= 4.35 **Example** bxml ```html ``` ## Props | Name | Type | Description | Default | | -------------------- | --------- | -------------------------------------------------------------------------------------------------- | ----------- | | `push-pinned-header` | `boolean` | Specifies the style class to press down on. when hover-class="none" There is no click state effect | `true` | | `padding` | `array` | Specifies whether to prevent this node's ancestor from clicking | `[0,0,0,0]` | --- ## Document: StickyHeader URL: /zh-CN/docs/products/mini-program/framework/components/StickyHeader # StickyHeader StickyHeader container msv >= 4.35 **Example** bxml ```html ``` ## Props | Name | Type | Description | Default | | ------------ | -------- | -------------------------------------------------------------------------------------------------- | ----------- | | `offset-top` | `number` | Specifies the style class to press down on. when hover-class="none" There is no click state effect | `0` | | `padding` | `array` | Specifies whether to prevent this node's ancestor from clicking | `[0,0,0,0]` | --- ## Document: SortableItem URL: /zh-CN/docs/products/mini-program/framework/components/SortableItem # SortableItem Only can be placed in Sortable component --- ## Document: SortableHandle URL: /zh-CN/docs/products/mini-program/framework/components/SortableHandle # SortableHandle Only can be placed in SortableItem component,to support handle drag and drop gesture --- ## Document: Sortable URL: /zh-CN/docs/products/mini-program/framework/components/Sortable # Sortable A sortable list component that supports drag-and-drop sorting **Example** bxml ```html btc {{item.title}} data: {{index}}: {{item.title}} ``` js ```js Page({ data: { list: [ { title: "eth", icon: "https://bin.bnbstatic.com/image/admin_mgs_image_upload/20201110/3a8c9fe6-2a76-4ace-aa07-415d994de6f0.png", }, { title: "bnb", icon: "https://bin.bnbstatic.com/image/admin_mgs_image_upload/20220218/94863af2-c980-42cf-a139-7b9f462a36c2.png", }, { title: "xrp", icon: "https://bin.bnbstatic.com/image/admin_mgs_image_upload/20201110/4766a9cc-8545-4c2b-bfa4-cad2be91c135.png", }, { title: "sol", icon: "https://bin.bnbstatic.com/image/admin_mgs_image_upload/20230404/b2f0c70f-4fb2-4472-9fe7-480ad1592421.png", }, { title: "ada", icon: "https://bin.bnbstatic.com/image/admin_mgs_image_upload/20230404/b2f0c70f-4fb2-4472-9fe7-480ad1592421.png", }, { title: "ltc", icon: "https://bin.bnbstatic.com/image/admin_mgs_image_upload/20230404/b2f0c70f-4fb2-4472-9fe7-480ad1592421.png", }, { title: "trx", icon: "https://bin.bnbstatic.com/image/admin_mgs_image_upload/20230404/b2f0c70f-4fb2-4472-9fe7-480ad1592421.png", }, { title: "bch", icon: "https://bin.bnbstatic.com/image/admin_mgs_image_upload/20230404/b2f0c70f-4fb2-4472-9fe7-480ad1592421.png", }, { title: "bsv", icon: "https://bin.bnbstatic.com/image/admin_mgs_image_upload/20230404/b2f0c70f-4fb2-4472-9fe7-480ad1592421.png", }, ], }, onReorder(e) { const { oldIndex, newIndex } = e.detail; const list = this.data.list; const item = list.splice(oldIndex, 1)[0]; list.splice(newIndex, 0, item); this.setData({ list }); bn.showToast({ title: `from ${oldIndex} to ${newIndex}` }); }, }); ``` bxss ```css .handle { height: 20px; width: 20px; display: flex; flex-direction: column; justify-content: center; align-items: center; } .icon { width: 20px; height: 20px; margin-right: 4px; } .left { display: flex; flex-direction: row; align-items: center; justify-content: center; } .line { width: 13px; height: 2.5px; background-color: #929aa5; margin-bottom: 3px; } .disable { background-color: pink; } .line2 { margin-bottom: 0; } .item { height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 0 15px; font-size: 16px; line-height: 24px; background-color: white; } .app { height: 100vh; width: 100vw; background: #f0f0f0; } .title { width: 100%; height: 40px; display: flex; justify-content: center; align-items: center; font-size: 16px; line-height: 24px; font-weight: bold; } ``` - **remark** - supported jssdk >= 4.37.0 - **remark** - The configuration of being fixed at the top and not draggable is not supported. If you have similar requirements, please use two lists to implement it. - **remark** - If you use Pika to develop miniprogram, please do not use state to control sorting when using the Sortable component. React does not work well with sortablejs yet. Please use React ref to store the latest sorting state. ## Props | Name | Type | Description | Default | | ---------------------- | --------- | ---------------------------------------------------------- | ------- | | `enable-vibrate-short` | `boolean` | whether to enable vibration feedback | `true` | | `direction` | `string` | Set gesture direction, support x-axis/y-axis/free dragging | `"y"` | ## Events | Name | Description | | ------------- | ------------------------------------------------------------------------------- | | `bindreorder` | Triggered when the dragging item dropped,event.detail = { oldIndex, newIndex } | --- ## Document: slider URL: /zh-CN/docs/products/mini-program/framework/components/Slider # slider Slider. **Example** bxml: ```html Set step disabled Display current value Set min/max value controlled normal Taroslider with position: relative ``` js ```js Page({ data: { controlledValue: 50, }, sliderChange(e) { console.log("slider fire change event,value:", e.detail.value); }, sliderClick(e) { console.log("slider fire click event,value:", e.detail.value); }, sliderLonePress(e) { console.log("slider fire lonePress event,value:", e.detail.value); }, onControlledValueChange(e) { console.log("slider fire change event,value:", e.detail.value); this.setData({ controlledValue: e.detail.value, }); }, }); ``` ## Props | Name | Type | Description | Default | | ------------------ | --------- | -------------------------------------------------------------- | ------------------------ | | `min` | `number` | Least value | `0` | | `max` | `number` | Maximum value | `100` | | `step` | `number` | Step size must be greater than 0 and can be(Max - Min) integer | `1` | | `disabled` | `boolean` | Is it disabled? | `false` | | `value` | `number` | Current value | | | `show-value` | `boolean` | Displays current value | `false` | | `active-color` | `string` | Selected color | `\`var(--bnui-primay)\`` | | `background-color` | `string` | Background Bar Color | `"#e9e9e9"` | ## Events | Name | Description | | ---------------- | ------------------------------------------------------------------------------ | | `bindchange` | `bindchange` Event triggered after completing a drag, event.detail = `{value}` | | `bindchanging` | `bindchaning` Event triggered during drag, event. detail = `{value}` | | `bindtap` | `bindtap` Event tap | | `bindtapcapture` | `bindtapcapture` Event tap | --- ## Document: scroll-view URL: /zh-CN/docs/products/mini-program/framework/components/ScrollView # scroll-view Scrollable view area. A view group that allows the view hierarchy placed within it to be scrolled. When using vertical scrolling, you need to give the scroll view a fixed height. **Example** bxml ```html scrollY Vertical Scroll scroll-x="{{true}}" Horizontal Scroll scroll-y ScrollIntoView 2 item scroll-x ScrollIntoView 2 item Vertical Scroll with infinite scroll enhanced, fastDeceleration ``` bxss ```css .page-section-spacing { margin-top: 30px; } .scroll-view_H { white-space: nowrap; } .scroll-view-item { height: 150px; } .scroll-view-item_H { display: inline-block; width: 100%; height: 150px; } .demo-text-1 { position: relative; align-items: center; justify-content: center; background-color: #1aad19; color: #ffffff; font-size: 18px; } .demo-text-1:before { content: "A"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } .demo-text-2 { position: relative; align-items: center; justify-content: center; background-color: #2782d7; color: #ffffff; font-size: 18px; } .demo-text-2:before { content: "B"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } .demo-text-3 { position: relative; align-items: center; justify-content: center; background-color: #f1f1f1; color: #353535; font-size: 18px; } .demo-text-3:before { content: "C"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } ``` js ```js Page({ data: { items: new Array(3).fill(1), scrollTop: 25, scrollIntoView: "demo3", }, onShow() { setTimeout(() => { this.setData({ scrollTop: 50, scrollIntoView: "demo2", }); }, 3000); }, onScroll(e) { console.log("onScroll", e); }, onScrollToUpper(e) { console.log("onScrollToUpper", e); }, onScrollToLower(e) { console.log("onScrollToLower", e); }, onTap(e) { console.log(`[scroll-view] bindtap`, e); }, onLongpress(e) { console.log(`[scroll-view] longpress`, e); }, scrollToTop() {}, loadMore() { this.setData({ items: [...this.data.items, ...new Array(3).fill(1)], }); }, }); ``` **Bug & Tip** - `tip`: The priority of scroll-into-view is higher than that of scroll-top. - `tip`: Scrolling in the scroll-view will prevent the page from bouncing back, so scrolling in the scroll-view cannot trigger onpulldownrefresh. - `tip`: To use the pull-down refresh, please use the scroll of the page instead of the scroll-view, so that you can return to the top of the page by clicking the status bar at the top. ## Props | Name | Type | Description | Default | | ---------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------ | | `scroll-x` | `boolean` | Allow lateral scrolling | `false` | | `scroll-y` | `boolean` | Allow vertical scrolling | `false` | | `scroll-top` | `string` | `number` | Set vertical scroll bar position | | | `scroll-left` | `string` | `number` | Set horizontal scroll bar position | | | `scroll-into-view` | `string` | The value should be the ID of a child element (ID cannot start with a number). Set which direction to scroll, then scroll to the element in which direction | | | `scroll-into-view-alignment` | `string` | set alignment of target view when scroll into the view, support from jssdk >= 4.17.0 | `"start"` | | `upper-threshold` | `string` | `number` | When it is far from the top / left, the scrolltupper event is triggered | `50` | | `lower-threshold` | `string` | `number` | When it is far from the bottom / right, the scrollcolor event is triggered | `50` | | `enhanced` | `boolean` | Enable the scroll view enhancement feature. After enabling, you can operate scroll view through ScrollViewContext | `false` | | `fast-deceleration` | `boolean` | Sliding deceleration rate control (effective after the enhanced attribute is turned on at the same time) | `false` | | `show-scrollbar` | `boolean` | Enabled when enhanced:true, control the scrollbar show/hide | `true` | | `refresher-enabled` | `boolean` | Enable pull-down refresh, support from jssdk >= 4.9.0 | `false` | | `refresher-threshold` | `number` | refresher threshold to trigger refresh (in px), support from jssdk >= 4.9.0 | `45` | | `refresher-default-style` | `string` | refresher default style, support from jssdk >= 4.9.0 options: black, white, none | `"black"` | | `refresher-background` | `string` | refresher background style, support from jssdk >= 4.9.0 | `"#FFF"` | | `refresher-triggered` | `boolean` | is refresher triggered, support from jssdk >= 4.9.0 | `false` | | `scroll-anchoring` | `boolean` | solve the problem of content jumping from jssdk >= 4.14.0 | | | `scroll-with-animation` | `boolean` | Use animation transitions when setting scroll bar position, support from jssdk >= 4.17.0 | `false` | | `scroll-speed-limit` | `number` | Scroll pixels per millisecond, Limit scroll speed, support from jssdk >= 4.18.0 | `"Infinity"` | | `type` | `string` | Skyline props for better long list performance, support from jssdk >= 4.31.0 | | | `extra` | `object` | Business related-custom data, support from jssdk >= 4.32.0 | | | `bounces` | `boolean` | | `true` | | `virtual-list-buffer` | `number` | | `250` | | `enable-back-to-top` | `boolean` | Enables the scroll bar to return to the top when the top status bar is tapped on iOS or the title bar is double-tapped on Android. Only vertical scrolling is supported. iOS support from jssdk >= 4.44.0, Android should support from jssdk >= 4.45.0 | `false` | ## Events | Name | Description | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `bindscroll` | `bindscroll` Triggered when scrolling,
**Arguments**
  • **`event: detail: Object`** — The detail event object`Object{ scrollLeft, scrollTop, scrollHeight, scrollWidth, scrollWidth, deltaX, deltaY }`
| | `bindscrollstart` | `bindscrollstart` Triggered when scroll start, support msv >= 4.36.0
**Arguments**
  • **`event: detail: Object`** — The detail event object`Object{ scrollLeft, scrollTop, scrollHeight, scrollWidth, scrollWidth }`
| | `bindscrollend` | `bindscrollend` Triggered when scroll end, support msv >= 4.36.0
**Arguments**
  • **`event: detail: Object`** — The detail event object`Object{ scrollLeft, scrollTop, scrollHeight, scrollWidth, scrollWidth }`
| | `bindscrolltoupper` | `bindscrolltoupper` Scroll to the top/Triggered on the left | | `bindscrolltolower` | `bindscrolltolower` Scroll to the bottom/Triggered on the right | | `bindrefresherpulling` | `bindrefresherpulling` Triggered when pulling down | | `bindrefresherrefresh` | `bindrefresherrefresh` Triggered when refreshing | | `bindrefresherrestore` | `bindrefresherrestore` Triggered when pull-down refresher restoring | | `bindrefresherabort` | `bindrefresherabort` Triggered when refresh aborting | | `bindvirtuallistitemupdate` | `bindvitruallistitemupdate` Triggered when virtual list mounted item update | --- ## Document: ScrollViewItem URL: /zh-CN/docs/products/mini-program/framework/components/ScrollItem # ScrollViewItem ## Props | Name | Type | Description | | ---------- | -------- | ------------------------------------------------------ | | `item-key` | `string` | Required. Need an unique key to calculate virtual list | --- ## Document: root-portal URL: /zh-CN/docs/products/mini-program/framework/components/RootPortal # root-portal Makes the entire subtree off the page, similar to using fixed position in CSS. It is mainly used to make pop-up windows, pop-up layers, etc. **Example** bxml ```html I'm a dialog ``` js ```js Page({ data() { return { enable: true, }; }, }); ``` when use bn.createSelectorQuery, you may not get the dom in . add a second parameter in select funtion will make it work. **Example** ````html ``` ts bn.createSelectorQuery() .select('#canvas', { rootPortal: true }}) .fields({ node: true, size: true }) .exec(res => { const canvas = res[0].node const ctx = canvas.getContext('2d') ctx.fillRect(0, 0, 100, 100) }) ```` ## Props | Name | Type | Description | Default | | -------- | --------- | ------------------------------ | ------- | | `enable` | `boolean` | whether detached from the page | `true` | --- ## Document: rich-text URL: /zh-CN/docs/products/mini-program/framework/components/RichText # rich-text rich text component. **Example** bxml ```html Select a space:  {{space || "default"}} HTML string