Skip to main content
還沒有帳號?點擊這裡註冊 Polymarket 並完成入金,才能用錢包私鑰為訂單籤名、實際成交。
法律合規提醒:在使用 Polymarket 服務或 API 前,請確認您所在地區的法律規定。Polymarket 目前不支援比利時、法國、新加坡、泰國、中國大陸等地區,政策可能隨時變化。
Data API 提供了一些額外的端點用於獲取各種數據。

市場統計

端點

GET https://data-api.polymarket.com/stats

響應示例

{
  "total_markets": 5000,
  "active_markets": 1200,
  "total_volume": "500000000.00",
  "total_traders": 50000,
  "24h_volume": "5000000.00"
}

Python 示例

import requests

response = requests.get('https://data-api.polymarket.com/stats')
stats = response.json()

print(f"總市場數: {stats['total_markets']}")
print(f"總交易量: ${stats['total_volume']}")
print(f"24小時交易量: ${stats['24h_volume']}")

趨勢市場

端點

GET https://data-api.polymarket.com/trending

請求參數

參數類型描述
timeframestring時間範圍(24h, 7d, 30d)
limitnumber返回數量

示例

response = requests.get(
    'https://data-api.polymarket.com/trending',
    params={
        'timeframe': '24h',
        'limit': 10
    }
)

trending = response.json()
for market in trending:
    print(f"市場: {market['question']}")
    print(f"24h 交易量: ${market['volume_24h']}")

價格歷史

端點

GET https://data-api.polymarket.com/prices/{token_id}

請求參數

參數類型描述
start_timenumber開始時間戳
end_timenumber結束時間戳
intervalstring時間間隔(1h, 1d)

示例

import time

token_id = "0xabc123..."
start_time = int(time.time()) - 7 * 24 * 3600  # 7天前
end_time = int(time.time())

response = requests.get(
    f'https://data-api.polymarket.com/prices/{token_id}',
    params={
        'start_time': start_time,
        'end_time': end_time,
        'interval': '1h'
    }
)

prices = response.json()
for price_point in prices:
    print(f"時間: {price_point['timestamp']}")
    print(f"價格: {price_point['price']}")

排行榜

端點

GET https://data-api.polymarket.com/leaderboard

請求參數

參數類型描述
metricstring排序指標(volume, pnl, win_rate)
timeframestring時間範圍(all, 30d, 7d)
limitnumber返回數量

示例

response = requests.get(
    'https://data-api.polymarket.com/leaderboard',
    params={
        'metric': 'pnl',
        'timeframe': '30d',
        'limit': 100
    }
)

leaderboard = response.json()
for rank, user in enumerate(leaderboard, 1):
    print(f"#{rank} {user['username']}")
    print(f"  盈虧: ${user['pnl']}")
    print(f"  交易量: ${user['volume']}")

市場分析

端點

GET https://data-api.polymarket.com/analysis/{market_id}

響應示例

{
  "market_id": "123",
  "question": "...",
  "metrics": {
    "avg_position_size": "100.00",
    "unique_traders": 500,
    "maker_taker_ratio": "0.6",
    "bid_ask_spread": "0.02"
  },
  "price_stats": {
    "high_24h": "0.65",
    "low_24h": "0.55",
    "volatility": "0.15"
  }
}

事件通知

端點

GET https://data-api.polymarket.com/notifications
需要認證。返回用戶相關的通知:
  • 市場結算通知
  • 持倉變化提醒
  • 價格警報

示例

headers = {'Authorization': 'Bearer YOUR_TOKEN'}

response = requests.get(
    'https://data-api.polymarket.com/notifications',
    headers=headers
)

notifications = response.json()
for notif in notifications:
    print(f"類型: {notif['type']}")
    print(f"消息: {notif['message']}")
    print(f"時間: {notif['timestamp']}")

導出數據

端點

GET https://data-api.polymarket.com/export
導出用戶的交易歷史(CSV 格式)。

示例

response = requests.get(
    'https://data-api.polymarket.com/export',
    headers={'Authorization': 'Bearer YOUR_TOKEN'},
    params={
        'format': 'csv',
        'start_date': '2024-01-01',
        'end_date': '2024-12-31'
    }
)

# 保存 CSV
with open('trades.csv', 'w') as f:
    f.write(response.text)

下一步