Skip to main content
Every request to the Alphacast API must include an API key. You can obtain your key from your account settings at alphacast.io — navigate to Account Settings → API Key to generate or view your key. Alphacast supports two ways to pass your API key: as an HTTP Basic Auth credential, or as a URL query parameter.
Your API key grants full access to your Alphacast account. Do not share it publicly, commit it to version control, or expose it in client-side code.

Authentication methods

Alphacast supports two ways to pass your API key. HTTP Basic Auth is the recommended option for most integrations.

Authentication errors

If a request is missing credentials or the API key is invalid, the API responds with HTTP 401 Unauthorized:
{"error": "Unauthorized"}
Common causes:
  • The API key was not included in the request
  • The API key has been revoked or regenerated
  • The key was passed as the password instead of the username in Basic Auth

Keeping your API key safe

Store your API key in an environment variable rather than hardcoding it. For example, set ALPHACAST_API_KEY in your environment and read it at runtime:
import os
import requests

api_key = os.environ["ALPHACAST_API_KEY"]

response = requests.get(
    "https://api.alphacast.io/datasets",
    auth=(api_key, "")
)
If you believe your API key has been compromised, regenerate it immediately from your account settings at alphacast.io. Regenerating a key immediately invalidates the previous one.