# Ch. 16 (API) + Ch. 10 (regression)
import requests, pandas as pd
import statsmodels.formula.api as smf

resp = requests.get(
    "https://api.example-stats.org/v1/indicators",
    params={"indicator": "health_spend_pct_gdp", "year": 2024},
)
resp.raise_for_status()
spending = pd.DataFrame(resp.json()["results"])

combined = spending.merge(outcomes, on="country_code")   # Ch. 7
model = smf.ols(
    "life_expectancy ~ health_spend_pct_gdp + gdp_per_capita",
    data=combined,
).fit()
>>> print(model.summary())
