How to set enviroment variables

I’m fairly new to Python, but have run some code. Anyways, how do I set up the env variables like here:

TY!

Which OS are you using?

Windows 10 professional/64

Do you run your code through the CMD?

I am using Pycharm. I have done some stuff in CMD but I don’t know how to setup the environment variable for my API keys. Thanks for your help!

If you run the code through CMD you can add environment variables by:
“setx ENV_VAR_NAME DASHBOARD_VALUE”
where ENV_VAR_NAME is the name of the variable and DASHBOARD_VALUE is the value of the variable

In windows you can also set environment variables by typing in the search bar in the bottom left “edit the system environment variables”, clicking on “environment variables” and adding them to the list in the prompt that comes up

Thank you! So I do see the ENV_VAR_NAME and DASHBOARD_VALUE in the environment variables, I’m still confused what I need to do/edit this to put in my API Base url/keys like the article mentioned. Again, somewhat of a Pythin noob :slight_smile:

lets say your api key is 2187392183 and your secret key is odjfoisudf09j0

you would do this in cmd:
setx APCA_API_KEY_ID 2187392183
setx APCA_API_SECRET_KEY odjfoisudf09j0

or adding these variables to the list in the settings i mentioned above

1 Like

I have my Alpaca API’s set and working using environment variables. I’m trying to add my Alpha Vantage premium key but it is not working. According to this https://github.com/alpacahq/alpaca-trade-api-python, it is:
ALPHAVANTAGE_API_KEY (I have it set like this)

But that doesn’t work and I get no errors. I only know because when I run more than 5 api calls a minute I do get an error telling me I can sign up for more.

Is that the correct variable to use or is it something else?