Reference
SDKs & Libraries
The Heisenberg API is a single POST endpoint — no SDK required. But here are ready-to-use wrappers to get you started faster.
Python
requests or httpx — zero dependencies beyond stdlib
heisenberg.py — drop into your project
import requests
class Heisenberg:
URL = "https://narrative.agent.heisenberg.so/api/v2/semantic/retrieve/parameterized"
def __init__(self, token: str):
self.headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
def query(self, agent_id: int, params: dict = None,
limit: int = 10, offset: int = 0):
body = {
"agent_id": agent_id,
"params": params or {},
"pagination": {"limit": limit, "offset": offset},
"formatter_config": {"format_type": "raw"}
}
resp = requests.post(self.URL, json=body, headers=self.headers)
resp.raise_for_status()
return resp.json()
# Usage
h = Heisenberg("YOUR_API_TOKEN")
markets = h.query(574, {"min_volume": "1000", "closed": "False"})
print(markets["data"]["results"])JavaScript / TypeScript
Fetch API — works in Node.js, Deno, Bun, and browsers
heisenberg.ts — drop into your project
const URL = "https://narrative.agent.heisenberg.so/api/v2/semantic/retrieve/parameterized";
export async function query(
token: string,
agentId: number,
params: Record<string, string> = {},
limit = 10,
offset = 0
) {
const resp = await fetch(URL, {
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
agent_id: agentId,
params,
pagination: { limit, offset },
formatter_config: { format_type: "raw" },
}),
});
if (!resp.ok) throw new Error(`${resp.status}: ${await resp.text()}`);
return resp.json();
}
// Usage
const data = await query("YOUR_TOKEN", 574, { min_volume: "1000" });
console.log(data.data.results);cURL
Quick testing from the command line
Shell
# Set your token once
export HEISENBERG_TOKEN="YOUR_API_TOKEN"
# Query any endpoint by changing agent_id and params
curl -s -X POST https://narrative.agent.heisenberg.so/api/v2/semantic/retrieve/parameterized \
-H "Authorization: Bearer $HEISENBERG_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"agent_id": 574,
"params": {"min_volume": "1000"},
"pagination": {"limit": 5, "offset": 0},
"formatter_config": {"format_type": "raw"}
}' | python3 -m json.toolNo Code? Use Claude MCP
Skip the code entirely. Connect Heisenberg as an MCP server and query prediction markets in natural language directly inside Claude.
Set up Claude MCP →Community Contributions
Building a wrapper, SDK, or integration? We'd love to feature it here. Reach out at contact@heisenberg.so.