I am experimenting with the IEX API. I have created a website to query stock info via a symbol
(e.g. NFLX or AAPL) in an IDE provided via the edX Harvard CS50x course and am now trying to set up VS Code desktop to be independent of their provided IDE.
I am struggling to set my API_KEY in VS Code, desktop version. I downloaded VS Code (desktop version +python, nodejs, flask, etc. etc.), cloned my repository from Github and then tried to run the website to query stock info (which works perfectly fine in the IDE after setting my api-key).
The code for the key looks as follows:
# Contact API
try:
api_key = os.environ.get("API_KEY")
url = f"https://cloud.iexapis.com/stable/stock/{urllib.parse.quote_plus(symbol)}/quote?token={api_key}"
response = requests.get(url)
response.raise_for_status()
except requests.RequestException:
return None
I get the following error: API_KEY not set in VS Code Desktop
I am working on windows and have managed to set the flask app with this syntax: set FLASK_APP=app.py
I set the API_KEY accordingly (set API_KEY=xxx
), but when running flask, I get the error above. I use this command to run flask:python3 -m flask run
I tried to set the API_KEY within the app.py file, just to see if it would work (despite security issues), but no success: os.environ["API_KEY"] = "xxx"
Any experiences with this in windows? I found this stackoverflow post, but that guy didn't get an answer either: How do I set an API_KEY in Windows terminal?