Check the setup
- Python 3.10 or newer
- A notebook environment such as Jupyter or Google Colab
- A documented BLS series ID
Official U.S. labor-market and price time series for building inflation, employment, wage, and economic-release monitoring tools.
From source to product signal
The BLS Public Data API provides published time series from BLS programs. Start with one documented series ID and a two-year response. Interpretation depends on the series units, seasonal-adjustment status, release cadence, and revisions, so record both the identifier and retrieval date.
Install the packages, then run the notebook cell.
python -m pip install pandas requests
import pandas as pd
import requests
response = requests.get(
"https://api.bls.gov/publicAPI/v2/timeseries/data/CUUR0000SA0",
params={"startyear": "2024", "endyear": "2025"},
timeout=30,
)
response.raise_for_status()
payload = response.json()
if payload["status"] != "REQUEST_SUCCEEDED":
raise RuntimeError(payload["message"])
cpi = pd.DataFrame(payload["Results"]["series"][0]["data"])
cpi = cpi[cpi["period"].str.match(r"M\d{2}")].copy()
cpi["value"] = pd.to_numeric(cpi["value"], errors="coerce")
cpi["date"] = pd.to_datetime(cpi["year"] + "-" + cpi["period"].str[1:] + "-01")
cpi = cpi.sort_values("date")
cpi["change_12m_pct"] = cpi["value"].pct_change(12) * 100
cpi["retrieved_at_utc"] = pd.Timestamp.now(tz="UTC")
print(cpi[["date", "value", "change_12m_pct", "retrieved_at_utc"]].tail(12))Test a useful signal
Calculate the 12-month percentage change in the not-seasonally-adjusted U.S. city average CPI-U series.
U.S. Bureau of Labor Statistics is a government source. Last verified 2026-08-11. Temporal coverage: series-dependent historical records through current releases.