# Requires Rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install CLI
cargo install polymarket-cli
# Verify
polymarket --version
git clone https://github.com/Polymarket/polymarket-cli
cd polymarket-cli
cargo build --release
# Binary at ./target/release/polymarket
Polymarket runs on Polygon. You need a funded wallet to place orders.
# Create new wallet (saves to ~/.polymarket/wallet.json)
polymarket wallet create
# Or import existing
polymarket wallet import --private-key YOUR_PRIVATE_KEY
# Check balance
polymarket wallet balance
# Get active markets
polymarket markets list
# Filter by category
polymarket markets list --category sports
polymarket markets list --category crypto
polymarket markets list --category politics
# JSON output (for agents)
polymarket markets list --output json
# Get specific market
polymarket market get 0x1234...
# Output
{
"id": "0x1234...",
"question": "Will Team Liquid win ESL Pro League?",
"outcomes": ["Yes", "No"],
"prices": {
"yes": 0.65,
"no": 0.37
},
"volume": 125000,
"liquidity": 50000,
"endDate": "2026-03-15T00:00:00Z"
}
# Search by keyword
polymarket markets search "esports"
polymarket markets search "CS2"
polymarket markets search "League of Legends"
# Buy YES shares
polymarket order market --market 0x1234... --side yes --amount 100
# Buy NO shares
polymarket order market --market 0x1234... --side no --amount 50
# Buy YES at specific price
polymarket order limit --market 0x1234... --side yes --amount 100 --price 0.55
# Sell existing position
polymarket order limit --market 0x1234... --side yes --amount 50 --price 0.70 --sell
# View open orders
polymarket orders list
# Cancel order
polymarket order cancel ORDER_ID
# View all positions
polymarket positions
# Output
{
"positions": [
{
"market": "0x1234...",
"question": "Will Team Liquid win ESL Pro League?",
"side": "yes",
"shares": 150,
"avgPrice": 0.58,
"currentPrice": 0.65,
"pnl": "+$10.50",
"pnlPercent": "+12.1%"
}
],
"totalValue": 97.50,
"totalPnl": 10.50
}
For autonomous agents, use JSON output mode and pipe to your decision engine:
#!/bin/bash
# Example: Monitor market and alert on price changes
MARKET="0x1234..."
THRESHOLD=0.70
while true; do
PRICE=$(polymarket market get $MARKET --output json | jq '.prices.yes')
if (( $(echo "$PRICE > $THRESHOLD" | bc -l) )); then
echo "ALERT: Price above threshold: $PRICE"
# Trigger your agent's sell logic
fi
sleep 60
done
import subprocess
import json
def get_market(market_id):
result = subprocess.run(
["polymarket", "market", "get", market_id, "--output", "json"],
capture_output=True, text=True
)
return json.loads(result.stdout)
def place_order(market_id, side, amount, price=None):
cmd = ["polymarket", "order"]
if price:
cmd.extend(["limit", "--price", str(price)])
else:
cmd.append("market")
cmd.extend([
"--market", market_id,
"--side", side,
"--amount", str(amount)
])
result = subprocess.run(cmd, capture_output=True, text=True)
return json.loads(result.stdout)
# Usage
market = get_market("0x1234...")
if market["prices"]["yes"] < 0.50:
place_order("0x1234...", "yes", 100)
For more sophisticated autonomous trading, Polymarket also offers a Python SDK specifically for AI agents:
# Install
pip install polymarket-agents
# Clone examples
git clone https://github.com/Polymarket/agents
cd agents
The Agents SDK connects to LLMs for market analysis and automated decision-making. View on GitHub →
| Command | Description |
|---|---|
polymarket markets list |
List all active markets |
polymarket market get ID |
Get market details |
polymarket markets search QUERY |
Search markets |
polymarket order market |
Place market order |
polymarket order limit |
Place limit order |
polymarket orders list |
View open orders |
polymarket positions |
View portfolio |
polymarket wallet balance |
Check wallet balance |