mexc-openapi-skill

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MEXC Spot API Skill

MEXC现货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.
使用此Skill通过
uxc
+ OpenAPI执行MEXC现货REST操作。
复用
uxc
Skill以实现共享执行、认证和错误处理指引。

Prerequisites

前置条件

  • uxc
    is installed and available in
    PATH
    .
  • Network access to
    https://api.mexc.com
    .
  • Access to the curated OpenAPI schema URL:
    • https://raw.githubusercontent.com/holon-run/uxc/main/skills/mexc-openapi-skill/references/mexc-spot.openapi.json
  • 已安装
    uxc
    并可在
    PATH
    中访问。
  • 可访问
    https://api.mexc.com
    网络。
  • 可访问精选OpenAPI schema的URL:
    • https://raw.githubusercontent.com/holon-run/uxc/main/skills/mexc-openapi-skill/references/mexc-spot.openapi.json

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
此Skill涵盖精选的MEXC现货REST操作,包括:
  • 公开市场数据读取
  • 签名账户数据读取
  • 签名订单的创建、取消和查询流程
此Skill 涵盖:
  • 期货API
  • 更广泛的平台产品系列

Authentication

认证

Public market endpoints do not require credentials.
Signed Spot endpoints require:
  • api_key
    field for
    X-MEXC-APIKEY
  • secret_key
    field for HMAC SHA256 query signing
Create one credential:
bash
uxc auth credential set mexc-spot \
  --auth-type api_key \
  --field api_key=env:MEXC_API_KEY \
  --field secret_key=env:MEXC_SECRET_KEY
Add one signer binding:
bash
uxc auth binding add \
  --id mexc-spot \
  --host api.mexc.com \
  --path-prefix /api/v3 \
  --scheme https \
  --credential mexc-spot \
  --signer-json '{"kind":"hmac_query_v1","algorithm":"hmac_sha256","signing_field":"secret_key","key_field":"api_key","key_placement":"header","key_name":"X-MEXC-APIKEY","signature_param":"signature","signature_encoding":"hex","timestamp_param":"timestamp","timestamp_unit":"milliseconds","canonicalization":{"mode":"preserve_order"}}' \
  --priority 100
Validate the active mapping when auth looks wrong:
bash
uxc auth binding match https://api.mexc.com/api/v3/account
公开市场端点无需凭证。
签名现货端点需要:
  • api_key
    字段,用于
    X-MEXC-APIKEY
  • secret_key
    字段,用于HMAC SHA256请求签名
创建凭证:
bash
uxc auth credential set mexc-spot \
  --auth-type api_key \
  --field api_key=env:MEXC_API_KEY \
  --field secret_key=env:MEXC_SECRET_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":"hmac_query_v1","algorithm":"hmac_sha256","signing_field":"secret_key","key_field":"api_key","key_placement":"header","key_name":"X-MEXC-APIKEY","signature_param":"signature","signature_encoding":"hex","timestamp_param":"timestamp","timestamp_unit":"milliseconds","canonicalization":{"mode":"preserve_order"}}' \
  --priority 100
当认证出现问题时,验证当前映射:
bash
uxc auth binding match https://api.mexc.com/api/v3/account

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
    • mexc-openapi-cli -h
  2. Inspect operation help before execution:
    • 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. Prefer public reads first:
    • mexc-openapi-cli get:/api/v3/ticker/price symbol=BTCUSDT
    • mexc-openapi-cli get:/api/v3/depth symbol=BTCUSDT limit=20
  4. Use signed reads before writes:
    • mexc-openapi-cli get:/api/v3/account recvWindow=5000
    • mexc-openapi-cli get:/api/v3/openOrders symbol=BTCUSDT recvWindow=5000
  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

Operation Groups

操作分组

Public Market

公开市场

  • 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/ping
  • get:/api/v3/exchangeInfo
  • get:/api/v3/ticker/price
  • get:/api/v3/ticker/24hr
  • get:/api/v3/depth

Signed Reads

签名读取

  • get:/api/v3/account
  • get:/api/v3/openOrders
  • get:/api/v3/order
  • get:/api/v3/account
  • get:/api/v3/openOrders
  • get:/api/v3/order

Signed Writes

签名写入

  • post:/api/v3/order
  • delete:/api/v3/order
  • post:/api/v3/order
  • delete:/api/v3/order

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.
  • timestamp
    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.
  • mexc-openapi-cli <operation> ...
    is equivalent to
    uxc https://api.mexc.com --schema-url <mexc_spot_openapi_schema> <operation> ...
    .
  • 自动化操作基于JSON输出格式;请勿使用
    --text
    参数。
  • 优先解析稳定字段:
    ok
    ,
    kind
    ,
    protocol
    ,
    data
    ,
    error
  • 将签名写入操作视为高风险操作,执行前需明确确认。
  • timestamp
    signature
    由签名绑定自动注入;用户通常只需提供业务参数及可选的
    recvWindow
  • 下单前查询
    exchangeInfo
    ,了解币种过滤规则和下单数量限制。
  • mexc-openapi-cli <operation> ...
    等效于
    uxc https://api.mexc.com --schema-url <mexc_spot_openapi_schema> <operation> ...

References

参考资料