法律合規提醒:在使用 Polymarket 服務或 API 前,請確認您所在地區的法律規定。Polymarket 目前不支援比利時、法國、新加坡、泰國、中國大陸等地區,政策可能隨時變化。
市場端點是 Gamma API 最重要的端點,返回市場的詳細信息。
GET https://gamma-api.polymarket.com/markets
GET https://gamma-api.polymarket.com/markets/{condition_id}
請求參數
| 參數 | 類型 | 描述 |
|---|
limit | number | 返回數量(默認:20,最大:100) |
offset | number | 偏移量(默認:0) |
closed | boolean | 是否包含已關閉市場 |
active | boolean | 是否只返回活躍市場 |
tag | string | 按標籤過濾 |
order | string | 排序方式(volume, liquidity, etc.) |
請求示例
獲取活躍市場
import requests
response = requests.get(
'https://gamma-api.polymarket.com/markets',
params={
'limit': 10,
'active': True,
'closed': False,
'order': 'volume'
}
)
markets = response.json()
for market in markets:
print(f"問題: {market['question']}")
print(f"交易量: ${market['volume']}")
print(f"流動性: ${market['liquidity']}")
print("---")
獲取特定市場
condition_id = "0x1234..."
response = requests.get(
f'https://gamma-api.polymarket.com/markets/{condition_id}'
)
market = response.json()
響應示例
{
"id": "12345",
"condition_id": "0x1234...",
"question": "川普會贏得 2024 年大選嗎?",
"description": "詳細描述...",
"tokens": [
{
"token_id": "0xabc...",
"outcome": "Yes",
"price": "0.55",
"winner": null
},
{
"token_id": "0xdef...",
"outcome": "No",
"price": "0.45",
"winner": null
}
],
"volume": "1234567.89",
"liquidity": "234567.89",
"active": true,
"closed": false,
"end_date": "2024-11-06T00:00:00Z",
"tags": ["politics", "elections"],
"created_at": "2023-01-01T00:00:00Z"
}
市場欄位
| 欄位 | 類型 | 描述 |
|---|
id | string | 市場 ID |
condition_id | string | 條件 ID(鏈上) |
question | string | 市場問題 |
description | string | 詳細描述 |
tokens | array | 結果代幣信息 |
volume | string | 總交易量(USDC) |
liquidity | string | 流動性(USDC) |
active | boolean | 是否活躍 |
closed | boolean | 是否已關閉 |
end_date | string | 結束時間 |
高級過濾
# 獲取高交易量的政治市場
response = requests.get(
'https://gamma-api.polymarket.com/markets',
params={
'tag': 'politics',
'order': 'volume',
'limit': 20,
'active': True
}
)
TypeScript 示例
interface Market {
id: string;
condition_id: string;
question: string;
volume: string;
liquidity: string;
active: boolean;
}
async function getMarkets(): Promise<Market[]> {
const response = await fetch(
'https://gamma-api.polymarket.com/markets?limit=10&active=true'
);
return await response.json();
}