I've been thinking about the subject and I've always wondered, from where do they obtain the data that is analized in applications, I've looked at Nasdaq's website and they do not seem to have any sort of APIs, do the firms parse yahoo's finance section, or are there special contracts, agreements in places with the different stock markets?
There are firms that specialize in providing Market Data for most asset classes. Reuters, Bloomberg and Markit are three of many. The data is sold, so there likely won't be public APIs for most of it. Academics use CRSP to track stock returns - most of the data on efficient markets is from that data set.
Yahoo does have a simple API for obtaining current data for individual stocks. Details here:
But it's not a way to get historic data. For that, you'll probably have to subscribe to a service.