Skip to main content

Module client

Module client 

Source
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.
AuthInterceptor
Tonic interceptor that puts the current JWT into the authorization metadata of every call.
FinamApi
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 TokenManager for secret on a fresh channel to ep.

Type Aliases§

Authorized
Channel with the AuthInterceptor on it: the transport type of every client of FinamApi.