stocks_api

Crates.iostocks_api
lib.rsstocks_api
version0.1.6
sourcesrc
created_at2023-04-09 01:26:42.346005
updated_at2023-04-19 09:27:15.902193
descriptionA library to get finance data using YahooFinanceAPI
homepage
repositoryhttps://github.com/Byte-Forge/stocks-api-rs
max_upload_size
id833877
size42,212
Stephan Vedder (feliwir)

documentation

README

stocks_api

CI

Retrieve finance data using YahooFinanceAPI

Examples

Get a single quote

use stocks_api::YahooFinanceAPI;
use tokio::runtime::Runtime;

fn main() {
    let rt = Runtime::new().unwrap();
    let api = YahooFinanceAPI::new();
    let quote = rt.block_on(api.get_quote("AAPL")).unwrap();
    print!("Current AAPL price: {}", quote.regular_market_price)
}

Search for symbols

use stocks_api::YahooFinanceAPI;
use tokio::runtime::Runtime;

fn main() {
    let rt = Runtime::new().unwrap();
    let api = YahooFinanceAPI::new();
    let symbols = rt.block_on(api.search_symbols("Microsoft")).unwrap();
    println!("Search results for: Microsoft");
    println!(
        "{}",
        symbols
            .into_iter()
            .map(|symbol| symbol.symbol)
            .collect::<Vec<String>>()
            .join(",")
    );
}
Commit count: 11

cargo fmt