Skip to content

API Authentication

All FinBrain API requests require authentication using your API key. This guide explains how to obtain and use your API key.

  1. Visit finbrain.tech and create an account
  2. Navigate to your account dashboard
  3. Copy your API key from the API section

Your API key is a unique string that identifies your account and tracks your usage.

The FinBrain API uses token-based authentication. Include your API key as a query parameter in every request:

?token=YOUR_API_KEY
from finbrain import FinBrainClient
# Initialize with your API key
fb = FinBrainClient(api_key="YOUR_API_KEY")
# All subsequent calls use this key automatically
# Use as_dataframe=True for pandas DataFrames
df = fb.predictions.ticker("AAPL", prediction_type="daily",
as_dataframe=True)
sentiment_df = fb.sentiments.ticker("S&P 500", "AAPL",
as_dataframe=True)

Follow these best practices to keep your API key secure:

  • Store your API key in environment variables
  • Use secrets management in production (AWS Secrets Manager, HashiCorp Vault, etc.)
  • Rotate your key periodically
  • Use different keys for development and production
  • Commit your API key to version control
  • Share your API key publicly
  • Include your API key in client-side code
  • Log requests that contain your API key
import os
from finbrain import FinBrainClient
# Load from environment variable
api_key = os.environ.get("FINBRAIN_API_KEY")
fb = FinBrainClient(api_key=api_key)

If authentication fails, you’ll receive one of these error responses:

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

Causes:

  • Missing token parameter
  • Invalid API key
  • Expired API key

Solution: Verify your API key is correct and included in the request.

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

Causes:

  • Your subscription doesn’t include this endpoint
  • Account suspended
  • Rate limit exceeded

Solution: Check your subscription tier or contact support.

API rate limits depend on your subscription tier:

TierRequests/DayRequests/Minute
Free10010
Basic1,00060
Professional10,000300
EnterpriseUnlimitedCustom

When you exceed your rate limit, you’ll receive a 429 Too Many Requests response.