Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

polymarket-cli

> 编程语言
Open source

Polymarket CLI Rust CLI for Polymarket. Browse markets, place orders, manage positions, and interact with onchain contracts — from a termin…

2.8K stars0 likes0 views
WebsiteGitHub

About

Polymarket CLI Rust CLI for Polymarket. Browse markets, place orders, manage positions, and interact with onchain contracts — from a termin…

Polymarket CLI

Rust CLI for Polymarket. Browse markets, place orders, manage positions, and interact with onchain contracts — from a terminal or as a JSON API for scripts and agents.

Warning: This is early, experimental software. Use at your own risk and do not use with large amounts of funds. APIs, commands, and behavior may change without notice. Always verify transactions before confirming.

Install

Homebrew (macOS / Linux)

bash
brew tap Polymarket/polymarket-cli https://github.com/Polymarket/polymarket-cli
brew install polymarket

Shell script

bash
curl -sSL https://raw.githubusercontent.com/Polymarket/polymarket-cli/main/install.sh | sh

Build from source

bash
git clone https://github.com/Polymarket/polymarket-cli
cd polymarket-cli
cargo install --path .

Quick Start

bash
# No wallet needed — browse markets immediately
polymarket markets list --limit 5
polymarket markets search "election"
polymarket events list --tag politics

# Check a specific market
polymarket markets get will-trump-win-the-2024-election

# JSON output for scripts
polymarket -o json markets list --limit 3

To trade, set up a wallet:

bash
polymarket setup
# Or manually:
polymarket wallet create
polymarket approve set

Configuration

Wallet Setup

The CLI needs a private key to sign orders and on-chain transactions. Three ways to provide it (checked in this order):

  1. CLI flag: --private-key 0xabc...
  2. Environment variable: POLYMARKET_PRIVATE_KEY=0xabc...
  3. Config file: ~/.config/polymarket/config.json
bash
# Create a new wallet (generates random key, saves to config)
polymarket wallet create

# Import an existing key
polymarket wallet import 0xabc123...

# Check what's configured
polymarket wallet show

The config file (~/.config/polymarket/config.json):

json
{
  "private_key": "0x...",
  "chain_id": 137,
  "signature_type": "proxy"
}

Signature Types

  • proxy (default) — uses Polymarket's proxy wallet system
  • eoa — signs directly with your key
  • gnosis-safe — for multisig wallets

Override per-command with --signature-type eoa or via POLYMARKET_SIGNATURE_TYPE.

What Needs a Wallet

Most commands work without a wallet — browsing markets, viewing order books, checking prices. You only need a wallet for:

  • Placing and canceling orders (clob create-order, clob market-order, clob cancel-*)
  • Checking your balances and trades (clob balance, clob trades, clob orders)
  • On-chain operations (approve set, ctf split/merge/redeem)
  • Reward and API key management (clob rewards, clob create-api-key)

Output Formats

Every command supports --output table (default) and --output json.

bash
# Human-readable table (default)
polymarket markets list --limit 2
 Question                            Price (Yes)  Volume   Liquidity  Status
 Will Trump win the 2024 election?   52.00¢       $145.2M  $1.2M      Active
 Will BTC hit $100k by Dec 2024?     67.30¢       $89.4M   $430.5K    Active
bash
# Machine-readable JSON
polymarket -o json markets list --limit 2
json
[
  { "id": "12345", "question": "Will Trump win the 2024 election?", "outcomePrices": ["0.52", "0.48"], ... },
  { "id": "67890", "question": "Will BTC hit $100k by Dec 2024?", ... }
]

Short form: -o json or -o table.

Errors follow the same pattern — table mode prints Error: ... to stderr, JSON mode prints {"error": "..."} to stdout. Non-zero exit code either way.

Commands

Markets

bash
# List markets with filters
polymarket markets list --limit 10
polymarket markets list --active true --order volume_num
polymarket markets list --closed false --limit 50 --offset 25

# Get a single market by ID or slug
polymarket markets get 12345
polymarket markets get will-trump-win

# Search
polymarket markets search "bitcoin" --limit 5

# Get tags for a market
polymarket markets tags 12345

Flags for markets list: --limit, --offset, --order, --ascending, --active, --closed

Events

Events group related markets (e.g. "2024 Election" contains multiple yes/no markets).

bash
polymarket events list --limit 10
polymarket events list --tag politics --active true
polymarket events get 500
polymarket events tags 500

Flags for events list: --limit, --offset, --order, --ascending, --active, --closed, --tag

