CPI dataset from BLS
The BLS details the construction of the CPI Index in detail here
Moreover, you can find some notes on methodology changes here
You may find the package IndexNumR in R useful for index number calculation, you can find the documentation here