Skip to main content

rhood_core/
lib.rs

1//! Async Rust client for the Robinhood trading API.
2//!
3//! Provides authenticated access to stock quotes, options chains, order
4//! placement, and account data through [`RobinhoodClient`].
5//!
6//! # Example
7//!
8//! ```no_run
9//! use rhood_core::RobinhoodClient;
10//!
11//! # async fn run() -> rhood_core::Result<()> {
12//! let client = RobinhoodClient::new()?;
13//! client.login_from_cache().await?;
14//!
15//! let quotes = client.get_quotes(&["AAPL", "TSLA"]).await?;
16//! for quote in quotes {
17//!     println!("{:?}: {:?}", quote.symbol, quote.last_trade_price);
18//! }
19//! # Ok(())
20//! # }
21//! ```
22//!
23//! # Modules
24//!
25//! - [`auth`] - Device token generation, token caching, and auth state machine
26//! - [`client`] - [`RobinhoodClient`] struct with authenticated HTTP helpers
27//! - [`config`] - [`RhoodConfig`] loaded from TOML files and environment variables
28//! - [`endpoints`] - API methods organized by domain (stocks, options, orders, account)
29//! - [`error`] - [`RhoodError`] enum with [`thiserror`] integration
30//! - [`models`] - Serde response types for API data
31//! - [`pagination`] - Generic paginated response wrappers
32//! - [`api`] - Robinhood API path constants
33
34#![warn(missing_docs)]
35#![forbid(unsafe_code)]
36
37/// Robinhood API path constants organized by domain.
38pub mod api;
39/// Authentication state machine, token caching, and device token generation.
40pub mod auth;
41/// The [`RobinhoodClient`] struct and its HTTP transport methods.
42pub mod client;
43/// Configuration loaded from TOML files, environment variables, and defaults.
44pub mod config;
45/// Endpoint methods on [`RobinhoodClient`] organized by domain.
46pub mod endpoints;
47/// Environment variable abstraction ([`Env`](env::Env)/[`SystemEnv`](env::SystemEnv)/[`MapEnv`](env::MapEnv))
48/// plus [`env_non_empty`](env::env_non_empty) helpers threaded through the config loader
49/// so tests can inject env values without mutating process state.
50pub mod env;
51/// Error types for this crate.
52pub mod error;
53/// Serde response structs for Robinhood API data.
54pub mod models;
55/// Generic paginated and results response wrappers.
56pub mod pagination;
57/// In-memory caches for identity/metadata lookups (symbol ↔ id, etc.).
58pub mod resolver_cache;
59/// Small shared helpers (e.g. URL parsing utilities).
60pub mod util;
61
62pub use client::RobinhoodClient;
63pub use config::RhoodConfig;
64pub use error::{ChallengeType, RhoodError};
65pub use resolver_cache::ResolverCache;
66
67/// A specialized [`Result`](std::result::Result) type for this crate.
68///
69/// All fallible operations in `rhood-core` return this type.
70pub type Result<T> = std::result::Result<T, RhoodError>;