From 066703c17fc58a4da5a5d4ec50806ef5b53104d7 Mon Sep 17 00:00:00 2001 From: Nicholas Keller Date: Thu, 21 Aug 2025 04:05:54 +0000 Subject: [PATCH] v1.0.1 --- .gitignore | 2 ++ index.d.ts | 35 +++++++++++++++++++++++++++++++++++ index.js | 35 +++++++++++++++++++++++++++++++++++ package.json | 9 +++++++-- 4 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 index.d.ts diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..25c8fdb --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +package-lock.json \ No newline at end of file diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..3d2783b --- /dev/null +++ b/index.d.ts @@ -0,0 +1,35 @@ +export interface JavaUser { + username: string, + uuid: string, + skin: string, + cape: string, + linked: boolean, + bedrock_gamertag?: string, + bedrock_xuid?: number, + bedrock_fuid?: string +} + +export interface BedrockUser { + gamertag: string, + xuid: string, + floodgateuid: string, + icon: string, + gamescore: string, + accounttier: string, + textureid: string, + skin: string, + linked: boolean, + java_uuid?: string, + java_name?: string +} + +export const java: { + getPlayerByUsername(username: string): Promise; + getPlayerByUUID(uuid: string): Promise; +}; + +export const bedrock: { + getPlayerByUsername(gamertag: string): Promise; + getPlayerByXUID(xuid: string): Promise; + getPlayerByFUID(fuid: string): Promise; +}; diff --git a/index.js b/index.js index e69de29..f682cbd 100644 --- a/index.js +++ b/index.js @@ -0,0 +1,35 @@ +import fetch from 'node-fetch'; +const BASE = 'https://mcprofile.io/api/v1'; + +export const java = { + getPlayerByUsername: async function(username) { + const response = await fetch(`${BASE}/java/username/${encodeURIComponent(username)}`); + if (!response.ok) throw new Error('Failed to fetch profile'); + return response.json(); + }, + getPlayerByUUID: async function(uuid) { + const response = await fetch(`${BASE}/java/uuid/${encodeURIComponent(uuid)}`); + if (!response.ok) throw new Error('Failed to fetch profile'); + return response.json(); + } +} + +export const bedrock = { + getPlayerByUsername: async function(gamertag) { + const response = await fetch(`${BASE}/bedrock/gamertag/${encodeURIComponent(gamertag)}`); + if (!response.ok) throw new Error('Failed to fetch profile'); + return response.json(); + }, + getPlayerByXUID: async function(xuid) { + const response = await fetch(`${BASE}/bedrock/xuid/${encodeURIComponent(xuid)}`); + if (!response.ok) throw new Error('Failed to fetch profile'); + return response.json(); + }, + getPlayerByFUID: async function(xuid) { + const response = await fetch(`${BASE}/bedrock/fuid/${encodeURIComponent(fuid)}`); + if (!response.ok) throw new Error('Failed to fetch profile'); + return response.json(); + } +} + +export default {java, bedrock} \ No newline at end of file diff --git a/package.json b/package.json index 7519dfe..e843b9c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mcprofile", - "version": "1.0.0", + "version": "1.0.1", "description": "Connect to mcprofile.io", "main": "index.js", "scripts": { @@ -18,5 +18,10 @@ "bugs": { "url": "https://github.com/profilelag/mcprofile/issues" }, - "homepage": "https://github.com/profilelag/mcprofile#readme" + "homepage": "https://github.com/profilelag/mcprofile#readme", + "type": "module", + "dependencies": { + "node-fetch": "^3.3.2" + }, + "types": "index.d.ts" }