-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_api_format.py
More file actions
50 lines (42 loc) · 2.02 KB
/
debug_api_format.py
File metadata and controls
50 lines (42 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""
Debug script to inspect actual API response format
"""
import asyncio
import json
from clients.gamma_client import GammaClient
async def inspect_markets():
async with GammaClient() as client:
print("Fetching 10 markets...")
markets = await client.get_markets(limit=10, active=True, closed=False)
print(f"\n✅ Got {len(markets)} markets\n")
for i, market in enumerate(markets[:3], 1):
print(f"\n{'='*70}")
print(f"MARKET {i}: {market.get('question', 'NO QUESTION')[:60]}")
print(f"{'='*70}")
# Check key fields
print(f"✓ slug: {market.get('slug', 'MISSING')[:50]}")
print(f"✓ outcomes type: {type(market.get('outcomes', 'MISSING'))}")
print(f"✓ outcomes value: {market.get('outcomes', 'MISSING')}")
# Critical: Check outcomePrices
if 'outcomePrices' in market:
prices = market.get('outcomePrices')
print(f"✓ outcomePrices EXISTS")
print(f" - Type: {type(prices)}")
print(f" - Value: {prices}")
# Try parsing
if isinstance(prices, str):
print(f" - Attempting JSON parse...")
try:
parsed = json.loads(prices)
print(f" - ✅ Parsed to: {parsed}")
print(f" - Parsed types: {[type(p).__name__ for p in parsed]}")
except Exception as e:
print(f" - ❌ Parse failed: {e}")
else:
print(f"❌ outcomePrices MISSING")
# Check other price fields
print(f"\nOther price fields:")
print(f" - lastTradePrice: {market.get('lastTradePrice', 'MISSING')}")
print(f" - bestBid: {market.get('bestBid', 'MISSING')}")
print(f" - bestAsk: {market.get('bestAsk', 'MISSING')}")
asyncio.run(inspect_markets())