Export forecasts to a spreadsheet
You will build: a CSV of every forecast in your workspace’s sectors, one row each, ready for a spreadsheet or BI tool, and a check of the track record against the API’s own figure.
You need: a key with intel:read.
One request
Section titled “One request”GET /forecasts does not page: limit=200 with status=all returns up to the 200 most recent. Ask per sector if you need more than that.
curl "https://dash.alethman.com/api/v1/forecasts?status=all&limit=200" \ -H "Authorization: Bearer $ALETHMAN_KEY"Beside data, the response carries counts and track_record. Both cover every forecast in your sectors, not only the page returned:
{ "counts": { "open": 90, "due_this_week": 42, "awaiting": 71, "resolved": 351 }, "track_record": { "resolved": 294, "void": 57, "brier_score": 0.22685238095238117 }}The export
Section titled “The export”"""forecasts.csv: every forecast in the workspace's sectors."""import csvimport os
import requests
API = "https://dash.alethman.com/api/v1"s = requests.Session()s.headers["Authorization"] = f"Bearer {os.environ['ALETHMAN_KEY']}"
sectors = s.get(f"{API}/workspace", timeout=30).json()["scope"]["sectors"]rows = {}for sector in sectors: r = s.get(f"{API}/forecasts", params={"sector": sector, "status": "all", "limit": 200}, timeout=30) r.raise_for_status() for f in r.json()["data"]: rows[f["id"]] = f
cols = ["id", "sector", "question", "probability", "made_at", "resolves_by", "status", "outcome", "resolved_at", "resolution_rule", "verdict"]with open("forecasts.csv", "w", newline="", encoding="utf-8") as out: w = csv.DictWriter(out, fieldnames=cols, extrasaction="ignore") w.writeheader() w.writerows(sorted(rows.values(), key=lambda f: f["made_at"], reverse=True))
judged = [f for f in rows.values() if f["outcome"] is not None]if judged: brier = sum((f["probability"] - f["outcome"]) ** 2 for f in judged) / len(judged) print(f"{len(rows)} forecasts, {len(judged)} judged, Brier {brier:.3f}")// forecasts.csv: every forecast in the workspace's sectors.import { writeFileSync } from "node:fs";
const API = "https://dash.alethman.com/api/v1";const headers = { Authorization: `Bearer ${process.env.ALETHMAN_KEY}` };const get = async (path) => { const res = await fetch(API + path, { headers }); if (!res.ok) throw new Error((await res.json()).error.message); return res.json();};
const ws = await get("/workspace");const rows = new Map();for (const sector of ws.scope.sectors) { const { data } = await get(`/forecasts?${new URLSearchParams({ sector, status: "all", limit: "200" })}`); for (const f of data) rows.set(f.id, f);}
const cols = ["id", "sector", "question", "probability", "made_at", "resolves_by", "status", "outcome", "resolved_at", "resolution_rule", "verdict"];const cell = (v) => (v == null ? "" : /[",\n]/.test(String(v)) ? `"${String(v).replaceAll('"', '""')}"` : String(v));const sorted = [...rows.values()].sort((a, b) => b.made_at.localeCompare(a.made_at));writeFileSync("forecasts.csv", [cols.join(","), ...sorted.map((f) => cols.map((c) => cell(f[c])).join(","))].join("\n"));
const judged = sorted.filter((f) => f.outcome !== null);const brier = judged.reduce((s, f) => s + (f.probability - Number(f.outcome)) ** 2, 0) / judged.length;console.log(`${rows.size} forecasts, ${judged.length} judged, Brier ${brier.toFixed(3)}`);Reading the columns
Section titled “Reading the columns”| Column | Notes |
|---|---|
probability |
0 to 1, the chance given when the forecast was made. It never changes afterwards. |
resolves_by |
The deadline. A forecast past it with no verdict has status awaiting. |
outcome |
true came true, false did not, empty until judged. A resolved forecast with an empty outcome was voided: the question could not be settled as asked. |
resolution_rule |
What counts as yes, written when the forecast was made. |
Keeping it fresh
Section titled “Keeping it fresh”Forecasts are made and judged daily. Rerun the export daily and replace the file; rows are keyed by id, and a forecast’s status, outcome, resolved_at and verdict fill in when it is judged.