For developers

Type examples

Worked TypeScript examples that consume Warconomy's published type declarations: import the .d.ts, type the dataset fetch, narrow observations by data mode, join observations to sources, and guard against the clearly-labeled sample rows. Static files only — no runtime API, no SDK. Partial coverage, not real-time.

static reference · data June 5, 2026

These examples consume the published TypeScript declarations to read the dataset in a type-safe way: import the .d.ts, type the fetch of data.json, narrow observations to live values, join each observation to its source for citation, and check confidence and freshness. The types are generated from the same schema the JSON Schemas use, so they stay in lockstep with the export.

  • Consumes /developers/types/warconomy-types.d.ts (also at the dataset path).
  • Narrowing keeps sample rows out of cited figures.
  • Types track the schema; see /developers/changelog for additions.

Import the declarations

Download the .d.ts next to your code, or reference the dataset-level resource. It declares the observation, source, series, provenance, and export shapes.

// curl -s https://warconomy.com/datasets/conflict-economic-impact/types.d.ts -o warconomy-types.d.ts
import type { MetricObservation, Source, DatasetExport } from "./warconomy-types";

Type the dataset fetch

Fetch the export and assert the top-level shape.

const res = await fetch("https://warconomy.com/datasets/conflict-economic-impact/data.json");
const data = (await res.json()) as DatasetExport;
const observations: MetricObservation[] = data.observations;

Narrow by data mode

Only cite live values. The dataMode field discriminates live observations from clearly-labeled sample rows.

const live = observations.filter(
  (o): o is MetricObservation => o.dataMode === "live",
);
// sample rows are illustrative — never cite them as current data

Join observations to sources

Every observation carries a sourceId; build a lookup for citations.

const sourceById = new Map<string, Source>(
  data.sources.map((s) => [s.id, s]),
);
for (const o of live) {
  const src = sourceById.get(o.sourceId);
  console.log(o.value, o.unit, "—", src?.publisher, src?.url);
}

Guard confidence and freshness

Each live value carries a confidence level and an asOf date. Treat them as re-check signals, not correctness guarantees.

const highConfidence = live.filter((o) => o.confidence === "high");
const needsRecheck = (o: MetricObservation) =>
  o.asOf < data.dataAsOf; // older than the dataset's curation date

More

Types overview: /developers/types · declarations: warconomy-types.d.ts · fixtures: /developers/fixtures · validation: /developers/validation.

Related Warconomy pages