This guide shows how to retrieve real-time stock prices in Python using the FinancialData.Net API and the fdnpy SDK. It covers single and batch quotes, pandas, alerts, and direct REST calls.
import os
from fdnpy import FinancialDataClient
client = FinancialDataClient(api_key=os.environ["FDN_API_KEY"])
quotes = client.get_stock_quotes(identifiers=["AAPL"])
print(quotes[0])
Requirements
- Python 3.6+
- An API key from FinancialData.Net
- A plan that includes the endpoint you call. The
stock-quotesendpoint requires a Premium plan, whilestock-prices(daily history) is available on the free plan. See pricing.
Set the key as an environment variable.
export FDN_API_KEY="your_api_key"
Install
pip install fdnpy pandas
fdnpy wraps the REST API, paginates automatically, and retries with exponential backoff.
Get a quote
get_stock_quotes calls GET /api/v1/stock-quotes.
quote = client.get_stock_quotes(identifiers=["MSFT"])[0]
Response:
{
"trading_symbol": "MSFT",
"registrant_name": "MICROSOFT CORP",
"time": "2025-09-02 15:55:57",
"price": 502.42,
"change": -2.7,
"percentage_change": -0.53
}
| Field | Description |
|---|---|
trading_symbol | Ticker |
registrant_name | Company name |
time | Quote time (EST) |
price | Last price |
change | Price change |
percentage_change | Percentage change |
Get multiple quotes
identifiers takes a list of ticker symbols. Each request returns quotes for up to 300 symbols.
import pandas as pd
quotes = client.get_stock_quotes(identifiers=["AAPL", "MSFT", "NVDA", "AMZN"])
df = pd.DataFrame(quotes)[["trading_symbol", "price", "change", "time"]]
print(df.sort_values("change", ascending=False))
Batch symbols instead of looping one request per ticker.
Refresh on a schedule
To keep a watchlist current, call get_stock_quotes on an interval. Each call is one request regardless of symbol count.
import os
import time
import pandas as pd
from fdnpy import FinancialDataClient
client = FinancialDataClient(api_key=os.environ["FDN_API_KEY"])
while True:
df = pd.DataFrame(client.get_stock_quotes(identifiers=["AAPL", "MSFT", "NVDA"]))
df = df[["trading_symbol", "price", "change", "time"]]
print(df.sort_values("trading_symbol"))
time.sleep(10)
Price alerts
import os
import time
from fdnpy import FinancialDataClient
client = FinancialDataClient(api_key=os.environ["FDN_API_KEY"])
ALERTS = {"AAPL": ("above", 250.00), "NVDA": ("below", 120.00)}
triggered = set()
while len(triggered) < len(ALERTS):
for quote in client.get_stock_quotes(identifiers=list(ALERTS)):
symbol, price = quote["trading_symbol"], quote["price"]
direction, target = ALERTS[symbol]
hit = price >= target if direction == "above" else price <= target
if hit and symbol not in triggered:
triggered.add(symbol)
print(f"{symbol} {direction} {target}: {price}") # replace with webhook/email
time.sleep(10)
Crypto, forex, indexes, ETFs
Same call pattern, different method.
crypto = client.get_crypto_quotes(identifiers=["BTCUSD", "ETHUSD"])
forex = client.get_forex_quotes(identifiers=["EURUSD", "GBPUSD"])
indexes = client.get_index_quotes(identifiers=["^GSPC", "^DJI"])
etfs = client.get_etf_quotes(identifiers=["SPY", "QQQ"])
- Crypto and forex quote times are UTC. Crypto
changeis over a 24-hour window. - Index symbols use a
^prefix.
Raw REST
All endpoints are GET. Authenticate with a key query parameter.
curl "https://financialdata.net/api/v1/stock-quotes?identifiers=MSFT,AAPL&key=$FDN_API_KEY"
import os
import requests
resp = requests.get(
"https://financialdata.net/api/v1/stock-quotes",
params={"identifiers": "MSFT,AAPL", "key": os.environ["FDN_API_KEY"]},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Add format=csv to get CSV instead of JSON.
Rate limits
| Plan | Limit |
|---|---|
| Free | 300 requests/day |
| Standard | 10 requests/second |
| Premium | 30 requests/second |
| Professional | 30 requests/second |
| Enterprise | 50 requests/second |
| Endpoint | Method | Plan |
|---|---|---|
stock-prices (daily) | get_stock_prices | Free |
stock-quotes | get_stock_quotes | Premium |
crypto-quotes, forex-quotes, index-quotes, etf-quotes | get_*_quotes | Premium |
Troubleshooting
- Auth or permission error: confirm
FDN_API_KEYis set in the running shell and that your plan includes the endpoint. - Timestamps off by hours: stock, index, and ETF quotes are EST, while crypto and forex quotes are UTC.
- Rate limited: batch symbols, increase the refresh interval.