Python client for the PalDefender REST API.
Project description
PalDefender-REST-Client (Python)
Installable Python client for the PalDefender REST API. The package covers every route currently registered in the PalDefender reference implementation under Reference/.
Install
pip install paldefender-rest-client
Quick Start
from PalDefender import RESTClient
with RESTClient(
base_url="http://127.0.0.1",
bearer_token="your-token",
) as client:
version = client.get_version()
players = client.get_players()
result = client.give_items("player-uid-or-userid", "Stone", ("Stone", 99))
Or:
import PalDefender
CLI
The package also installs a paldefender-cli command.
paldefender-cli --env .env version
Set these variables in .env or in your shell environment:
PALDEFENDER_BASE_URLPALDEFENDER_BEARER_TOKENPALDEFENDER_DISPLAY_ADDRESS(optional)PALDEFENDER_TIMEOUT(optional)
If base_url omits a port, the client defaults to 17993.
Available Methods
Read operations
get_version()get_guilds()get_guild(guild_id)get_players()get_player(player_identifier)get_pals(player_identifier)get_items(player_identifier)get_techs(player_identifier)get_progression(player_identifier)
Write operations
give_items(player_identifier, *items)give_recipe_materials(player_identifier, product, quantity=1)give_pals(player_identifier, pals)give_pal_templates(player_identifier, templates)give_pal_eggs(player_identifier, pal_eggs)give_progression(player_identifier, request)learn_tech(player_identifier, technology)forget_tech(player_identifier, technology)delete_base(base_camp_identifier)
Helper Models
The package includes request helper dataclasses:
GiveItemGivePalGivePalEggGiveProgressionRequest
Constants And Recipes
Generated constants and recipe helpers are exported from the package root:
ItemId,PalId,PassiveId,SkillId,TechnologyIdITEM_ID_TO_NAME,PAL_ID_TO_NAME,PASSIVE_ID_TO_NAME,SKILL_ID_TO_NAME,TECHNOLOGY_ID_TO_NAMERecipe,has_recipe(),get_recipe(),get_recipe_materials(),get_recipes()
give_recipe_materials() resolves a product recipe locally and then calls the existing give_items() endpoint with the required material counts.
give_items() accepts strings, (item_id, count) tuples, GiveItem objects, or a single list/tuple containing those values. Duplicate item ids are merged before the request is sent.
You can also pass plain dictionaries when that is more convenient.
Errors
HTTP errors raise PalDefenderApiError. The exception exposes:
status_codemethodpathresponse_body
Endpoint Reference
Full endpoint documentation is in docs/ENDPOINTS.md.
Usage Guide
For a more detailed Python-focused guide with examples for typed GET responses, friendly POST helpers, constants, recipes, and error handling, see docs/USAGE_GUIDE.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file paldefender_rest_client-0.1.0.tar.gz.
File metadata
- Download URL: paldefender_rest_client-0.1.0.tar.gz
- Upload date:
- Size: 104.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fa643fb24b12daba74a54df039fb385d79b5cc656bb8d9af44f91edf2304b2a
|
|
| MD5 |
b0895ec182a29906c9e8e1d11807631d
|
|
| BLAKE2b-256 |
120c298c3a8376c05dfadce43fe3b73545481e1d155ac5977f09c336d1bcd948
|
Provenance
The following attestation bundles were made for paldefender_rest_client-0.1.0.tar.gz:
Publisher:
publish.yml on PalLink/PD-REST-Python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
paldefender_rest_client-0.1.0.tar.gz -
Subject digest:
6fa643fb24b12daba74a54df039fb385d79b5cc656bb8d9af44f91edf2304b2a - Sigstore transparency entry: 1415407383
- Sigstore integration time:
-
Permalink:
PalLink/PD-REST-Python@08ee41758855a44f3a915f295d49a801bf0f9ba3 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/PalLink
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08ee41758855a44f3a915f295d49a801bf0f9ba3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file paldefender_rest_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: paldefender_rest_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 101.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbed0bb32b4824cd52d33f62a2f5852366a9b9b516b39c4290292c350d755db3
|
|
| MD5 |
4a516e3cb045142b4702a46b123b856c
|
|
| BLAKE2b-256 |
8f4fb51586d4ba61cd4ee1f2d62641640fea69f4de165bc58970224b44f44231
|
Provenance
The following attestation bundles were made for paldefender_rest_client-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on PalLink/PD-REST-Python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
paldefender_rest_client-0.1.0-py3-none-any.whl -
Subject digest:
cbed0bb32b4824cd52d33f62a2f5852366a9b9b516b39c4290292c350d755db3 - Sigstore transparency entry: 1415407446
- Sigstore integration time:
-
Permalink:
PalLink/PD-REST-Python@08ee41758855a44f3a915f295d49a801bf0f9ba3 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/PalLink
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08ee41758855a44f3a915f295d49a801bf0f9ba3 -
Trigger Event:
push
-
Statement type: