A teacher or student can turn live official data into exercises. This page runs two: the real interest rate from a policy rate and inflation, and the price growth hidden inside nominal GDP growth, with the requests, the responses and the Python calculation.
Exercise 1: the real interest rate
Students learn that a nominal rate hides the loss of purchasing power. The exercise needs a policy rate and an inflation rate for the same country. The request below returns the US policy rate, and the next one returns US inflation.
curl -s "https://api.narwhalapi.com/v1/economics/USA/central-bank/policy-rate" \
-H "Authorization: Bearer $NARWHAL_API_KEY"{
"country": "USA",
"authority": "federal_reserve",
"currency": "USD",
"instrument": "federal_funds_target_range",
"unit": "percent",
"effective_on": "2026-09-17",
"observed_on": null,
"announced_on": null,
"rate_type": "range",
"lower_bound": "3.75",
"upper_bound": "4.00"
}curl -s "https://api.narwhalapi.com/v1/economics/USA/inflation" \
-H "Authorization: Bearer $NARWHAL_API_KEY"{
"country": "USA",
"period": "2026-09",
"year_over_year": "3.7",
"month_over_month": "0.6",
"year_to_date": "4.0",
"released_on": "2026-10-14"
}The policy rate arrives as a range, lower_bound 3.75 and upper_bound 4.00, so the first question for the class is which single number to use. The script takes the midpoint, 3.875. The inflation figure is year_over_year 3.7 for the period 2026-09. A second question follows: the rate is the level set today, while the inflation figure describes the past twelve months, so the answer is a backward looking real rate. Ask students what an investor would need to know instead.
Exercise 2: price growth hidden in GDP
Nominal GDP growth is the change in the dollar value of output. Real GDP growth removes price changes. The gap between them tells the class how much of nominal growth was prices. The levels come from the GDP route and the real growth from the GDP growth route.
curl -s "https://api.narwhalapi.com/v1/economics/USA/gdp/observations?start=2025-Q3&end=2026-Q3" \
-H "Authorization: Bearer $NARWHAL_API_KEY"{
"annualized": true,
"country": "USA",
"as_of": "2026-10-29T00:00:00Z",
"currency": "USD",
"observations": [
{
"period": "2025-Q3",
"value": "31180493000000"
},
{
"period": "2025-Q4",
"value": "31462523000000"
},
{
"period": "2026-Q1",
"value": "31906274000000"
},
{
"period": "2026-Q2",
"value": "32563030000000"
},
{
"period": "2026-Q3",
"value": "33010036000000"
}
]
}curl -s "https://api.narwhalapi.com/v1/economics/USA/gdp-growth?period=2026-Q3" \
-H "Authorization: Bearer $NARWHAL_API_KEY"{
"country": "USA",
"period": "2026-Q3",
"year_over_year": "2.1",
"quarter_over_quarter": "0.832",
"released_on": "2026-10-29"
}The levels are at current prices, in USD, with annualized set to true. The growth response is real, and year_over_year is 2.1 for 2026-Q3. Both calls refer to the same quarter and the same span, which matters. Mixing a year over year rate with a quarter over quarter rate gives a meaningless answer, so have students name the span of every number before they divide, and write it beside the result in their notes.
Run both calculations
- Real rate, approximate Subtract inflation from the nominal rate: 3.875 minus 3.7 is 0.175 percentage points. This is the shortcut students meet first.
- Real rate, exact Divide one plus the nominal rate by one plus inflation and subtract one: 1.03875 divided by 1.037 minus one is 0.169 percent. The two answers differ in the third decimal, which is a useful talking point.
- Nominal GDP growth Divide the 2026-Q3 level by the 2025-Q3 level, 33010036000000 over 31180493000000, and subtract one. The result is 5.87 percent.
- Implied price growth Divide one plus nominal growth by one plus real growth, 1.0587 over 1.021, and subtract one. The result is 3.69 percent.
import os import requests BASE = "https://api.narwhalapi.com" HEAD = {"Authorization": f"Bearer {os.environ['NARWHAL_API_KEY']}"} def get(path, **params): r = requests.get(BASE + path, params=params, headers=HEAD, timeout=15) r.raise_for_status() return r.json() # Exercise 1: the real policy rate policy = get("/v1/economics/USA/central-bank/policy-rate") lower, upper = float(policy["lower_bound"]), float(policy["upper_bound"]) rate = (lower + upper) / 2 inflation = float(get("/v1/economics/USA/inflation")["year_over_year"]) approx = rate - inflation exact = ((1 + rate / 100) / (1 + inflation / 100) - 1) * 100 print(f"policy {rate} inflation {inflation} approx {approx:.3f} exact {exact:.3f}") # Exercise 2: how much of nominal GDP growth is price growth levels = get("/v1/economics/USA/gdp/observations", start="2025-Q3", end="2026-Q3") by_quarter = {o["period"]: float(o["value"]) for o in levels["observations"]} nominal = (by_quarter["2026-Q3"] / by_quarter["2025-Q3"] - 1) * 100 real = float(get("/v1/economics/USA/gdp-growth", period="2026-Q3")["year_over_year"]) prices = ((1 + nominal / 100) / (1 + real / 100) - 1) * 100 print(f"nominal {nominal:.2f} real {real} implied price growth {prices:.2f}")
| Exercise | Inputs | Answer |
|---|---|---|
| Real rate, approximate | 3.875 and 3.7 | 0.175 points |
| Real rate, exact | 3.875 and 3.7 | 0.169 percent |
| Nominal GDP growth | 31180493000000 to 33010036000000 | 5.87 percent |
| Implied price growth | 5.87 and 2.1 | 3.69 percent |
The implied price growth sits close to the 3.7 inflation rate from the first exercise. Consumer prices and the prices inside GDP cover different baskets, so ask the class why they could differ more in another quarter.
What other exercises fit the same data?
- Inflation: compare the month on month and year on year fields in one response and ask which one a central bank would quote. The inflation calculator lets students check a result by hand.
- Yield curve: take the 2 year and 10 year yields from the yield curve route and compute the spread, as in the yield curve how-to.
- GDP growth: repeat exercise 2 for another country and compare each country's
annualizedflag first.
Students can check their inputs for each exercise against the published figures, because every route returns the number the calculation starts from.
Can students use their own country?
Often yes, but check coverage first. Indonesia and Brazil returned both an inflation rate and a policy rate. Mexico returned inflation and no policy rate, with a 404 and the code series_not_found. Give students a short list of countries that you have tested yourself, and let them handle a 404 as a data gap in their notebook.
Why do some GDP levels have an annualized flag?
The US, Japan and Canada returned annualized true, so their quarterly levels are expressed at an annual rate. The UK and Germany returned no such flag. A ratio between two levels of the same series is unaffected, which is why exercise 2 works, but two countries' levels are not comparable until the flag, the currency and the period agree.
Is the data fresh enough for a classroom?
Each response shows released_on and period, so students can see how old a figure is. For a lesson, fix the date the class pulls the data and keep the output, because a later call can return a newer period and a different answer.
Published .