Registry / data / finnhub-python

finnhub-python

JSON →
library2.4.28pypypi✓ verified 84d ago

finnhub-python is the official Python client for the Finnhub API, providing institutional-grade financial data. This includes real-time stock prices, global fundamentals, global ETF holdings, and alternative data. The library is actively maintained, with regular updates and a current version of 2.4.27, offering a comprehensive interface for financial market data access.

pip install finnhub-python
INSTALL
IMPORT
SIG · FINNHUB-PYTHON
F
finnhub-python
datapythonv2.4.28
Install
2.2s avg
Import
579ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.4.28 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.608s · 21.3MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.2s · import 0.549s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
from finnhub import Client
import finnhub

This quickstart demonstrates how to initialize the Finnhub client using an API key from an environment variable and fetch basic stock data such as a real-time quote and company profile for Apple Inc. Make sure to replace 'YOUR_FREE_API_KEY_HERE' with a valid Finnhub API key or set the FINNHUB_API_KEY environment variable.

import finnhub import os # Get API key from environment variable for security finnhub_api_key = os.environ.get('FINNHUB_API_KEY', 'YOUR_FREE_API_KEY_HERE') # Setup client finnhub_client = finnhub.Client(api_key=finnhub_api_key) # Fetch real-time stock quote for Apple Inc. quote = finnhub_client.quote('AAPL') print("AAPL Quote:", quote) # Fetch company profile for Apple Inc. company_profile = finnhub_client.company_profile2(symbol='AAPL') print("AAPL Company Profile:", company_profile)
Debug
Known issues
breakingVersion 2.0.0 introduced significant changes, simplifying library usage and making return data more compatible with data analysis libraries like pandas. Code written for version 1.x.x will likely break.
fix
Refer to the CHANGELOG on GitHub and update your code to align with the new API patterns for `finnhub.Client` and data access methods. Many return values are now more directly consumable by pandas DataFrames.
affects: >=2.0.0
gotchaNaming your Python script 'finnhub.py' will lead to a circular import error: 'AttributeError: partially initialized module 'finnhub' has no attribute 'Client''.
fix
Rename your script file to anything other than `finnhub.py` (e.g., `my_finnhub_app.py`) to avoid conflicts with the installed library's module name.
affects: All versions
gotchaFree tier API keys often have strict rate limits (e.g., 60 calls/minute) and may not have access to all resources. Exceeding limits results in '429 Too Many Requests', and attempting to access premium data will return 'You don't have access to this resource.'.
fix
Implement exponential backoff and retry logic for API calls to handle rate limits gracefully. For 'access denied' errors, check the Finnhub API documentation to confirm if the requested endpoint requires a premium subscription, or verify your API key and plan details.
affects: All versions
gotchaWhen deploying applications using `finnhub-python` on certain hosting platforms (e.g., PythonAnywhere), you might encounter '403 Forbidden' errors due to proxy restrictions.
fix
Ensure that the Finnhub API domain (`api.finnhub.io`) is whitelisted on your hosting provider. Contact your hosting support if necessary to confirm and enable access.
affects: All versions
Upgrade
Version history
2.4.28latest on PyPI · released Apr 22, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
61 hits · last 30 days
node
58
Perplexity
1
Resources
finnhub-python — pip install finnhub-python · libregistry