FXDatapi

Crates.io Build Status

A Rust library to interact with the Currency API.

Usage

Add this library as a dependency in your Cargo.toml:

toml [dependencies] fxdatapi = "0.1.4"

Authentication

```rs use fxdatapi::auth;

// Currency API Authentication async fn main() { let username = "yourusername"; let password = "yourpassword";

let result = auth::login(username, password).await;

match result {
    Ok(response) => println!("Received response: {:?}", response),
    Err(error) => println!("Error: {:?}", error),
}

} ```

Currencies

```rs use fxdatapi::currencies;

// Get All Currencies async fn currenciesgetall() { let usertype = "member"; let username = "yourusername"; let day = "19"; let month = "04"; let year = "2024"; let uuid = None;

let result = currencies(user_type, username, day, month, year, uuid).await;

match result {
    Ok(response) => println!("Received response (Get All): {:?}", response),
    Err(error) => println!("Error: {:?}", error),
}

}

// Get Currency By ID async fn currenciesgetbyid() { let usertype = "member"; let username = "yourusername"; let day = "19"; let month = "04"; let year = "2023"; let uuid = Some("currencyuuid");

let result = currencies(user_type, username, day, month, year, uuid).await;

match result {
    Ok(response) => println!("Received response (Get By ID): {:?}", response),
    Err(error) => println!("Error: {:?}", error),
}

} ```

Historical

```rs use fxdatapi::historical;

// Get All Historical Data async fn historicalgetall() { let usertype = "member"; let username = "yourusername"; let date = "20230402"; let day = "19"; let month = "04"; let year = "2023"; let uuid = None;

let result = historical(user_type, username, date, day, month, year, uuid).await;

match result {
    Ok(response) => println!("Received response (Get All): {:?}", response),
    Err(error) => println!("Error: {:?}", error),
}

}

// Get Historical Data By ID async fn historicalgetbyid() { let usertype = "member"; let username = "yourusername"; let date = "20230402"; let day = "02"; let month = "04"; let year = "2023"; let uuid = Some("historicaluuid");

let result = historical(user_type, username, date, day, month, year, uuid).await;

match result {
    Ok(response) => println!("Received response (Get By ID): {:?}", response),
    Err(error) => println!("Error: {:?}", error),
}

} ```

Convert

```rs use fxdatapi::convert;

// Converting between two currencies async fn main() { let usertype = "member"; let username = "yourusername"; let date = "20230402"; let basecurrency = "GBP"; let targetcurrency = "EUR"; let amount = "500";

let result = convert::convert(user_type, username, date, base_currency, target_currency, amount).await;

match result {
    Ok(response) => println!("Received response: {:?}", response),
    Err(error) => println!("Error: {:?}", error),
}

} ```

Convert All

```rs use fxdatapi::convert_all;

// Converting between two currencies async fn main() { let usertype = "member"; let username = "yourusername"; let basecurrency = "GBP"; let amount = "500"; let date = "202304_02";

let result = convert_all::convert_all(user_type, username, base_currency, amount, date).await;

match result {
    Ok(response) => println!("Received response: {:?}", response),
    Err(error) => println!("Error: {:?}", error),
}

} ```

Daily Average

```rs use fxdatapi::daily_average;

// Retrieve daily average data async fn main() { let usertype = "member"; let username = "yourusername"; let date = "20230410";

let result = daily_average::daily_average(user_type, username, date).await;

match result {
    Ok(response) => println!("Received response: {:?}", response),
    Err(error) => println!("Error: {:?}", error),
}

} ```

Weekly Average

```rs use fxdatapi::weekly_average;

// Retrieve weekly average data async fn main() { let usertype = "member"; let username = "yourusername"; let fromdate = "20230403"; let todate = "20230407";

let result = weekly_average::weekly_average(user_type, username, from_date, to_date).await;

match result {
    Ok(response) => println!("Received response: {:?}", response),
    Err(error) => println!("Error: {:?}", error),
}

} ```

Monthly Average

```rs use fxdatapi::monthly_average;

// Retrieve monthly average data async fn main() { let usertype = "member"; let username = "yourusername"; let year = "2023"; let month = "04";

let result = monthly_average::monthly_average(user_type, username, year, month).await;

match result {
    Ok(response) => println!("Received response: {:?}", response),
    Err(error) => println!("Error: {:?}", error),
}

} ```

Margins and Spreads

```rs use fxdatapi::margins_spreads;

// Get All Margins and Spreads pub async fn marginsspreadsgetall() { let usertype = "member"; let username = "your_username"; let day = "19"; let month = "04"; let year = "2023"; let uuid = None;

let result = margins_spreads(user_type, username, day, month, year, uuid).await;

match result {
    Ok(response) => println!("Received response (Get All): {:?}", response),
    Err(error) => println!("Error: {:?}", error),
}

}

// Get Margins and Spreads By ID pub async fn marginsspreadsgetbyid() { let usertype = "member"; let username = "yourusername"; let day = "19"; let month = "04"; let year = "2023"; let uuid = Some("marginsspreadsuuid");

let result = margins_spreads(user_type, username, day, month, year, uuid).await;

match result {
    Ok(response) => println!("Received response (Get By ID): {:?}", response),
    Err(error) => println!("Error: {:?}", error),
}

} ```

Performances

```rs use fxdatapi::performances;

// Get All Performances pub async fn performancesgetall() { let usertype = "member"; let username = "yourusername"; let uuid = None;

let result = performances(user_type, username, uuid).await;

match result {
    Ok(response) => println!("Received response (Get All): {:?}", response),
    Err(error) => println!("Error: {:?}", error),
}

}

// Get Performances By ID pub async fn performancesgetbyid() { let usertype = "member"; let username = "yourusername"; let uuid = Some("performancesuuid");

let result = performances(user_type, username, uuid).await;

match result {
    Ok(response) => println!("Received response (Get By ID): {:?}", response),
    Err(error) => println!("Error: {:?}", error),
}

} ```

Signals

```rs use fxdatapi::signals;

// Get All Signals pub async fn signalsgetall() { let usertype = "member"; let username = "yourusername"; let uuid = None;

let result = signals(user_type, username, uuid).await;

match result {
    Ok(response) => println!("Received response (Get All): {:?}", response),
    Err(error) => println!("Error: {:?}", error),
}

}

// Get Signals By ID pub async fn signalsgetbyid() { let usertype = "member"; let username = "yourusername"; let uuid = Some("signalsuuid");

let result = signals(user_type, username, uuid).await;

match result {
    Ok(response) => println!("Received response (Get By ID): {:?}", response),
    Err(error) => println!("Error: {:?}", error),
}

} ```

Setting up Currency API Account

Subscribe here for a user account.

Using the Currency API

You can read the API documentation to understand what's possible with the Currency API. If you need further assistance, don't hesitate to contact us.

License

This project is licensed under the BSD 3-Clause License.

Copyright

(c) 2020 - 2023 Moat Systems Limited.