事件
一个事件围绕一组相关问题组织一个或多个市场。单市场事件只提出一个是非问题;多市场事件则将更广泛的问题拆分为各个结果,例如在选举中为每位候选人建立一个市场。获取事件
已知事件标识符时,获取单个事件。- TypeScript
- Python
- API
在 也可以通过 Polymarket URL 或 slug 获取事件:
PublicClient 或 SecureClient 上调用 fetchEvent(),按 ID 获取事件。const event = await client.fetchEvent({ id: "90177" });
// event: Event
const event = await client.fetchEvent({
url: "https://polymarket.com/event/will-the-us-confirm-that-aliens-exist-before-2027",
});
const event = await client.fetchEvent({
slug: "will-the-us-confirm-that-aliens-exist-before-2027",
});
输出:Event
输出:Event
type Market = {
id: string;
slug?: string | null;
question?: string | null;
conditionId: string | null;
outcomes: {
yes: { tokenId: string | null };
no: { tokenId: string | null };
};
};
type Event = {
id: string;
slug?: string | null;
title?: string | null;
markets: Market[];
};
{
"id": "90177",
"slug": "will-the-us-confirm-that-aliens-exist-before-2027",
"title": "Will the US confirm that aliens exist by...?",
"markets": [
{
"id": "703257",
"slug": "will-the-us-confirm-that-aliens-exist-before-2027-789-924-249",
"question": "Will the US confirm that aliens exist before 2027?",
"conditionId": "0x747dc809fb79e1b05be09c42d6179459a58de2ef3e40f02484a4e1260f741f75",
"outcomes": {
"yes": {
"tokenId": "107505882767731489358349912513945399560393482969656700824895970500493757150417"
},
"no": {
"tokenId": "7305630249804085635496399869905769372294302716159034447326228509068694952392"
}
}
},
"..."
]
}
在 也可以通过 Polymarket URL 或 slug 获取事件:
AsyncPublicClient 或 AsyncSecureClient 上调用 get_event(),按 ID 获取事件。
同步的 PublicClient 和 SecureClient 也提供相同方法。event = await client.get_event(id="90177")
# event: Event
event = await client.get_event(
url="https://polymarket.com/event/will-the-us-confirm-that-aliens-exist-before-2027",
)
event = await client.get_event(
slug="will-the-us-confirm-that-aliens-exist-before-2027",
)
输出:Event
输出:Event
class MarketOutcome:
token_id: str | None
class MarketOutcomes:
yes: MarketOutcome
no: MarketOutcome
class Market:
id: str
slug: str | None
question: str | None
condition_id: str | None
outcomes: MarketOutcomes
class Event:
id: str
slug: str | None
title: str | None
markets: tuple[Market, ...]
{
"id": "90177",
"slug": "will-the-us-confirm-that-aliens-exist-before-2027",
"title": "Will the US confirm that aliens exist by...?",
"markets": [
{
"id": "703257",
"slug": "will-the-us-confirm-that-aliens-exist-before-2027-789-924-249",
"question": "Will the US confirm that aliens exist before 2027?",
"condition_id": "0x747dc809fb79e1b05be09c42d6179459a58de2ef3e40f02484a4e1260f741f75",
"outcomes": {
"yes": {
"token_id": "107505882767731489358349912513945399560393482969656700824895970500493757150417"
},
"no": {
"token_id": "7305630249804085635496399869905769372294302716159034447326228509068694952392"
}
}
},
"..."
]
}
按 ID 获取事件:也可以按 slug 获取事件:
curl "https://gamma-api.polymarket.com/events/90177"
curl "https://gamma-api.polymarket.com/events/slug/will-the-us-confirm-that-aliens-exist-before-2027"
输出:Event
输出:Event
type Market = {
id: string;
slug: string;
question: string | null;
conditionId: string | null;
clobTokenIds: string | null;
};
type Event = {
id: string;
slug: string | null;
title: string | null;
markets: Market[];
};
{
"id": "90177",
"slug": "will-the-us-confirm-that-aliens-exist-before-2027",
"title": "Will the US confirm that aliens exist by...?",
"markets": [
{
"id": "703257",
"slug": "will-the-us-confirm-that-aliens-exist-before-2027-789-924-249",
"question": "Will the US confirm that aliens exist before 2027?",
"conditionId": "0x747dc809fb79e1b05be09c42d6179459a58de2ef3e40f02484a4e1260f741f75",
"clobTokenIds": "[\"107505882767731489358349912513945399560393482969656700824895970500493757150417\",\"7305630249804085635496399869905769372294302716159034447326228509068694952392\"]"
},
"..."
]
}
列出事件
需要可浏览或可筛选的数据源时,列出事件。- TypeScript
- Python
- API
在
传入一个或多个数字标签 ID,按标签筛选:
PublicClient 或 SecureClient 上调用 listEvents(),分页浏览事件。const pages = client.listEvents({ closed: false, pageSize: 20 });
for await (const page of pages) {
// page.items: Event[]
}
输出:Event[]
输出:Event[]
type Market = {
id: string;
slug?: string | null;
question?: string | null;
conditionId: string | null;
};
type Event = {
id: string;
slug?: string | null;
title?: string | null;
markets: Market[];
};
type Page = {
items: Event[];
hasMore: boolean;
nextCursor?: string;
};
{
"items": [
{
"id": "16183",
"slug": "kraken-ipo-in-2025",
"title": "Kraken IPO by ___ ?",
"markets": [
{
"id": "516950",
"slug": "kraken-ipo-in-2025",
"question": "Kraken IPO in 2025?"
},
"..."
]
},
{
"id": "16263",
"slug": "macron-out-in-2025",
"title": "Macron out by...?",
"markets": ["..."]
},
"..."
],
"hasMore": true,
"nextCursor": "9YTr9qyfU9571U9_leL7LNSWUI6EXd7rpAqdh-EbPr17InYiOjEsImsiOiJldmVudHMiLCJvaCI6IjRmNTNjZGExOGMyYmFhMGMwMzU0YmI1ZjlhM2VjYmU1ZWQxMmFiNGQ4ZTExYmE4NzNjMmYxMTE2MTIwMmI5NDUiLCJrZXlzIjpbeyJ0Ijoic3RyaW5nIiwidiI6IjI1ODE1In1dfQ"
}
const pages = client.listEvents({
tagIds: [745], // numeric ID for the "nba" tag; see Tags below to look these up
closed: false,
});
for await (const page of pages) {
// page.items: Event[]
}
在
传入数字标签 ID,按标签筛选:
AsyncPublicClient 或 AsyncSecureClient 上调用 list_events(),分页浏览事件。
同步的 PublicClient 和 SecureClient 也提供相同方法。pages = client.list_events(closed=False, page_size=20)
async for page in pages:
... # page.items: tuple[Event, ...]
输出:Event[]
输出:Event[]
class Market:
id: str
slug: str | None
question: str | None
condition_id: str | None
class Event:
id: str
slug: str | None
title: str | None
markets: tuple[Market, ...]
class Page:
items: tuple[Event, ...]
has_more: bool
next_cursor: str | None
{
"items": [
{
"id": "16183",
"slug": "kraken-ipo-in-2025",
"title": "Kraken IPO by ___ ?"
},
{
"id": "16263",
"slug": "macron-out-in-2025",
"title": "Macron out by...?"
},
"..."
],
"has_more": true,
"next_cursor": "eyJmIjoiYWQyZjRkNmY4ZDZkIiwiayI6IjlZVHI5cXlmVTk1NzFVOV9sZUw3TE5TV1VJNkVYZDdycEFxZGgtRWJQcjE3SW5ZaU9qRXNJbXNpT2lKbGRtVnVkSE1pTENKdmFDSTZJalJtTlROalpHRXhPR015WW1GaE1HTXdNelUwWW1JMVpqbGhNMlZqWW1VMVpXUXhNbUZpTkdRNFpURXhZbUU0TnpOak1tWXhNVEUyTVRJd01tSTVORFVpTENKclpYbHpJanBiZXlKMElqb2ljM1J5YVc1bklpd2lkaUk2SWpJMU9ERTFJbjFkZlEiLCJwIjoiL2V2ZW50cy9rZXlzZXQiLCJzdmMiOiJnYW1tYSIsInYiOjF9"
}
pages = client.list_events(
tag_ids=[745], # numeric ID for the "nba" tag; see Tags below to look these up
closed=False,
)
async for page in pages:
... # page.items: tuple[Event, ...]
列出活跃事件:
将 使用
curl "https://gamma-api.polymarket.com/events/keyset?closed=false&limit=20"
输出:事件分页
输出:事件分页
Example
{
"events": [
{
"id": "16183",
"slug": "kraken-ipo-in-2025",
"title": "Kraken IPO by ___ ?"
},
"..."
],
"next_cursor": "9YTr9qyfU9571U9_leL7LNSWUI6EXd7rpAqdh-EbPr17InYiOjEsImsiOiJldmVudHMiLCJvaCI6IjRmNTNjZGExOGMyYmFhMGMwMzU0YmI1ZjlhM2VjYmU1ZWQxMmFiNGQ4ZTExYmE4NzNjMmYxMTE2MTIwMmI5NDUiLCJrZXlzIjpbeyJ0Ijoic3RyaW5nIiwidiI6IjI1ODE1In1dfQ"
}
next_cursor 作为 after_cursor 传入,以获取下一页:curl "https://gamma-api.polymarket.com/events/keyset?closed=false&limit=20&after_cursor=<next_cursor>"
tag_id 按标签筛选:curl "https://gamma-api.polymarket.com/events/keyset?tag_id=745&closed=false&limit=20"
市场
一个市场对应一个是非问题,并包含两个结果 token ID:一个对应 YES,另一个对应 NO。获取市场
已知市场标识符时,获取单个市场。- TypeScript
- Python
- API
在 也可以通过 Polymarket URL 或 slug 获取市场:
PublicClient 或 SecureClient 上调用 fetchMarket(),按 ID 获取市场。const market = await client.fetchMarket({ id: "703257" });
// market: Market
const market = await client.fetchMarket({
url: "https://polymarket.com/market/will-the-us-confirm-that-aliens-exist-before-2027-789-924-249",
});
const market = await client.fetchMarket({
slug: "will-the-us-confirm-that-aliens-exist-before-2027-789-924-249",
});
输出:Market
输出:Market
type Market = {
id: string;
slug?: string | null;
question?: string | null;
conditionId: string | null;
outcomes: {
yes: { tokenId: string | null };
no: { tokenId: string | null };
};
};
{
"id": "703257",
"slug": "will-the-us-confirm-that-aliens-exist-before-2027-789-924-249",
"question": "Will the US confirm that aliens exist before 2027?",
"conditionId": "0x747dc809fb79e1b05be09c42d6179459a58de2ef3e40f02484a4e1260f741f75",
"outcomes": {
"yes": {
"tokenId": "107505882767731489358349912513945399560393482969656700824895970500493757150417"
},
"no": {
"tokenId": "7305630249804085635496399869905769372294302716159034447326228509068694952392"
}
}
}
在 也可以通过 Polymarket URL 或 slug 获取市场:
AsyncPublicClient 或 AsyncSecureClient 上调用 get_market(),按 ID 获取市场。
同步的 PublicClient 和 SecureClient 也提供相同方法。market = await client.get_market(id="703257")
# market: Market
market = await client.get_market(
url="https://polymarket.com/market/will-the-us-confirm-that-aliens-exist-before-2027-789-924-249",
)
market = await client.get_market(
slug="will-the-us-confirm-that-aliens-exist-before-2027-789-924-249",
)
输出:Market
输出:Market
class MarketOutcome:
token_id: str | None
class MarketOutcomes:
yes: MarketOutcome
no: MarketOutcome
class Market:
id: str
slug: str | None
question: str | None
condition_id: str | None
outcomes: MarketOutcomes
{
"id": "703257",
"slug": "will-the-us-confirm-that-aliens-exist-before-2027-789-924-249",
"question": "Will the US confirm that aliens exist before 2027?",
"condition_id": "0x747dc809fb79e1b05be09c42d6179459a58de2ef3e40f02484a4e1260f741f75",
"outcomes": {
"yes": {
"token_id": "107505882767731489358349912513945399560393482969656700824895970500493757150417"
},
"no": {
"token_id": "7305630249804085635496399869905769372294302716159034447326228509068694952392"
}
}
}
按 ID 获取市场:也可以按 slug 获取市场:
curl "https://gamma-api.polymarket.com/markets/703257"
curl "https://gamma-api.polymarket.com/markets/slug/will-the-us-confirm-that-aliens-exist-before-2027-789-924-249"
输出:Market
输出:Market
Example
{
"id": "703257",
"slug": "will-the-us-confirm-that-aliens-exist-before-2027-789-924-249",
"question": "Will the US confirm that aliens exist before 2027?",
"conditionId": "0x747dc809fb79e1b05be09c42d6179459a58de2ef3e40f02484a4e1260f741f75",
"clobTokenIds": "[\"107505882767731489358349912513945399560393482969656700824895970500493757150417\",\"7305630249804085635496399869905769372294302716159034447326228509068694952392\"]"
}
列出市场
需要可筛选的数据源时,列出市场,例如按标签、体育项目或流动性浏览。- TypeScript
- Python
- API
在
PublicClient 或 SecureClient 上调用 listMarkets(),分页浏览市场。const pages = client.listMarkets({
tagId: 745, // numeric ID for the "nba" tag; see Tags below to look these up
closed: false,
pageSize: 20,
});
for await (const page of pages) {
// page.items: Market[]
}
输出:Market[]
输出:Market[]
Example
[
{
"id": "741099",
"slug": "will-lebron-james-retire-before-next-nba-season",
"question": "Will LeBron James retire before next NBA season?",
"conditionId": "0x73057b771600660ac6e659c5b831587fd3bdd378e63f359731aa3e1538577fb0"
},
{
"id": "1747460",
"slug": "will-giannis-antetokounmpo-play-for-the-atlanta-hawks-in-2026-27",
"question": "Will Giannis Antetokounmpo play for the Atlanta Hawks in 2026-27?",
"conditionId": "0xff2715084bb2cf20d9b88b74ef809c3317b1e99f6c006faee9b83bc85aa0fc99"
},
"..."
]
在
AsyncPublicClient 或 AsyncSecureClient 上调用 list_markets(),分页浏览市场。
同步的 PublicClient 和 SecureClient 也提供相同方法。pages = client.list_markets(
tag_id=745, # numeric ID for the "nba" tag; see Tags below to look these up
closed=False,
page_size=20,
)
async for page in pages:
... # page.items: tuple[Market, ...]
输出:Market[]
输出:Market[]
Example
[
{
"id": "741099",
"slug": "will-lebron-james-retire-before-next-nba-season",
"question": "Will LeBron James retire before next NBA season?",
"condition_id": "0x73057b771600660ac6e659c5b831587fd3bdd378e63f359731aa3e1538577fb0"
},
{
"id": "1747460",
"slug": "will-giannis-antetokounmpo-play-for-the-atlanta-hawks-in-2026-27",
"question": "Will Giannis Antetokounmpo play for the Atlanta Hawks in 2026-27?",
"condition_id": "0xff2715084bb2cf20d9b88b74ef809c3317b1e99f6c006faee9b83bc85aa0fc99"
},
"..."
]
按标签列出活跃市场:
将
curl "https://gamma-api.polymarket.com/markets/keyset?tag_id=745&closed=false&limit=20"
输出:市场分页
输出:市场分页
Example
{
"markets": [
{
"id": "540817",
"slug": "new-rhianna-album-before-gta-vi-926",
"question": "New Rihanna Album before GTA VI?",
"conditionId": "0x1fad72fae204143ff1c3035e99e7c0f65ea8d5cd9bd1070987bd1a3316f772be"
},
"..."
],
"next_cursor": "8ejWEAtEdA8gG05m-tRMeLtBDl1Wbw1fUbXVfm0eYSZ7InYiOjEsImsiOiJtYXJrZXRzIiwib2giOiI0ZjUzY2RhMThjMmJhYTBjMDM1NGJiNWY5YTNlY2JlNWVkMTJhYjRkOGUxMWJhODczYzJmMTExNjEyMDJiOTQ1Iiwia2V5cyI6W3sidCI6InN0cmluZyIsInYiOiI1NTg5NDAifV19"
}
next_cursor 作为 after_cursor 传入,以获取下一页:curl "https://gamma-api.polymarket.com/markets/keyset?tag_id=745&closed=false&limit=20&after_cursor=<next_cursor>"
系列
系列将同一主题下定期发生的一组事件组织在一起。例如,每周的美联储利率决议系列可为每次会议建立一个事件,而贯穿赛季的联赛系列可为每场对阵建立一个事件。获取系列
按 ID 获取系列。- TypeScript
- Python
- API
在
PublicClient 或 SecureClient 上调用 fetchSeries(),按 ID 获取系列。const series = await client.fetchSeries({ id: "1" });
// series: Series
输出:Series
输出:Series
Example
{
"id": "1",
"slug": "nfl",
"title": "NFL",
"recurrence": "weekly",
"closed": false
}
在
AsyncPublicClient 或 AsyncSecureClient 上调用 get_series(),按 ID 获取系列。
同步的 PublicClient 和 SecureClient 也提供相同方法。series = await client.get_series("1")
# series: Series
输出:Series
输出:Series
Example
{
"id": "1",
"slug": "nfl",
"title": "NFL",
"recurrence": "weekly",
"closed": false
}
按 ID 获取系列:
curl "https://gamma-api.polymarket.com/series/1"
输出:Series
输出:Series
Example
{
"id": "1",
"slug": "nfl",
"title": "NFL",
"recurrence": "weekly",
"closed": false
}
列出系列
- TypeScript
- Python
- API
在
PublicClient 或 SecureClient 上调用 listSeries(),分页浏览系列。const pages = client.listSeries({
recurrence: "weekly",
closed: false,
pageSize: 20,
});
for await (const page of pages) {
// page.items: Series[]
}
输出:Series[]
输出:Series[]
Example
[
{ "id": "1", "slug": "nfl", "title": "NFL" },
{ "id": "2", "slug": "nba", "title": "NBA" },
{ "id": "3", "slug": "mlb", "title": "MLB" },
"..."
]
在
AsyncPublicClient 或 AsyncSecureClient 上调用 list_series(),分页浏览系列。
同步的 PublicClient 和 SecureClient 也提供相同方法。pages = client.list_series(
recurrence="weekly",
closed=False,
page_size=20,
)
async for page in pages:
... # page.items: tuple[Series, ...]
输出:Series[]
输出:Series[]
Example
[
{ "id": "1", "slug": "nfl", "title": "NFL" },
{ "id": "2", "slug": "nba", "title": "NBA" },
{ "id": "3", "slug": "mlb", "title": "MLB" },
"..."
]
列出活跃的每周系列:
curl "https://gamma-api.polymarket.com/series?recurrence=weekly&closed=false&limit=20"
输出:Series[]
输出:Series[]
Example
[
{ "id": "1", "slug": "nfl", "title": "NFL" },
{ "id": "2", "slug": "nba", "title": "NBA" },
{ "id": "3", "slug": "mlb", "title": "MLB" },
"..."
]
体育
体育元数据将体育项目映射到 Polymarket 标签和市场类型。你可以用它按联赛浏览体育市场、查询可用于筛选的有效市场类型,或查找球队名单。列出体育项目
- TypeScript
- Python
- API
在
PublicClient 或 SecureClient 上调用 listSports(),列出支持的体育项目。const sports = await client.listSports();
// sports: SportsMetadata[]
输出:SportsMetadata[]
输出:SportsMetadata[]
Example
[
{ "id": 1, "sport": "ncaab", "tags": "1,100149,100639" },
{ "id": 2, "sport": "epl", "tags": "1,82,306,100639,100350" },
{ "id": 3, "sport": "lal", "tags": "1,780,100639,100350" }
]
在
AsyncPublicClient 或 AsyncSecureClient 上调用 get_sports(),列出支持的体育项目。
同步的 PublicClient 和 SecureClient 也提供相同方法。sports = await client.get_sports()
# sports: tuple[SportsMetadata, ...]
输出:SportsMetadata[]
输出:SportsMetadata[]
Example
[
{ "id": 1, "sport": "ncaab", "tags": "1,100149,100639" },
{ "id": 2, "sport": "epl", "tags": "1,82,306,100639,100350" },
{ "id": 3, "sport": "lal", "tags": "1,780,100639,100350" }
]
列出支持的体育项目:
curl "https://gamma-api.polymarket.com/sports"
输出:SportsMetadata[]
输出:SportsMetadata[]
Example
[
{ "sport": "ncaab", "tags": "1,100149,100639" },
{ "sport": "epl", "tags": "1,82,306,100639,100350" },
{ "sport": "lal", "tags": "1,780,100639,100350" }
]
体育市场类型
体育市场的sportsMarketType 字段表示其定价的盘口:独赢盘(哪支球队获胜)、让分盘(胜出多少)或总分盘(双方总得分高于或低于某值)。先获取有效值,再将其中一个或多个传给 listMarkets 进行筛选。
- TypeScript
- Python
- API
在
按类型筛选市场:
PublicClient 或 SecureClient 上调用 fetchSportsMarketTypes(),列出
支持的市场类型。const { marketTypes } = await client.fetchSportsMarketTypes();
// marketTypes: string[]
输出:string[]
输出:string[]
Example
{
"marketTypes": ["moneyline", "spreads", "totals"]
}
const pages = client.listMarkets({
sportsMarketTypes: ["spreads"],
closed: false,
pageSize: 20,
});
for await (const page of pages) {
// page.items: Market[]
}
在
按类型筛选市场:
AsyncPublicClient 或 AsyncSecureClient 上调用
get_sports_market_types(),列出支持的市场类型。同步的
PublicClient 和 SecureClient 也提供相同方法。market_types = await client.get_sports_market_types()
# market_types.market_types: tuple[str, ...] | None
输出:string[]
输出:string[]
Example
{
"market_types": ["moneyline", "spreads", "totals"]
}
pages = client.list_markets(
sports_market_types=["spreads"],
closed=False,
page_size=20,
)
async for page in pages:
... # page.items: tuple[Market, ...]
列出支持的体育市场类型:
按类型筛选市场:
curl "https://gamma-api.polymarket.com/sports/market-types"
输出:string[]
输出:string[]
Example
{
"marketTypes": ["moneyline", "spreads", "totals"]
}
curl "https://gamma-api.polymarket.com/markets/keyset?sports_market_types=spreads&closed=false&limit=20"
列出球队
- TypeScript
- Python
- API
在
PublicClient 或 SecureClient 上调用 listTeams(),分页浏览球队。const pages = client.listTeams({ league: ["nba"], pageSize: 20 });
for await (const page of pages) {
// page.items: Team[]
}
输出:Team[]
输出:Team[]
Example
[
{
"id": 114168,
"name": "Candace's Rising Stars",
"league": "nba",
"abbreviation": "crs"
},
{
"id": 114166,
"name": "Chuck's Global Stars",
"league": "nba",
"abbreviation": "cgs"
},
"..."
]
在
AsyncPublicClient 或 AsyncSecureClient 上调用 list_teams(),分页
浏览球队。同步的 PublicClient 和 SecureClient 也提供相同方法。pages = client.list_teams(league="nba", page_size=20)
async for page in pages:
... # page.items: tuple[Team, ...]
输出:Team[]
输出:Team[]
Example
[
{
"id": 114168,
"name": "Candace's Rising Stars",
"league": "nba",
"abbreviation": "crs"
},
{
"id": 114166,
"name": "Chuck's Global Stars",
"league": "nba",
"abbreviation": "cgs"
},
"..."
]
列出联赛中的球队:
curl "https://gamma-api.polymarket.com/teams?league=nba&limit=20"
输出:Team[]
输出:Team[]
Example
[
{
"id": 114168,
"name": "Candace's Rising Stars",
"league": "nba",
"abbreviation": "crs"
},
"..."
]
搜索
搜索可通过一次自由文本查询返回匹配的事件、标签和个人资料。可用于搜索栏或“跳转到市场”输入框。- TypeScript
- Python
- API
在
PublicClient 或 SecureClient 上调用 search(),搜索 Polymarket。const pages = client.search({ q: "aliens", pageSize: 10 });
for await (const page of pages) {
// page.items.events: Event[]
// page.items.tags: SearchTag[]
// page.items.profiles: Profile[]
}
输出:SearchResults
输出:SearchResults
type Event = {
id: string;
slug?: string | null;
title?: string | null;
};
type SearchTag = {
id: string;
label?: string | null;
slug?: string | null;
eventCount?: number | null;
};
type Profile = {
pseudonym?: string | null;
wallet?: string | null;
};
type SearchResults = {
events: Event[];
tags: SearchTag[];
profiles: Profile[];
};
{
"events": [
{
"id": "90177",
"slug": "will-the-us-confirm-that-aliens-exist-before-2027",
"title": "Will the US confirm that aliens exist by...?"
},
"..."
],
"tags": [],
"profiles": []
}
在
AsyncPublicClient 或 AsyncSecureClient 上调用 search(),搜索
Polymarket。同步的 PublicClient 和 SecureClient 也提供相同方法。pages = client.search(q="aliens", page_size=10)
async for page in pages:
for search_results in page.items:
# search_results.events: tuple[Event, ...]
# search_results.tags: tuple[SearchTag, ...]
# search_results.profiles: tuple[Profile, ...]
...
输出:SearchResults
输出:SearchResults
class Event:
id: str
slug: str | None
title: str | None
class SearchTag:
id: str
label: str | None
slug: str | None
event_count: int | None
class Profile:
pseudonym: str | None
wallet: str | None
class SearchResults:
events: tuple[Event, ...]
tags: tuple[SearchTag, ...]
profiles: tuple[Profile, ...]
{
"events": [
{
"id": "90177",
"slug": "will-the-us-confirm-that-aliens-exist-before-2027",
"title": "Will the US confirm that aliens exist by...?"
},
"..."
],
"tags": [],
"profiles": []
}
搜索 Polymarket:
curl "https://gamma-api.polymarket.com/public-search?q=aliens"
输出:搜索结果
输出:搜索结果
Example
{
"events": [
{
"id": "90177",
"slug": "will-the-us-confirm-that-aliens-exist-before-2027",
"title": "Will the US confirm that aliens exist by...?"
},
"..."
],
"tags": [],
"profiles": [],
"pagination": {
"hasMore": true,
"totalResults": 28
}
}
标签
标签按类别、联赛、人物和主题组织事件与市场。每个标签可以关联多个带有排序的 相关标签,因此形成的是有向图,而不是严格的树状结构。利用这些关系,可以从 一个主题扩展到相邻主题。列出标签
浏览可用标签,例如用于构建类别筛选器。- TypeScript
- Python
- API
在
PublicClient 或 SecureClient 上调用 listTags(),分页浏览标签。const pages = client.listTags({ pageSize: 20 });
for await (const page of pages) {
// page.items: Tag[]
}
输出:Tag[]
输出:Tag[]
Example
[
{
"id": "101867",
"slug": "product-marekt-fit",
"label": "product marekt fit"
},
{ "id": "1512", "slug": "caitlin-clark", "label": "caitlin clark" },
"..."
]
在
AsyncPublicClient 或 AsyncSecureClient 上调用 list_tags(),分页
浏览标签。同步的 PublicClient 和 SecureClient 也提供相同方法。pages = client.list_tags(page_size=20)
async for page in pages:
... # page.items: tuple[Tag, ...]
输出:Tag[]
输出:Tag[]
Example
[
{
"id": "101867",
"slug": "product-marekt-fit",
"label": "product marekt fit"
},
{ "id": "1512", "slug": "caitlin-clark", "label": "caitlin clark" },
"..."
]
列出标签:
curl "https://gamma-api.polymarket.com/tags?limit=20"
输出:Tag[]
输出:Tag[]
Example
[
{
"id": "101867",
"slug": "product-marekt-fit",
"label": "product marekt fit"
},
{ "id": "1512", "slug": "caitlin-clark", "label": "caitlin clark" },
"..."
]
获取标签
通过 slug 获取标签并解析其数字 ID。前文“事件”和“市场”中的tagId/tagIds 筛选器需要使用该 ID。
- TypeScript
- Python
- API
在
PublicClient 或 SecureClient 上调用 fetchTag(),按 slug 获取标签。const nba = await client.fetchTag({ slug: "nba" });
// nba: Tag
输出:Tag
输出:Tag
Example
{ "id": "745", "slug": "nba", "label": "NBA" }
在
AsyncPublicClient 或 AsyncSecureClient 上调用 get_tag(),按 slug
获取标签。同步的 PublicClient 和 SecureClient 也提供相同方法。nba = await client.get_tag(slug="nba")
# nba: Tag
输出:Tag
输出:Tag
Example
{ "id": "745", "slug": "nba", "label": "NBA" }
按 slug 获取标签:
curl "https://gamma-api.polymarket.com/tags/slug/nba"
输出:Tag
输出:Tag
Example
{ "id": "745", "slug": "nba", "label": "NBA" }
获取标签关系
获取某个标签与相关标签之间的关系记录,可用于构建“你可能还喜欢”之类的功能。每条记录只是一个轻量指针(排序值和两个数字标签 ID),而不是完整的标签对象。- TypeScript
- Python
- API
在
PublicClient 或 SecureClient 上调用 fetchRelatedTags(),获取标签的
关系记录。const relatedTags = await client.fetchRelatedTags({ slug: "nba" });
// relatedTags: RelatedTag[]
输出:RelatedTag[]
输出:RelatedTag[]
Example
[{ "id": "58212", "tagId": 745, "relatedTagId": 1512, "rank": 1 }]
在
AsyncPublicClient 或 AsyncSecureClient 上调用 get_related_tags(),
获取标签的关系记录。同步的 PublicClient 和 SecureClient 也提供相同方法。related_tags = await client.get_related_tags(slug="nba")
# related_tags: tuple[RelatedTag, ...]
输出:RelatedTag[]
输出:RelatedTag[]
Example
[{ "id": "58212", "tag_id": 745, "related_tag_id": 1512, "rank": 1 }]
获取标签的关系记录:
curl "https://gamma-api.polymarket.com/tags/slug/nba/related-tags"
输出:RelatedTag[]
输出:RelatedTag[]
Example
[{ "id": "58212", "tagID": 745, "relatedTagID": 1512, "rank": 1 }]
获取相关标签
一次获取某个标签所有相关标签的完整Tag 对象,无需再按 ID 逐个获取。
- TypeScript
- Python
- API
在
PublicClient 或 SecureClient 上调用 fetchRelatedTagResources(),
获取相关标签对象。const relatedTagObjects = await client.fetchRelatedTagResources({
slug: "nba",
status: "active",
});
// relatedTagObjects: Tag[]
输出:Tag[]
输出:Tag[]
Example
[{ "id": "1512", "slug": "caitlin-clark", "label": "caitlin clark" }]
在
AsyncPublicClient 或 AsyncSecureClient 上调用
get_related_tag_resources(),获取相关标签对象。同步的
PublicClient 和 SecureClient 也提供相同方法。related_tag_objects = await client.get_related_tag_resources(
slug="nba",
status="active",
)
# related_tag_objects: tuple[Tag, ...]
输出:Tag[]
输出:Tag[]
Example
[{ "id": "1512", "slug": "caitlin-clark", "label": "caitlin clark" }]
获取相关标签对象:
curl "https://gamma-api.polymarket.com/tags/slug/nba/related-tags/tags"
输出:Tag[]
输出:Tag[]
Example
[{ "id": "1512", "slug": "caitlin-clark", "label": "caitlin clark" }]