There are two main free finance API's that I know of: Yahoo and Google. I prefer Yahoo's Finance API over Google's simply because it offers more data. Arguably, it could also be said that it is easier to use. However, I do not know what the terms of use on the APIs are. YahooOverviewThere are two options I know of for Yahoo's Finance APIs: CSV and YQL. The CSV API is great for getting historical data and YQL is great for getting the latest data in bulk. As I will mention later, there are a few other alleged Yahoo APIs that I haven't tested out. Yahoo CSV Finance APIAs Vitalyson explained on a StackOverflow comment, you can send a request to Yahoo's CSV API and get historical data. For example, http://ichart.finance.yahoo.com/table.csv?s=^GSPC&ignore=.csv However, there are many other parameters, such as date range, that you can pass as explains. Yahoo YQL Finance APIYou can send a YQL query to Yahoo's API which returns an XML document. An example query request looks like: They also show how to do this in a post on the YQL blog. Other Yahoo Finance APIsAs mentioned, there are several other alleged finance APIs that Yahoo has, but I haven't tested them:
Yahoo Finance API LibrariesA C# Example for YQLhttp://www./get-yahoo-finance-api-data-via-yql/ A PHP Example for YQLIf you are writing PHP, here is an example snippet: $tickers = array('GLD', 'SLV'); $url = 'http://query./v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20%28%22'.implode(',', $tickers).'%22%29&env=store://datatables.org/alltableswithkeys'; And then make an HTTP request to that URL in your code. YahooFinanceAPI (for PHP)I wrote a simple YahooFinanceAPI script on GitHub that supports YQL. I have not contributed to it in a long time, but I welcome any collaborators. Here is an example of how to use it: $y = new YahooFinanceAPI; $tickers = array('SLV','GLD'); $data = $y->api($tickers); Yahoo! Managed (for .NET)There is a seemingly well put together program for Yahoo's webservice in general that includes the finance APIs on Google Code called Yahoo! Managed. It could also be used for code examples. Google Finance APIOfficially, it would seem that Google has discontinued their Finance API. However, they do have support for Google Finance data in their Google Docs using the GoogleFinance() function (example). Also, Digitalpbk describes an API that seems to still work (example). In addition, it looks like their iGoogle API still works too (example). Other Finance APIsI have not tried any of these:
|
|