This commit is contained in:
Nicholas Keller
2025-08-21 04:05:54 +00:00
parent 8028e5144a
commit 066703c17f
4 changed files with 79 additions and 2 deletions
+2
View File
@@ -0,0 +1,2 @@
node_modules
package-lock.json
Vendored
+35
View File
@@ -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<JavaUser>;
getPlayerByUUID(uuid: string): Promise<JavaUser>;
};
export const bedrock: {
getPlayerByUsername(gamertag: string): Promise<BedrockUser>;
getPlayerByXUID(xuid: string): Promise<BedrockUser>;
getPlayerByFUID(fuid: string): Promise<BedrockUser>;
};
+35
View File
@@ -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}
+7 -2
View File
@@ -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"
}