Binance official spot

From jiayaoqijia/cryptoskill · View interactive version

Binance official spot is an AI agent skill from the GitHub repository jiayaoqijia/cryptoskill. Binance Spot request using the Binance API. Authentication requires API key and secret key. Supports testnet, mainnet, and demo.

How to use this skill

Skill file

Binance Spot Skill

Spot request on Binance using authenticated API endpoints. Requires API key and secret key for certain endpoints. Return the result in JSON format.

Quick Reference

| Endpoint | Description | Required | Optional | Authentication |

|----------|-------------|----------|----------|----------------|

| /api/v3/exchangeInfo (GET) | Exchange information | None | symbol, symbols, permissions, showPermissionSets, symbolStatus | No |

| /api/v3/ping (GET) | Test connectivity | None | None | No |

| /api/v3/time (GET) | Check server time | None | None | No |

| /api/v3/aggTrades (GET) | Compressed/Aggregate trades list | symbol | fromId, startTime, endTime, limit | No |

| /api/v3/avgPrice (GET) | Current average price | symbol | None | No |

| /api/v3/depth (GET) | Order book | symbol | limit, symbolStatus | No |

| /api/v3/historicalTrades (GET) | Old trade lookup | symbol | limit, fromId | No |

| /api/v3/klines (GET) | Kline/Candlestick data | symbol, interval | startTime, endTime, timeZone, limit | No |

| /api/v3/ticker (GET) | Rolling window price change statistics | None | symbol, symbols, windowSize, type, symbolStatus | No |

| /api/v3/ticker/24hr (GET) | 24hr ticker price change statistics | None | symbol, symbols, type, symbolStatus | No |

| /api/v3/ticker/bookTicker (GET) | Symbol order book ticker | None | symbol, symbols, symbolStatus | No |

| /api/v3/ticker/price (GET) | Symbol price ticker | None | symbol, symbols, symbolStatus | No |

| /api/v3/ticker/tradingDay (GET) | Trading Day Ticker | None | symbol, symbols, timeZone, type, symbolStatus | No |

| /api/v3/trades (GET) | Recent trades list | symbol | limit | No |

| /api/v3/uiKlines (GET) | UIKlines | symbol, interval | startTime, endTime, timeZone, limit | No |

| /api/v3/openOrders (DELETE) | Cancel All Open Orders on a Symbol | symbol | recvWindow | Yes |

| /api/v3/openOrders (GET) | Current open orders | None | symbol, recvWindow | Yes |

| /api/v3/order (POST) | New order | symbol, side, type | timeInForce, quantity, quoteOrderQty, price, newClientOrderId, strategyId, strategyType, stopPrice, trailingDelta, icebergQty, newOrderRespType, selfTradePreventionMode, pegPriceType, pegOffsetValue, pegOffsetType, recvWindow | Yes |

| /api/v3/order (DELETE) | Cancel order | symbol | orderId, origClientOrderId, newClientOrderId, cancelRestrictions, recvWindow | Yes |

| /api/v3/order (GET) | Query order | symbol | orderId, origClientOrderId, recvWindow | Yes |

| /api/v3/order/amend/keepPriority (PUT) | Order Amend Keep Priority | symbol, newQty | orderId, origClientOrderId, newClientOrderId, recvWindow | Yes |

| /api/v3/order/cancelReplace (POST) | Cancel an Existing Order and Send a New Order | symbol, side, type, cancelReplaceMode | timeInForce, quantity, quoteOrderQty, price, cancelNewClientOrderId, cancelOrigClientOrderId, cancelOrderId, newClientOrderId, strategyId, strategyType, stopPrice, trailingDelta, icebergQty, newOrderRespType, selfTradePreventionMode, cancelRestrictions, orderRateLimitExceededMode, pegPriceType, pegOffsetValue, pegOffsetType, recvWindow | Yes |

| /api/v3/order/oco (POST) | New OCO - Deprecated | symbol, side, quantity, price, stopPrice | listClientOrderId, limitClientOrderId, limitStrategyId, limitStrategyType, limitIcebergQty, trailingDelta, stopClientOrderId, stopStrategyId, stopStrategyType, stopLimitPrice, stopIcebergQty, stopLimitTimeInForce, newOrderRespType, selfTradePreventionMode, recvWindow | Yes |

