# monaco-grpc-sdk
Typed Rust gRPC client SDK for the Monaco Exchange API, generated from Protocol Buffer definitions.
## Usage
### Plaintext (development / localhost)
```toml
[dependencies]
monaco-grpc-sdk = "0.6"
tonic = { version = "0.14", features = ["transport"] }
tokio = { version = "1", features = ["full"] }
```
```rust
use monaco_grpc_sdk::monaco::api::orders::orders_service_client::OrdersServiceClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut client = OrdersServiceClient::connect("http://localhost:9090").await?;
// ...
Ok(())
}
```
### TLS (remote / HTTPS endpoints)
The `transport` feature alone does not enable TLS. To connect to `https://` endpoints, enable a TLS backend in `tonic` and a roots provider:
```toml
[dependencies]
monaco-grpc-sdk = "0.6"
tonic = { version = "0.14", features = ["transport", "tls-ring", "tls-webpki-roots"] }
tokio = { version = "1", features = ["full"] }
```
The gRPC service is exposed behind path-based routing on the same ALB as the REST API (see the [v0.5.2 release notes](https://docs.0xmonaco.com/releases/v0.5.2)). Connect to the environment host on port `443`:
| Development | `develop.apimonaco.xyz` |
| Staging | `staging.apimonaco.xyz` |
```rust
use monaco_grpc_sdk::monaco::api::orders::orders_service_client::OrdersServiceClient;
use tonic::transport::{Channel, ClientTlsConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let channel = Channel::from_static("https://develop.apimonaco.xyz")
.tls_config(ClientTlsConfig::new().with_webpki_roots())?
.connect()
.await?;
let mut client = OrdersServiceClient::new(channel);
// ...
Ok(())
}
```
## Other languages — Buf Schema Registry
The proto definitions that back this SDK are published to BSR at [`buf.build/monaco-sdk/api`](https://buf.build/monaco-sdk/api). Pick a channel that matches the backend branch you're targeting:
| `develop` | `develop` | Latest dev snapshot, breaking changes possible |
| `release-X.Y` | `release/X.Y` | Release candidate |
| `main` | `main` | Latest stable |
Example `buf.gen.yaml` for Go:
```yaml
version: v2
plugins:
- remote: buf.build/protocolbuffers/go
out: gen/go
- remote: buf.build/grpc/go
out: gen/go
inputs:
- module: buf.build/monaco-sdk/api:main
```
```bash
buf generate
```
Python, TypeScript, C++, Java, Ruby, Swift, Kotlin and more are available via [BSR remote plugins](https://buf.build/plugins).
## Regenerating
After proto changes, run from the repo root:
```bash
make sdk-gen
```
This requires a valid `BUF_TOKEN` environment variable with access to `buf.build/monaco-sdk/api`.