Function apex_legends_api::get_user_retry
source · [−]pub async fn get_user_retry(
username: String,
api_key: &str,
retry: bool
) -> Result<ApexUser, String>Expand description
Gets information about a User. This version automatically retries if the API returns code 429 (too many requests).
For the sleep time it reads the x-current-rate header or uses the DEFAULT_RATE
See https://apexlegendsapi.com/#player-statistics
Arguments
username- The Origin username of the playerapi_key- The API key for https://apexlegendsstatus.comretry- Wether to retry after a timeout or error out immediately
Examples
use std::env;
#[tokio::test]
async fn user() {
dotenv::dotenv().expect("Could not load .env file");
let user_name = env::var("USERNAME").expect("Expected key USERNAME");
let api_key = env::var("API_KEY").expect("Expected key API_KEY");
// This example automatically handles the 429 error code (too many requests)
match apex_legends::get_user_retry(String::from(&user_name), &api_key, true).await {
Ok(data) => {
println!(
"You are level {}, and you have {} kills.",
data.global.level, data.stats.br_kills.value
);
}
Err(e) => {
println!("there was an error!: {}", e);
}
}
}