// Reproduces the 2026-11-24 FMCSA Company Census snapshot. Public open data, no key, $0. // Usage: node fmcsa-census-snapshot.mjs (prints JSON; compare with fmcsa-census-snapshot-2026-11-24.json) const B = 'https://data.transportation.gov/resource/az4n-8mr2.json'; const NAME = "(upper(legal_name) like '%MOVING%' OR upper(legal_name) like '%MOVERS%' OR upper(dba_name) like '%MOVING%' OR upper(dba_name) like '%MOVERS%')"; const base = "status_code='A' AND crgo_household='X'"; const CA = `${base} AND phy_state='CA' AND ${NAME}`; async function n(where) { const u = `${B}?$select=${encodeURIComponent('count(*) as n')}&$where=${encodeURIComponent(where)}`; return Number((await (await fetch(u)).json())[0].n); } const ymd = (days) => new Date(Date.now() - days * 864e5).toISOString().slice(0, 10).replaceAll('-', ''); const out = { source: 'FMCSA Company Census File, data.transportation.gov dataset az4n-8mr2', pulled: new Date().toISOString().slice(0, 10) }; out.us_name_filtered = await n(`${base} AND ${NAME}`); out.ca_name_filtered = await n(CA); out.la_county_037 = await n(`${CA} AND phy_cnty='037'`); out.san_diego_073 = await n(`${CA} AND phy_cnty='073'`); out.orange_059 = await n(`${CA} AND phy_cnty='059'`); out.riverside_065 = await n(`${CA} AND phy_cnty='065'`); out.san_bernardino_071 = await n(`${CA} AND phy_cnty='071'`); out.corona = await n(`${CA} AND upper(phy_city)='CORONA'`); out.added_last_12_months = await n(`${CA} AND add_date >= '${ymd(365)}'`); out.added_last_24_months = await n(`${CA} AND add_date >= '${ymd(730)}'`); out.power_units_le_2 = await n(`${CA} AND power_units::number <= 2`); out.power_units_ge_10 = await n(`${CA} AND power_units::number >= 10`); { const u = `${B}?$select=${encodeURIComponent('phy_city, count(*) as n')}&$where=${encodeURIComponent(CA)}&$group=phy_city&$order=${encodeURIComponent('n DESC')}&$limit=15`; out.top_cities_ca = (await (await fetch(u)).json()).map((r) => [r.phy_city, Number(r.n)]); } console.log(JSON.stringify(out, null, 2));