Skip to content

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).

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.

Terminal window
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.

GET /stories/{id} adds the summary (where outlets agree and where they differ), every article and the parties the reporting names.

"""Morning brief for one state: python brief.py maharashtra"""
import os
import 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")
Output (shortened)
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.
…
  • Several states: loop over them, or leave out state to cover the whole workspace scope.
  • One sector in a state: add sector=public_order_unrest.
  • Only what is getting worse: keep stories whose trajectory is rising or new.
  • Where outlets split: a story’s bloc_finding.statement says whether coverage divides into camps (Get a story).