use fmp_rs::{FmpClient, models::common::Period};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = FmpClient::new()?;
println!("=== FMP API Basic Example ===\n");
println!("1. Getting Apple stock quote...");
let quotes = client.quote().get_quote("AAPL").await?;
if let Some(quote) = quotes.first() {
println!(" Symbol: {}", quote.symbol);
println!(" Price: ${:.2}", quote.price);
println!(" Change: {:.2}%", quote.changes_percentage);
println!(" Volume: {}", quote.volume);
}
println!("\n2. Getting company profile...");
let profiles = client.company_info().get_profile("AAPL").await?;
if let Some(profile) = profiles.first() {
println!(" Company: {}", profile.company_name);
println!(" CEO: {}", profile.ceo);
println!(" Industry: {}", profile.industry);
println!(" Sector: {}", profile.sector);
println!(" Market Cap: ${}", profile.mkt_cap);
println!(" Website: {}", profile.website);
}
println!("\n3. Getting last 3 annual income statements...");
let statements = client
.financials()
.get_income_statement("AAPL", Period::Annual, Some(3))
.await?;
for statement in statements {
println!(
" Year {}: Revenue ${}, Net Income ${}",
statement.calendar_year, statement.revenue, statement.net_income
);
}
println!("\n4. Searching for tech companies...");
let results = client
.company_search()
.search("Microsoft", Some(5), None)
.await?;
for result in results {
println!(
" {} - {} ({})",
result.symbol, result.name, result.exchange_short_name
);
}
println!("\n5. Getting batch quotes for tech giants...");
let batch = client
.quote()
.get_quote_batch(&["AAPL", "MSFT", "GOOGL", "AMZN", "META"])
.await?;
for quote in batch {
println!(
" {}: ${:.2} ({:+.2}%)",
quote.symbol, quote.price, quote.changes_percentage
);
}
println!("\n✅ All examples completed successfully!");
Ok(())
}