| /api/v3/order/test (POST) | Test new order | symbol, side, type | computeCommissionRates, timeInForce, quantity, quoteOrderQty, price, newClientOrderId, strategyId, strategyType, stopPrice, trailingDelta, icebergQty, newOrderRespType, selfTradePreventionMode, pegPriceType, pegOffsetValue, pegOffsetType, recvWindow | Yes |

| /api/v3/orderList (DELETE) | Cancel Order list | symbol | orderListId, listClientOrderId, newClientOrderId, recvWindow | Yes |

| /api/v3/orderList (GET) | Query Order list | None | orderListId, origClientOrderId, recvWindow | Yes |

| /api/v3/orderList/oco (POST) | New Order list - OCO | symbol, side, quantity, aboveType, belowType | listClientOrderId, aboveClientOrderId, aboveIcebergQty, abovePrice, aboveStopPrice, aboveTrailingDelta, aboveTimeInForce, aboveStrategyId, aboveStrategyType, abovePegPriceType, abovePegOffsetType, abovePegOffsetValue, belowClientOrderId, belowIcebergQty, belowPrice, belowStopPrice, belowTrailingDelta, belowTimeInForce, belowStrategyId, belowStrategyType, belowPegPriceType, belowPegOffsetType, belowPegOffsetValue, newOrderRespType, selfTradePreventionMode, recvWindow | Yes |

| /api/v3/orderList/opo (POST) | New Order List - OPO | symbol, workingType, workingSide, workingPrice, workingQuantity, pendingType, pendingSide | listClientOrderId, newOrderRespType, selfTradePreventionMode, workingClientOrderId, workingIcebergQty, workingTimeInForce, workingStrategyId, workingStrategyType, workingPegPriceType, workingPegOffsetType, workingPegOffsetValue, pendingClientOrderId, pendingPrice, pendingStopPrice, pendingTrailingDelta, pendingIcebergQty, pendingTimeInForce, pendingStrategyId, pendingStrategyType, pendingPegPriceType, pendingPegOffsetType, pendingPegOffsetValue, recvWindow | Yes |

| /api/v3/orderList/opoco (POST) | New Order List - OPOCO | symbol, workingType, workingSide, workingPrice, workingQuantity, pendingSide, pendingAboveType | listClientOrderId, newOrderRespType, selfTradePreventionMode, workingClientOrderId, workingIcebergQty, workingTimeInForce, workingStrategyId, workingStrategyType, workingPegPriceType, workingPegOffsetType, workingPegOffsetValue, pendingAboveClientOrderId, pendingAbovePrice, pendingAboveStopPrice, pendingAboveTrailingDelta, pendingAboveIcebergQty, pendingAboveTimeInForce, pendingAboveStrategyId, pendingAboveStrategyType, pendingAbovePegPriceType, pendingAbovePegOffsetType, pendingAbovePegOffsetValue, pendingBelowType, pendingBelowClientOrderId, pendingBelowPrice, pendingBelowStopPrice, pendingBelowTrailingDelta, pendingBelowIcebergQty, pendingBelowTimeInForce, pendingBelowStrategyId, pendingBelowStrategyType, pendingBelowPegPriceType, pendingBelowPegOffsetType, pendingBelowPegOffsetValue, recvWindow | Yes |

| /api/v3/orderList/oto (POST) | New Order list - OTO | symbol, workingType, workingSide, workingPrice, workingQuantity, pendingType, pendingSide, pendingQuantity | listClientOrderId, newOrderRespType, selfTradePreventionMode, workingClientOrderId, workingIcebergQty, workingTimeInForce, workingStrategyId, workingStrategyType, workingPegPriceType, workingPegOffsetType, workingPegOffsetValue, pendingClientOrderId, pendingPrice, pendingStopPrice, pendingTrailingDelta, pendingIcebergQty, pendingTimeInForce, pendingStrategyId, pendingStrategyType, pendingPegPriceType, pendingPegOffsetType, pendingPegOffsetValue, recvWindow | Yes |

