#io #polygon #daily #market #stock #rest #api

polygon_rs_api

Unofficial Library for interacting with the polygon.io api

2 releases

0.6.4 Nov 15, 2024
0.6.3 Nov 11, 2024
0.4.0 Oct 7, 2024
0.3.3 Nov 16, 2023
0.1.0 Oct 24, 2023

#17 in #stocks

Download history 18/week @ 2024-09-20 151/week @ 2024-10-04 30/week @ 2024-10-11 2/week @ 2024-10-18 104/week @ 2024-11-01 358/week @ 2024-11-08 198/week @ 2024-11-15 16/week @ 2024-11-22 4/week @ 2024-11-29 4/week @ 2024-12-06

234 downloads per month

MIT license

290KB
8K SLoC

polygon-rs-api

Unofficial Library for interacting with the polygon.io api.

This library has no affliation with polygon.io and makes no effort to do so. Use at your own risk.

use polygon_rs_api::{rest::market::{daily::{Daily, DailyRequest}, previous::PreviousRequest}, Stocks};

fn main() {
    let api_key = String::from("<API_KEY>");
    
    if let Ok(previous) = Stocks::get_previous(&api_key, String::from("AAPL"), None) {
        match serde_json::to_string(&previous) {
            Ok(prev) => println!("{}", prev),
            Err(e) => println!("Error: {}", e),
        }
    }

    let use_traits_for_custom_structs = MyStruct::new();
    println!("{:#?}", use_traits_for_custom_structs);
}

#[derive(Debug)]
pub struct MyStruct {
    pub daily: Daily,
}

impl DailyRequest for MyStruct {}

impl MyStruct {
    pub fn new() -> Self {
        let daily = Self::get_daily(&String::from("<API_KEY>"), String::from("AAPL"), String::from("2024-10-29"), None).unwrap();
        Self { daily }
    }
}

Dependencies

~10–23MB
~328K SLoC