16 releases

new 0.1.4 May 29, 2024
0.1.3 May 29, 2024
0.0.12 May 5, 2024
0.0.4 Mar 10, 2024
0.0.0 Jul 12, 2023

#1418 in Network programming

Download history 6/week @ 2024-02-28 148/week @ 2024-03-06 31/week @ 2024-03-13 4/week @ 2024-03-20 6/week @ 2024-03-27 15/week @ 2024-04-03 3/week @ 2024-04-10 90/week @ 2024-04-17 1105/week @ 2024-05-01 49/week @ 2024-05-08 9/week @ 2024-05-15 215/week @ 2024-05-22

1,378 downloads per month

MIT license

110KB
3K SLoC

Valorant API

This crate is a wrapper for the In-Game Valorant API.

Usage

1. Authenticate

To use this crate, you need to authenticate with your Riot Games account. Currently, the only way to do this is by using a username and password (no 2FA).

use valorant_api::utils::credentials_manager::CredentialsManager;
use valorant_api::utils::network::http_client::SimpleHttpClient;

#[tokio::main]
async fn main() {
    let http_client = SimpleHttpClient::new();
    let mut credentials_manager = valorant_api::utils::credentials_manager::CredentialsManager::new();
    let result = credentials_manager
        .authenticate(&http_client, "username", "password")
        .await;
    match result {
        Ok(_) => println!("Authenticated"),
        Err(_) => println!("Error while authenticating"),
    }
}

2. Use the API

use valorant_api::enums::region::Region;
use uuid::Uuid;
use std::collections::HashMap;

let puuid = Uuid::parse_str("ee89b4d9-13d0-5832-8dd7-eb5d8806d918").expect("Invalid UUID");
let region = Region::EU;
let queries = HashMap::new();
let result = valorant_api::get_competitve_updates_v1(credentials_manager, &http_client, region, &puuid, queries).await;
println!("Result: {:#?}", result);

Endpoints

Competitive Updates V1

Function: get_competitive_updates_v1

Result Type: CompetitveUpdatesV1

Match Details V1

Function: get_match_details_v1

Result Type: MatchDetailsV1

Match History V1

Function: get_match_history_v1

Result Type: MatchHistoryV1

MMRV1

Function: get_mmr_details_v1

Result Type: MMRDetailsV1

Leaderboard V1

Function: get_leaderboard_v1

Result Type: LeaderboardV1

Content V3

Function: get_content_v3

Result Type: ContentV3

Store Offers V1

Function: get_store_offers_v1

Result Type: StoreOffersV1

Store Front V2

Function: get_store_front_v2

Result Type: StoreFrontV2

Get the match history of a player

Arguments

  • credentials_manager - The credentials manager
  • region - The region of the player
  • puuid - The puuid of the player
  • query_args - The query arguments

Example

let puuid = Uuid::parse_str("ee89b4d9-13d0-5832-8dd7-eb5d8806d918").expect("Invalid UUID");
let region = Region::EU;
let queries = HashMap::new();
let result = valorant_api::get_match_history_v1(credentials_manager, &http_client, region, &puuid, queries).await;
println!("Result: {:#?}", result);

Get the match details of a match

Arguments

  • credentials_manager - The credentials manager
  • region - The region of the match
  • match_id - The match id of the match

Example

let match_id = Uuid::parse_str("3100c02b-17d2-4adb-97b5-e45dee67d292").expect("Invalid UUID");
let region = Region::EU;
let result = valorant_api::get_match_details_v1(credentials_manager, &http_client, region, &match_id).await;
println!("Result: {:#?}", result);

Get the mmr of a player

Arguments

  • credentials_manager - The credentials manager
  • region - The region of the player
  • puuid - The puuid of the player

Example

let puuid = Uuid::parse_str("ee89b4d9-13d0-5832-8dd7-eb5d8806d918").expect("Invalid UUID");
let region = Region::EU;
let result = valorant_api::get_mmr_details_v1(credentials_manager, &http_client, region, &puuid).await;
println!("Result: {:#?}", result);

Get the competitve updates of a player

Arguments

  • credentials_manager - The credentials manager
  • region - The region of the player
  • puuid - The puuid of the player
  • query_args - The query arguments

Example

let puuid = Uuid::parse_str("ee89b4d9-13d0-5832-8dd7-eb5d8806d918").expect("Invalid UUID");
let region = Region::EU;
let queries = HashMap::new();
let result = valorant_api::get_competitve_updates_v1(credentials_manager, &http_client, region, &puuid, queries).await;
println!("Result: {:#?}", result);

Get the content of the game

Arguments

  • credentials_manager - The credentials manager
  • region - The region of the player

Example

let region = Region::EU;
let result = valorant_api::get_content_v1(credentials_manager, &http_client, region).await;
println!("Result: {:#?}", result);

Get the leaderboard of a region

Arguments

  • credentials_manager - The credentials manager
  • region - The region of the leaderboard
  • season - The season of the leaderboard
  • query_args - The query arguments

Errors

RequestError - If the request failed

Example

let season = Uuid::parse_str("34093c29-4306-43de-452f-3f944bde22be").expect("Invalid UUID");
let region = Region::EU;
let queries = HashMap::new();
let result = valorant_api::get_leaderboard_v1(credentials_manager, &http_client, region, &season, queries).await;
println!("Result: {:#?}", result);

Get the store offers of a region

Arguments

  • credentials_manager - The credentials manager
  • region - The region of the leaderboard

Errors

RequestError - If the request failed

Example

let season = Uuid::parse_str("34093c29-4306-43de-452f-3f944bde22be").expect("Invalid UUID");
let region = Region::EU;
let result = valorant_api::get_store_offers_v1(credentials_manager, &http_client, region).await;
println!("Result: {:#?}", result);

Get the store front of a player

Arguments

  • credentials_manager - The credentials manager
  • region - The region of the leaderboard
  • puuid - The puuid of the player

Errors

RequestError - If the request failed

Example

let puuid = Uuid::parse_str("34093c29-4306-43de-452f-3f944bde22be").expect("Invalid UUID");
let region = Region::EU;
let result = valorant_api::get_store_front_v1(credentials_manager, &http_client, region, puuid).await;
println!("Result: {:#?}", result);

Get the account aliases of a player. This can be used to search for an account by game name and/or tag_line and get their puuid.

Arguments

  • credentials_manager - The credentials manager
  • http_client - The http client
  • cluster - The cluster of the player
  • game_name - The game name of the player
  • tag_line - The tag line of the player

Errors

RequestError - If the request failed

Example

let result = valorant_api::get_account_aliases(credentials_manager, &http_client, "eu", None, None).await;
println!("Result: {:#?}", result);

Dependencies

~16–34MB
~628K SLoC