Skip to main content

WeltenHub Client Framework — typed REST client and Pydantic schemas for the WeltenHub Story Universe API

Project description

weltenfw

WeltenHub Client Framework — typed REST client and Pydantic v2 schemas for the WeltenHub Story Universe API.

CI PyPI Python License: MIT

Installation

pip install weltenfw                  # core (httpx + pydantic)
pip install weltenfw[django]          # + Django AppConfig + DjangoCache
pip install weltenfw[authoring]       # + authoringfw adapter

Quick Start

from weltenfw import WeltenClient
from weltenfw.schema.world import WorldCreateInput

with WeltenClient(
    base_url="https://weltenforger.com/api/v1",
    token="your-token",
) as client:
    # Create a world
    world = client.worlds.create(WorldCreateInput(
        name="Aldoria",
        setting_era="medieval",
        description="A kingdom of runes and magic.",
    ))
    print(world.id, world.name)

    # List with pagination
    for w in client.worlds.iter_all():
        print(w.name)

    # Lookup cache
    genres = client.lookups.genres()   # cached after first call

Async

async with WeltenClient(base_url=..., token=...) as client:
    world = await client.worlds.aget(world_id)
    worlds = await client.worlds.alist()

Django Integration

# settings.py
INSTALLED_APPS = [..., "weltenfw.django"]
WELTENHUB_URL   = "https://weltenforger.com/api/v1"
WELTENHUB_TOKEN = env("WELTENHUB_TOKEN")

# views.py / services.py
from weltenfw.django import get_client
client = get_client()   # lazy singleton, per worker

Tenant Provisioning (S2S)

from weltenfw.schema.tenant import ProvisionRequest

result = client.tenants.provision(ProvisionRequest(
    username="hugo",
    email="hugo@example.com",
    display_name="Hugo",
))
# ProvisionResponse(token="...", tenant_id=UUID("..."), created=True)

Architecture

  • 1 Client = 1 Token = 1 Tenant — Multi-tenant consumers instantiate one client per tenant token.
  • Pydantic v2 — all responses validated into typed schemas (frozen=True).
  • Separate Input schemas*CreateInput for POST, *UpdateInput for PATCH.
  • Lookup cache — pluggable CacheBackend (NullCache default, MemoryCache, DjangoCache for Redis).
  • Trailing-slash normalization — prevents silent POST→GET method loss on Django's 301 redirect.

Links

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

weltenfw-0.1.0.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

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

weltenfw-0.1.0-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file weltenfw-0.1.0.tar.gz.

File metadata

  • Download URL: weltenfw-0.1.0.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for weltenfw-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e8282507a4555b0ce4b262098e8491d7daf106edd492c8175ab5fac5fe4854d2
MD5 fd8668c2242c02b62e7ccb385ba5b12c
BLAKE2b-256 25f7262460e233c342218c1b12974999293e2173f2f6320ccafe3ec5d3dfbe72

See more details on using hashes here.

File details

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

File metadata

  • Download URL: weltenfw-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for weltenfw-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d61ead2c4dbbf73041f56e5dc72b5dbe7022d752ce823d178a55a3ca90787629
MD5 a292b28ccdfd0268f453df87533b6e7b
BLAKE2b-256 c6bc1087b1a11d928cef91d0d49450b5a3131da6bb398722283435614a460162

See more details on using hashes here.

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