Tags, Series, Comments, Profiles, Sports

bash
# Tags
polymarket tags list
polymarket tags get politics
polymarket tags related politics
polymarket tags related-tags politics

# Series (recurring events)
polymarket series list --limit 10
polymarket series get 42

# Comments on an entity
polymarket comments list --entity-type event --entity-id 500
polymarket comments get abc123
polymarket comments by-user 0xf5E6...

# Public profiles
polymarket profiles get 0xf5E6...

# Sports metadata
polymarket sports list
polymarket sports market-types
polymarket sports teams --league NFL --limit 32

Order Book & Prices (CLOB)

All read-only — no wallet needed.

…

Interval options for price-history: 1m, 1h, 6h, 1d, 1w, max

Trading (CLOB, authenticated)

Requires a configured wallet.

…

Order types: GTC (default), FOK, GTD, FAK. Add --post-only for limit orders.

Rewards & API Keys (CLOB, authenticated)

…

On-Chain Data

Public data — no wallet needed.

…

Contract Approvals

Before trading, Polymarket contracts need ERC-20 (pUSD) and ERC-1155 (CTF token) approvals.

bash
# Check current approvals (read-only)
polymarket approve check
polymarket approve check 0xSOME_ADDRESS

# Approve all contracts (sends on-chain transactions, needs MATIC for gas)
polymarket approve set

CTF Operations

Split, merge, and redeem conditional tokens directly on-chain.

…

--amount is in pUSD (e.g., 10 = $10). The --partition flag defaults to binary (1,2). On-chain operations require MATIC for gas on Polygon.

Bridge

Deposit assets from other chains into Polymarket.

bash
# Get deposit addresses (EVM, Solana, Bitcoin)
polymarket bridge deposit 0xWALLET_ADDRESS

# List supported chains and tokens
polymarket bridge supported-assets

# Check deposit status
polymarket bridge status 0xDEPOSIT_ADDRESS

Wallet Management

bash
polymarket wallet create               # Generate new random wallet
polymarket wallet create --force       # Overwrite existing
polymarket wallet import 0xKEY...      # Import existing key
polymarket wallet address              # Print wallet address
polymarket wallet show                 # Full wallet info (address, source, config path)
polymarket wallet reset                # Delete config (prompts for confirmation)
polymarket wallet reset --force        # Delete without confirmation

Interactive Shell

bash
polymarket shell
# polymarket> markets list --limit 3
# polymarket> clob book 48331043336612883...
# polymarket> exit

Supports command history. All commands work the same as the CLI, just without the polymarket prefix.

Other

bash
polymarket status     # API health check
polymarket setup      # Guided first-time setup wizard
polymarket upgrade    # Update to the latest version
polymarket --version
polymarket --help

Common Workflows

Browse and research markets

bash
polymarket markets search "bitcoin" --limit 5
polymarket markets get bitcoin-above-100k
polymarket clob book 48331043336612883...
polymarket clob price-history 48331043336612883... --interval 1d

Set up a new wallet and start trading

bash
polymarket wallet create
polymarket approve set                    # needs MATIC for gas
polymarket clob balance --asset-type collateral
polymarket clob market-order --token TOKEN_ID --side buy --amount 5

Monitor your portfolio

bash
polymarket data positions 0xYOUR_ADDRESS
polymarket data value 0xYOUR_ADDRESS
polymarket clob orders
polymarket clob trades

Place and manage limit orders

bash
# Place order
polymarket clob create-order --token TOKEN_ID --side buy --price 0.45 --size 20

# Check it
polymarket clob orders

# Cancel if needed
polymarket clob cancel ORDER_ID

# Or cancel everything
polymarket clob cancel-all

Script with JSON output

bash
# Pipe market data to jq
polymarket -o json markets list --limit 100 | jq '.[].question'

# Check prices programmatically
polymarket -o json clob midpoint TOKEN_ID | jq '.mid'

# Error handling in scripts
if ! result=$(polymarket -o json clob balance --asset-type collateral 2>/dev/null); then
  echo "Failed to fetch balance"
fi

Architecture

src/
  main.rs        -- CLI entry point, clap parsing, error handling
  auth.rs        -- Wallet resolution, RPC provider, CLOB authentication
  config.rs      -- Config file (~/.config/polymarket/config.json)
  shell.rs       -- Interactive REPL
  commands/      -- One module per command group
  output/        -- Table and JSON rendering per command group

License

MIT

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言