UNPKG

@threadmc/minecraft-api

Version:

An advanced Minecraft API client for interacting with piston-meta, minecraft servers, and more

81 lines (80 loc) 3.41 kB
import { fetchVersionManifest, fetchVersionDetails } from "./rest.js"; import { VersionType } from "./enums/VersionType.js"; import type { Version, VersionManifest, VersionDetails } from "./types/VersionManifest.js"; /** * Main API client for interacting with Minecraft version data, Mojang APIs, and Minecraft servers. * Provides high-level methods for fetching version info, server status, user profiles, and more. */ export declare class Client { private rest; private server; /** * Create a new Client instance. */ constructor(); /** * Fetch detailed information about a specific Minecraft version. * @param version The version ID (e.g., "1.20.4"). * @returns The version details as returned by the manifest. */ fetchVersion(version: string): Promise<any>; /** * Fetch all Minecraft versions of a given type (release or snapshot). * @param type The version type (VersionType.RELEASE or VersionType.SNAPSHOT). * @returns An array of versions matching the type. */ fetchVersions(type: VersionType): Promise<Version[]>; /** * Fetch the latest Minecraft version of a given type. * @param type The version type (VersionType.RELEASE or VersionType.SNAPSHOT). * @returns The latest version object. */ fetchLatestVersion(type: VersionType): Promise<Version>; /** * Get the status of a Minecraft server using the server list ping protocol. * @param host The server hostname or IP. * @param port The server port (default 25565). * @returns The server status response. */ getServerStatus(host: string, port?: number): Promise<any>; /** * Ping a Minecraft server and return the latency in milliseconds. * @param host The server hostname or IP. * @param port The server port (default 25565). * @returns The latency in ms. */ pingServer(host: string, port?: number): Promise<any>; /** * Fetch the asset index for a specific Minecraft version. * @param version The version ID. * @returns The asset index JSON. */ fetchAssetIndex(version: string): Promise<any>; /** * Download a Minecraft library JAR file as an ArrayBuffer. * @param libraryPath The path to the library (e.g., "com/mojang/brigadier/1.0.18/brigadier-1.0.18.jar"). * @returns The library file as an ArrayBuffer. */ fetchLibrary(libraryPath: string): Promise<ArrayBuffer>; /** * Fetch a Mojang user profile by username. * @param username The Minecraft username. * @returns The user profile JSON. */ fetchUserProfile(username: string): Promise<any>; /** * Fetch the name history for a given UUID. * @deprecated This endpoint has been removed on the 13th September 2022. * For more information, see: https://shorturl.at/31VrF * @param uuid The user's UUID (with or without dashes). * @returns The name history array. */ fetchNameHistory(uuid: string): Promise<never>; /** * Fetch the skin and/or cape textures for a user by UUID. * @param uuid The user's UUID (with or without dashes). * @returns The textures object containing skin/cape URLs, or null if not found. */ fetchUserTextures(uuid: string): Promise<any>; } export { VersionType, Version, VersionManifest, VersionDetails, fetchVersionManifest, fetchVersionDetails, };