Occupational trends:
Whilst the Headline Consumer Price Index (CPI) is the price index that is most commonly referred to (it is the index for all urban areas, for all items), there are in fact many Consumer Price Indicies, across various different geographical regions, or types of goods.
🤖 Scrapes the latest CPI data from StatsSA's website
📈 Graphs of all the different types of inflation indicies
🟰 How much does a category contribute to Headline inflation? Checkbox for percentage-point difference from Headline inflation.
💽 Data downloads of the indicies
🖩 A calculation tool to see the increase in prices compared to an earlier date
9 April 2025: Gosh, it took me five years to find this public API: https://custom.resbank.co.za/SarbWebApi/WebIndicators/Shared/GetTimeseriesObservations/CPI1000A . This current web page will need to be edited.
Do you need the latest inflation index, to show your analysis at the most recent level of prices? You can use this R code to scrape the latest price indicies from StatsSA's website, and tidy the dataset. I often check that there are no bugs with the scraping code month-to-month. You may find future CPI publication dates in the UCT Economics Society's online calendar.
If you cannot run R, you can use the tidy Excel file that I keep updated in my Dropbox storage, or you can pull the .csv file programmatically. I maintain stable URL redirects for those files at http://xlsx.cpi.aidanhorn.co.za (download) and http://csv.cpi.aidanhorn.co.za (raw) respectively.
For example, in Stata, type this at the beginning of your .do file:
import delimited using "https://www.dropbox.com/s/nuv21cnr5w4qaz8/CPI.csv?raw=1" Then merge the data with your dataset.
Or, in R, type:
You can then get indicies at a more frequent rate than monthly (for example, if you are analyzing financial data), by doing a simple interpolation. For example, na.approx() or na.spline() in R.
EconData provides up-to-date data, which is accessible programmatically.
The World Bank releases core CPI data, with an API, but it is only at the annual level. https://data.worldbank.org/indicator/FP.CPI.TOTL.ZG
See the first page of https://aidanhorn.shinyapps.io/time-series-analytics for my inflation graphs web app.
Whilst StatsSA typically reports year-on-year statistics, I also calculate a smooth inflation rate trend, the derivative of a stochastic filter on log CPI. The formula is
=( exp( slope(log CPI trend) )^(time intervals per year) -1 ) *100%
where I use an HP filter for slope(log CPI trend). This formula can also be applied to other time-series variables to find the smooth growth rate trend. (My tweet.)