get_polymarket_event
Retrieve a specific Polymarket event including all its associated prediction markets using the event ID or slug.
Instructions
Get a single Polymarket event with all its associated markets. An event groups related prediction markets under one topic.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| eventId | Yes | Event ID or slug |
Implementation Reference
- src/polymarketApi.ts:113-115 (handler)The actual implementation of getEvent() - calls the Gamma API endpoint /events/{eventId} to fetch a single Polymarket event with all its associated markets.
export async function getEvent(eventId: string): Promise<GammaEvent> { return fetchJson<GammaEvent>(`${GAMMA_BASE}/events/${encodeURIComponent(eventId)}`); } - src/index.ts:1099-1116 (registration)Tool registration for 'get_polymarket_event' with input schema (eventId: string) and handler that calls getEvent(eventId) from polymarketApi.ts.
server.registerTool( "get_polymarket_event", { description: "Get a single Polymarket event with all its associated markets. An event groups related prediction markets under one topic.", inputSchema: { eventId: z.string().describe("Event ID or slug"), }, }, async ({ eventId }) => { try { const event = await getEvent(eventId); return textResult(event); } catch (error) { return errorResult(error); } } ); - src/polymarketApi.ts:60-69 (schema)GammaEvent interface defining the shape of the event object returned by getEvent - includes id, slug, title, description, startDate, endDate, and nested markets array.
export interface GammaEvent { id: string; slug: string; title: string; description: string; startDate: string; endDate: string; markets: GammaMarket[]; [key: string]: unknown; } - src/polymarketApi.ts:19-31 (helper)fetchJson helper used by getEvent to make the HTTP request and parse JSON.
async function fetchJson<T>(url: string): Promise<T> { const response = await fetch(url, { headers: { Accept: "application/json" }, }); if (!response.ok) { throw new PolymarketApiError( `HTTP ${response.status}: ${response.statusText}`, response.status, url ); } return response.json() as Promise<T>; }