Expand description
Channel setup and authorized service clients.
FinamApi is the entry point: one lazily connecting channel plus one shared
TokenManager. Every service client it hands out puts the current JWT
into the authorization header of each call, so a client never holds an expired token.
§Examples
use brokapi_finam_protocol::pb::grpc::tradeapi::v1::marketdata::QuoteRequest;
use brokapi_finam_protocol::{ApiEndpoint, FinamApi, start_token_manager};
// `endpoint` is `ApiEndpoint::default()` for the real broker, `secret` is your API secret.
let tokens = start_token_manager(&endpoint, secret, "my-app").await?;
let api = FinamApi::connect(&endpoint, tokens, false)?;
let quote = api
.market_data()
.last_quote(QuoteRequest { symbol: "SBER@MISX".into() })
.await?
.into_inner();
assert_eq!(quote.symbol, "SBER@MISX");Structs§
- ApiEndpoint
- Where and how to connect: the address and the timeouts of the channel.
- Auth
Interceptor - Tonic interceptor that puts the current JWT into the
authorizationmetadata of every call. - Finam
Api - One channel plus a shared token manager. Hands out service clients that attach the JWT to each call.
Constants§
- DEFAULT_
ENDPOINT - Address of the production Trade API (
https://api.finam.ru:443, TLS).
Functions§
- connect_
lazy - Builds a lazily connecting channel to
ep. - start_
token_ manager - Starts a
TokenManagerforsecreton a fresh channel toep.
Type Aliases§
- Authorized
- Channel with the
AuthInterceptoron it: the transport type of every client ofFinamApi.