Skip to main content
The SDK uses your Alphacast API key. You give it once, when you create the client.
Treat your API key like a password. Do not commit it, share it, or put it in client-side code.

Get your API key

Open your settings. Next to API Key, click Show Key.

Initialize the client

To use a second key, create a second client.

Read the key from an environment variable

Use a .env file

The SDK installs python-dotenv. Add a .env file:
Add .env to your .gitignore.

Authentication errors

Creating the client does not check the key. Read methods raise an exception on a failed request. For an invalid key, the message includes the status code:
Check that you copied the whole key without extra spaces and that it is your current key. In settings, Reset creates a new key. Scripts that use the old key can stop working. Some write methods and search.datasets behave differently. See Check write results and Search.