Crates.io | lol_api_rs |
lib.rs | lol_api_rs |
version | 0.2.0 |
source | src |
created_at | 2017-07-19 01:45:41.008034 |
updated_at | 2017-08-02 14:52:22.704919 |
description | A simple API wrapper for the Riot League of Legends API |
homepage | |
repository | https://github.com/gpit2286/lol-api-rs |
max_upload_size | |
id | 24010 |
size | 105,195 |
Want to create the next coolest thing with Rust? A discord bot? A new website? The next haxor information center? This is for you.
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;
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)
}
}
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.