Stock quote API ?

Chris Angelico rosuav at gmail.com
Sun Mar 11 00:26:08 EST 2018


On Sun, Mar 11, 2018 at 4:18 PM, Irv Kalb <Irv at 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



More information about the Python-list mailing list