polygon
A Rust async client library for polygon.io
Quick Start
[]
= "0.1"
= { = "1", = ["macros", "rt-multi-thread"] }
use Polygon;
use aggs;
async
Set your API key via environment variable:
Or use a .env file, or set it manually:
let client = default.with_key;
Query API
Endpoints return a Query builder. Call .get() to execute:
use Execute as _;
use ;
// Raw JSON response
let json = related.get.await?;
// Decoded into typed structs
let data = all
.param
.params
.get
.await?;
println!;
Design:
- Required parameters are function arguments, optional parameters use
.param()or.params() rest::raw::fooreturns JSON strings,rest::fooreturns decoded types- Same API for both: construct query, chain parameters, call
.get() .param()accepts any type implementingParam(integers, strings, bools)- Errors include HTTP status, message, and request ID
Available Endpoints
rest::aggs- Aggregate bars (OHLC)rest::tickers- Ticker reference data
Custom HTTP Client
Implement the Request trait to use your own HTTP client:
use ;
;
let client = with_client?;
License
MIT