Crate mojang[][src]

Expand description

🕹️ mojang

Rust Interface to the Mojang API!

🚀 Install

Just add the following to your Cargo.toml:

mojang = "0.1.0"

📄 Info

Unofficial Rust Crate that interfaces with the Mojang HTTP API. Mojang API docs here

For more information on this lib check the docs here

💥 Examples

🦦 Players

Get UUID from name / Name from UUID

// Import lib
use mojang::Player;

// Make a new Player
// This can be with player name or UUID
let p1 = Player::new("Sigma76").unwrap();

let p2 = Player::new("3c358264-b456-4bde-ab1e-fe1023db6679").unwrap();

assert_eq!(p1.uuid, p2.uuid);

Get Player Name Change History

// Import lib
use mojang::Player;

// Make a new Player
// Then fetch and add Name History Data
let p = Player::new("Sigma76").unwrap().add_name_change().unwrap();;

// Get name at timestamp (ms)
// Due to API limitations any timestamp before the first name change will count as the accounts original name
assert_eq!(p.name_at(16362446560000).unwrap(), "Sigma76");

Get Player Skin URL

// Import lib
use mojang::Player;

// Make a new Player
// Then fetch and add skin data to it
let p = Player::new("Sigma76").unwrap().add_skin().unwrap();

assert_eq!(p.skin_url.unwrap(), "");

🔮 Mojang Stats

Get Minecraft Sales Data

// Import Lib
use mojang::Stats;

// Get Stats for Default Metrics
let s = Stats::new().unwrap();

println!("Total Minecraft Sales: {}",;
println!("Minecraft Sales 24h: {}", s.last24h);
println!("Minecraft Sales / Sec: {}", s.sale_per_sec);

Get all Mojang Game Sales

// Import Lib
use mojang::Stats;
use mojang::MetricKeys;

let s = Stats::new_metrics(vec![

println!("Total Sales: {}",;
println!("Sales 24h: {}", s.last24h);
println!("Sales / Sec: {}", s.sale_per_sec);

🍞 Other

Check if server is blocked by Mojang

// Import Lib
use mojang::BlockedServers;

// Get Blocked Servers (Hashes only)
let blocked = BlockedServers::new().unwrap();

// Check if server is blocked


Info on all Mojang Blocked Servers

A Player…

Stats Response


Diffrent Mojang Products that can be added to the Stats Query

Varous errors that can come from the function in this crate