Code Monkey home page Code Monkey logo

aurilion's Introduction

Aurilion - A Rust library for easier interaction with Data Dragon

Aurilion is a small rust library that provides some useful functions to hep facilitate easier access to the Riot Games Data Dragon Web API.

Usage

Get started by adding the library to your project.

cargo add aurilion

Getting the data

At the time of writing, there are only four functions included:

  • get_versions() - To get all patch versions.
  • get_all_champions() - To get brief information about all available champions.
  • get_single_champion() - To get detailed information about a single champion.
  • get_all_items() - To get detailed information about all items.

Example

An example of implementation of all the functions would be something like this:

async fn do_everything() {
    // get all versions
    let versions = get_versions().await.unwrap();

    //The first version in the list is always the latest version
    let latest_version = versions.first().unwrap();

    // get all champions, this function requires the version you are requesting champions for
    let all_champions = get_all_champions(latest_version.clone()).await.unwrap();

    /*
        do something here with the champions

        we cycle through and list out all champion names and their title for now.
    */

    all_champions.data.into_iter().for_each(|value| {
        println!("{} : {}", value.1.id, value.1.title);
    });

    let single_champion = get_single_champion("Ahri".to_string(), latest_version.clone())
        .await
        .unwrap();

    // Get the champion from the Map received (must be the same as supplied to get_single_champion())
    // In our case, it is "Ahri"
    let champion_data = single_champion.data.get("Ahri").unwrap();
    // Just print the name of the champions and their skills for now.
    println!("\n\n{} Skill Names: ", champion_data.id);
    for (num, x) in champion_data.spells.clone().into_iter().enumerate() {
        println!("Skill {}: {}", num + 1, x.name)
    }
}

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.