← 返回
开发者工具 Key

polymarket-sdk

Interact with Polymarket US prediction markets. Use when the user wants to: browse/search prediction markets, check market prices and odds, view portfolio po...
与Polymarket US预测市场交互。用于浏览或搜索预测市场、查看市场价格与赔率、查看投资组合等。
tyhouch
开发者工具 clawhub v1.0.0 1 版本 99829.6 Key: 需要
★ 0
Stars
📥 1,172
下载
💾 30
安装
1
版本
#latest

概述

Polymarket US

Trade and browse prediction markets via the Polymarket US API using the Python SDK.

Setup

Ensure the SDK is installed:

pip install polymarket-us

API keys are needed only for trading/portfolio endpoints. Generate at https://polymarket.us/developer

Store credentials as environment variables:

  • POLYMARKET_KEY_ID — API key UUID
  • POLYMARKET_SECRET_KEY — Ed25519 private key (base64)

Usage

Write and execute Python scripts using the polymarket_us SDK. For full API details, read references/api_reference.md.

Public Data (no auth)

from polymarket_us import PolymarketUS
client = PolymarketUS()

# Search markets
results = client.search.query({"query": "bitcoin", "limit": 5})

# Browse trending markets
markets = client.markets.list({"limit": 10, "orderBy": ["volumeNum"], "orderDirection": "desc"})

# Check price
bbo = client.markets.bbo("market-slug")

client.close()

Trading (auth required)

import os
from polymarket_us import PolymarketUS

client = PolymarketUS(
    key_id=os.environ["POLYMARKET_KEY_ID"],
    secret_key=os.environ["POLYMARKET_SECRET_KEY"],
)

# Check balance
balances = client.account.balances()

# View positions
positions = client.portfolio.positions()

# Preview then place order
preview = client.orders.preview({"request": {
    "marketSlug": "some-market",
    "intent": "ORDER_INTENT_BUY_LONG",
    "type": "ORDER_TYPE_LIMIT",
    "price": {"value": "0.55", "currency": "USD"},
    "quantity": 100,
}})

# Place order (ALWAYS confirm with user before executing)
order = client.orders.create({
    "marketSlug": "some-market",
    "intent": "ORDER_INTENT_BUY_LONG",
    "type": "ORDER_TYPE_LIMIT",
    "price": {"value": "0.55", "currency": "USD"},
    "quantity": 100,
    "tif": "TIME_IN_FORCE_GOOD_TILL_CANCEL",
})

client.close()

Key Rules

  1. Always preview orders before placing — show the user what they're about to trade
  2. Always confirm with the user before placing any order — never auto-trade
  3. Price is always the YES side — to buy NO at $0.40, set price to $0.60 (1.00 - 0.40)
  4. In market slugs: first team = YES, second team = NO
  5. Valid price range: 0.001 to 0.999
  6. Handle errors gracefully — catch AuthenticationError, BadRequestError, RateLimitError, etc.

Formatting Results

When presenting market data to the user:

  • Show market title/question clearly
  • Display YES/NO prices as percentages (e.g., 55¢ = 55% implied probability)
  • For positions, show P&L and current value
  • Keep it conversational — this is prediction markets, make it fun

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-29 06:44 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 921 📥 185,834
developer-tools

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 68 📥 180,372
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 672 📥 324,405