#stocks #trading #alpaca #api #client


Unofficial Alpaca API Client

12 releases

0.3.2 Jul 7, 2023
0.3.1 Jul 5, 2023
0.2.1 Jun 27, 2023
0.1.6 Jun 19, 2023

#43 in Finance

Download history 13/week @ 2023-08-14 25/week @ 2023-08-28 21/week @ 2023-09-04 2/week @ 2023-09-11 5/week @ 2023-09-18 3/week @ 2023-09-25 3/week @ 2023-10-02 6/week @ 2023-10-16 13/week @ 2023-10-30 3/week @ 2023-11-13 31/week @ 2023-11-20 50/week @ 2023-11-27

84 downloads per month


574 lines

Alpaca API Client in Rust

Still a Work In Progress Not Production Ready. Not Liable for Any Issues. Recommended for Paper Accounts only.

Build Status Version 0.3.2

Table of Contents


Alpaca is a trading platform for developers and app makers, and they provide various endpoints to access over http. The goal of this package is to provide the bare minimum tools for using the Alpaca API.

Still exploring Rust and open source development, so this package may not be as professional or robust as other libraries out there. I am committed to creating and maintaining this library to the best of my ability, and do use this daily for stock trading.


  • Get Stock Bars
  • Get Stock Trades
  • Get Positions
  • Place Orders
  • View Account
  • View Activity


To install the Alpaca API Client, you will need Rust installed on your machine. If you don't have Rust installed, you can follow the official guide.

Once Rust is installed, you can install the Alpaca API Client using cargo:

cargo install alpaca_api_client

Add your API keys to an .env file in the root of your directory with these names.




RS Docs

Get Bars for a single stock

use alpaca_api_client::get_bars;

// Args(symbol, timeframe, query)
let bars = get_bars("BTU", "1Day", Some("start=2023-02-23")).unwrap();

Get Bars for multiple symbols

use alpaca_api_client::{get_multi_bars, MultiBars};

fn get_bars_for_sector() -> Option<MultiBars> {
    let watchlist: [&str; 30] = [
        "META", "DIS", "CMCSA", "VZ", "T", "CHTR", "NFLX", "TMUS", "TWTR", "FOXA", "FOX", "DISH",
        "CBS", "OMC", "TME", "TTWO", "EA", "ATVI", "ZM", "MTCH", "IAC", "NTES", "BIDU", "ROKU",
        "SPOT", "LYV", "IQ", "HUYA", "DOYU", "VIAV",

    // Args(stock_symbols, timeframe, query)
    match get_multi_bars(&watchlist, "1Day", Some("start=2023-01-01")) {
        Ok(multi_bars_map) => Some(multi_bars_map),
        Err(e) => {
            println!("MultiBar Request Error:{}", e);

Place Market order

use alpaca_api_client::{place_market_order, OrderSide};

// Args(symbol, quantity, side)
let order = place_market_order("SO", 3.0, OrderSide::Buy).unwrap();

Place Bracket order

use alpaca_api_client::{place_bracket_order, OrderSide};

// Args(symbol, quantity, side, take_profit, stop_loss)
let order = place_bracket_order("ABBV", 3.0, OrderSide::Buy, 170.00, 120.00).unwrap();


Any and all PR's are welcome. This is my first Rust project and my first foray into open source. I see a need for this type of Rust client to support Alpaca's v2 API.


This project is licensed under the MIT and APACHE License.


~106K SLoC