palworld-restapi 0.7.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- palworld_restapi-0.7.3/.github/workflows/publish.yml +32 -0
- palworld_restapi-0.7.3/.gitignore +218 -0
- palworld_restapi-0.7.3/.python-version +1 -0
- palworld_restapi-0.7.3/LICENSE +21 -0
- palworld_restapi-0.7.3/PKG-INFO +98 -0
- palworld_restapi-0.7.3/README.md +85 -0
- palworld_restapi-0.7.3/docs/CLI_GUIDE.md +104 -0
- palworld_restapi-0.7.3/docs/ENDPOINTS.md +23 -0
- palworld_restapi-0.7.3/docs/USAGE_GUIDE.md +69 -0
- palworld_restapi-0.7.3/examples/announcement.py +20 -0
- palworld_restapi-0.7.3/examples/banplayer.py +20 -0
- palworld_restapi-0.7.3/examples/kickplayer.py +18 -0
- palworld_restapi-0.7.3/examples/playerlist.py +20 -0
- palworld_restapi-0.7.3/examples/serverinfo.py +24 -0
- palworld_restapi-0.7.3/examples/shutdown.py +22 -0
- palworld_restapi-0.7.3/examples/sync_serverinfo.py +20 -0
- palworld_restapi-0.7.3/examples/unbanplayer.py +18 -0
- palworld_restapi-0.7.3/pyproject.toml +35 -0
- palworld_restapi-0.7.3/src/palworld_restapi/__init__.py +21 -0
- palworld_restapi-0.7.3/src/palworld_restapi/__main__.py +4 -0
- palworld_restapi-0.7.3/src/palworld_restapi/_core.py +33 -0
- palworld_restapi-0.7.3/src/palworld_restapi/async_client.py +96 -0
- palworld_restapi-0.7.3/src/palworld_restapi/cli.py +123 -0
- palworld_restapi-0.7.3/src/palworld_restapi/client.py +96 -0
- palworld_restapi-0.7.3/src/palworld_restapi/errors.py +13 -0
- palworld_restapi-0.7.3/src/palworld_restapi/models.py +253 -0
- palworld_restapi-0.7.3/src/palworld_restapi/py.typed +1 -0
- palworld_restapi-0.7.3/tests/test_async_client.py +60 -0
- palworld_restapi-0.7.3/tests/test_client.py +54 -0
- palworld_restapi-0.7.3/tests/test_palworld_cli.py +57 -0
- palworld_restapi-0.7.3/uv.lock +220 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
pypi-publish:
|
|
9
|
+
name: Build and publish Python package
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
# Required for Trusted Publishing
|
|
13
|
+
environment:
|
|
14
|
+
name: pypi
|
|
15
|
+
url: https://pypi.org/p/palworld-restapi
|
|
16
|
+
|
|
17
|
+
permissions:
|
|
18
|
+
id-token: write # IMPORTANT: mandatory for trusted publishing
|
|
19
|
+
contents: read
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- name: Checkout repository
|
|
23
|
+
uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- name: Install uv
|
|
26
|
+
uses: astral-sh/setup-uv@v5
|
|
27
|
+
|
|
28
|
+
- name: Build package
|
|
29
|
+
run: uv build
|
|
30
|
+
|
|
31
|
+
- name: Publish package distributions to PyPI
|
|
32
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.14
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AyanoKouji
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: palworld-restapi
|
|
3
|
+
Version: 0.7.3
|
|
4
|
+
Summary: This is a simple Palworld REST API Wrapper + CLI written in python.
|
|
5
|
+
Project-URL: Repository, https://github.com/KJAyano/Palworld-RESTAPI
|
|
6
|
+
Project-URL: Issues, https://github.com/KJAyano/Palworld-RESTAPI/issues
|
|
7
|
+
Author: KJAyano
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Python: >=3.14
|
|
10
|
+
Requires-Dist: httpx<1,>=0.27
|
|
11
|
+
Requires-Dist: python-dotenv
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# Palworld REST API
|
|
15
|
+
|
|
16
|
+
[](https://pypi.org/project/palworld-restapi/)
|
|
17
|
+
[](https://pypi.org/project/palworld-restapi/)
|
|
18
|
+
|
|
19
|
+
A modern, fast, and fully-typed Python client library and CLI wrapper for the official **Palworld Dedicated Server REST API**. Built on `httpx` to provide first-class support for both synchronous scripts and high-performance asynchronous applications.
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- **Dual Clients**: Contains both `PalworldClient` (sync) and `AsyncPalworldClient` (async) using connection pooling for maximum performance.
|
|
24
|
+
- **Strict Typing**: Fully typed with PEP 561 compliance. API responses are parsed into rigorous Python Dataclasses for safety and excellent IDE autocomplete.
|
|
25
|
+
- **CLI Included**: Manage your Palworld server directly from your terminal using the built-in `palworld-cli`.
|
|
26
|
+
- **Modern**: Formatted with `ruff`, built with `hatchling`, and rigorously tested.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
You can install the package directly from PyPI:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install palworld-restapi
|
|
36
|
+
```
|
|
37
|
+
*(Or use `uv add palworld-restapi` if you are using `uv`)*
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Quickstart
|
|
42
|
+
|
|
43
|
+
### Async Client (Recommended for Bots / Web Apps)
|
|
44
|
+
```python
|
|
45
|
+
import asyncio
|
|
46
|
+
from palworld_restapi import AsyncPalworldClient
|
|
47
|
+
|
|
48
|
+
async def main():
|
|
49
|
+
async with AsyncPalworldClient("http://127.0.0.1:8212", password="admin-password") as client:
|
|
50
|
+
info = await client.get_info()
|
|
51
|
+
print(f"Connected to {info.servername} (v{info.version})")
|
|
52
|
+
|
|
53
|
+
# Announce a message to the server
|
|
54
|
+
await client.announce("Hello from Python!")
|
|
55
|
+
|
|
56
|
+
if __name__ == "__main__":
|
|
57
|
+
asyncio.run(main())
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Sync Client (Recommended for simple scripts)
|
|
61
|
+
```python
|
|
62
|
+
from palworld_restapi import PalworldClient
|
|
63
|
+
|
|
64
|
+
with PalworldClient("http://127.0.0.1:8212", password="admin-password") as client:
|
|
65
|
+
players_resp = client.get_players()
|
|
66
|
+
print(f"There are currently {len(players_resp.players)} players online.")
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Command Line Interface (CLI)
|
|
72
|
+
|
|
73
|
+
The package ships with a built-in CLI to easily manage your server without writing code. It supports loading credentials from `.env` files automatically.
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Get server info
|
|
77
|
+
palworld-cli info
|
|
78
|
+
|
|
79
|
+
# See online players
|
|
80
|
+
palworld-cli players
|
|
81
|
+
|
|
82
|
+
# Kick a player by Steam ID
|
|
83
|
+
palworld-cli kick steam_00000000000000000 --message "AFK too long"
|
|
84
|
+
|
|
85
|
+
# Shut the server down in 60 seconds
|
|
86
|
+
palworld-cli shutdown 60 --message "Restarting for an update!"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Documentation & Examples
|
|
92
|
+
|
|
93
|
+
For full details, please refer to the documentation:
|
|
94
|
+
- **[Usage Guide](https://github.com/KJAyano/Palworld-RESTAPI/blob/main/docs/USAGE_GUIDE.md)**: Deep dive into using the Python clients.
|
|
95
|
+
- **[CLI Guide](https://github.com/KJAyano/Palworld-RESTAPI/blob/main/docs/CLI_GUIDE.md)**: Full command reference for the `palworld-cli` terminal tool.
|
|
96
|
+
- **[Endpoints Reference](https://github.com/KJAyano/Palworld-RESTAPI/blob/main/docs/ENDPOINTS.md)**: Available endpoints and payload details.
|
|
97
|
+
|
|
98
|
+
We also have a full suite of working scripts in the [`examples/`](https://github.com/KJAyano/Palworld-RESTAPI/tree/main/examples) directory demonstrating kick/ban management, player tracking, and server metrics.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Palworld REST API
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/palworld-restapi/)
|
|
4
|
+
[](https://pypi.org/project/palworld-restapi/)
|
|
5
|
+
|
|
6
|
+
A modern, fast, and fully-typed Python client library and CLI wrapper for the official **Palworld Dedicated Server REST API**. Built on `httpx` to provide first-class support for both synchronous scripts and high-performance asynchronous applications.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Dual Clients**: Contains both `PalworldClient` (sync) and `AsyncPalworldClient` (async) using connection pooling for maximum performance.
|
|
11
|
+
- **Strict Typing**: Fully typed with PEP 561 compliance. API responses are parsed into rigorous Python Dataclasses for safety and excellent IDE autocomplete.
|
|
12
|
+
- **CLI Included**: Manage your Palworld server directly from your terminal using the built-in `palworld-cli`.
|
|
13
|
+
- **Modern**: Formatted with `ruff`, built with `hatchling`, and rigorously tested.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
You can install the package directly from PyPI:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install palworld-restapi
|
|
23
|
+
```
|
|
24
|
+
*(Or use `uv add palworld-restapi` if you are using `uv`)*
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Quickstart
|
|
29
|
+
|
|
30
|
+
### Async Client (Recommended for Bots / Web Apps)
|
|
31
|
+
```python
|
|
32
|
+
import asyncio
|
|
33
|
+
from palworld_restapi import AsyncPalworldClient
|
|
34
|
+
|
|
35
|
+
async def main():
|
|
36
|
+
async with AsyncPalworldClient("http://127.0.0.1:8212", password="admin-password") as client:
|
|
37
|
+
info = await client.get_info()
|
|
38
|
+
print(f"Connected to {info.servername} (v{info.version})")
|
|
39
|
+
|
|
40
|
+
# Announce a message to the server
|
|
41
|
+
await client.announce("Hello from Python!")
|
|
42
|
+
|
|
43
|
+
if __name__ == "__main__":
|
|
44
|
+
asyncio.run(main())
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Sync Client (Recommended for simple scripts)
|
|
48
|
+
```python
|
|
49
|
+
from palworld_restapi import PalworldClient
|
|
50
|
+
|
|
51
|
+
with PalworldClient("http://127.0.0.1:8212", password="admin-password") as client:
|
|
52
|
+
players_resp = client.get_players()
|
|
53
|
+
print(f"There are currently {len(players_resp.players)} players online.")
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Command Line Interface (CLI)
|
|
59
|
+
|
|
60
|
+
The package ships with a built-in CLI to easily manage your server without writing code. It supports loading credentials from `.env` files automatically.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Get server info
|
|
64
|
+
palworld-cli info
|
|
65
|
+
|
|
66
|
+
# See online players
|
|
67
|
+
palworld-cli players
|
|
68
|
+
|
|
69
|
+
# Kick a player by Steam ID
|
|
70
|
+
palworld-cli kick steam_00000000000000000 --message "AFK too long"
|
|
71
|
+
|
|
72
|
+
# Shut the server down in 60 seconds
|
|
73
|
+
palworld-cli shutdown 60 --message "Restarting for an update!"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Documentation & Examples
|
|
79
|
+
|
|
80
|
+
For full details, please refer to the documentation:
|
|
81
|
+
- **[Usage Guide](https://github.com/KJAyano/Palworld-RESTAPI/blob/main/docs/USAGE_GUIDE.md)**: Deep dive into using the Python clients.
|
|
82
|
+
- **[CLI Guide](https://github.com/KJAyano/Palworld-RESTAPI/blob/main/docs/CLI_GUIDE.md)**: Full command reference for the `palworld-cli` terminal tool.
|
|
83
|
+
- **[Endpoints Reference](https://github.com/KJAyano/Palworld-RESTAPI/blob/main/docs/ENDPOINTS.md)**: Available endpoints and payload details.
|
|
84
|
+
|
|
85
|
+
We also have a full suite of working scripts in the [`examples/`](https://github.com/KJAyano/Palworld-RESTAPI/tree/main/examples) directory demonstrating kick/ban management, player tracking, and server metrics.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Palworld-RESTAPI Command Line Interface (CLI)
|
|
2
|
+
|
|
3
|
+
The `palworld-cli` tool allows you to query and manage your Palworld dedicated server directly from your terminal.
|
|
4
|
+
|
|
5
|
+
## Authentication & Configuration
|
|
6
|
+
|
|
7
|
+
The CLI requires your server's REST API URL and the Admin Password.
|
|
8
|
+
|
|
9
|
+
You can provide these in **three** ways, in order of priority:
|
|
10
|
+
|
|
11
|
+
1. **Command Line Arguments**:
|
|
12
|
+
```bash
|
|
13
|
+
palworld-cli --base-url "http://127.0.0.1:8212" --password "your_password" info
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
2. **Environment Variables**:
|
|
17
|
+
```bash
|
|
18
|
+
export PALWORLD_BASE_URL="http://127.0.0.1:8212"
|
|
19
|
+
export PALWORLD_PASSWORD="your_password"
|
|
20
|
+
palworld-cli info
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
3. **Dotenv (`.env`) File** (Recommended):
|
|
24
|
+
Create a `.env` file in the folder where you run the command. The CLI automatically loads it.
|
|
25
|
+
```env
|
|
26
|
+
PALWORLD_BASE_URL=http://127.0.0.1:8212
|
|
27
|
+
PALWORLD_USERNAME=admin
|
|
28
|
+
PALWORLD_PASSWORD=your_password
|
|
29
|
+
PALWORLD_TIMEOUT=10.0
|
|
30
|
+
```
|
|
31
|
+
*Note: If your `.env` file is located somewhere else, you can pass `--env /path/to/.env`.*
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Available Commands
|
|
36
|
+
|
|
37
|
+
All data-fetching commands output their results in clean, formatted **JSON**, making it perfect for piping into other tools like `jq`.
|
|
38
|
+
|
|
39
|
+
### `info`
|
|
40
|
+
Gets general server information (version, name, GUID).
|
|
41
|
+
```bash
|
|
42
|
+
palworld-cli info
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### `metrics`
|
|
46
|
+
Gets current server metrics (FPS, uptime, current players).
|
|
47
|
+
```bash
|
|
48
|
+
palworld-cli metrics
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### `players`
|
|
52
|
+
Gets a list of all currently online players, including their level, ping, and Steam ID.
|
|
53
|
+
```bash
|
|
54
|
+
palworld-cli players
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### `settings`
|
|
58
|
+
Gets the extensive list of server configurations (difficulty, drop rates, PvP settings, etc.).
|
|
59
|
+
```bash
|
|
60
|
+
palworld-cli settings
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### `announce`
|
|
64
|
+
Broadcasts a system message to all online players.
|
|
65
|
+
```bash
|
|
66
|
+
palworld-cli announce "Server will restart in 5 minutes!"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### `kick`
|
|
70
|
+
Kicks a player from the server using their `userid` (Steam ID). An optional message can be provided.
|
|
71
|
+
```bash
|
|
72
|
+
palworld-cli kick steam_00000000000000000
|
|
73
|
+
palworld-cli kick steam_00000000000000000 --message "AFK too long"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### `ban`
|
|
77
|
+
Bans a player from the server using their `userid`.
|
|
78
|
+
```bash
|
|
79
|
+
palworld-cli ban steam_00000000000000000 --message "Cheating"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### `unban`
|
|
83
|
+
Unbans a previously banned player.
|
|
84
|
+
```bash
|
|
85
|
+
palworld-cli unban steam_00000000000000000
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### `save`
|
|
89
|
+
Forces an immediate save of the world state.
|
|
90
|
+
```bash
|
|
91
|
+
palworld-cli save
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### `shutdown`
|
|
95
|
+
Initiates a graceful server shutdown. Requires a `waittime` (in seconds).
|
|
96
|
+
```bash
|
|
97
|
+
palworld-cli shutdown 60 --message "Restarting for update"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### `stop`
|
|
101
|
+
Forces the server to stop immediately without a grace period.
|
|
102
|
+
```bash
|
|
103
|
+
palworld-cli stop
|
|
104
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Palworld REST API Endpoints
|
|
2
|
+
|
|
3
|
+
Base URL for all endpoints: `http://<host>:8212/v1/api`
|
|
4
|
+
Authentication: **HTTP Basic** (`admin` / `AdminPassword`)
|
|
5
|
+
|
|
6
|
+
| Method | Endpoint | Description | Request Body | Response Body |
|
|
7
|
+
|--------|----------|-------------|--------------|---------------|
|
|
8
|
+
| `GET` | `/info` | Get server info | - | `ServerInfo` |
|
|
9
|
+
| `GET` | `/players` | Get list of online players | - | `PlayersResponse` |
|
|
10
|
+
| `GET` | `/settings` | Get server settings | - | `ServerSettings` |
|
|
11
|
+
| `GET` | `/metrics` | Get server metrics | - | `ServerMetrics` |
|
|
12
|
+
| `POST` | `/announce` | Send a server announcement | `{"message": "str"}` | - |
|
|
13
|
+
| `POST` | `/kick` | Kick a player | `{"userid": "str", "message": "str"}` | - |
|
|
14
|
+
| `POST` | `/ban` | Ban a player | `{"userid": "str", "message": "str"}` | - |
|
|
15
|
+
| `POST` | `/unban` | Unban a player | `{"userid": "str"}` | - |
|
|
16
|
+
| `POST` | `/save` | Save the server world state | - | - |
|
|
17
|
+
| `POST` | `/shutdown` | Shutdown the server | `{"waittime": int, "message": "str"}` | - |
|
|
18
|
+
| `POST` | `/stop` | Force stop the server | - | - |
|
|
19
|
+
|
|
20
|
+
> [!NOTE]
|
|
21
|
+
> All successful `POST` endpoints return a `200 OK` status without a specific JSON body.
|
|
22
|
+
> All endpoints will return `401 Unauthorized` if invalid credentials are provided.
|
|
23
|
+
> Endpoints will return `400 Bad Request` if payload is invalid.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Palworld REST API Usage Guide
|
|
2
|
+
|
|
3
|
+
This guide covers how to use the Palworld REST API Python client in both Synchronous and Asynchronous applications, and how to use the CLI.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Ensure your project environment is setup and install the library (e.g. `uv add palworld-restapi` or `pip install palworld-restapi`).
|
|
8
|
+
|
|
9
|
+
## Code Examples
|
|
10
|
+
We have a full suite of working scripts in the `examples/` directory of the repository:
|
|
11
|
+
- `announcement.py`
|
|
12
|
+
- `banplayer.py` / `kickplayer.py` / `unbanplayer.py`
|
|
13
|
+
- `playerlist.py`
|
|
14
|
+
- `serverinfo.py` / `sync_serverinfo.py`
|
|
15
|
+
- `shutdown.py`
|
|
16
|
+
|
|
17
|
+
## Sync Client Usage
|
|
18
|
+
|
|
19
|
+
Use `PalworldClient` for standard scripts and synchronous applications.
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from palworld_restapi import PalworldClient, PalworldApiError
|
|
23
|
+
|
|
24
|
+
def main():
|
|
25
|
+
try:
|
|
26
|
+
with PalworldClient("http://127.0.0.1:8212", password="admin-pass") as client:
|
|
27
|
+
info = client.get_info()
|
|
28
|
+
print(f"Server Name: {info.servername}")
|
|
29
|
+
print(f"Version: {info.version}")
|
|
30
|
+
|
|
31
|
+
players_resp = client.get_players()
|
|
32
|
+
print(f"Online Players: {len(players_resp.players)}")
|
|
33
|
+
|
|
34
|
+
client.announce("Hello from Palworld-RESTAPI!")
|
|
35
|
+
except PalworldApiError as e:
|
|
36
|
+
print(f"API Error: {e}")
|
|
37
|
+
|
|
38
|
+
if __name__ == "__main__":
|
|
39
|
+
main()
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Async Client Usage
|
|
43
|
+
|
|
44
|
+
Use `AsyncPalworldClient` for highly concurrent applications, like Discord bots (e.g., discord.py).
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
import asyncio
|
|
48
|
+
from palworld_restapi import AsyncPalworldClient, PalworldApiError
|
|
49
|
+
|
|
50
|
+
async def main():
|
|
51
|
+
try:
|
|
52
|
+
async with AsyncPalworldClient("http://127.0.0.1:8212", password="admin-pass") as client:
|
|
53
|
+
metrics = await client.get_metrics()
|
|
54
|
+
print(f"Server FPS: {metrics.serverfps}")
|
|
55
|
+
|
|
56
|
+
settings = await client.get_settings()
|
|
57
|
+
print(f"Difficulty: {settings.Difficulty}")
|
|
58
|
+
except PalworldApiError as e:
|
|
59
|
+
print(f"API Error: {e}")
|
|
60
|
+
|
|
61
|
+
if __name__ == "__main__":
|
|
62
|
+
asyncio.run(main())
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## CLI Usage
|
|
66
|
+
|
|
67
|
+
The package provides a built-in CLI `palworld-cli`.
|
|
68
|
+
|
|
69
|
+
For full details on authentication, options, and commands, please see the dedicated **[CLI Guide](CLI_GUIDE.md)**!
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from palworld_restapi import AsyncPalworldClient, PalworldApiError
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
async def main():
|
|
6
|
+
server_url = "http://127.0.0.1:8212"
|
|
7
|
+
password = "admin_password"
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
async with AsyncPalworldClient(server_url, password=password) as client:
|
|
11
|
+
await client.announce(
|
|
12
|
+
"Server restarting in 5 minutes! Please find a safe place."
|
|
13
|
+
)
|
|
14
|
+
print("Announcement sent successfully.")
|
|
15
|
+
except PalworldApiError as e:
|
|
16
|
+
print(f"API Error: {e}")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
if __name__ == "__main__":
|
|
20
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from palworld_restapi import AsyncPalworldClient, PalworldApiError
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
async def main():
|
|
6
|
+
server_url = "http://127.0.0.1:8212"
|
|
7
|
+
password = "admin_password"
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
async with AsyncPalworldClient(server_url, password=password) as client:
|
|
11
|
+
await client.ban_player(
|
|
12
|
+
"steam_00000000000000000", message="Violation of server rules."
|
|
13
|
+
)
|
|
14
|
+
print("Player banned successfully.")
|
|
15
|
+
except PalworldApiError as e:
|
|
16
|
+
print(f"API Error: {e}")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
if __name__ == "__main__":
|
|
20
|
+
asyncio.run(main())
|