還沒有帳號?點擊這裡註冊 Polymarket 並完成入金,才能用錢包私鑰為訂單籤名、實際成交。
端點
請求參數
| 參數 | 類型 | 描述 |
|---|---|---|
q | string | 搜索關鍵詞 |
type | string | 搜索類型(markets, events, users) |
limit | number | 返回數量 |
搜索市場和事件
GET https://gamma-api.polymarket.com/search
| 參數 | 類型 | 描述 |
|---|---|---|
q | string | 搜索關鍵詞 |
type | string | 搜索類型(markets, events, users) |
limit | number | 返回數量 |
import requests
query = "Trump"
response = requests.get(
'https://gamma-api.polymarket.com/search',
params={
'q': query,
'type': 'markets',
'limit': 10
}
)
results = response.json()
for market in results['markets']:
print(f"市場: {market['question']}")
print(f"相關度: {market['score']}")
response = requests.get(
'https://gamma-api.polymarket.com/search',
params={
'q': 'election',
'type': 'events'
}
)
{
"markets": [
{
"id": "123",
"question": "川普會贏得 2024 年大選嗎?",
"score": 0.95,
"volume": "1000000.00"
}
],
"events": [
{
"id": "456",
"title": "2024 年美國總統大選",
"score": 0.90
}
],
"total_count": 15
}
# 搜索包含關鍵詞的市場
results = requests.get(
'https://gamma-api.polymarket.com/search',
params={
'q': 'bitcoin price',
'type': 'markets'
}
).json()
interface SearchResult {
markets: Market[];
events: Event[];
total_count: number;
}
async function searchMarkets(query: string): Promise<SearchResult> {
const response = await fetch(
`https://gamma-api.polymarket.com/search?q=${encodeURIComponent(query)}&type=markets`
);
return await response.json();
}
// 使用
const results = await searchMarkets('election 2024');
console.log(`找到 ${results.total_count} 個結果`);