Polymarket CLI
Use the polymarket binary directly. Prefer read-only commands by default, use -o json for structured output, and treat any trading or on-chain action as sensitive.
Safety rules
Never read ~/.config/polymarket/config.json or any file that may contain private keys.
Never run wallet-management commands yourself. The user must run these directly:
- - INLINECODE3
- INLINECODE4
- INLINECODE5
- INLINECODE6
- INLINECODE7
- INLINECODE8
Ask before running any command that can:
- - place, modify, or cancel orders
- approve contracts
- split, merge, redeem, or bridge assets
- create/delete API keys or notifications
- write private keys or config
Safe to run without extra confirmation:
- -
markets, events, tags, series, comments, profiles, INLINECODE15 - read-only
clob commands like book, price, midpoint, spread, price-history, INLINECODE22 - public
data commands for wallets, markets, holders, volume, leaderboards - health/version/help commands
Read-only authenticated commands are allowed only when they do not reveal secrets and do not modify state.
Quick start
Check availability first:
CODEBLOCK0
Use JSON for agent work:
CODEBLOCK1
Opinionated workflows
Research a market
Use this when the user wants a quick market read without trading.
- 1. Search likely candidates:
CODEBLOCK2
- 2. Pick the most relevant slug or tokenized market.
- If needed, inspect details:
CODEBLOCK3
- 4. If token IDs are available, inspect price/action:
CODEBLOCK4
Summarize with: question, current odds, spread/liquidity hints, recent price context, and any obvious caveats.
Check a wallet safely
Use this when the user wants exposure, PnL-ish status, or activity without changing anything.
CODEBLOCK5
If the local configured wallet is relevant and the user wants account state, use read-only authenticated checks that do not expose secrets:
CODEBLOCK6
Do not run wallet show; tell the user to run wallet-management commands themselves.
Place a limit order safely
Do not run until the user confirms all of:
- - market or token
- side (
buy/sell) - price
- size or amount
- whether post-only is desired
Recommended sequence:
CODEBLOCK7
Repeat the full order back to the user before execution.
Common tasks
Browse markets and events
CODEBLOCK8
Inspect price/action on the CLOB
CODEBLOCK9
Inspect public wallet/market data
CODEBLOCK10
Wallet and setup
Wallet-management commands are user-only. Do not run them yourself. If the user wants setup help, tell them which command to run locally.
CODEBLOCK11
Trading
Only run after confirmation.
CODEBLOCK12
Working style
- 1. Prefer read-only discovery first.
- If the user wants trading, verify the exact token/market, side, size/amount, and price before running anything.
- For scripts and summaries, use
-o json and parse the result. - If a command fails, rerun with
--help on the relevant subcommand to inspect flags. - If the CLI is missing, tell the user how to install it:
CODEBLOCK13
Reference
Read references/command-map.md when you need a fuller command inventory or a reminder of which areas are read-only vs sensitive.
Polymarket CLI
直接使用 polymarket 二进制文件。默认优先使用只读命令,使用 -o json 获取结构化输出,并将任何交易或链上操作视为敏感操作。
安全规则
切勿读取 ~/.config/polymarket/config.json 或任何可能包含私钥的文件。
切勿自行运行钱包管理命令。用户必须直接运行以下命令:
- - polymarket wallet create
- polymarket wallet import
- polymarket wallet show
- polymarket wallet reset
- polymarket wallet address
- polymarket setup
在运行任何可能执行以下操作的命令前需征得同意:
- - 下单、修改或取消订单
- 批准合约
- 拆分、合并、赎回或桥接资产
- 创建/删除 API 密钥或通知
- 写入私钥或配置
无需额外确认即可安全运行:
- - markets、events、tags、series、comments、profiles、sports
- 只读 clob 命令,如 book、price、midpoint、spread、price-history、market
- 用于钱包、市场、持有者、交易量、排行榜的公共 data 命令
- 健康检查/版本/帮助命令
只读认证命令仅在不会泄露秘密且不修改状态时才允许使用。
快速开始
首先检查可用性:
bash
polymarket --help
polymarket --version
为代理工作使用 JSON:
bash
polymarket -o json markets list --limit 5
polymarket -o json markets search bitcoin --limit 5
polymarket -o json clob midpoint TOKEN_ID
个性化工作流程
研究市场
当用户希望快速了解市场但不进行交易时使用此流程。
- 1. 搜索可能的候选市场:
bash
polymarket -o json markets search QUERY --limit 10
- 2. 选择最相关的 slug 或代币化市场。
- 如有需要,查看详细信息:
bash
polymarket -o json markets get MARKETIDOR_SLUG
- 4. 如果代币 ID 可用,查看价格/动态:
bash
polymarket -o json clob midpoint TOKEN_ID
polymarket -o json clob spread TOKEN_ID
polymarket -o json clob book TOKEN_ID
polymarket -o json clob price-history TOKEN_ID --interval 1d --fidelity 30
总结内容包括:问题、当前赔率、价差/流动性提示、近期价格背景以及任何明显的注意事项。
安全查看钱包
当用户希望查看敞口、盈亏状态或活动但不做任何更改时使用此流程。
bash
polymarket -o json data positions 0xWALLET
polymarket -o json data value 0xWALLET
polymarket -o json data trades 0xWALLET --limit 50
如果本地配置的钱包相关且用户需要账户状态,使用不会泄露秘密的只读认证检查:
bash
polymarket -o json clob balance --asset-type collateral
polymarket -o json clob orders
polymarket -o json clob trades
polymarket approve check
不要运行 wallet show;告知用户自行运行钱包管理命令。
安全下达限价单
在用户确认以下所有信息前不要运行:
- - 市场或代币
- 方向(buy/sell)
- 价格
- 数量或金额
- 是否仅做挂单
推荐顺序:
bash
1) 首先验证市场背景
polymarket -o json clob midpoint TOKEN_ID
polymarket -o json clob spread TOKEN_ID
polymarket -o json clob book TOKEN_ID
2) 确认后再下单
polymarket clob create-order --token TOKEN_ID --side buy --price 0.50 --size 10
在执行前向用户复述完整订单信息。
常见任务
浏览市场和事件
bash
polymarket markets list --limit 10
polymarket markets search election --limit 5
polymarket markets get MARKETIDOR_SLUG
polymarket events list --limit 10
polymarket events get EVENT_ID
查看 CLOB 价格/动态
bash
polymarket clob ok
polymarket clob book TOKEN_ID
polymarket clob midpoint TOKEN_ID
polymarket clob spread TOKEN_ID
polymarket clob price-history TOKEN_ID --interval 1d --fidelity 30
查看公共钱包/市场数据
bash
polymarket data positions 0xWALLET
polymarket data value 0xWALLET
polymarket data trades 0xWALLET --limit 50
polymarket data holders 0xCONDITION_ID
polymarket data open-interest 0xCONDITION_ID
polymarket data leaderboard --period month --order-by pnl --limit 10
钱包和设置
钱包管理命令仅限用户操作。请勿自行运行。如果用户需要设置帮助,告知他们应在本地运行哪个命令。
bash
仅限用户操作
polymarket setup
polymarket wallet create
polymarket wallet import 0xPRIVATE_KEY
polymarket wallet show
代理可运行只读审批检查
polymarket approve check
代理在进行任何链上审批写入前必须征得同意
polymarket approve set
交易
仅在确认后运行。
bash
polymarket clob create-order --token TOKEN_ID --side buy --price 0.50 --size 10
polymarket clob market-order --token TOKEN_ID --side buy --amount 5
polymarket clob orders
polymarket clob cancel ORDER_ID
polymarket clob cancel-all
工作风格
- 1. 优先进行只读探索。
- 如果用户想要交易,在运行任何操作前验证确切的代币/市场、方向、数量/金额和价格。
- 对于脚本和摘要,使用 -o json 并解析结果。
- 如果命令失败,在相关子命令上使用 --help 重新运行以查看参数。
- 如果 CLI 缺失,告知用户如何安装:
bash
brew tap Polymarket/polymarket-cli https://github.com/Polymarket/polymarket-cli
brew install polymarket
参考
当需要更完整的命令清单或提醒哪些区域是只读 vs 敏感时,请阅读 references/command-map.md。