-
Notifications
You must be signed in to change notification settings - Fork 11
Storing the Alpaca API key
Axel Gard edited this page Jul 23, 2024
·
2 revisions
Cira has some different ways of how to store the API key. The code for how this is done can is in the cira/alpaca.py
One of the easy ways to store your key is to so keep it in a file. Cira supports JSON by default. The JSON file needs to have the following format to work with cira.
{
"APCA-API-KEY-ID":"your_pub_key",
"APCA-API-SECRET-KEY":"your_private_key"
}
Then all you need to do is to set the KEY_FILE variable.
cira.alpaca.KEY_FILE = "../mypath/key.json"
You can use environment variables to set the API key.
for Linux and MacOS
export APCA_ID = "your_pub_key"
export APCA_KEY = "your_private_key"
The API function will check for it the environment variable.
You can set the variable directly.
cira.auth.APCA_API_KEY_ID = "my key"
cira.auth.APCA_API_SECRET_KEY = "my secret key"
© Copyright 2024, Axel Gard | Get cira with pip