You can install the package by using go get
in your Go Project.
go get -u github.com/Ju0x/palworldapi
This will pull the latest release.
First you need to initialize a new PalworldAPI instance with credentials.
pal := palworldapi.New("http://localhost:8212", "admin", "admin password")
Typically the username is admin
.
The AdminPassword
is set in the Server Configuration. (How to configure the Palworld Server)
The REST API must be activated on the server with the RESTAPIEnabled=True
option.
With the palworldapi instance you are now able to use the wrapper functions.
package main
import "github.com/Ju0x/palworldapi"
func main() {
pal := palworldapi.New("http://localhost:8212", os.Getenv("USERNAME"), os.Getenv("ADMIN_PASSWORD"))
// Sends the message to the server globally
pal.Announce("Hello World!")
}
Then run it
USERNAME=admin ADMIN_PASSWORD=your_admin_password go run .
The result should look like this:
You can find some examples here