Use the Finnhub API to query stock market data, including real-time prices, company fundamentals, candlestick data, financial statements, and more.
Features
- Real-time stock prices - Get real-time quotes for stocks
- Company fundamentals - Query company overview, industry, market cap, and other information
- Candlestick data - Get historical price data (daily, weekly, monthly)
- Financial statements - Query income statements, balance sheets, cash flow statements
- News sentiment - Get stock-related news and sentiment analysis
- Search stocks - Search for stocks by company name or ticker
- Analyst ratings - Query analyst recommendations, price targets, earnings estimates (new)
Usage
1. Query real-time stock prices
node ~/.openclaw/workspace/skills/finnhub-stock/scripts/query.mjs quote AAPL
2. Query company fundamentals
node ~/.openclaw/workspace/skills/finnhub-stock/scripts/query.mjs profile AAPL
3. Get candlestick data
node ~/.openclaw/workspace/skills/finnhub-stock/scripts/query.mjs candle AAPL --resolution D --days 30
4. Search stocks
node ~/.openclaw/workspace/skills/finnhub-stock/scripts/query.mjs search Apple
5. Query financial statements
node ~/.openclaw/workspace/skills/finnhub-stock/scripts/query.mjs financials AAPL
6. Get news
node ~/.openclaw/workspace/skills/finnhub-stock/scripts/query.mjs news AAPL
7. Query comprehensive analyst ratings (recommended)
node ~/.openclaw/workspace/skills/finnhub-stock/scripts/query.mjs rating AAPL
8. Query analyst recommendation trends
node ~/.openclaw/workspace/skills/finnhub-stock/scripts/query.mjs recommendation TSLA
9. Query analyst price targets
node ~/.openclaw/workspace/skills/finnhub-stock/scripts/query.mjs target MSFT
10. Query earnings estimates
node ~/.openclaw/workspace/skills/finnhub-stock/scripts/query.mjs earnings GOOGL
Parameter descriptions
symbol: Stock ticker (e.g., AAPL, TSLA, MSFT)--resolution: Candlestick resolution (1, 5, 15, 30, 60, D, W, M)--days: Get data for the last N days--from: Start date (YYYY-MM-DD)--to: End date (YYYY-MM-DD)
Supported markets
- US Stocks
- Global stocks
- Forex
- Crypto
API limits
Free tier limits:
- 60 requests per minute
- Real-time data access
Examples
Query Apple Inc. stock price
node ~/.openclaw/workspace/skills/finnhub-stock/scripts/query.mjs quote AAPL
Output:
{
"c": 150.25, // 当前价格
"h": 151.50, // 最高价
"l": 149.80, // 最低价
"o": 150.00, // 开盘价
"pc": 149.50, // 前收盘价
"t": 1234567890
}
Query Tesla Inc. company information
node ~/.openclaw/workspace/skills/finnhub-stock/scripts/query.mjs profile TSLA
Get the last 30 days of daily candlestick data
node ~/.openclaw/workspace/skills/finnhub-stock/scripts/query.mjs candle AAPL --resolution D --days 30
Configuration
Need to configure .openclaw/env.json in Finnhub API key:
{
"FINNHUB_API_KEY": "your_api_key_here"
}
Get API key: visit Finnhub.io to register for a free account.
Notes
- Need to configure
.openclaw/env.jsoninFINNHUB_API_KEYenvironment variable - Stock tickers need to use the correct format (usually uppercase)
- The free tier has a request rate limit (60 per minute), please use it reasonably
- Data is for reference only and does not constitute investment advice
Technical details
- Implemented using Node.js
- RESTful API calls
- JSON format output
- Supports command-line parameters