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
+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}