Benzinga Python Client
raw JSON → 1.21 verified Fri May 01 auth: no python
Python client library for Benzinga Data API (financial data). Current version 1.21. Active development on GitHub.
pip install benzinga Common errors
error ModuleNotFoundError: No module named 'benzinga' ↓
cause Library not installed.
fix
pip install benzinga
error benzinga.exceptions.AuthenticationError: 401 Client Error: Unauthorized ↓
cause Invalid or missing API key.
fix
Ensure you have a valid Benzinga API key and pass it to Client: Client(api_key='your_key_here')
error TypeError: Client() got an unexpected keyword argument 'retries' ↓
cause Old version of benzinga (<1.20) does not support retries/timeout.
fix
Upgrade benzinga: pip install --upgrade benzinga
Warnings
breaking In version 1.x, the Client class replaced the old legacy API calls. Ensure you instantiate Client with api_key, retries, timeout. ↓
fix Use `client = benzinga.Client(api_key='...')` instead of raw requests.
gotcha The `data()` method returns raw JSON by default. To get a pandas DataFrame, you must pass `format='pandas'`. ↓
fix `client.data(symbols=[...], format='pandas')`
gotcha API key is required for all requests. The library does not read environment variables automatically; you must pass the key explicitly. ↓
fix Set BENZINGA_API_KEY environment variable or pass string to Client.
deprecated The `retries` and `timeout` parameters in Client were introduced in version 1.20. Older code without these may timeout on slow connections. ↓
fix Update to >=1.20 and add retries=3, timeout=30.
Imports
- benzinga
import benzinga - NewsClient wrong
from benzinga import NewsClientcorrectfrom benzinga.news import NewsClient - InstrumentsClient wrong
from benzinga import InstrumentsClientcorrectfrom benzinga.instruments import InstrumentsClient
Quickstart
import benzinga
client = benzinga.Client(api_key=os.environ.get('BENZINGA_API_KEY', ''), retries=3, timeout=30)
data = client.data(symbols=['AAPL'], start_date='2024-01-01', end_date='2024-01-05', format='json')
print(data)