Skip to main content

Python client for the PalDefender REST API.

Project description

PyPI version Python versions License Discord

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_URL
  • PALDEFENDER_BEARER_TOKEN
  • PALDEFENDER_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:

  • GiveItem
  • GivePal
  • GivePalEgg
  • GiveProgressionRequest

Constants And Recipes

Generated constants and recipe helpers are exported from the package root:

  • ItemId, PalId, PassiveId, SkillId, TechnologyId
  • ITEM_ID_TO_NAME, PAL_ID_TO_NAME, PASSIVE_ID_TO_NAME, SKILL_ID_TO_NAME, TECHNOLOGY_ID_TO_NAME
  • Recipe, 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_code
  • method
  • path
  • response_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paldefender_rest_client-0.1.0.tar.gz (104.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paldefender_rest_client-0.1.0-py3-none-any.whl (101.5 kB view details)

Uploaded Python 3

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

Hashes for paldefender_rest_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6fa643fb24b12daba74a54df039fb385d79b5cc656bb8d9af44f91edf2304b2a
MD5 b0895ec182a29906c9e8e1d11807631d
BLAKE2b-256 120c298c3a8376c05dfadce43fe3b73545481e1d155ac5977f09c336d1bcd948

See more details on using hashes here.

Provenance

The following attestation bundles were made for paldefender_rest_client-0.1.0.tar.gz:

Publisher: publish.yml on PalLink/PD-REST-Python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file paldefender_rest_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for paldefender_rest_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cbed0bb32b4824cd52d33f62a2f5852366a9b9b516b39c4290292c350d755db3
MD5 4a516e3cb045142b4702a46b123b856c
BLAKE2b-256 8f4fb51586d4ba61cd4ee1f2d62641640fea69f4de165bc58970224b44f44231

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page