fyers 0.2.0

Idiomatic async Rust client for the Fyers trading API.
Documentation

fyers

An idiomatic, strongly-typed, async Rust client for the Fyers Trading API.

Crates.io Docs.rs CI License

Features

  • Fully async (reqwest + tokio)
  • Typed request builders and response models - no raw JSON responses or dynamic dictionaries
  • Single, ergonomic error type (FyersError)
  • Authentication helpers

Examples

use fyers::{Fyers, FyersError, OrderRequest, OrderType, ProductType, Side, Validity};

#[tokio::main]
async fn main() -> Result<(), FyersError> {
    // Create a fyers client.
    let fyers = Fyers::new("CLIENT_ID", "ACCESS_TOKEN");

    // Get profile info.
    let profile = fyers.profile().await?;
    println!("{profile:?}");

    // Construct an order request.
    let order = OrderRequest::builder(
        "NSE:JIOFIN-EQ",
        1,
        OrderType::Market,
        Side::Buy,
        ProductType::Intraday,
        Validity::Day,
    )
    .offline_order(true) // Chain optional args
    .build(); // build the request

    // Pass it to the appropriate method.
    let order = fyers.place_order(&order).await?;
    println!("{order:?}");

    Ok(())
}

You can find more examples in the examples directory.

Also, check the docs for more information on all the endpoints and return types.

Scope

This crate does not aim to mirror the entire Fyers API one-to-one. Only commonly used and practically necessary endpoints are implemented for now.

If you need support for a specific endpoint, please feel free to open an issue.

License

Licensed under either of:

at your option.