[][src]Crate dota2_webapi_bindings

The crate serves as an bindings to the official (outdated) dota2 webapi The crate has been made so you can call make calls directly and get a result back in a Struct.

Read the full list of api(outdated) calls here.

Use xpaw for latest.

The webapi terms are same as official except they are all in lowercase, Eg : GetGameItems is now get_game_items().

You also need a key that you can get here.

Originally posted by Zoid at forum When you go to http://steamcommunity.com/dev/apikey the "domain" field is just a note. It's not actually used for anything and is just a helpful field so you can tell us what your website is. You can just put your name in for now. Once you get a key, its what uniquely identifies you when accessing our WebAPI calls.

In your main.rs or anywhere you intend to use the library create a non-mutable string of you token pass first to use the library, there is no calls without the token.

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
  // 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");
Available calls :
  • IEconDOTA2_570
    • GetGameItems
    • GetHeroes
    • GetRarities
    • GetTournamentPrizePool
  • IDOTA2Match_205790
    • GetLeagueListing
  • IDOTA2Match_570
    • GetLiveLeagueGames
    • GetTopLiveGame

Note: Try using language() with everything, just put in any string, it seems like its gives better readable name and description for some reason, I have not set-up a default cause sometimes that might not be your intension.



I have by default use Json instead of XML cause it is more popular and easy to work with, and you do not need ti use them directly!!



The main Dota2Api of you library works by saving states of all the invoked URLs (you only call the one you need) language macro for easy implementation in various builder struct




different type of errors we can receive during either fetching of data or just unpacking JSON