-
-{messages.map((message) => (
-
-
-{message.role === 'user' ? 'You' : 'Assistant'}
-
-
{message.content}
-
-))}
-
+ return (
+
+
+ {messages.map((message) => (
+
+
+ {message.role === 'user' ? 'You' : 'Assistant'}
+
+
{message.content}
+
+ ))}
+
-
-);
+ );
}`}
-
### 4. Use in Your App
@@ -127,6 +138,68 @@ export default function HomePage() {
}`}
+## Available Tools
+
+FMP Tools provides comprehensive financial tools organized into categories:
+
+### 📊 Quote Tools
+- `getStockQuote` - Real-time stock quotes and price data
+
+### 🏢 Company Tools
+- `getCompanyProfile` - Comprehensive company profiles and information
+- `getCompanySharesFloat` - Company shares float and liquidity data
+- `getCompanyExecutiveCompensation` - Executive compensation information
+
+### 💰 Financial Tools
+- `getBalanceSheet` - Balance sheet statements (annual/quarterly)
+- `getIncomeStatement` - Income statements (annual/quarterly)
+- `getCashFlowStatement` - Cash flow statements (annual/quarterly)
+- `getKeyMetrics` - Key financial metrics and KPIs (annual/quarterly)
+- `getFinancialRatios` - Financial ratios and metrics (annual/quarterly)
+- `getEnterpriseValue` - Enterprise value calculations (annual/quarterly)
+- `getCashflowGrowth` - Cash flow growth analysis (annual/quarterly)
+- `getIncomeGrowth` - Income growth analysis (annual/quarterly)
+
+### 📈 Market Tools
+- `getMarketPerformance` - Overall market performance data
+- `getSectorPerformance` - Sector performance data
+- `getGainers` - Top gaining stocks
+- `getLosers` - Top losing stocks
+- `getMostActive` - Most actively traded stocks
+
+### 🏛️ Economic Tools
+- `getTreasuryRates` - Treasury rates and yields
+- `getEconomicIndicators` - Economic indicators including GDP, CPI, unemployment, inflation, retail sales, consumer sentiment, durable goods, housing starts, vehicle sales, and more
+
+### 📋 ETF Tools
+- `getETFHoldings` - Holdings for a specific ETF
+- `getETFProfile` - ETF profile and information
+
+### 📅 Calendar Tools
+- `getEarningsCalendar` - Upcoming earnings calendar
+- `getEconomicCalendar` - Economic calendar events
+
+### 🏛️ Congressional Tools
+- `getSenateTrading` - Recent Senate trading activity by symbol
+- `getHouseTrading` - Recent House trading activity by symbol
+- `getSenateTradingByName` - Senate trading by politician name
+- `getHouseTradingByName` - House trading by politician name
+- `getSenateTradingRSSFeed` - Senate trading RSS feed with pagination
+- `getHouseTradingRSSFeed` - House trading RSS feed with pagination
+
+### 🏢 Institutional Tools
+- `getInstitutionalHolders` - Institutional holders for a company
+
+### 👤 Insider Tools
+- `getInsiderTrading` - Insider trading data for a company
+
+### 📊 Stock Tools
+- `getMarketCap` - Market capitalization for a company
+- `getStockSplits` - Historical stock splits for a company
+- `getDividendHistory` - Dividend history and payments for a company
+
+[**View detailed tool categories →**](/docs/tools/categories)
+
## Advanced Configuration
### Custom Tool Selection
@@ -140,48 +213,69 @@ import { quoteTools, financialTools } from 'fmp-ai-tools/vercel-ai';
// Use only quote and financial tools
const selectedTools = {
-...quoteTools,
-...financialTools,
+ ...quoteTools,
+ ...financialTools,
};
export async function POST(req: Request) {
const { messages } = await req.json();
-const result = streamText({
-model: openai('gpt-4o-mini'),
-messages: convertToModelMessages(messages),
-tools: selectedTools as ToolSet,
-});
+ const result = streamText({
+ model: openai('gpt-4o-mini'),
+ messages: convertToModelMessages(messages),
+ tools: selectedTools as ToolSet,
+ });
-return result.toUIMessageStreamResponse();
+ return result.toUIMessageStreamResponse();
}`}
-
### Custom Model Configuration
{`import { openai } from '@ai-sdk/openai';
-import { streamText, convertToModelMessages, ToolSet } from 'ai';
+import { streamText, convertToModelMessages, stepCountIs, ToolSet } from 'ai';
import { fmpTools } from 'fmp-ai-tools/vercel-ai';
export async function POST(req: Request) {
const { messages } = await req.json();
-const result = streamText({
-model: openai('gpt-4o-mini', {
-temperature: 0.7,
-maxTokens: 1000,
-}),
-messages: convertToModelMessages(messages),
-tools: fmpTools as ToolSet,
-stopWhen: stepCountIs(3), // Limit tool usage
-system: \`You are a helpful financial assistant. Use the available tools to provide accurate financial information. Always cite your sources when providing data.\`,
-});
-
-return result.toUIMessageStreamResponse();
+ const result = streamText({
+ model: openai('gpt-4o-mini', {
+ temperature: 0.7,
+ maxTokens: 1000,
+ }),
+ messages: convertToModelMessages(messages),
+ tools: fmpTools as ToolSet,
+ stopWhen: stepCountIs(3), // Limit tool usage
+ system: \`You are a helpful financial assistant. Use the available tools to provide accurate financial information. Always cite your sources when providing data.\`,
+ });
+
+ return result.toUIMessageStreamResponse();
}`}
+
+
+### Using Individual Tools
+
+{`import {
+ getStockQuote,
+ getCompanyProfile,
+ getBalanceSheet
+} from 'fmp-ai-tools/vercel-ai';
+
+// Use only specific tools
+const customTools = {
+ getStockQuote,
+ getCompanyProfile,
+ getBalanceSheet,
+};
+
+const result = streamText({
+ model: openai('gpt-4o-mini'),
+ messages: convertToModelMessages(messages),
+ tools: customTools as ToolSet,
+});`}
## Example Conversations
@@ -206,6 +300,30 @@ Here are some example conversations you can have with your AI assistant:
**Assistant:** "Let me fetch the current treasury rates and the most recent GDP data for you."
+## Tool Parameters
+
+Each tool accepts specific parameters. Here are some common ones:
+
+- `symbol` - Stock/ETF symbol (e.g., "AAPL", "SPY")
+- `period` - For financial statements: "annual" or "quarter"
+- `from` - Start date in YYYY-MM-DD format
+- `to` - End date in YYYY-MM-DD format
+- `name` - For economic indicators: specific indicator name
+
+## Error Handling
+
+The tools include built-in error handling and validation:
+
+- **Input Validation**: All tools use Zod schemas to validate input parameters
+- **API Error Handling**: Graceful handling of FMP API errors and rate limits
+- **User-Friendly Messages**: Clear error messages for debugging and user feedback
+
+## Performance Considerations
+
+- **Tool Selection**: Only include the tools you need to reduce complexity
+- **Rate Limiting**: Be mindful of FMP API rate limits in production
+- **Caching**: Consider implementing caching for frequently requested data
+
## Next Steps
- [View Tool Categories](/docs/tools/categories) - Explore all available tools
@@ -214,3 +332,10 @@ Here are some example conversations you can have with your AI assistant:
- [Error Handling](/docs/tools/error-handling) - Learn about comprehensive error handling
- [API Documentation](/docs/api) - Learn about direct API access
- [GitHub Repository](https://github.com/e-roy/fmp-node-wrapper) - Source code and issues
+
+## Related Resources
+
+- [Vercel AI SDK Documentation](https://sdk.vercel.ai/) - Official Vercel AI SDK docs
+- [OpenAI Platform](https://platform.openai.com/) - OpenAI API documentation
+- [Financial Modeling Prep](https://site.financialmodelingprep.com/pricing-plans?couponCode=eroy) - Get free API key (10% discount on paid plans)
+- [FMP API Documentation](https://financialmodelingprep.com/developer/docs) - FMP API documentation
\ No newline at end of file