INNER CODE UNIT · Python
get_closing_soon_markets_route
caiovicentino/polymarket-mcp-server · src/polymarket_mcp/web/app.py:399
async def get_closing_soon_markets_route(limit: int = 20, hours: int = 24):
"""Get markets closing within the given window (dashboard Markets page).
Mirrors the trending/search routes: tool result is a bare market list,
wrapped as {"markets": [...]} for the dashboard frontend; dict payloads
(error envelopes from the tool) pass through unchanged (stub-compat).
"""
stats["api_calls"] = cast(int, stats["api_calls"]) + 1
try:
result = await market_discovery.handle_tool("get_closing_soon_markets", {
"hours": hours,
"limit": limit,
})
stats["markets_viewed"] = cast(int, stats["markets_viewed"]) + 1
if result and len(result) > 0:
import json