MEXC Spot API Skill
Use this skill to run MEXC Spot REST operations through uxc + OpenAPI.
Reuse the uxc skill for shared execution, auth, and error-handling guidance.
Prerequisites
- -
uxc is installed and available in PATH. - Network access to
https://api.mexc.com. - Access to the curated OpenAPI schema URL:
- INLINECODE5
Scope
This skill covers a curated MEXC Spot REST surface for:
- - public market reads
- signed account reads
- signed order create, cancel, and lookup flows
This skill does not cover:
- - futures APIs
- broader platform product families
Authentication
Public market endpoints do not require credentials.
Signed Spot endpoints require:
- -
api_key field for INLINECODE7 - INLINECODE8 field for HMAC SHA256 query signing
Create one credential:
CODEBLOCK0
Add one signer binding:
CODEBLOCK1
Validate the active mapping when auth looks wrong:
CODEBLOCK2
Core Workflow
- 1. Use the fixed link command by default:
-
command -v mexc-openapi-cli
- If missing, create it:
uxc link mexc-openapi-cli https://api.mexc.com --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/mexc-openapi-skill/references/mexc-spot.openapi.json
- INLINECODE11
- 2. Inspect operation help before execution:
-
mexc-openapi-cli get:/api/v3/ticker/price -h
-
mexc-openapi-cli get:/api/v3/account -h
- INLINECODE14
- 3. Prefer public reads first:
-
mexc-openapi-cli get:/api/v3/ticker/price symbol=BTCUSDT
- INLINECODE16
- 4. Use signed reads before writes:
-
mexc-openapi-cli get:/api/v3/account recvWindow=5000
- INLINECODE18
Operation Groups
Public Market
- - INLINECODE19
- INLINECODE20
- INLINECODE21
- INLINECODE22
- INLINECODE23
Signed Reads
- - INLINECODE24
- INLINECODE25
- INLINECODE26
Signed Writes
- - INLINECODE27
- INLINECODE28
Guardrails
- - Keep automation on the JSON output envelope; do not use
--text. - Parse stable fields first:
ok, kind, protocol, data, error. - Treat signed write operations as high-risk and require explicit confirmation before execution.
- INLINECODE35 and
signature are injected by the signer binding; users normally provide business parameters plus optional recvWindow. - Query
exchangeInfo before placing orders so symbol filters and lot sizes are known. - INLINECODE39 is equivalent to
uxc https://api.mexc.com --schema-url <mexc_spot_openapi_schema> <operation> ....
References
- - Usage patterns: INLINECODE41
- Curated OpenAPI schema: INLINECODE42
- Official MEXC Spot v3 docs: https://mexcdevelop.github.io/apidocs/spotv3en/
MEXC 现货 API 技能
使用此技能通过 uxc + OpenAPI 运行 MEXC 现货 REST 操作。
复用 uxc 技能以获取共享执行、认证和错误处理指导。
前提条件
- - uxc 已安装并位于 PATH 中。
- 可访问 https://api.mexc.com 的网络连接。
- 可访问精选的 OpenAPI 模式 URL:
- https://raw.githubusercontent.com/holon-run/uxc/main/skills/mexc-openapi-skill/references/mexc-spot.openapi.json
范围
此技能涵盖精选的 MEXC 现货 REST 接口,包括:
- - 公开市场查询
- 签名账户查询
- 签名订单的创建、取消和查询流程
此技能不涵盖:
认证
公开市场端点无需凭据。
签名现货端点需要:
- - apikey 字段用于 X-MEXC-APIKEY
- secretkey 字段用于 HMAC SHA256 查询签名
创建一个凭据:
bash
uxc auth credential set mexc-spot \
--auth-type api_key \
--field apikey=env:MEXCAPI_KEY \
--field secretkey=env:MEXCSECRET_KEY
添加一个签名者绑定:
bash
uxc auth binding add \
--id mexc-spot \
--host api.mexc.com \
--path-prefix /api/v3 \
--scheme https \
--credential mexc-spot \
--signer-json {kind:hmacqueryv1,algorithm:hmacsha256,signingfield:secretkey,keyfield:apikey,keyplacement:header,keyname:X-MEXC-APIKEY,signatureparam:signature,signatureencoding:hex,timestampparam:timestamp,timestampunit:milliseconds,canonicalization:{mode:preserveorder}} \
--priority 100
当认证看起来有问题时,验证活动映射:
bash
uxc auth binding match https://api.mexc.com/api/v3/account
核心工作流程
- 1. 默认使用固定链接命令:
- command -v mexc-openapi-cli
- 如果缺失,则创建它:
uxc link mexc-openapi-cli https://api.mexc.com --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/mexc-openapi-skill/references/mexc-spot.openapi.json
- mexc-openapi-cli -h
- 2. 执行前检查操作帮助:
- mexc-openapi-cli get:/api/v3/ticker/price -h
- mexc-openapi-cli get:/api/v3/account -h
- mexc-openapi-cli post:/api/v3/order -h
- 3. 优先使用公开查询:
- mexc-openapi-cli get:/api/v3/ticker/price symbol=BTCUSDT
- mexc-openapi-cli get:/api/v3/depth symbol=BTCUSDT limit=20
- 4. 在写入前使用签名查询:
- mexc-openapi-cli get:/api/v3/account recvWindow=5000
- mexc-openapi-cli get:/api/v3/openOrders symbol=BTCUSDT recvWindow=5000
操作组
公开市场
- - get:/api/v3/ping
- get:/api/v3/exchangeInfo
- get:/api/v3/ticker/price
- get:/api/v3/ticker/24hr
- get:/api/v3/depth
签名查询
- - get:/api/v3/account
- get:/api/v3/openOrders
- get:/api/v3/order
签名写入
- - post:/api/v3/order
- delete:/api/v3/order
防护措施
- - 保持自动化在 JSON 输出信封上;不要使用 --text。
- 首先解析稳定字段:ok、kind、protocol、data、error。
- 将签名写入操作视为高风险,并在执行前要求明确确认。
- timestamp 和 signature 由签名者绑定注入;用户通常提供业务参数以及可选的 recvWindow。
- 在下单前查询 exchangeInfo,以便了解交易对过滤器和最小交易量。
- mexc-openapi-cli ... 等同于 uxc https://api.mexc.com --schema-url spotopenapi_schema> ...。
参考资料
- - 使用模式:references/usage-patterns.md
- 精选的 OpenAPI 模式:references/mexc-spot.openapi.json
- 官方 MEXC 现货 v3 文档:https://mexcdevelop.github.io/apidocs/spotv3en/