Skip to main content

alpaca_trade/
lib.rs

1//! Async Rust client for the Alpaca Trading HTTP API.
2//!
3//! The default builder targets Alpaca paper trading. Use `Client::builder().live()`
4//! to select the live base URL, or `base_url_str(...)` for a custom endpoint.
5//!
6//! Environment variables:
7//!
8//! - `ALPACA_TRADE_API_KEY`
9//! - `ALPACA_TRADE_SECRET_KEY`
10//! - `ALPACA_TRADE_BASE_URL`
11//!
12//! ```no_run
13//! use alpaca_trade::Client;
14//!
15//! let client = Client::builder()
16//!     .credentials_from_env()?
17//!     .base_url_from_env()?
18//!     .build()?;
19//! let _account = client.account();
20//! # Ok::<(), alpaca_trade::Error>(())
21//! ```
22//!
23//! For mock-backed lifecycle validation, see `alpaca-mock` and the workspace
24//! docs site at <https://wmzhai.github.io/alpaca-rust/>.
25//!
26#![forbid(unsafe_code)]
27
28mod client;
29mod error;
30mod pagination;
31
32pub mod account;
33pub mod account_configurations;
34pub mod activities;
35pub mod assets;
36pub mod calendar;
37pub mod clock;
38pub mod options_contracts;
39pub mod orders;
40pub mod portfolio_history;
41pub mod positions;
42pub mod watchlists;
43
44pub use client::{
45    Client, ClientBuilder, DEFAULT_LIVE_BASE_URL, DEFAULT_PAPER_BASE_URL, TRADE_API_KEY_ENV,
46    TRADE_BASE_URL_ENV, TRADE_SECRET_KEY_ENV,
47};
48pub use error::Error;
49
50#[cfg(test)]
51mod tests;