| /api/v3/orderList/otoco (POST) | New Order list - OTOCO | symbol, workingType, workingSide, workingPrice, workingQuantity, pendingSide, pendingQuantity, pendingAboveType | listClientOrderId, newOrderRespType, selfTradePreventionMode, workingClientOrderId, workingIcebergQty, workingTimeInForce, workingStrategyId, workingStrategyType, workingPegPriceType, workingPegOffsetType, workingPegOffsetValue, pendingAboveClientOrderId, pendingAbovePrice, pendingAboveStopPrice, pendingAboveTrailingDelta, pendingAboveIcebergQty, pendingAboveTimeInForce, pendingAboveStrategyId, pendingAboveStrategyType, pendingAbovePegPriceType, pendingAbovePegOffsetType, pendingAbovePegOffsetValue, pendingBelowType, pendingBelowClientOrderId, pendingBelowPrice, pendingBelowStopPrice, pendingBelowTrailingDelta, pendingBelowIcebergQty, pendingBelowTimeInForce, pendingBelowStrategyId, pendingBelowStrategyType, pendingBelowPegPriceType, pendingBelowPegOffsetType, pendingBelowPegOffsetValue, recvWindow | Yes |

| /api/v3/sor/order (POST) | New order using SOR | symbol, side, type, quantity | timeInForce, price, newClientOrderId, strategyId, strategyType, icebergQty, newOrderRespType, selfTradePreventionMode, recvWindow | Yes |

| /api/v3/sor/order/test (POST) | Test new order using SOR | symbol, side, type, quantity | computeCommissionRates, timeInForce, price, newClientOrderId, strategyId, strategyType, icebergQty, newOrderRespType, selfTradePreventionMode, recvWindow | Yes |

| /api/v3/account (GET) | Account information | None | omitZeroBalances, recvWindow | Yes |

| /api/v3/account/commission (GET) | Query Commission Rates | symbol | None | Yes |

| /api/v3/allOrderList (GET) | Query all Order lists | None | fromId, startTime, endTime, limit, recvWindow | Yes |

| /api/v3/allOrders (GET) | All orders | symbol | orderId, startTime, endTime, limit, recvWindow | Yes |

| /api/v3/myAllocations (GET) | Query Allocations | symbol | startTime, endTime, fromAllocationId, limit, orderId, recvWindow | Yes |

| /api/v3/myFilters (GET) | Query relevant filters | symbol | recvWindow | Yes |

| /api/v3/myPreventedMatches (GET) | Query Prevented Matches | symbol | preventedMatchId, orderId, fromPreventedMatchId, limit, recvWindow | Yes |

| /api/v3/myTrades (GET) | Account trade list | symbol | orderId, startTime, endTime, fromId, limit, recvWindow | Yes |

| /api/v3/openOrderList (GET) | Query Open Order lists | None | recvWindow | Yes |

| /api/v3/order/amendments (GET) | Query Order Amendments | symbol, orderId | fromExecutionId, limit, recvWindow | Yes |

| /api/v3/rateLimit/order (GET) | Query Unfilled Order Count | None | recvWindow | Yes |


Parameters

Common Parameters

Enums

Authentication

For endpoints that require authentication, you will need to provide Binance API credentials.

Required credentials:

Base URLs:

Security

Share Credentials

Users can provide Binance API credentials in different ways. The agent will try to retrieve automatically with the two first ways the credentials, but users can also explicitly tell the agent that they have set the credentials or stored them in a .env file, and the agent should re-read that file when they do. The agent can also make http requests with the two first methods without user confirmation.

  1. Environment variables

Search for the following specific variables only (never dump the full environment):

Authorized environment variables

Read and use in a single exec call so the raw key never enters the agent's context:

KEY="$BINANCE_API_KEY"
SECRET="$BINANCE_SECRET_KEY"

response=$(curl -s -X GET "$URL" \
  -H "X-MBX-APIKEY: $KEY" \
  --data-urlencode "param1=value1")

echo "$response"

Environment variables must be set before OpenClaw starts. They are inherited at process startup and cannot be injected into a running instance. If you need to add or update credentials without restarting, use a secrets file (see option 2).

  1. Secrets file (.env)

