> On Mar 10, 2018, at 9:26 PM, Chris Angelico <ros...@gmail.com> wrote: > > On Sun, Mar 11, 2018 at 4:18 PM, Irv Kalb <i...@furrypants.com> wrote: >> Hi, >> >> I teach courses on beginning Python (Python3). In one of my topics, I >> explain how we can write simple programs that reach out to the internet and >> download data (request/response). >> >> I show a number of examples using: urllib.request.urlopen( >> <urlWIthParameters> ) to get things like weather data, currency exchange >> rates, etc. >> >> I just tried my examples again, and they are all working fine, except for >> one. I had an example where I used the call above to get simple (American) >> stock quotes from Yahoo. However, with this example, now I get a bunch >> errors. In tracking it down, I found that Yahoo has shut down this public >> API, discontinued this service. >> >> So ... I am looking for a replacement. I have done quite a bit of >> searching, but I have not been able to find a simple way to get a stock >> quote (no need for historical data - most recent price is fine). I have >> found many examples where people have built custom packages for doing this >> type of thing. However, I am in a college environment, and I cannot install >> any new packages on the computers there. I've also seen examples of people >> building SQL-style queries to get this type of information, but that's >> beyond what I am trying to teach. >> >> Wondering if anyone has any example of an API where I could just make a call >> using Python Standard Library interfaces to get stock quotes? >> > > Check out https://www.alphavantage.co/ for something you can query for > free. Extensive and amazingly useful. One of my students did some > second-tier analysis on the data they provide as a capstone project on > stock trading analysis. > > You may want to consider, though, modifying the "no new packages" > rule. The 'requests' library is WAY better for teaching Python and web > APIs than the raw urllib. Get just a small handful of pip-installable > packages whitelisted and your life will be better. > > ChrisA >
Hi Chris, Thank you very much for this. It is very close to what I am looking for. I had seen this early in my searches but I didn't go into it in detail because it looked like it was designed to give way more information than I was looking for - for example, the first example is about time series data. I did look into it today, and I got a free API key to check it out. It does have the ability to give just a stock quote for a symbol, but it looks like the minimum I can get back is a csv: symbol,price,volume,timestamp MSFT,96.1800,--,2018-03-09 16:01:30 which is easy enough for me to break apart. I just wish there was a way to eliminate the header line so I wouldn't have to go through an explanation about that. Thanks very much. If I can't find another one that just give back a price, I'll probably use this one. Irv PS: The "no new packages" rule is not mine. It's the rule imposed by the college. They are the administrators of the computers and I don't have an admin password. -- https://mail.python.org/mailman/listinfo/python-list