Expand description
Low-level T-Bank (T-Invest) API wire protocol: the gRPC client generated from the official .proto.
This is the protocol layer of the T-Bank connector. It knows how to talk to the broker and
nothing about orders, books or events. The connector crate brokapi-tbank sits on top of it and
turns these messages into the shared brokapi-core types. Use this crate directly only when you
need a call the connectors do not wrap.
v1- generated messages, enums and gRPC clients. Every service and method of the official contract is generated. Their documentation comes from the.protocomments.TbankConfig- endpoint (production, sandbox or a local mock), token, account, timeouts.TbankClient- one shared HTTP/2 channel with Bearer-token authorization. Each accessor (for exampleTbankClient::orders) returns a ready generated client.AuthInterceptor- the piece that addsauthorization: Bearer <token>to every request.money-QuotationandMoneyValue(units and nano) converted to and fromDecimal, withoutf64on the way.ProtocolError- configuration and transport errors raised while building the channel.
The full guide is in the book: https://brokapi.ru/docs/.
§Examples
The example below starts the in-process T-Bank mock, builds a client for it and lists the accounts the token can see. Nothing touches the network and no money is involved.
use brokapi_tbank_protocol::{TbankClient, TbankConfig};
// In real code: `TbankConfig::sandbox("t.your-token")` or `TbankConfig::production(..)`.
let client = TbankClient::new(&cfg)?;
let accounts = client.list_accounts().await?;
assert!(!accounts.is_empty());
for account in &accounts {
println!("account {}", account.id);
}Re-exports§
pub use client::AuthInterceptor;pub use client::Authed;pub use client::TbankClient;pub use config::PROD_ENDPOINT;pub use config::SANDBOX_ENDPOINT;pub use config::TbankConfig;pub use error::ProtocolError;
Modules§
- client
- gRPC channel with Bearer-token authorization.
- config
- Client configuration: endpoint, token, account.
- error
- Protocol-level errors.
- money
Quotation/MoneyValue(units + nano) <-> [Decimal], exactly.- v1
- Messages, enums and gRPC clients generated from the official T-Bank
.protofiles.
Constants§
- FILE_
DESCRIPTOR_ SET - The descriptors of every service and message of the API, as a serialized
FileDescriptorSet(the.protofiles this crate is built from, with their imports). Load it into a descriptor pool to call a method by its name, seeTbankClient::grpc.