lol_api_rs

Crates.iolol_api_rs
lib.rslol_api_rs
version0.2.0
sourcesrc
created_at2017-07-19 01:45:41.008034
updated_at2017-08-02 14:52:22.704919
descriptionA simple API wrapper for the Riot League of Legends API
homepage
repositoryhttps://github.com/gpit2286/lol-api-rs
max_upload_size
id24010
size105,195
Kyle Baldwin (gpit2286)

documentation

README

League of Legends API Wrapper for Rust

Want to create the next coolest thing with Rust? A discord bot? A new website? The next haxor information center? This is for you.

Getting Started

The first thing is first. In your Cargo.toml file, add the following line

[dependencies]
lol_api_rs = "0.2.0"

In your main file add:

extern crate lol_api_rs;

Making Your First Call

Once everything is installed, making your first call is as easy as creating a constructor function and calling an endpoint.

// Use the Riot API constructor
use lol_api_rs::client::Riot;

// Define your Riot API Key
const RIOT_API_KEY: &'static str = "RGAPI-xxxxxxxxxxx";

fn main () {
	// Define new riot API factory
    // It accepts the following arguments.
    // The first param is your API key
    // The second param is the region to run your queries against. (NA is default)
    // The third param is if you want to use a custom logger to log debug statements
    let riot = Riot::new(RIOT_API_KEY, None, None);

    // For our example we'll get champion information for Champion 99 - Lux
    let json = riot.get_champions_by_id(99);

    // Every call will return a Result<DataType, String> The below match is a simple handler for this.
    match json {
        Ok(j) => println!("{:?}", j),
        Err(e) => println!("There was an error: {}", e)
    }
}

Breaking changes

0.2.0

  • Previously all calls returned the result or paniced. This was changed to returning a type Result.

Questions/Comments?

Open an issue on Github or send me an email. I would love to make this more robust/better working. Aware of rate limits, better coded, etc. This is my first rust project and I'm looking forward to learning more about the language and the community.

Commit count: 0

cargo fmt