Skip to content

deeper747/Climate_Trade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

US–EU CBAM Trade Monitor

Monthly trade flows in CBAM-regulated sectors (iron & steel, aluminum, cement, fertilizers, hydrogen) between the US and EU, with the EU's own import data from Eurostat as a cross-check. Built for the Niskanen Center.

Live dashboard: deeper747.github.io/Climate_Trade


How the data pipeline works

Census Bureau API ──┐
                    ├──► python/build_data.py ──► docs/data/trade_data.json
Eurostat Comext  ───┘                                        │
                                                             ▼
                                                   docs/index.html (GitHub Pages)
                                                             │
                                                             ▼
                                                   User's browser fetches JSON on load

Two data sources are pulled on each update:

Source What it provides Script
US Census Bureau International Trade API Monthly US exports/imports by HS6 code and partner country (2019–present) python/build_data.py
Eurostat Comext DS-045409 Monthly EU27 imports from the US by CN code (2022–present) python/build_data.py

build_data.py aggregates both into a single docs/data/trade_data.json file. The dashboard (docs/index.html) fetches that file in the browser every time a visitor loads the page — no server required.

The two fetch scripts (fetch_eu_trade_raw.py, fetch_us_trade_raw.py) produce the partner-level bilateral CSVs in data/raw/ used for historical analysis and are run as part of the update cycle.


Updating the data (one command)

./update.sh

This runs four steps in sequence:

  1. fetch_eu_trade_raw.py — pulls annual EU bilateral trade from Eurostat Comext → data/raw/eu_trade_hard_to_abate_partner_raw.csv
  2. fetch_us_trade_raw.py — pulls annual US bilateral trade from Census Bureau → data/raw/us_trade_hard_to_abate_partner_raw.csv
  3. build_data.py — calls both APIs again for full monthly time-series, writes docs/data/trade_data.json
  4. git commit + git push — deploys the updated JSON to GitHub Pages

A cloud routine (via Claude Code) creates a GitHub issue on the 15th of each month as a reminder to run this script.

Requires: CENSUS_API_KEY in a .env file at the project root. The Eurostat API needs no key.

CENSUS_API_KEY=your_key_here

Repository structure

python/
  build_data.py               # Fetches Census + Comext APIs → docs/data/trade_data.json
  fetch_eu_trade_raw.py       # Annual EU bilateral trade from Eurostat Comext
  fetch_us_trade_raw.py       # Annual US bilateral trade from Census Bureau

data/
  raw/
    eu_trade_hard_to_abate_partner_raw.csv   # EU bilateral trade by partner/sector/year (EUR)
    us_trade_hard_to_abate_partner_raw.csv   # US bilateral trade by partner/sector/year (USD)
    us_eu27_trade_raw.csv                    # US→EU27 trade by HS6 code
    comext_us_cbam_trade.csv                 # CN-level Comext snapshot
  processed/
    eu_trade_hard_to_abate_partner.csv       # Cleaned EU trade data

docs/
  index.html                  # Dashboard (self-contained, fetches trade_data.json on load)
  data/
    trade_data.json           # Generated by build_data.py — the single data file the browser loads

update.sh                     # One-command update + deploy

CBAM sectors covered

Dashboard key HS codes Notes
Iron & steel (primary) HS 72 + HS 2601.12 CBAM: full chapter
Steel articles HS 73 CBAM: partial, treated as upper bound
Aluminum HS 76 CBAM: most of chapter
Cement HS 2523 + 2507 CBAM: full
Fertilizers HS 31 CBAM: nitrogenous only
Ammonia HS 2814 CBAM: full
Hydrogen HS 2804.10 CBAM: full

Data sources

  • US Census BureauInternational Trade API: domestic exports (FAS value), general imports, and shipping weights by HS6 code and partner country
  • Eurostat Comext (DS-045409): EU27 imports from the US by CN code, monthly, in EUR and tonnes

All values are nominal. Comext values are CIF in euros and are not directly comparable to Census Bureau FAS dollar figures.


License

CC BY-NC 4.0 — © 2026 Niskanen Center. Free to share and adapt with attribution; not for commercial use.

About

Bilateral trade flows in hard-to-abate sectors (iron & steel, aluminum, cement) for both the EU and the U.S., 2019–2023.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors