GithubHelp home page GithubHelp logo

mingweisamuel / riven Goto Github PK

View Code? Open in Web Editor NEW
103.0 5.0 11.0 2.64 MB

Riot API Library for Rust

Home Page: https://docs.rs/riven/latest/riven/

License: MIT License

Rust 98.49% JavaScript 1.36% Shell 0.15%
rust riot-games-api

riven's Introduction

Riven

Riven Github Crates.io Docs.rs unsafe forbidden

Rust Library for the Riot Games API.

Riven's goals are speed, reliability, and maintainability. Riven handles rate limits and large requests with ease. Data structs and endpoints are automatically generated from the Riot API Reference (Swagger).

Design

  • Fast, asynchronous, thread-safe.
  • Automatically retries failed requests, configurable.
  • Supports all endpoints, kept up-to-date using riotapi-schema.
  • Can compile to Wasm for server-side or browser+proxy use.

Usage

use riven::RiotApi;
use riven::consts::PlatformRoute;

// Enter tokio async runtime.
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
    // Create RiotApi instance from key string.
    let api_key = std::env!("RGAPI_KEY"); // "RGAPI-01234567-89ab-cdef-0123-456789abcdef";
    let riot_api = RiotApi::new(api_key);

    // The region.
    let platform = PlatformRoute::NA1;

    // Get account data.
    let account = riot_api.account_v1()
        .get_by_riot_id(platform.to_regional(), "잘 못", "NA1").await
        .expect("Get summoner failed.")
        .expect("There is no summoner with that name.");

    // Print account name#tag.
    println!(
        "{}#{} Champion Masteries:",
        account.game_name.unwrap_or_default(),
        account.tag_line.unwrap_or_default(),
    );

    // Get champion mastery data.
    let masteries = riot_api.champion_mastery_v4()
        .get_all_champion_masteries_by_puuid(platform, &account.puuid).await
        .expect("Get champion masteries failed.");

    // Print champion masteries.
    for (i, mastery) in masteries.iter().take(10).enumerate() {
        println!("{: >2}) {: <9}    {: >7} ({})", i + 1,
            mastery.champion_id.name().unwrap_or("UNKNOWN"),
            mastery.champion_points, mastery.champion_level);
    }
});

Output:

잘 못 Champion Masteries:
 1) Riven        1236866 (7)
 2) Fiora         230679 (5)
 3) Katarina      175985 (5)
 4) Lee Sin       156070 (7)
 5) Jax           102662 (5)
 6) Gnar           76373 (6)
 7) Kai'Sa         64271 (5)
 8) Caitlyn        46614 (5)
 9) Irelia         46465 (5)
10) Vladimir       37176 (5)

The RiotApi struct documentation contains additional usage information. The tests and example proxy provide more example usage.

Feature Flags

Nightly vs Stable

Enable the nightly feature to use nightly-only functionality. This enables nightly optimizations in the parking_lot crate.

riven = { version = "...", features = [ "nightly" ] }

rustls

Riven uses reqwest for making requests. By default, reqwest uses the native TLS library. If you prefer using rustls you can do so by turning off the Riven default features and specifying the rustls-tls feature:

riven = { version = "...", default-features = false, features = [ "rustls-tls" ] }

log or tracing

Riven is additionally able to produce tracing spans for requests if the tracing feature is enabled. By default the tracing feature is disabled and Riven instead writes to log.

Docs

On docs.rs.

Error Handling

Riven returns either Result<T> or Result<Option<T>> within futures.

If the Result is errored, this indicates that the API request failed to complete successfully, which may be due to bad user input, Riot server errors, incorrect API key, etc.

