Query Player
Example
import {
getPlayer,
type CachedPlayer,
type RestfulMCAPIError,
} from "restfulmc-lib";
try {
const player: CachedPlayer = await getPlayer("Rainnny");
console.log(`Hello ${player.username}, your UUID is ${player.uniqueId}!`);
} catch (err) {
if ((err as RestfulMCAPIError).code == 404) {
console.error("Player with UUID or username not found.");
}
}
Output
$ bun index.ts
Hello Rainnny, your UUID is fc1d5fe7-f29b-430d-80bb-3b093a638b0f!