palworld
v1.0.1
Published
A Palworld REST API wrapper
Downloads
8
Readme
Palworld Rest API
This is a simple wrapper around the Palworld API. The REST documentation can be found here
Installation
npm install palworld -s
Usage
import {Palworld} from "palworld";
const palworld = new Palworld("admin", "admin");
(async () => {
const info = await palworld.serverInfo()
console.log(`Server Name: ${info.servername}`)
console.log(`Server Version: ${info.version}`)
const players = await palworld.playerList()
console.log("Players:")
players.forEach(player => {
console.log(`- ${player.name} (Level: ${player.level} | Ping: ${player.ping}ms | Location: (${player.location_x}, ${player.location_y}) | IP: ${player.ip} | Player ID: ${player.playerId} | User ID: ${player.userId})`)
})
const settings = await palworld.serverSettings()
console.log("Settings:")
Object.entries(settings).forEach(([key, value]) => {
console.log(`- ${key}: ${value}`)
})
const metrics = await palworld.serverMetrics()
console.log("Metrics:")
Object.entries(metrics).forEach(([key, value]) => {
console.log(`- ${key}: ${value}`)
})
const announceSuccess = await palworld.announceMessage("Hello, Palworld from nodeJS!")
console.log(`Announce Success: ${announceSuccess}`)
if (players.length > 0) {
const kickSuccess = await palworld.kickPlayer(players[0].userId, "You have been kicked from nodeJS!")
console.log(`Kick Success: ${kickSuccess}`)
}
await palworld.saveWorld()
await palworld.shutdown(30, "Server is shutting down from nodeJS!")
await palworld.stop()
})()