Crates.io | dota2_webapi_bindings |
lib.rs | dota2_webapi_bindings |
version | 0.6.0 |
source | src |
created_at | 2020-10-15 16:10:51.189563 |
updated_at | 2020-10-18 00:20:16.132221 |
description | Rust bindings for official dota2 webapi |
homepage | https://github.com/sn99/dota2_webapi_bindings |
repository | |
max_upload_size | |
id | 300060 |
size | 36,488 |
Dota 2 webapi bindings for rust
You can find the official(outdated) documentation here
I am currently using xpaw to get a list of APIs
In Cargo.toml
:
[dependencies]
dota2_webapi_bindings = "*"
In main.rs
:
//main.rs
use dota2_webapi_bindings::Dota2Api;
static DOTA2_KEY: &str = "0123456789"; //example token
fn main() {
let mut dota = Dota2Api::new(String::from(DOTA2_KEY));
// we use `set` to configure the URL first
dota.set_heroes().itemized_only(true).language("zh_zh");
// you can also write the above as just `dota.set_heroes();` or `dota.set_heroes().itemized_only(true);`
// or just `dota.set_heroes().language("zh_zh");` or `dota.set_heroes().language("zh_zh").itemized_only(true);`
// our builder like function takes care of optional parameters
// and finally `get` to retrieve our struct
let data = dota.get_heroes().expect("something went wrong, ez mid");
}
The webapi terms are same as official except they are all in lowercase, Eg : GetGameItems
is now get_game_items()
.
See documentation for more.
Note: Try using language()
with everything, just put in any string, it seems like its gives better readable name
and description for some reason
Licensed under