| Crates.io | robinrust |
| lib.rs | robinrust |
| version | 1.0.3 |
| created_at | 2025-10-02 23:07:35.167965+00 |
| updated_at | 2025-11-17 04:25:22.852324+00 |
| description | A lightweight, async Rust library for interacting with Robinhood's Crypto trading endpoints. |
| homepage | |
| repository | https://github.com/Saver05/robinrust |
| max_upload_size | |
| id | 1865246 |
| size | 90,954 |
A lightweight, async Rust library for interacting with Robinhood's Crypto trading endpoints. It includes helpers for request signing, market data (best bid/ask and estimated price), account holdings, and basic order management.
Note: This project is community-maintained and is not affiliated with, endorsed by, or supported by Robinhood Markets, Inc. Use at your own risk.
This is a library crate. You can consume it by cloning and adding it to your workspace, or by using a git dependency in Cargo.toml.
Example (git dependency):
[dependencies]
robinrust = { git = "https://github.com/your-org/robinrust" }
If you are developing locally inside the same workspace, you can use a path dependency instead:
[dependencies]
robinrust = { path = "../robinrust" }
The library expects credentials in your environment. A .env file is supported via the dotenv crate.
Required variables:
Example .env:
ROBINHOOD_API_KEY=rh-api-xxxxxxxxxxxxxxxx
ROBINHOOD_SIGNING_PRIVATE_B64=BASE64_OF_32_BYTE_ED25519_SECRET
ROBINHOOD_PUBLIC_KEY=ed25519-pub-key-string
All calls are async. Use within a Tokio runtime.
use robinrust::auth::Robinhood;
use robinrust::market_data::get_best_price;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let rh = Robinhood::from_env();
let resp = get_best_price(&rh, vec!["BTC-USD", "ETH-USD"]).await?;
for r in resp.results {
println!("{} best price: {}", r.symbol, r.price);
}
Ok(())
}
use robinrust::auth::Robinhood;
use robinrust::market_data::get_estimated_price;
use rust_decimal::Decimal;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let rh = Robinhood::from_env();
let quote = get_estimated_price(&rh, "BTC-USD", "bid", Decimal::from(1)).await?;
println!("{:?}", quote);
Ok(())
}
use robinrust::auth::Robinhood;
use robinrust::trading::{get_crypto_trading_pairs, TradingPairs};
use rust_decimal::Decimal;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let rh = Robinhood::from_env();
let pairs = get_crypto_trading_pairs(&rh, vec!["BTC-USD"]).await?;
let btc_usd = &pairs.results[0];
let ok = btc_usd.check_valid_trade(Decimal::from(1));
println!("Size valid? {}", ok);
Ok(())
}
use robinrust::auth::Robinhood;
use robinrust::trading::{get_crypto_orders, GetCryptoOrderParams};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let rh = Robinhood::from_env();
let orders = get_crypto_orders(&rh, GetCryptoOrderParams::builder().symbol("BTC-USD").build()).await?;
println!("Found {} orders", orders.results.len());
Ok(())
}
use robinrust::auth::Robinhood;
use robinrust::trading::{create_crypto_order, cancel_crypto_order, CreateCyptoOrderParams, MarketOrderConfig};
use uuid::Uuid;
use rust_decimal::Decimal;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let rh = Robinhood::from_env();
// Create a market buy order for 0.001 BTC
let params = CreateCyptoOrderParams::builder()
.symbol("BTC-USD")
.client_order_id(Uuid::new_v4().to_string())
.side("buy")
.order_type("market")
.market_order_config(MarketOrderConfig { asset_quantity: Decimal::from_str_radix("0.001", 10).unwrap() })
.build();
let order = create_crypto_order(&rh, params).await?;
println!("Created order {} state={}", order.id, order.state);
// Optionally cancel
let cancel_resp = cancel_crypto_order(&rh, order.id.clone()).await?;
println!("Cancel response: {}", cancel_resp);
Ok(())
}
use robinrust::auth::Robinhood;
use robinrust::trading::get_crypto_holdings;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let rh = Robinhood::from_env();
let holdings = get_crypto_holdings(&rh, vec!["BTC"]).await?;
println!("{:?}", holdings.results);
Ok(())
}