Or CAPE ratio?
I would love to be able to pull the current P/E ratio for the S&P 500 into a spreadsheet, for example.
Neither the Google or Yahoo APIs have a P/E ratio associated with indices.
Personal Finance & Money Stack Exchange is a question and answer site for people who want to be financially literate. It only takes a minute to sign up.Sign up to join this community
I don't know of any free APIs (which I assume you are looking for) that do the pre-calculation of that for you. In Robert Shiller's book Irrational Exuberence he referenced data available on his website (here: http://www.econ.yale.edu/~shiller/data.htm), but it is not comprehensive or up to date.
You could however, using any APIs for individual stocks, calculate it for short periods of time. You would need to know the index members, their respective weights, and then fetch historical prices and earnings.
There are plenty of paid sources of this data. Xignite APIs could be used to get the core data pretty easily. And in the past http://www.valueline.com has done this calculation for me, for a charge.