Skip to content

Authentication

Every API call requires a Canard API key. Get yours from the dashboard.

Credential Lookup Order

The SDK checks for credentials in this order:

  1. Direct parameterClient(api_key="...")
  2. Environment variableCANARD_API_KEY
  3. Credentials file~/.canard/credentials

If no key is found, the Client raises ConfigurationError.

Managing Credentials

Save

from canard import save_api_key
save_api_key("your_api_key")
# Saved to ~/.canard/credentials (chmod 600)

Load

from canard import load_api_key
key = load_api_key()  # Returns None if not found

File Location

from canard.utils import get_credentials_path
print(get_credentials_path())  # ~/.canard/credentials

Security

  • The credentials file is created with 0600 permissions (owner read/write only)
  • Never commit API keys to git
  • Use environment variables in CI/CD pipelines
  • Rotate keys from the dashboard if compromised