All examples

10-K filing diff

Pull the two most recent 10-K filings for a ticker and print the year-over-year change in headline financials.

javascript
const API = "https://sec-stream-io.lovable.app/api/public/v1";
const KEY = process.env.SECSTREAM_KEY;
const ticker = process.argv[2] || "AAPL";

const res = await fetch(`${API}/filings?ticker=${ticker}&type=10-K&limit=2`, {
  headers: { Authorization: `Bearer ${KEY}` },
});
const { data } = await res.json();
const [curr, prev] = data.data;
if (!prev) {
  console.log("Need at least 2 10-K filings.");
  process.exit(1);
}

const fields = ["revenue", "net_income", "total_assets", "total_debt"];
console.log(`${ticker} 10-K diff (${curr.period_of_report} vs ${prev.period_of_report})`);
for (const f of fields) {
  const a = curr[f], b = prev[f];
  if (!a || !b) continue;
  const pct = (((a - b) / b) * 100).toFixed(1);
  console.log(`  ${f.padEnd(15)} ${a.toLocaleString().padStart(15)}  (${pct > 0 ? "+" : ""}${pct}%)`);
}