📈 FMP-RS: Production-Grade Rust Client for Financial Modeling Prep
A comprehensive, production-ready Rust wrapper for the Financial Modeling Prep (FMP) API. Designed for high-performance financial applications with enterprise-grade reliability features.
🚀 Features
📊 Comprehensive API Coverage
- 186 API endpoints across all FMP categories
- Complete data models with full type safety
- Real-time and historical financial data
- Stocks, ETFs, Forex, Crypto, and Commodities
🏗️ Production-Grade Architecture
- ⚡ Intelligent Caching - Smart TTL strategies per endpoint
- 🛡️ Advanced Retry Logic - Exponential backoff with jitter
- 📊 Rate Limiting - Token bucket algorithm (300 req/sec default)
- 🔗 Connection Pooling - Optimized HTTP/2 connections
- 📈 Performance Monitoring - Built-in metrics and health checks
- 🧠 Memory Optimization - Chunked bulk data processing
� Developer Experience
- Zero Configuration - Sensible defaults, full customization
- Async/Await Native - Built on Tokio for maximum performance
- Type Safety - Full Rust type system leverage
- Comprehensive Examples - Real-world usage patterns
- Rich Error Handling - Detailed error context and recovery
Installation
Add this to your Cargo.toml:
[]
= "0.1"
= { = "1.0", = ["full"] }
Quick Start
Set your FMP API key as an environment variable:
Or in PowerShell:
$env:FMP_API_KEY = "your_api_key_here"
Then use the client:
use FmpClient;
async
Usage Examples
Company Search
// Search by name
let results = client.company_search
.search
.await?;
// Search by ticker
let results = client.company_search
.search_symbol
.await?;
// Search by CIK
let results = client.company_search
.search_cik
.await?;
Stock Quotes
// Single quote
let quote = client.quote.get_quote.await?;
// Batch quotes
let quotes = client.quote
.get_quote_batch
.await?;
// Exchange quotes
let nyse_quotes = client.quote
.get_exchange_quotes
.await?;
// Price change data
let changes = client.quote
.get_price_change
.await?;
Financial Statements
use Period;
// Income statement
let income = client.financials
.get_income_statement
.await?;
// Balance sheet
let balance = client.financials
.get_balance_sheet
.await?;
// Cash flow statement
let cash_flow = client.financials
.get_cash_flow_statement
.await?;
// Key metrics
let metrics = client.financials
.get_key_metrics
.await?;
// Financial ratios
let ratios = client.financials
.get_ratios
.await?;
Historical Prices
use Timeframe;
// Daily historical prices
let daily = client.charts
.get_historical_prices
.await?;
// Intraday prices
let intraday_1min = client.charts
.get_1min_prices
.await?;
let intraday_5min = client.charts
.get_5min_prices
.await?;
// Custom timeframe
let custom = client.charts
.get_intraday_prices
.await?;
Company Information
// Full company profile
let profile = client.company_info
.get_profile
.await?;
// Key executives
let executives = client.company_info
.get_executives
.await?;
// Market cap
let market_cap = client.company_info
.get_market_cap
.await?;
// Share float
let float = client.company_info
.get_share_float
.await?;
// Stock peers
let peers = client.company_info
.get_peers
.await?;
Custom Configuration
use Duration;
let client = builder
.api_key
.base_url // For testing
.timeout
.build?;
Testing
The library is designed to be testable without making actual API requests.
Running Tests
# Run unit tests (no API key required)
# Run integration tests (requires FMP_API_KEY)
# Run specific test module
Writing Tests with Mocks
The library is structured to allow easy mocking. You can override the base URL to point to a mock server:
API Coverage
This library provides comprehensive coverage of the FMP API:
✅ Implemented
- Company Search (search, CIK, CUSIP, ISIN)
- Stock Quotes (single, batch, exchange)
- Company Information (profile, executives, market cap, peers)
- Financial Statements (income, balance sheet, cash flow)
- Financial Ratios and Key Metrics
- Historical Price Charts (daily and intraday)
- News and Press Releases (general news, company-specific, press releases)
- Analyst Estimates and Ratings (estimates, grades, price targets, consensus)
- SEC Filings (10-K, 10-Q, 8-K, proxy statements, insider transactions)
- Insider Trading (trades, statistics, RSS feeds)
- ETF and Mutual Fund Data (holdings, performance, expense ratios, country allocations)
- Market Performance Indicators (sector performance, market hours, gainers/losers)
- Technical Indicators (RSI, EMA, SMA, Williams %R, ADX, and more)
- Economics Data (treasury rates, economic indicators, commodities)
- Institutional Ownership (Form 13F filings, institutional holders)
- Corporate Actions (stock splits, dividends, mergers & acquisitions)
- Cryptocurrency & Forex data
- Congress Trading (members' trades and statistics)
- ESG Scores and ratings
- Bulk data processing capabilities
Error Handling
The library uses a custom Error type that covers common failure scenarios:
use ;
match client.quote.get_quote.await
Contributing
Contributions are welcome! The API is extensive, and help implementing additional endpoints would be greatly appreciated.
Adding New Endpoints
- Add the response model to
src/models/ - Implement the endpoint in the appropriate file under
src/endpoints/ - Add tests in the endpoint module
- Update the README
License
This project is licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Disclaimer
This library is not officially associated with or endorsed by Financial Modeling Prep. Use of the FMP API is subject to their terms of service and API usage limits.