starlightskinapi
v1.0.10
Published
Starlight SkinAPI Wrapper
Downloads
24
Maintainers
Readme
Starlight SkinAPI Wrapper
This package is a Starlight SkinAPI wrapper
Oficial Starlight SkinAPI Documentation : https://docs.lunareclipse.studio/
Installation
npm install starlightskinapi
fetchSkinInfo function usage:
import { fetchSkinInfo } from "starlightskinapi";
async function main(){
const playerNickname = "RinckoZ_";
const infoResult = await fetchSkinInfo(playerNickname)
if (infoResult.success){
console.log(infoResult.playerUUID)
console.log(infoResult.skinUrl)
console.log(infoResult.userCape)
console.log(infoResult.skinTextureWidth)
console.log(infoResult.skinTextureHeight)
}
}
main();
Output:
f169e30f110943dfba445da3b7dee1ce
http://textures.minecraft.net/texture/4d24cc4874ba673963ca57818a0be02666aa80f4747d00b45571e380ed9b54f7
http://textures.minecraft.net/texture/2340c0e03dd24a11b15a8b33c2a7e9e32abb2051b2481d0ba7defd635ca7a933
64
64
If the nick or uuid is not found, success will be false, and you will have the error property
async function main(){
const playerNickname = "NicknameVeryLongAndUnlikely";
const infoResult = await fetchSkinInfo(playerNickname)
if (!infoResult.success){
console.log(infoResult.error)
}
}
main();
Output:
Unknown player username/uuid.
See how to get a render pose
import { RenderCrops, RenderTypes, fetchSkinRender } from "starlightskinapi";
import { writeFile } from "node:fs/promises"
async function main(){
const playerNickname = "RinckoZ_";
const renderResult = await fetchSkinRender(playerNickname, {
type: RenderTypes.Default,
crop: RenderCrops.Full,
})
if (!renderResult.success){
console.log(renderResult.error)
return;
}
if (renderResult.success){
const { buffer, url } = renderResult;
console.log(url) //
await writeFile("./render.png", buffer);
}
}
main();
Output:
You can customize the model, camera and lighting options
import { RenderCrops, RenderTypes, fetchSkinRender } from "starlightskinapi";
import { writeFile } from "node:fs/promises"
async function main(){
const playerNickname = "RinckoZ_";
const renderResult = await fetchSkinRender(playerNickname, {
type: RenderTypes.Default,
crop: RenderCrops.Full,
model: {
capeEnabled: true,
// ... other model options ...
},
camera: {
cameraPosition: { x: "10", y: "10", z: "-20" },
cameraWidth: 720,
cameraHeight: 1080,
// ... other camera options ...
},
lighting: {
dirLightPos: { x: "-10", y: "10", z: "-10" },
// ... other lighting options ...
},
});
if (!renderResult.success){
console.log(renderResult.error)
return;
}
if (renderResult.success){
const { buffer } = renderResult;
await writeFile("./customized.png", buffer);
}
}
main();
Output:
Full Render Type List
| Render Types | Supported Crops | Preview | | ------------ | --------------- | ------- | | Default | Full, Bust, Face | | | Marching | Full, Bust, Face | | | Walking | Full, Bust, Face | | | Crouching | Full, Bust, Face | | | Crossed | Full, Bust, Face | | | CrissCross| Full, Bust, Face | | | Cheering| Full, Bust, Face | | | Relaxing| Full, Bust, Face | | | Trudging | Full, Bust, Face | | | Cowering| Full, Bust, Face | | | Pointing| Full, Bust, Face | | | Lunging| Full, Bust, Face | | | Dungeons| Full, Bust, Face | | | Facepalm| Full, Bust, Face | | | Sleeping| Full, Bust | | | Dead| Full, Bust, Face | | | Archer| Full, Bust, Face | | | Facepalm| Full, Bust, Face | | | Mojavatar| Full, Bust | | | Ultimate| Full, Bust, Face | | | Isometric| Full, Bust, Face | | | Head| Full | | | Bitzel| Full, Bust, Face | | | Pixel| Full, Bust, Face | | | Ornament| Full | | | Skin| Default, Processed | |