Today's stories for a state
You will build: a script that prints the stories of the last 24 hours in one state, most widely carried first, with a one-line reading for each and the full summary for the top three.
You need: a key with intel:read, and a workspace that follows the state (or all of India).
1. List the day’s stories
Section titled “1. List the day’s stories”GET /stories with state, a 24-hour window and order=voices puts the stories most outlets carried independently at the top. That is a good proxy for what matters most today; order=risk is the other useful order.
curl "https://dash.alethman.com/api/v1/stories?state=maharashtra&hours=24&order=voices&limit=20" \ -H "Authorization: Bearer $ALETHMAN_KEY"Each story carries label, independent_outlets, risk_level, place and reading: enough for a one-line brief.
2. Read the top stories in full
Section titled “2. Read the top stories in full”GET /stories/{id} adds the summary (where outlets agree and where they differ), every article and the parties the reporting names.
The whole script
Section titled “The whole script”"""Morning brief for one state: python brief.py maharashtra"""import osimport sys
import requests
API = "https://dash.alethman.com/api/v1"s = requests.Session()s.headers["Authorization"] = f"Bearer {os.environ['ALETHMAN_KEY']}"
def get(path, **params): r = s.get(f"{API}{path}", params=params, timeout=30) if not r.ok: err = r.json()["error"] sys.exit(f"{r.status_code} {err['code']}: {err['message']}") return r.json()
state = sys.argv[1] if len(sys.argv) > 1 else "maharashtra"stories = get("/stories", state=state, hours=24, order="voices", limit=20)["data"]if not stories: sys.exit(f"No stories in {state} in the last 24 hours (or the workspace does not follow it).")
print(f"{len(stories)} stories in {state}, last 24 hours\n")for st in stories: level = st["risk_level"] or "unread" print(f"[{level:>8}] {st['independent_outlets']:>3} outlets {st['label']}") if st["reading"]: print(f"{'':14}{st['reading']}")
print("\nIn full:\n")for st in stories[:3]: full = get(f"/stories/{st['id']}") print(full["label"]) print(full["summary"] or (full["tag"] or {}).get("reading") or "") print(f" {full['articles_count']} articles; first seen {full['first_seen'][:16]} UTC\n")// Morning brief for one state: node brief.mjs maharashtraconst API = "https://dash.alethman.com/api/v1";const headers = { Authorization: `Bearer ${process.env.ALETHMAN_KEY}` };
async function get(path, params = {}) { const url = new URL(API + path); url.search = new URLSearchParams(params); const res = await fetch(url, { headers }); const body = await res.json(); if (!res.ok) throw new Error(`${res.status} ${body.error.code}: ${body.error.message}`); return body;}
const state = process.argv[2] ?? "maharashtra";const { data: stories } = await get("/stories", { state, hours: "24", order: "voices", limit: "20" });if (!stories.length) throw new Error(`No stories in ${state} in the last 24 hours.`);
console.log(`${stories.length} stories in ${state}, last 24 hours\n`);for (const st of stories) { console.log(`[${(st.risk_level ?? "unread").padStart(8)}] ${String(st.independent_outlets).padStart(3)} outlets ${st.label}`); if (st.reading) console.log(" ".repeat(14) + st.reading);}
console.log("\nIn full:\n");for (const st of stories.slice(0, 3)) { const full = await get(`/stories/${st.id}`); console.log(full.label); console.log(full.summary ?? full.tag?.reading ?? ""); console.log(` ${full.articles_count} articles; first seen ${full.first_seen.slice(0, 16)} UTC\n`);}14 stories in maharashtra, last 24 hours
[ guarded] 13 outlets Massive fire engulfs Pune’s Timber Market; over 50 shops gutted A late-night fire gutted dozens of timber and plywood shops and six houses at Pune's Timber Market in Bhavani Peth; no injuries were reported.…Variations
Section titled “Variations”- Several states: loop over them, or leave out
stateto cover the whole workspace scope. - One sector in a state: add
sector=public_order_unrest. - Only what is getting worse: keep stories whose
trajectoryisrisingornew. - Where outlets split: a story’s
bloc_finding.statementsays whether coverage divides into camps (Get a story).