Sample starter scripts
Copy. Paste. Run.
Ready-to-run Python scripts that show what you can build with the PredictionHunt API. Grab your and start experimenting, or run them right here in your browser.
Cross-Platform Price Scanner
~48 linesSee how the same event is priced differently across Polymarket, Kalshi, Opinion, and others.
Key Required
python
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
# Cross-Platform Price Scanner
# Compare how the same event is priced across prediction market platforms.
#
# pip install requests tabulate
import requests
from tabulate import tabulate
API_KEY = "YOUR_API_KEY"
BASE = "https://www.predictionhunt.com/api/v2"
HEADERS = {"X-API-Key": API_KEY}
TOPICS = ["presidential election", "fed interest rate", "bitcoin"]
for topic in TOPICS:
resp = requests.get(
f"{BASE}/search", params={"q": topic, "limit": 3}, headers=HEADERS
).json()
if "error" in resp:
print(f"\nAPI Error: {resp['error']}")
raise SystemExit
print(f"\n{'=' * 60}")
print(f" {topic.upper()}")
print(f"{'=' * 60}")
found = False
for event in resp.get("events", []):
for group in event.get("groups", []):
markets = group.get("markets", [])
if len(markets) < 2:
continue
found = True
rows = []
for m in markets:
rows.append([
m["platform"].capitalize(),
f"{m.get('yes_bid', '-')}",
f"{m.get('yes_ask', '-')}",
f"{m.get('last_price', '-')}",
])
print(f"\n {group['title']} ({event['event_name']})")
print(tabulate(rows, headers=["Platform", "Bid", "Ask", "Last"], tablefmt="grid"))
if not found:
print(" No cross-platform markets found for this topic.")
Need higher limits? View pricing