FinanceQuery
FinanceQuery is an open-source API for financial data that provides real-time quotes, market data, news, and technical indicators. It sources data from the unofficial Yahoo Finance API, web scraping, and other financial data providers.
The key features are:
- Fast: Very high performance, on par with NodeJS and Go (thanks to FastAPI and Starlette). One of the fastest Python frameworks available for financial data.
- Robust: Get production-ready code. With automatic interactive documentation.
- Standards-based: Based on (and fully compatible with) the open standards for APIs: OpenAPI and JSON Schema.
Free & Open Source
FinanceQuery is completely free and open-source. No hidden fees, no rate limits on your own deployment. Built by developers, for developers.
Production Ready
Deploy to AWS Lambda, Render, or any cloud provider. Includes Docker support, automatic documentation, and comprehensive testing.
Real-Time Data
Get live stock quotes, market data, and financial news through WebSocket connections and REST APIs. Perfect for trading applications and financial dashboards.
Getting Started¶
For requirements, installation instructions and quick start guide, see Getting Started.
Interactive API Documentation¶
For a live interactive API documentation with demo requests, visit Scalar FinanceQuery.
Example Usage¶
A demo API is ready to use out of the box. Here's how to get stock data:
REST API Example¶
# Get detailed quote for NVIDIA stock
curl -X GET 'https://finance-query.onrender.com/v1/quotes?symbols=nvda' \
-H 'x-api-key: your-api-key'
Response¶
[
{
"symbol": "NVDA",
"name": "NVIDIA Corporation",
"price": "120.15",
"change": "-11.13",
"percentChange": "-8.48%",
"marketCap": "2.94T",
"sector": "Technology",
"industry": "Semiconductors"
}
]
WebSocket Real-Time Updates¶
// Connect to WebSocket for real-time updates
const ws = new WebSocket('wss://finance-query.onrender.com/quotes');
ws.onopen = () => {
console.log('Connected to FinanceQuery WebSocket');
ws.send('TSLA'); // Subscribe to Tesla updates
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Real-time update:', data);
};
What You Get¶
In summary, you declare your financial data needs once, and FinanceQuery provides:
-
✅ Data validation:
- Automatic and clear errors when requests are invalid
- Validation for stock symbols, date ranges, and parameters
- Support for complex nested financial data structures
-
✅ Multiple data sources:
- Yahoo Finance integration
- Web scraping for additional data points and fallbacks
- Real-time and historical data support
-
✅ Performance optimizations:
- Cython-accelerated technical indicators
- Redis caching for frequently requested data
- Efficient data processing and serialization
-
✅ Production features:
- Rate limiting and API key management
- Proxy support for reliable data fetching
- Docker containerization
- Cloud deployment ready (AWS Lambda, Render)
Available REST Endpoints¶
Endpoint | Description |
---|---|
/health , /ping |
API status and health monitoring |
/hours |
Trading hours and market status |
/v1/quotes |
Detailed quotes and information |
/v1/simple-quotes |
Simplified quotes with summary information |
/v1/similar |
Find similar quotes to queried symbol |
/v1/historical |
Historical price data with customizable ranges |
/v1/movers |
Market gainers, losers, and most active stocks |
/v1/news |
Financial news and market updates |
/v1/indices |
Major market indices (S&P 500, NASDAQ, DOW) |
/v1/sectors |
Market sector performance and analysis |
/v1/search |
Search for securities with filters |
/v1/indicator |
Get specific indicator history over time |
/v1/indicators |
Technical indicators summary for interval |
/v1/stream |
SSE for real-time quote updates |
Available WebSocket Endpoints¶
Endpoint | Description |
---|---|
/quotes |
Real-time quotes updates |
/profile |
Real-time detailed ticker updates (quote, news, similar) |
/market |
Real-time market updates (indices, news, movers, sectors) |
/hours |
Real-time market hour updates |
Deployment Options¶
Multiple Deployment Options
Perfect for serverless applications with automatic scaling:
Easy deployment with WebSocket support:
Configuration¶
Customize FinanceQuery with environment variables:
These environment variables are optional. The API will function with default settings if not provided.
Security Configuration
Proxy Configuration
Redis Caching
Algolia Search
Performance¶
FinanceQuery leverages:
- FastAPI for lightning-fast HTTP performance
- fastapi-injectable for efficient dependency injection
- curl_cffi for async browser curl impersonation
- lxml for fast and reliable web scraping
- Cython for accelerated technical indicator calculations
- Redis for intelligent caching of market data
- logo.dev for fetching stock logos
License¶
This project is licensed under the terms of the MIT License.
Support & Feedback¶
Need Help?
- 📧 Email: harveytseng2@gmail.com
- 🐛 Issues: GitHub Issues
- 📖 Documentation: OpenAPI Documentation
As most data is scraped, some endpoints may break. If something is not working or if you have any suggestions, please reach out!