Understand the index and how it is made
The consumer price index, or CPI, tracks changes in the prices households pay for a basket of goods and services. A statistics office collects prices and combines them using expenditure weights. Items that account for more household spending have more influence on the headline index. The office also handles changes in product quality and updates the basket as spending patterns change.
The index has a reference base period and a base value, commonly 100. Its level describes price change relative to that reference. It is not a currency amount or the cost of buying the same basket in another country. A household's own spending mix can also differ from the basket behind the national figure.
An inflation rate compares two index levels. The general calculation is (later index / earlier index - 1) × 100. Always state which earlier period you used. Year-over-year, month-over-month, and year-to-date rates answer different questions about the same price series.
Work through an illustrative calculation
All numbers in this calculation are illustrative. Suppose the index is 200 in July of the previous year, 204 in December, 208 in June, and 210 in July of the current year. Each observation uses the same basket series, base period, and adjustment convention.
Year-over-year inflation is (210 / 200 - 1) × 100 = 5%. Month-over-month inflation is (210 / 208 - 1) × 100, or about 0.96%. Year-to-date inflation is (210 / 204 - 1) × 100, or about 2.94%. Narwhal defines the year-to-date comparison against the prior December.
The monthly increase is 2 index points, but it is not 2%. The denominator matters. If inflation later slows while staying positive, the index still rises. Prices are increasing more slowly; they have not returned to their earlier level. A negative change would indicate a fall over the stated interval.
Check the basis before comparing countries
Countries use different expenditure weights, population coverage, and housing treatments. They can also use different base periods. A higher national index level does not show that one country is more expensive than another. Even rebasing both series to the same starting value only compares their subsequent price changes.
Match the observation month and change interval. An annual average inflation measure compares averages across years. A year-over-year rate for one month compares that month with the same month a year earlier. These are not interchangeable. A large movement in the earlier comparison month can also affect the year-over-year rate.
Check seasonal adjustment before comparing monthly changes. Adjustment removes recurring seasonal patterns, and adjusted and unadjusted series can give different monthly results. Keep the same base and adjustment basis when calculating a change yourself. Do not add monthly percentage changes to produce an annual rate; the changes compound.
Request CPI and inflation from Narwhal
Use /v1/economics/{country}/cpi for the headline index and /v1/economics/{country}/inflation for the percentage changes. Both operations use monthly periods in YYYY-MM format. These requests select USA and the same illustrative observation month so the two outputs can be read together.
Send the API key in the Authorization header. Keep it in a server-side environment variable. The inflation response names each comparison interval, so a chart or table can use the field that matches its label.
curl --request GET \
--url "https://api.narwhalapi.com/v1/economics/USA/cpi?period=2026-07" \
--header "Authorization: Bearer $NARWHAL_API_KEY"
curl --request GET \
--url "https://api.narwhalapi.com/v1/economics/USA/inflation?period=2026-07" \
--header "Authorization: Bearer $NARWHAL_API_KEY"Read the index response
This illustrative CPI response shows the index level in value and its reference in base_period and base_value. The value is a decimal string. It represents an index level, so do not append a percent sign to it. The period identifies the observation month; released_on identifies the release date.
The separate inflation response uses year_over_year, month_over_month, and year_to_date with unit set to percent. Its illustrative July values are 3.651%, 0.153%, and 0.755%, respectively. These API examples are separate from the simplified calculation above. Keep the interval visible when displaying any of the three rates.
{
"country": "USA",
"period": "2026-07",
"value": "333.918",
"base_period": "1982-84",
"base_value": "100",
"released_on": "2026-08-12"
}Explore the inflation and CPI data pages
Open Inflation rate by country and CPI by country below to choose the measure your application needs. Use the United States inflation rate page for the country view. Compare the rate with its interval and the index with its base period, then use the Economics API reference for request details.
“Unemployment rate and participation explained” covers another common distinction between a headline rate and the population or total behind it.
Sources and references
- U.S. Bureau of Labor Statistics: CPI questions and answers
- U.S. Bureau of Labor Statistics: calculating percent changes
- U.S. Bureau of Labor Statistics: CPI technical notes
Published . Last reviewed .