Check ~/.openclaw/secrets.env , ~/.env, or a .env file in the workspace. Read individual keys with grep, never source the full file:

# Try all credential locations in order
API_KEY=$(grep '^BINANCE_API_KEY=' ~/.openclaw/secrets.env 2>/dev/null | cut -d= -f2-)
SECRET_KEY=$(grep '^BINANCE_SECRET_KEY=' ~/.openclaw/secrets.env 2>/dev/null | cut -d= -f2-)

# Fallback: search .env in known directories (KEY=VALUE then raw line format)
for dir in ~/.openclaw ~; do
  [ -n "$API_KEY" ] && break
  env_file="$dir/.env"
  [ -f "$env_file" ] || continue

  # Read first two lines
  line1=$(sed -n '1p' "$env_file")
  line2=$(sed -n '2p' "$env_file")

  # Check if lines contain '=' indicating KEY=VALUE format
  if [[ "$line1" == *=* && "$line2" == *=* ]]; then
    API_KEY=$(grep '^BINANCE_API_KEY=' "$env_file" 2>/dev/null | cut -d= -f2-)
    SECRET_KEY=$(grep '^BINANCE_SECRET_KEY=' "$env_file" 2>/dev/null | cut -d= -f2-)
  else
    # Treat lines as raw values
    API_KEY="$line1"
    SECRET_KEY="$line2"
  fi
done

This file can be updated at any time without restarting OpenClaw, keys are read fresh on each invocation. Users can tell you the variables are now set or stored in a .env file, and you should re-read that file when they do.

  1. Inline file

Sending a file where the content is in the following format:

abc123...xyz
secret123...key

Never Disclose API Key and Secret

Never disclose the location of the API key and secret file.

Never send the API key and secret to any website other than Mainnet and Testnet.

Never Display Full Secrets

When showing credentials to users:

Example response when asked for credentials:

Account: main

API Key: su1Qc...8akf

Secret: ***...aws1

Environment: Mainnet

Listing Accounts

When listing accounts, show names and environment only — never keys:

Binance Accounts:

Transactions in Mainnet

When performing transactions in mainnet, always confirm with the user before proceeding by asking them to write "CONFIRM" to proceed.


Binance Accounts

main

testnet-dev

TOOLS.md Structure

## Binance Accounts

### main
- API Key: abc123...xyz
- Secret: secret123...key
- Testnet: false
- Description: Primary trading account

### testnet-dev
- API Key: test456...abc
- Secret: testsecret...xyz
- Testnet: true
- Description: Development/testing

### futures-keys
- API Key: futures789...def
- Secret: futuressecret...uvw
- Testnet: false
- Description: Futures trading account

Agent Behavior

  1. Credentials requested: Mask secrets (show last 5 chars only)
  2. Listing accounts: Show names and environment, never keys
  3. Account selection: Ask if ambiguous, default to main
  4. When doing a transaction in mainnet, confirm with user before by asking to write "CONFIRM" to proceed
  5. New credentials: Prompt for name, environment, signing mode
  6. When a request requires signing, if the request isn't an order and the API keys aren't described as mainnet, testnet or demo keys, try to make request to the different base urls and see if it works, without asking the user. If it works, store the keys with the corresponding environment.

Adding New Accounts

When user provides new credentials by Inline file or message:

Signing Requests

For trading endpoints that require a signature:

  1. Detect key type first, inspect the secret key format before signing.
  2. Build query string with all parameters, including the timestamp (Unix ms).
  3. Percent-encode the parameters using UTF-8 according to RFC 3986.
  4. Sign query string with secretKey using HMAC SHA256, RSA, or Ed25519 (depending on the account configuration).
  5. Append signature to query string.
  6. Include X-MBX-APIKEY header.

Otherwise, do not perform steps 4–6.

New Client Order ID

For endpoints that include the newClientOrderId parameter, the value must always start with agent-. If the parameter is not provided, agent- followed by 18 random alphanumeric characters will be generated automatically. If a value is provided, it will be prefixed with agent-

Example: agent-1a2b3c4d5e6f7g8h9i

User Agent Header

Include User-Agent header with the following string: binance-spot/1.1.0 (Skill)

See CODE0 for implementation details.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.