On C$50 Finance, when I refresh my web server too many times, AlphaVantage stops returning stock quotes.

As a result, Flask returns "TypeError: 'NoneType' object is not subscriptable" when my code tries to use any variable created with the lookup() function.

How can I replace AlphaVantage?

Research: I realized AlphaVantage was the culprit, when I found this answer on CS50 Stack Exchange.

CS50 Exchange Related Question: pset7 index TypeError: 'NoneType' object is not subscriptable

I called the API directly from my browser's address bar. AlphaVantage returned an error message instead of an excel download.

API call pasted into browser and refreshed a couple times: "https://www.alphavantage.co/query?apikey=NAJXWIA8D6VN6A3K&datatype=csv&function=TIME_SERIES_INTRADAY&interval=1min&symbol=GOOG"

AlphaVantage Error: "Please consider optimizing your API call frequency"

AlphaVantage begins to respond again, given enough time. However, for debugging purposes, I need to refresh my app many times. It is inefficient to wait for AlpaVantage to work again, every time I need to try new code.

There is a long list of APIs here, but all of them either seem to be paid, or much more confusing https://www.programmableweb.com/news/96-stocks-apis-bloomberg-nasdaq-and-etrade/2013/05/22

How can I replace AlphaVantage?

1 Answer 1


To avoid AlphaVantage when testing your code, you can return a random price when calling lookup()

Either paste this before the AlphaVantage API call or comment out the AlphaVantage code, then paste this below.

return hard coded values when AlphaVantage does not work


    # return stock's name (as a str), price (as a float), and (uppercased) symbol (as a str)
    return {
        "name": symbol.upper(), # for backward compatibility with Yahoo
        "price": random.randrange(500.00, 1500.00),
        "symbol": symbol.upper()

    return None

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .