Binance P2P Trading Skill
Help users interact with Binance P2P (C2C) via natural-language queries.
When to Use / When NOT to Use
Use this skill when the user wants to:
- - Check P2P buy/sell quotes for a crypto/fiat pair (e.g., USDT/CNY).
- Search P2P advertisements and filter by payment method(s), limits, merchant quality.
- Compare prices across payment methods (e.g., Alipay vs bank transfer).
- View their own P2P order history / summary (requires API key).
Do NOT use this skill when the user asks about:
- - Spot/Convert prices, futures/derivatives, margin, trading bots.
- Deposits/withdrawals, wallet transfers, on-chain transactions.
- Creating/cancelling orders, appeals, releasing coins (trading operations).
Ask clarifying questions (do not guess) if any key inputs are missing:
- -
fiat (e.g., CNY) - INLINECODE1 (e.g., USDT)
- user intent: buy crypto or sell crypto
- preferred payment method(s)
- target amount (optional but recommended for ad filtering)
Core Concepts
tradeType mapping (avoid ambiguity)
- - User wants to buy crypto (pay fiat, receive USDT/BTC) → INLINECODE3
- User wants to sell crypto (receive fiat, pay USDT/BTC) → INLINECODE4
Always reflect this mapping in responses when the user’s wording is ambiguous.
Capabilities
Phase 1 — Public Market (No Auth)
- - Quote P2P prices
- Search ads
- Compare payment methods
- Filter/Rank ads by limits and merchant indicators
Phase 2 — Personal Orders (Requires API Key)
- - List P2P order history
- Filter by trade type / time range
- Provide summary statistics
Security & Privacy Rules
Credentials
-
BINANCE_API_KEY (sent as header)
-
BINANCE_SECRET_KEY (used for signing)
Never display full secrets
- - API Key: show first 5 + last 4 characters: INLINECODE7
- Secret Key: always mask; show only last 5: INLINECODE8
Permission minimization
- - Binance API permissions: Enable Reading only.
- Do NOT request/encourage trading, withdrawal, or modification permissions.
Storage guidance
- - Prefer environment injection (session/runtime env vars) over writing to disk.
- Only write to
.env if the user explicitly agrees. - Ensure
.env is in .gitignore before saving.
⚠️ CRITICAL: SAPI Signing (Different from Standard Binance API)
Parameter ordering
- - DO NOT sort parameters for SAPI requests.
- Keep original insertion order when building the query string.
Example:
CODEBLOCK0
Signing details
See:
references/authentication.md for:
- - RFC 3986 percent-encoding
- HMAC SHA256 signing process
- Required headers (incl. User-Agent)
- SAPI-specific parameter ordering
API Overview
Public Queries (MGS C2C Agent API — No Auth)
Base URL:
https://www.binance.com
| Endpoint | Method | Params | Usage |
|---|
| INLINECODE14 | GET | fiat, asset, tradeType | Quick price quote |
| INLINECODE15 |
GET | fiat, asset, tradeType, limit, order, tradeMethodIdentifiers | Search ads |
|
/bapi/c2c/v1/public/c2c/agent/trade-methods | GET | fiat | Payment methods |
Parameter notes:
- -
tradeType: BUY or SELL (treat as case-insensitive) - INLINECODE20 : 1–20 (default 10)
- INLINECODE21 : pass as a plain string (not JSON array) — e.g.
tradeMethodIdentifiers=BANK or tradeMethodIdentifiers=WECHAT. Values must use the identifier field returned by the trade-methods endpoint (see workflow below). ⚠️ Do NOT use JSON array syntax like ["BANK"] — it will return empty results.
Workflow: Compare Prices by Payment Method
When the user wants to compare prices across payment methods (e.g., "Alipay vs WeChat"), follow this two-step flow:
Step 1 — Call trade-methods to get the correct identifiers for the target fiat:
CODEBLOCK1
Step 2 — Pass the identifier as a plain string into ad-list via tradeMethodIdentifiers, one payment method per request, then compare:
GET /bapi/c2c/v1/public/c2c/agent/ad-list?fiat=CNY&asset=USDT&tradeType=BUY&limit=5&tradeMethodIdentifiers=ALIPAY&tradeMethodIdentifiers=WECHAT
Compare the best price from each result set.
Important: Do not hardcode identifier values like "Alipay" or "BANK". Always call trade-methods first to get the exact identifier strings for the given fiat currency.
Personal Orders (Binance SAPI — Requires Auth)
Base URL:
https://api.binance.com
| Endpoint | Method | Auth | Usage |
|---|
| INLINECODE35 | GET | Yes | Order history |
| INLINECODE36 |
GET | Yes | User statistics |
Authentication requirements:
- - Header: INLINECODE37
- Query:
timestamp + INLINECODE39 - Header: INLINECODE40
Output Format Guidelines
Price quote
- - Show both sides when available (best buy / best sell).
- Use fiat symbol and 2-decimal formatting.
Example:
CODEBLOCK3
Ad list
Return
Top N items with a stable schema:
1) adNo (ad number / identifier)
2) price (fiat)
3) merchant name
4) completion rate
5) limits
6) payment methods (identifiers)
Avoid generating parameterized external URLs unless the API returns them.
Placing orders (when user requests):
- - This skill does NOT support automated order placement.
- When user wants to place an order, provide a direct link to the specific ad using the adNo:
https://c2c.binance.com/en/adv?code={adNo}
-
{adNo}: the ad number/identifier from the ad list result
Example: https://c2c.binance.com/en/adv?code=123
- - This opens the specific ad detail page where user can place order directly with the selected advertisement.
Personal orders
- - Time format:
YYYY-MM-DD HH:mm (UTC+0) — always display in UTC timezone - Include: type, asset/fiat, amount, total, status
- Provide a brief summary line (count + totals) when filtering
Time field conversion (for createTime in listUserOrderHistory):
- - The
createTime field returns a Unix timestamp in milliseconds (13 digits). - Convert to human-readable format in UTC+0 timezone:
# Python example
from datetime import datetime, timezone
readable_time = datetime.fromtimestamp(createTime / 1000, tz=timezone.utc).strftime('%Y-%m-%d %H:%M (UTC+0)')
# JavaScript example
const readableTime = new Date(createTime).toISOString().replace('T', ' ').slice(0, 16) + ' (UTC+0)';
// Or more explicitly:
const date = new Date(createTime);
const readableTime = date.getUTCFullYear() + '-' +
String(date.getUTCMonth() + 1).padStart(2, '0') + '-' +
String(date.getUTCDate()).padStart(2, '0') + ' ' +
String(date.getUTCHours()).padStart(2, '0') + ':' +
String(date.getUTCMinutes()).padStart(2, '0') + ' (UTC+0)';
- - Always display the converted time to users with timezone info, not the raw timestamp.
Error Handling (User-Facing)
- - Invalid API key (-2015): prompt to verify
.env / API Management. - Signature failed (-1022): warn about wrong secret, sorted params, or stale timestamp.
- Timestamp invalid (-1021): advise time sync / regenerate timestamp.
- Rate limit: ask to retry later.
Limitations (By Design)
This skill does NOT:
- - Place/cancel orders
- Mark as paid / release coins
- Submit appeals
- Post/modify advertisements
- Expose sensitive order-detail endpoints beyond what’s needed for history/summary
For in-app actions, guide users to the official P2P orders page (only as a general entry point).
Developer Notes
Version Check (First Invocation per Conversation)
On the first invocation of this skill per conversation, call:
- -
GET /bapi/c2c/v1/public/c2c/agent/check-version?version=1.0.1 (Base: https://www.binance.com)
Behavior:
- - If
needUpdate=true: show: INLINECODE51 - Else / on failure: proceed silently.
Client-side operations
- - Asset filtering: if API doesn’t support it, fetch then filter locally.
- Aggregations: compute totals client-side when summary endpoint is insufficient.
币安P2P交易技能
帮助用户通过自然语言查询与币安P2P(C2C)进行交互。
何时使用 / 何时不使用
在以下情况下使用此技能:
- - 查询某个加密货币/法币交易对(例如USDT/CNY)的P2P买入/卖出报价。
- 搜索P2P广告,并按支付方式、限额、商家质量进行筛选。
- 比较不同支付方式(例如支付宝 vs 银行转账)的价格。
- 查看自己的P2P订单历史/摘要(需要API密钥)。
当用户询问以下内容时,请勿使用此技能:
- - 现货/兑换价格、期货/衍生品、杠杆、交易机器人。
- 充值/提现、钱包转账、链上交易。
- 创建/取消订单、申诉、释放币种(交易操作)。
如果缺少任何关键输入,请提出澄清性问题(不要猜测):
- - fiat(例如CNY)
- asset(例如USDT)
- 用户意图:购买加密货币或出售加密货币
- 首选支付方式
- 目标金额(可选,但建议用于广告筛选)
核心概念
tradeType 映射(避免歧义)
- - 用户想要购买加密货币(支付法币,接收USDT/BTC)→ tradeType=BUY
- 用户想要出售加密货币(接收法币,支付USDT/BTC)→ tradeType=SELL
当用户表述模糊时,始终在回复中反映此映射关系。
功能
第一阶段 — 公开市场(无需认证)
- - 查询P2P价格
- 搜索广告
- 比较支付方式
- 按限额和商家指标筛选/排序广告
第二阶段 — 个人订单(需要API密钥)
- - 列出P2P订单历史
- 按交易类型/时间范围筛选
- 提供摘要统计
安全与隐私规则
凭证
- BINANCE
APIKEY(作为请求头发送)
- BINANCE
SECRETKEY(用于签名)
切勿显示完整密钥
- - API密钥:显示前5位 + 后4位字符:abc12...z789
- 密钥:始终遮盖;仅显示后5位:*...c123
权限最小化
- - 币安API权限:仅启用读取。
- 不要请求/鼓励交易、提现或修改权限。
存储指南
- - 优先使用环境注入(会话/运行时环境变量),而非写入磁盘。
- 仅在用户明确同意时才写入.env文件。
- 保存前确保.env已在.gitignore中。
⚠️ 关键:SAPI签名(与标准币安API不同)
参数排序
- - 不要对SAPI请求的参数进行排序。
- 构建查询字符串时保持原始插入顺序。
示例:
py
✅ SAPI正确做法:保持插入顺序
params = {page: 1, rows: 20, timestamp: 1710460800000}
query_string = urlencode(params) # 不排序
❌ 错误做法(仅适用于标准币安API):已排序
query_string = urlencode(sorted(params.items()))
签名详情
参见:references/authentication.md 了解:
- - RFC 3986百分比编码
- HMAC SHA256签名过程
- 必需的请求头(包括User-Agent)
- SAPI特定的参数排序
API概览
公开查询(MGS C2C代理API — 无需认证)
基础URL:https://www.binance.com
| 端点 | 方法 | 参数 | 用途 |
|---|
| /bapi/c2c/v1/public/c2c/agent/quote-price | GET | fiat, asset, tradeType | 快速价格报价 |
| /bapi/c2c/v1/public/c2c/agent/ad-list |
GET | fiat, asset, tradeType, limit, order, tradeMethodIdentifiers | 搜索广告 |
| /bapi/c2c/v1/public/c2c/agent/trade-methods | GET | fiat | 支付方式 |
参数说明:
- - tradeType:BUY或SELL(不区分大小写)
- limit:1–20(默认10)
- tradeMethodIdentifiers:作为纯字符串传递(非JSON数组)——例如 tradeMethodIdentifiers=BANK 或 tradeMethodIdentifiers=WECHAT。值必须使用trade-methods端点返回的identifier字段(参见下方工作流程)。⚠️ 不要使用类似 [BANK] 的JSON数组语法——这将返回空结果。
工作流程:按支付方式比较价格
当用户想要比较不同支付方式(例如支付宝 vs 微信)的价格时,请遵循以下两步流程:
第1步 — 调用trade-methods获取目标法币的正确标识符:
GET /bapi/c2c/v1/public/c2c/agent/trade-methods?fiat=CNY
→ [{identifier:ALIPAY,...}, {identifier:WECHAT,...}, {identifier:BANK,...}]
第2步 — 将标识符作为纯字符串通过tradeMethodIdentifiers传递给ad-list,每次请求一个支付方式,然后进行比较:
GET /bapi/c2c/v1/public/c2c/agent/ad-list?fiat=CNY&asset=USDT&tradeType=BUY&limit=5&tradeMethodIdentifiers=ALIPAY&tradeMethodIdentifiers=WECHAT
比较每个结果集中的最佳价格。
重要提示: 不要硬编码标识符值,如Alipay或BANK。始终先调用trade-methods获取给定法币的确切identifier字符串。
个人订单(币安SAPI — 需要认证)
基础URL:https://api.binance.com
| 端点 | 方法 | 认证 | 用途 |
|---|
| /sapi/v1/c2c/orderMatch/listUserOrderHistory | GET | 是 | 订单历史 |
| /sapi/v1/c2c/orderMatch/getUserOrderSummary |
GET | 是 | 用户统计 |
认证要求:
- - 请求头:X-MBX-APIKEY
- 查询参数:timestamp + signature
- 请求头:User-Agent: binance-wallet/1.0.0 (Skill)
输出格式指南
价格报价
- - 可用时显示双边价格(最佳买入/最佳卖出)。
- 使用法币符号和2位小数格式。
示例:
USDT/CNY (P2P)
- - 购买USDT(您购买加密货币):¥7.20
- 出售USDT(您出售加密货币):¥7.18
广告列表
返回
前N条项目,使用稳定模式:
1) adNo(广告编号/标识符)
2) price(法币价格)
3) merchant name(商家名称)
4) completion rate(完成率)
5) limits(限额)
6) payment methods(支付方式标识符)
除非API返回,否则避免生成带参数的外部URL。
下单(当用户请求时):
- - 此技能不支持自动下单。
- 当用户想要下单时,使用adNo提供特定广告的直接链接:
https://c2c.binance.com/en/adv?code={adNo}
- {adNo}:广告列表结果中的广告编号/标识符
示例:https://c2c.binance.com/en/adv?code=123
- - 这将打开特定广告详情页面,用户可以在该页面直接与所选广告下单。
个人订单
- - 时间格式:YYYY-MM-DD HH:mm (UTC+0) — 始终以UTC时区显示
- 包含:类型、资产/法币、金额、总额、状态
- 筛选时提供简要摘要行(数量 + 总额)
时间字段转换(针对listUserOrderHistory中的createTime):
- - createTime字段返回毫秒单位的Unix时间戳(13位数字)。
- 转换为UTC+0时区的可读格式:
# Python示例
from datetime import datetime, timezone
readable_time = datetime.fromtimestamp(createTime / 1000, tz=timezone.utc).strftime(%Y-%m-%d %H:%M (UTC+0))
# JavaScript示例
const readableTime = new Date(createTime).toISOString().replace(T, ).slice(0, 16) + (UTC+0);
// 或者更明确地: