Polygon.io#
abstract · Cargo Docs
info · Feature flag required
finance-query = { version = "...", features = ["polygon"] }Polygon.io provides real-time and historical market data for stocks, options, forex, crypto, indices, and futures. Free tier: 5 requests per second.
Setup#
Set the API key via environment variable:
export POLYGON_API_KEY="your-polygon-api-key"
No manual init call needed — the provider reads the key during TickerBuilder::build().
Usage#
use finance_query::format::Raw;
use finance_query::{Capability, Fetch, Provider, Providers};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let providers = Providers::builder()
.route(Capability::QUOTE, [Provider::Polygon, Provider::Yahoo])
.fetch(Fetch::Sequential)
.build()
.await?;
let ticker = providers.ticker("AAPL").build().await?;
let quote = ticker.quote::<Raw>().await?;
println!("{} quote received", quote.symbol);
Ok(())
}
Capabilities#
| Data type | Support |
|---|---|
| Quote | ✓ |
| Chart | ✓ |
| Fundamentals | ✓ |
| Corporate | ✓ |
| Options | ✓ |
| Market | ✓ |
| Discovery | ✓ |
| Indices | ✓ |
| Commodities | — |
| Forex | ✓ |
| Crypto | ✓ |
| Futures | ✓ |
| Technicals | ✓ |
| Economic | ✓ |
| Filings | ✓ |
| Sentiment | ✓ |
See Also#
- Multi-Provider Architecture — Provider configuration and strategies
- Ticker API — Single-symbol data access
built with cargo soothfast docs build
source