If the Option is None, this indicates that the request completed successfully but no data was returned. This happens in several situations, such as getting an account (by name#tag) or match (by id) that doesn't exist, or getting spectator data for a summoner who is not in-game. Specifically, the API returned an HTTP 404 (or 204) status code.

The error type returned by Riven is RiotApiError. It provides some basic diagnostic information, such as the source reqwest error, the number of retries attempted, and the reqwest Response object.

By default, Riven retries up to 3 times (4 requests total). Some errors, such as 400 client errors, are not retried as they would inevitably fail again.

You can configure Riven by creating a RiotApiConfig instance, setting the desired config values, and passing that to RiotApi::new (instead of just the API key). For example, you can configure the number of times Riven retries using RiotApiConfig::set_retries(...).

Semantic Versioning

This package follows semantic versioning to an extent. However, the Riot API itself changes often and does not follow semantic versioning, which makes things difficult. Keep Riven up-to-date as out-of-date versions will slowly cease to work.

When the API changes, this may result in breaking changes in the models module, endpoints module, and some of the consts module. Models may receive new fields (and, less frequently, have fields removed), endpoints may be added or removed, and new enum variants may be added. These breaking changes will increment the MINOR version, not the major version. (major.minor.patch)

Parts of Riven that do not depend on Riot API changes do follow semantic versioning.

Additional Help

Feel free to make an issue if you are have any questions or trouble with Riven.

Development

NodeJS is used to generate code for Riven. The riven/srcgen folder contains the code and doT.js templates. index.js lists the JSON files downloaded and used to generate the code.

To set up the srcgen, you will first need to install NodeJS. Then enter the riven/srcgen folder and run npm ci (or npm install) to install dependencies.

To run the srcgen use node riven/srcgen from the repository root.

riven's People

Contributors

apinat avatar dependabot[bot] avatar guillerlt avatar jsdt avatar m1so avatar mingweisamuel avatar molenzwiebel avatar remicorniere avatar theseikoda avatar tomchandler182 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

riven's Issues

Error getting TFT games

API: tft_match_v1 / get_match
"error decoding response body: missing field items at line 1 column 2493"

get_current_game_info_by_summoner panics in custom games.

Description

When using the spectator_v4.get_current_game_info_by_summoner() API, to lookup a summoner, who is currently playing a Custom Game, it will panic, due to missing gameQueueConfigId.

Steps to reproduce

  1. Join a custom game
  2. Lookup the encrypted summoner id & correct region, with spectator_v4.get_current_game_info_by_summoner().
  3. Riven should panic.

Expected outcome

Correct parsing of API response.
Example response:

{
    "gameId": 4302399720,
    "gameStartTime": 1575296347917,
    "platformId": "EUW1",
    "gameMode": "CLASSIC",
    "mapId": 11,
    "gameType": "CUSTOM_GAME",
    "bannedChampions": [],
    "observers": {
        "encryptionKey": "rvOzZDwZdkQg8ET3Nqr4/fHJ67vbuIBO"
    },
    "participants": [
        {
            "profileIconId": 3545,
            "championId": 429,
            "summonerName": "S1mplescripts",
            "gameCustomizationObjects": [],
            "bot": false,
            "perks": {
                "perkStyle": 8200,
                "perkIds": [
                    8214,
                    8226,
                    8233,
                    8237,
                    8313,
                    8321,
                    5008,
                    5008,
                    5002
                ],
                "perkSubStyle": 8300
            },
            "spell2Id": 4,
            "teamId": 100,
            "spell1Id": 7,
            "summonerId": "frGEWr2kt1fizZRVHY9IuJLEG7LDfVGjVE0BYT0MB-oJK3Du"
        }
    ],
    "gameLength": 87
}

Add EnumVariantNames derive to relevant enums

I just stumbled upon EnumVariantNames which can be used to create a static list of an enum variant. I think it would be nice to use it for the constant enums defined in src/consts/*.rs (and maybe some other places too)

For example, let's say I am writing a cli interface and I want the user to input a server (or champion, or tier, etc), currently I have to do something ugly like:

let server_strings = PlatformRoute::iter().map(|server| &server.to_string() as &str).collect::<Vec<&str>>();
let matches = App::new("my awesome app")
    .arg(Arg::new("server")
        .about("Selected server")
        .short("s")
        .long("server")
        .possible_values(&server_strings)
    )

While with EnumVariantNames I could simply write

let matches = App::new("my awesome app")
    .arg(Arg::new("server")
        .about("Selected server")
        .short("s")
        .long("server")
        .possible_values(PlatformRoute::VARIANTS)
    )

Feature request: ability to access the API's response on error

as discussed on Discord, it'd be convenient to have access to the underlying Reqwests' response in the RiotApiError struct in case of 4xx and 5xx responses.

One of the use-cases is to wrap the Error with an error handler in a web framework (actix-web example) (notice that the trait requires async fn, whereas potentially obtaining the response body from Reqwest would require an async context).

invalid value: 147

RiotApiError {
    reqwest_error: reqwest::Error {
        kind: Decode,
        source: Error("invalid value: 147, expected one of: -1, 266, 103, 84, 12, 32, 34, 1, 523, 22, 136, 268, 432, 53, 63, 201, 51, 164, 69, 31, 42, 122, 131, 36, 119, 245, 60, 28, 81, 9, 114, 105, 3, 41, 86, 150, 79, 104, 120, 74, 420, 39, 427, 40, 59, 24, 126, 202, 222, 145, 429, 43, 30, 38, 55, 10, 141, 85, 121, 203, 240, 96, 7, 64, 89, 876, 127, 236, 117, 99, 54, 90, 57, 11, 21, 82, 25, 267, 75, 111, 518, 76, 56, 20, 2, 61, 516, 80, 78, 555, 246, 133, 497, 33, 421, 58, 107, 92, 68, 13, 360, 113, 235, 875, 35, 98, 102, 27, 14, 15, 72, 37, 16, 50, 517, 134, 223, 163, 91, 44, 17, 412, 18, 48, 23, 4, 29, 77, 6, 110, 67, 45, 161, 254, 112, 8, 106, 19, 62, 498, 101, 5, 157, 777, 83, 350, 154, 238, 115, 26, 142, 143", line: 1, column: 3832),
    },
    retries: 0,
    response: None,
    status_code: Some(
        200,
    ),
}

How do I handle users inputting invalid summoner names?

Hi there,
whenever a user inputs a invalid summoner name my entire app crashes because you are supposed to use except for error handeling? In my specific case it's :

let summoner = &ctx.data().riot_api.summoner_v4() .get_by_summoner_name(region, &name).await .expect("Something went wrong") .expect("Something went wrong");

How do I fix that? It's code within an async method, so I have really no clue how to handle it due to me being entirely new to rust.

get_matchlist() only with region and summoner account id returns reqwest decode error

let matches = riot_api
    .match_v4()
    .get_matchlist(
        region,
        &summoner.account_id,
        None,
        None,
        None,
        None,
        None,
        None,
        None,
    ).await;
log::debug!("matches: {:?}", &matches);

stdout:

matches: Err(RiotApiError { reqwest_error: reqwest::Error { kind: Decode, source: Error("invalid value: 1300, expected one of: 0, 2, 430, 4, 420, 6, 7, 8, 9, 470, 14, 400, 16, 17, 25, 31, 830, 32, 840, 33, 850, 41, 42, 52, 61, 65, 450, 67, 70, 1020, 72, 73, 75, 76, 78, 83, 91, 92, 93, 96, 910, 98, 100, 300, 920, 310, 313, 315, 940, 317, 318, 325, 410, 440, 460, 600, 610, 700, 800, 810, 820, 900, 950, 960, 980, 990, 1000, 1010, 1030, 1040, 1050, 1060, 1070, 1090, 1100, 1110, 1200, 2000, 2010, 2020", line: 1, column: 1152) }, retries: 0, response: None, status_code: Some(200) })
DEBUG reqwest::async_impl::client            > response '200 OK' for https://ru.api.riotgames.com/lol/match/v4/matchlists/by-account/bJc_fTv5UuIOn_lg-kcouLTwT5QU1fWNqByMSlk2rtKBpCU?

riven version: 1.7.0

How to serialize PlatformRoute, Tier, Division, etc?

Some structures like Match derive serde::Serialize and serde::Deserialize for parsing purpose but a few enums don't. Is there a reason?

For example, I would like to create a serializable structure like this:

#[derive(Serialize, Deserialize)]
pub struct config {
    pub version: String,
    pub servers: Vec<PlatformRoute>,
    pub tiers: Vec<Tier>
}

TFT Trait Decode error: "missing field `tier_total`"

let game = riot_api.tft_match_v1().get_match(Region::EUROPE, "EUW1_4571378004").await.expect("Get match failed.");

thread 'main' panicked at 'Get match failed.: RiotApiError { reqwest_error: reqwest::Error { kind: Decode, source: Error("missing field tier_total", line: 1, column: 5235) }, retries: 0, response: None, status_code: Some(200) }', src/main.rs:10:16

Not every request fails, but quite a large amount do, including:
EUW1_4568680990
EUW1_4568595387
EUW1_4568448008
EUW1_4568443707
EUW1_4568396630
EUW1_4570765723
EUW1_4570647555

The culprit seems to be this bizarre trait which pops up every so often:
{ "name": "TemplateTrait", "num_units": 1, "style": 0, "tier_current": 0 }

New gamemode

A new gamemode "ultimate spellbook" is out.

RiotApiError {
    reqwest_error: reqwest::Error {
        kind: Decode, source: Error("invalid value: 1400, expected one of: 0, 2, 4, 6, 7, 8, 9, 14, 16, 17, 25, 31, 32, 33, 41, 42, 52, 61, 65, 67, 70, 72, 73, 75, 76, 78, 83, 91, 92, 93, 96, 98, 100, 300, 310, 313, 315, 317, 318, 325, 400, 410, 420, 430, 440, 450, 460, 470, 600, 610, 700, 800, 810, 820, 830, 840, 850, 900, 910, 920, 940, 950, 960, 980, 990, 1000, 1010, 1020, 1030, 1040, 1050, 1060, 1070, 1090, 1100, 1110, 1111, 1200, 1300, 2000, 2010, 2020", line: 1, column: 80)
    },
    retries: 0, response: None, status_code: Some(200)
}

Add per method rate limit.

Allow users to set the rate limit factor per method, Ex. you could set "account-v1.getByPuuid" to have a usage factor of 0.5 which would mean that it would use up to half the rate limit on just that method. This would probably override the method_rate_limit. It could overwrite the app_rate_limit or multiply against it not sure, and for the over all rate limit it would probably multiply against it.

[TFT] UnitDto occasionally has extra field 'chosen'

Riot has recently added an extra field on the unitDto
Here is an extract from
https://europe.api.riotgames.com/tft/match/v1/matches/EUW1_4899709674
"units":[{"character_id":"TFT4_Maokai","items":[],"name":"","rarity":0,"tier":2},{"character_id":"TFT4_Sylas","chosen":"Set4_Brawler","items":[],"name":"","rarity":1,"tier":2},{"character_id":"TFT4_Vi","items":[],"name":"","rarity":1,"tier":2},{"character_id":"TFT4_Nunu","items":[57],"name":"","rarity":2,"tier":2},{"character_id":"TFT4_Kindred","items":[39,22,23],"name":"","rarity":2,"tier":2},{"character_id":"TFT4_Warwick","items":[],"name":"","rarity":3,"tier":2},{"character_id":"TFT4_Ashe","items":[69,11,16],"name":"","rarity":3,"tier":1}]

Unfortunately riot haven't documented this in their official docs.

Super hyped to get this data

Rare decoding errors with `get_match`?

RU 184554369

 RiotApiError {
    reqwest_error: reqwest::Error {
        kind: Decode,
        source: Error("Matching variant not found", line: 1, column: 1225),
    },
    retries: 0,
    response: None,
    status_code: Some(
        200,
    ),
}

OC1 227513707

 RiotApiError {
    reqwest_error: reqwest::Error {
        kind: Decode,
        source: Error("Matching variant not found", line: 1, column: 9112),
    },
    retries: 0,
    response: None,
    status_code: Some(
        200,
    ),
}

JP1 188794778

 RiotApiError {
    reqwest_error: reqwest::Error {
        kind: Decode,
        source: Error("Matching variant not found", line: 1, column: 1225),
    },
    retries: 0,
    response: None,
    status_code: Some(
        200,
    ),
}

Decode error in `get_match` when some participants are bots

RiotApiError {
    reqwest_error: reqwest::Error {
        kind: Decode,
        source: Error("missing field `summonerId`", line: 1, column: 27627)
    },
    retries: 0,
    response: None,
    status_code: Some(200)
}

This happened to me when requesting match id 3251803350 in NA. The participant identities for the bots don't have a summonerId field.

tft-league result doesn't deserialize when the player has a hyperroll rank.

https://jp1.api.riotgames.com/tft/league/v1/entries/by-summoner/8Dx9uc0lPVrx7otKTx9kQi7Aj17_a1Zjbzsl1Fqa-HT1k6o
(This example is a JP1 player called Caihonbbt)

[
    {
        "leagueId": "d5947363-4424-4c91-8dd0-17338fed53ff",
        "queueType": "RANKED_TFT",
        "tier": "GOLD",
        "rank": "I",
        "summonerId": "8Dx9uc0lPVrx7otKTx9kQi7Aj17_a1Zjbzsl1Fqa-HT1k6o",
        "summonerName": "Caihonbbt",
        "leaguePoints": 27,
        "wins": 8,
        "losses": 20,
        "veteran": false,
        "inactive": false,
        "freshBlood": true,
        "hotStreak": false
    },
    {
        "queueType": "RANKED_TFT_TURBO",
        "ratedTier": "ORANGE",
        "ratedRating": 4392,
        "summonerId": "8Dx9uc0lPVrx7otKTx9kQi7Aj17_a1Zjbzsl1Fqa-HT1k6o",
        "summonerName": "Caihonbbt",
        "wins": 24,
        "losses": 83
    }
]

The deserialization error is:

RiotApiError {
    reqwest_error: reqwest::Error {
        kind: Decode,
        source: Error(\"Matching variant not found\", line: 1, column: 32),
    },\n    retries: 0,
    response: None,
    status_code: Some(
        200,
    ),
}

Is there a way for me to see my current rate limit?

As the title says, is there a way for me to see what my current rate limit usage is, if I have 10 requests left or if I have to wait for 3 seconds before my next request. Also does the API do rate limits per region as described here

"Remember that this rate limit is enforced per region."

Incomplete Toutnament API

Hi, @MingweiSamuel !
This library does not support any requests other than GET requests.
In tournament-v4 there are missing api:

  • POST /lol/tournament/v4/codes
  • PUT /lol/tournament/v4/codes/{tournamentCode}
  • POST /lol/tournament/v4/providers
  • POST /lol/tournament/v4/tournaments

In tournament-stub-v4 there are missing api:

  • POST /lol/tournament-stub/v4/codes
  • POST /lol/tournament-stub/v4/providers
  • POST /lol/tournament-stub/v4/tournaments

Are you @MingweiSamuel planning to add missing api?
Or maybe I can help in their implementation? =)

Metadata field can be null in `TournamentV5::get_games()`

When querying TournamentV5::get_games(), the method always attempts to decode the metadata field even when it's omitted.
This leads to the following error:
image

This is due to the field being required in OpenAPI spec used to generate the code.

On the Riot docs for the endpoint, the field isn't noted to be optional, but if removed from the body during tournament code creation, it's not returned.

[Help/Clarification] Rate limiting and actix state

Hi, I'm relatively new to rust and wanted to make sure I do things right without going over the rate limits.

If I use the following setup to pass the riot api instance to my web handlers, will the rate limiting guarantees remain or will the different threads to handle the various web requests have their own rate limiting?

pub struct AppState {
    db_conn: Pool,
    riot_api: RiotApi,
}

#[tokio::main]
async fn main() -> std::io::Result<()> {
    dotenv().ok();

    let local = tokio::task::LocalSet::new();
    let sys = actix_web::rt::System::run_in_tokio("server", &local);

    let server = HttpServer::new(|| {
        App::new()
            .data(AppState {
                riot_api: rito::create_riot_api(),
                db_conn: establish_pool(),
            })
            .service(get_masteries)
    })
    .bind("0.0.0.0:9000")?
    .run()
    .await?;
    sys.await?;
    Ok(server)
}

#[get("/api/v1/mastery/{username}")]
pub async fn get_masteries(data: web::Data<AppState>, path: web::Path<String>) -> impl Responder {
    let masteries = riot::get_masteries(&data.riot_api, path.0).await;
    HttpResponse::Ok().body(masteries.to_string())
}

Fix tutorial

Hi,
Your tutorial has a for (i, mastery) in masteries[..10].iter().enumerate(), but this option would be better for (i, mastery) in masteries.iter().take(10).enumerate(). Because if the array does not contain 10 elements, there will be a panic for exiting the range :)

Missing tft field "game_variation"

The field is missing from here: https://docs.rs/riven/1.2.0/riven/models/tft_match_v1/struct.Info.html

I'm not sure if it needs be an option, perhaps for backwards compatibility

sample from riot

"info": {
        "game_datetime": 1587749742531,
        "game_length": 2275.833984375,
        "game_variation": "TFT3_GameVariation_BigLittleLegends",
        "game_version": "Version 10.8.317.8137 (Apr 17 2020/16:09:11) [PUBLIC] <Releases/10.8>",
        "participants": [       ...

Currently the field is just discarded

Decode error for `get_match_timeline`

thread 'tokio-runtime-worker' panicked at 'Game KR 4416790570: RiotApiError { reqwest_error: reqwest::Error { kind: Decode, source: Error("missing field `laneType`", line: 1, column: 3758) }, retries: 0, response: None, status_code: Some(200) }', src/grabbing.rs:107:33

Seems to be erroring for every game

Error for tft match `EUW1_6864291557`

Error: "Failed to get match EUW1_6864291557: RiotApiError { reqwest_error: reqwest::Error { kind: Decode, source: Error("unknown field Deaths, expected one of Assists, DamageDealt, DamageDealtToObjectives, DamageDealtToTurrets, DamageTaken, DoubleKills, GoldEarned, GoldSpent, InhibitorsDestroyed, Kills, LargestKillingSpree, LargestMultiKill, MagicDamageDealt, MagicDamageDealtToChampions, NeutralMinionsKilledTeamJungle, PhysicalDamageDealt, PhysicalDamageTaken, PlayerScore0, PlayerScore1, PlayerScore2, PlayerScore3, PlayerScore4, PlayerScore5, PlayerScore6, PlayerScore9, PlayerScore10, PlayerScore11, QuadraKills, Spell1Casts, Spell2Casts, Spell3Casts, Spell4Casts, SummonerSpell1Casts, TimeCCOthers, TotalMinionsKilled, TrueDamageDealtToChampions, UnrealKills, VisionScore, WardsKilled", line: 1, column: 1386) }, retries: 0, response: None, status_code: Some(200) }"

Needs regen for new champion Rell

I don't really know how this crate works but I have been getting errors since the Rell release, and I have seen mentions of a regen in the commit log. So yeah, a regen is needed since the Rell release.

429 errors

I'm getting the below error a lot when running my program. I would leave the program to run overnight and come back to a bunch of 429 errors.

RiotApiError {
    reqwest_error: reqwest::Error {
        kind: Status(
            429,
        ),
        url: Url {
            scheme: "https",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: Some(
                Domain(
                    "na1.api.riotgames.com",
                ),
            ),
            port: None,
            path: "/lol/summoner/v4/summoners/PJS9OIBjDIN41fZyeWR3t8Ajz7ZIWrWIODBrrs2yL6XFvBwK",
            query: None,
            fragment: None,
        },
    },
    retries: 3,
    response: Some(
        Response {
            url: Url {
                scheme: "https",
                cannot_be_a_base: false,
                username: "",
                password: None,
                host: Some(
                    Domain(
                        "na1.api.riotgames.com",
                    ),
                ),
                port: None,
                path: "/lol/summoner/v4/summoners/PJS9OIBjDIN41fZyeWR3t8Ajz7ZIWrWIODBrrs2yL6XFvBwK",
                query: None,
                fragment: None,
            },
            status: 429,
            headers: {
                "date": "Thu, 13 Jul 2023 05:46:12 GMT",
                "content-type": "application/json;charset=utf-8",
                "transfer-encoding": "chunked",
                "connection": "keep-alive",
                "retry-after": "1",
                "x-app-rate-limit": "20:1,100:120",
                "x-app-rate-limit-count": "10:1,76:120",
                "x-method-rate-limit": "2000:60",
                "x-method-rate-limit-count": "76:60",
                "x-rate-limit-type": "service",
                "x-riot-edge-trace-id": "cc445cf6-b58e-4be9-96e8-48352a37f2ec",
            },
        },
    ),
    status_code: Some(
        429,
    ),
}

This is how I initialized the riot session. This is the only session used.

let config = RiotApiConfig::with_key(dotenv!("RIOT_API_KEY")).set_rate_usage_factor(0.90);

let riot_api = RiotApi::new(config);

And this is the endpoint I'm calling. I'm calling the code below in a loop iterating over a list of summoner_ids gathered from leaguev4.

match self
    .riot_client
    .summoner_v4()
    .get_by_summoner_id(self.platform_route_map[region], &id)
    .await
{
    Ok(res) => {
        summoners.push(res.clone());
        player.puuid = res.puuid;
    }
    Err(e) => println!("{}", e),
}

Some matches have PascalCasing for ParticipantMissions.

It looks like some matches have version 14.6 for some reason (despite it not being released), and these matches are using PascalCase for the fields in ParticipantMissions for the match v5 endpoint response. It seems like an alias is needed to make parsing work for both versions.

I didn't dig into the code generation, but I made some changes locally to get it working. This commit adds the aliases and adds a test with one of the problematic matches: jsdt@d156223

`UNRANKED` equivalent for Division?

You added an UNRANKED variant to the Tier enum, but there is no equivalent for the Division enum. This is a bit awkward. I'm working with a

struct RankStuff {
   tier: Tier,
   division: Option<Division>
}

Also, as a side note, how did you choose the u8 values for the Tier enum?

add #[derive(Clone)] on models

I see that none of the structs defined in src/models.rs implements the Clone trait, which would be very useful to extract data.

For example let's say I want to extract ban information from a game, I cannot do something like:

let bans: Vec<Ban> = match_data.info.teams.iter().map(|t| t.bans.clone()).flatten().collect();

Yet Ban is a struct only containing Champion and i32, which are both Clone (and even Copy), so it could simply derive Clone. It seems to me that other structures in src/models.rs could also derive the Clone trait. Would it be possible to make this change?

Add arena game mode

Since arena game mode is out when trying to retrieve a match from it I get this error
RiotApiError { reqwest_error: reqwest::Error { kind: Decode, source: Error("invalid value: 0, expected one of: 100, 200, 300", line: 1, column: 27238) }, retries: 0, response: None, status_code: Some(200) }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.