1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//! Rust client library for polygon.io
//!
//! # Quick Start
//!
//! ```no_run
//! use polygon::Polygon;
//! use polygon::rest::aggs;
//! use polygon::query::Execute as _;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = Polygon::default().with_key("your_api_key");
//! let result = aggs::previous_close(&client, "AAPL").get().await?;
//! println!("{:?}", result);
//! Ok(())
//! }
//! ```
//!
//! # Query API
//!
//! Endpoints return a `Query` builder. Call `.get()` to execute:
//!
//! ```no_run
//! use polygon::Polygon;
//! use polygon::query::Execute as _;
//! use polygon::rest::{raw, tickers};
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = Polygon::default().with_key("your_api_key");
//!
//! // Raw JSON response
//! let json = raw::tickers::related(&client, "AAPL").get().await?;
//!
//! // Decoded into typed structs
//! let data = tickers::all(&client)
//! .param("limit", 10)
//! .params([("exchange", "XNYS"), ("sort", "ticker")])
//! .get()
//! .await?;
//!
//! println!("{:?} {:?}", data[0].ticker, data[0].name);
//! # Ok(())
//! # }
//! ```
//!
//! # Features
//!
//! - **`reqwest`** (default) - Uses [`reqwest`](https://docs.rs/reqwest) as the HTTP client.
//! Disable this if you want to provide your own HTTP client implementation.
//!
//! - **`decoder`** (default) - Enables typed response decoding using the [`decoder`](https://docs.rs/decoder) crate.
//! Provides `rest::tickers`, `rest::aggs`, etc. that return strongly-typed Rust structs.
//! Raw JSON endpoints in `rest::raw::*` are always available regardless of this feature.
//!
//! - **`dotenvy`** - Enables loading API keys from environment variables via [`dotenvy`](https://docs.rs/dotenvy).
//! Adds `Polygon::new()` which loads `POLYGON_API_KEY` from `.env` or environment.
//! Without this feature, use `Polygon::default().with_key("your_key")` instead.
// Re-export main types
pub use ;
pub use Request;
/// The main polygon.io API client with the default `reqwest::Client` HTTP client.
///
/// This type alias is only available when the `reqwest` feature is enabled.
/// When `reqwest` is disabled, use `client::Polygon<YourClient>` directly.
pub type Polygon = Polygon;
// When reqwest is disabled, re-export the generic Polygon
pub use Polygon;