Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rinckodev/starlightskinapi
https://github.com/rinckodev/starlightskinapi
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/rinckodev/starlightskinapi
- Owner: rinckodev
- Created: 2023-11-22T17:00:38.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-03-16T13:20:24.000Z (8 months ago)
- Last Synced: 2024-10-26T01:07:37.994Z (24 days ago)
- Language: TypeScript
- Size: 376 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Starlight SkinAPI Wrapper
This package is a Starlight SkinAPI wrapper
Oficial Starlight SkinAPI Documentation : https://docs.lunareclipse.studio/
### Installation
```bash
npm install starlightskinapi
```fetchSkinInfo function usage:
```ts
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:
```bash
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
```ts
async function main(){
const playerNickname = "NicknameVeryLongAndUnlikely";
const infoResult = await fetchSkinInfo(playerNickname)if (!infoResult.success){
console.log(infoResult.error)
}
}
main();
```Output:
```bash
Unknown player username/uuid.
```See how to get a render pose
```ts
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
```ts
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 | |