Cite a figure with its official source
Resolve a measure’s source_id and print a citation from fields present in the district schema.
Resolve a measure’s source_id and print a citation from fields present in the district schema.
What you will produce: A citation line with publisher host, measure title, period, locator, URL, and reproducibility hashes.
1. Read one district record
This example uses the committed Capital School District artifact.
curl
curl --fail --silent --show-error \
https://www.districtfacts.com/data/v1/de/districts/capital-school-district.jsoncurl
const response = await fetch("https://www.districtfacts.com/data/v1/de/districts/capital-school-district.json");
if (!response.ok) throw new Error(`HTTP ${response.status}`);
interface DistrictRecord {
api_version: string;
state: string;
leaid: string | null;
slug: string;
name: string;
measures: Array<{ status: "published" | "withheld" | "not_collected"; key: string }>;
schools: Array<{ code: string; name: string }>;
line_items: Array<{ code: string; label: string }>;
licence_status: "final" | "under_review";
}
const district = (await response.json()) as DistrictRecord;
console.log(district.name, `${district.measures.length} measures`);JavaScript
const response = await fetch("https://www.districtfacts.com/data/v1/de/districts/capital-school-district.json");
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
console.log(data);Python
import json
from urllib.request import Request, urlopen
request = Request("https://www.districtfacts.com/data/v1/de/districts/capital-school-district.json")
with urlopen(request, timeout=30) as response:
data = json.load(response)
print(json.dumps(data, indent=2))Sample output
{ "name": "Capital School District", "generated_at": "2026-09-25T12:00:00.000Z" }2. Choose an exact published measure
A published cell carries its title in `label`, plus its period, source_id, and cell-level locator.
curl
curl -sS https://www.districtfacts.com/data/v1/de/districts/capital-school-district.json | jq '.measures[] | select(.status == "published" and .key == "edstats_revenue_per_pupil" and .period == "2024-2025")'JavaScript
const district = await fetch("https://www.districtfacts.com/data/v1/de/districts/capital-school-district.json").then(response => response.json());
const measure = district.measures.find(cell => cell.status === "published" && cell.key === "edstats_revenue_per_pupil" && cell.period === "2024-2025");
if (!measure) throw new Error("Measure not found");
console.log(measure);Python
import json
from urllib.request import urlopen
with urlopen("https://www.districtfacts.com/data/v1/de/districts/capital-school-district.json") as response: district = json.load(response)
measure = next(cell for cell in district["measures"] if cell["status"] == "published" and cell["key"] == "edstats_revenue_per_pupil" and cell["period"] == "2024-2025")
print(json.dumps(measure, indent=2))Sample output
{ "label": "Revenue per pupil (DDOE)", "period": "2024-2025", "value": 2592280, "unit": "cents per pupil", "source_id": "de-edstats-fy25" }3. Resolve the source registry entry
Use the measure’s source_id as the key in `sources`. The entry supplies the official URL, source hash, source host, retrieval time, and source-level locator.
curl
curl -sS https://www.districtfacts.com/data/v1/de/districts/capital-school-district.json | jq '. as $d | first(.measures[] | select(.key == "edstats_revenue_per_pupil" and .period == "2024-2025")) as $m | $d.sources[$m.source_id]'JavaScript
const source = district.sources[measure.source_id];
if (!source) throw new Error(`Missing source ${measure.source_id}`);
console.log(source);Python
source = district["sources"][measure["source_id"]]
print(json.dumps(source, indent=2))Sample output
{ "id": "de-edstats-fy25", "source_host": "education.delaware.gov", "sha256": "c0380d7f689ec95e539e9f88ac7151a02daab389e9b0382ab8a57de4d1968b49" }4. Print the citation line
The schema has no separate publisher or dataset-title fields. Use source_host as publisher and the measure label as title; keep period, locator, and official URL verbatim.
curl
curl -sS https://www.districtfacts.com/data/v1/de/districts/capital-school-district.json | jq -r '. as $d | first(.measures[] | select(.key == "edstats_revenue_per_pupil" and .period == "2024-2025")) as $m | $d.sources[$m.source_id] as $s | "Publisher: \($s.source_host). Title: \($m.label). Period: \($m.period). Locator: \($m.locator). URL: \($s.url)"'JavaScript
console.log(`Publisher: ${source.source_host}. Title: ${measure.label}. Period: ${measure.period}. Locator: ${measure.locator}. URL: ${source.url}`);Python
print(f"Publisher: {source['source_host']}. Title: {measure['label']}. Period: {measure['period']}. Locator: {measure['locator']}. URL: {source['url']}")Sample output
Publisher: education.delaware.gov. Title: Revenue per pupil (DDOE). Period: 2024-2025. Locator: Financial Educational Statistics Report 2024–2025 (FY2025); T06, row for district 13; column "Total revenue per pupil". URL: https://education.delaware.gov/wp-content/uploads/2026/05/fy25_edstats_final.pdfAlso retain the directory’s district-record hash. The source hash identifies input bytes; the record hash identifies API response bytes.