https://github.com/connorslade/mojang-rs
đšī¸ Interface for the Mojang API
https://github.com/connorslade/mojang-rs
minecraft mojang mojang-api rust
Last synced: 6 months ago
JSON representation
đšī¸ Interface for the Mojang API
- Host: GitHub
- URL: https://github.com/connorslade/mojang-rs
- Owner: connorslade
- Created: 2021-11-06T04:52:13.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-05-22T16:44:51.000Z (over 2 years ago)
- Last Synced: 2025-04-02T21:24:03.437Z (6 months ago)
- Topics: minecraft, mojang, mojang-api, rust
- Language: Rust
- Homepage: https://crates.io/crates/mojang
- Size: 48.8 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Rust Interface to the Mojang API!
## đ Install
Just add the following to your `Cargo.toml`:
```toml
[dependencies]
mojang = "0.2.0"
```Or use the cargo add subcommand:
```sh
cargo add mojang
```## đ Info
This is an unofficial Rust crate that interfaces with the Mojang HTTP API.
You can view the Mojang API docs [here](https://wiki.vg/Mojang_API).
Note: Mojang has recently removed the ability to get sale statistics or username history from the API.For more information on this lib check the docs [here](https://crates.io/crates/mojang).
## đĨ Examples
### đĻĻ Players
Get UUID from name or Name from UUID:
```rust
// 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.name, p2.name);
assert_eq!(p1.id, p2.id);
```Get Player Skin URL:
```rust
// Import lib
use mojang::Player;// Make a new Player
// Then fetch and add skin data to it
let p = Player::new("Sigma76").unwrap();assert_eq!(p.skin_url().unwrap(), "http://textures.minecraft.net/texture/c05f5efaf313464bde6060fb48aab8e6d07202cae19c764daee52029663df8b4");
```### đŽ Other
Check if server is blocked by Mojang:
```rust
// Import Lib
use mojang::BlockedServers;// Get Blocked Servers
let blocked = BlockedServers::new().unwrap();// Check if server is blocked
assert!(blocked.blocked("mc.playmc.mx"));
```