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 v2 API supports multiple authentication methods. Choose the one that best fits your use case:

Authorization: Bearer YOUR_API_KEY
X-API-Key: YOUR_API_KEY
?apiKey=YOUR_API_KEY
?token=YOUR_API_KEY
from finbrain import FinBrainClient
# Initialize with your API key
fb = FinBrainClient(api_key="YOUR_API_KEY")
# All subsequent calls use Bearer token auth automatically
predictions = fb.predictions.ticker("AAPL", as_dataframe=True)
sentiment = fb.sentiments.ticker("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
# Reads from FINBRAIN_API_KEY env var automatically
fb = FinBrainClient()

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

{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or missing API key"
}
}

Causes:

  • Missing API key
  • Invalid API key
  • Expired API key

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

{
"success": false,
"error": {
"code": "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 plan:

Plan Rate Limit
Terminal + API + MCP 2,000 requests/hour
Enterprise Custom, sized to your throughput requirements

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

Every API response includes rate limit headers so you can track your usage:

Header Description
X-RateLimit-Limit Maximum requests allowed in the current window
X-RateLimit-Remaining Requests remaining in the current window
X-RateLimit-Reset Unix timestamp when the rate limit window resets