#runescape #oldschool #api #game #tokio #player #gamemode

bin+lib libosrs

An Oldschool Runescape API written in Rust

5 releases

0.1.4 Oct 20, 2022
0.1.3 Oct 11, 2022
0.1.2 Oct 6, 2022
0.1.1 Oct 4, 2022
0.1.0 Oct 4, 2022

#443 in Games

27 downloads per month

MIT license

22KB
537 lines

libosrs

An Oldschool RuneScape API library written in Rust. Can serialize the output into JSON format.

Examples

use libosrs;
use libosrs::gamemode::Gamemode;

#[tokio::main]
async fn main() {
    let name = "Soupshi";
    let mut gamemode: Gamemode = Gamemode::Auto;

    let client = libosrs::ClientOSRS::new();

    let soupshi = client.get_hiscore(name, gamemode).await.unwrap();

    println!("Overall: {:#?}", soupshi.skills.overall);
    println!("Agility level: {}", soupshi.skills.agility.level);
    println!("Agility xp: {}", soupshi.skills.agility.xp);
    println!("Vorkath rank: {}", soupshi.bosses.vorkath.rank);
    println!("Vorkath kills: {}", soupshi.bosses.vorkath.score);

    // Pass a Hiscore struct and return json
    println!("JSON output: {}", soupshi.to_json());

    // Try to retrieve a players current gamemode
    gamemode = client.get_player_gamemode(name).await;
    println!("{:#?}", gamemode);

    // Request hiscore from API and return json
    println!(
        "JSON output: {}",
        client.get_hiscore_json(name, gamemode).await
    );

    // Get Player struct and Player json
    println!("{:#?}", client.get_player(name, gamemode).await);
    println!(
        "JSON output: {}",
        client.get_player_json(name, gamemode).await
    );
}

Game modes

Gamemode::Auto
Gamemode::Regular
Gamemode::Ironman
Gamemode::Hardcore
Gamemode::Ultimate
Gamemode::Deadman
Gamemode::Seasonal
Gamemode::Tournament

Auto will try to fetch a player's current game mode from Regular, Ironman, Hardcore and Ultimate, i.e. a player who used to be Iron Man but converted to regular will output their regular game stats. Only works if they gained Xp or Boss scores after conversion.

Struct names

See the docs.rs page.

Todo

  • Blocking IO
  • Serialize to json without re-calling RuneScape API
  • Formatters
  • Grand Exchange

Dependencies

~7–22MB
~305K SLoC