Skip to content

Authentication

All FinBrain API requests require authentication using your API key passed as a query parameter.

Include your API key in every request using the token query parameter:

https://api.finbrain.tech/v1/endpoint?token=YOUR_API_KEY
Terminal window
curl "https://api.finbrain.tech/v1/ticker/AAPL/predictions/daily?token=YOUR_API_KEY"
  1. Visit finbrain.tech
  2. Create an account or sign in
  3. Navigate to your account dashboard
  4. Copy your API key

Returned when the API key is missing or invalid.

Response:

{
"error": "Unauthorized",
"message": "Invalid or missing API key"
}

Common causes:

  • Missing token parameter in the request
  • Typo in the API key
  • Using an expired or revoked API key

Returned when the API key is valid but lacks permission for the requested resource.

Response:

{
"error": "Forbidden",
"message": "Access denied for this resource"
}

Common causes:

  • Endpoint not included in your subscription tier
  • Account suspended
  • Accessing a restricted resource

Returned when rate limits are exceeded.

Response:

{
"error": "Too Many Requests",
"message": "Rate limit exceeded. Please slow down."
}
TierRequests/DayRequests/Minute
Free10010
Basic1,00060
Professional10,000300
EnterpriseUnlimitedCustom

Never hardcode your API key. Use environment variables:

import os
from finbrain import FinBrainClient
api_key = os.environ.get("FINBRAIN_API_KEY")
fb = FinBrainClient(api_key=api_key)

For local development, use a .env file:

.env
FINBRAIN_API_KEY=your_api_key_here

Add .env to your .gitignore:

.gitignore
.env

In production, use your platform’s secrets management:

  • AWS: Secrets Manager or Parameter Store
  • Google Cloud: Secret Manager
  • Azure: Key Vault
  • Heroku: Config Vars
  • Vercel: Environment Variables
  1. Never commit API keys to version control
  2. Don’t expose keys in client-side code - use a backend proxy
  3. Rotate keys periodically - especially after team member changes
  4. Use different keys for development and production
  5. Monitor usage - check for unexpected API call patterns