Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

wger-api-client

Typed Python client for the wger workout manager REST API, generated from the server's OpenAPI schema with openapi-python-client. Built on httpx, with a sync and an async call for every endpoint.

Note that this is still new, if you encounter any problems, please contact us.

Install

pip install wger-api-client

Usage

Every endpoint has its own module under wger_api_client.api.<tag>, and each of those exposes four functions:

Function Returns
sync the parsed body, or None
sync_detailed a Response with status code, headers and the parsed body
asyncio as sync, awaitable
asyncio_detailed as sync_detailed, awaitable

With an API key from /en/user/api-key:

from wger_api_client import AuthenticatedClient
from wger_api_client.api.routine import routine_list

with AuthenticatedClient(
    base_url="https://wger.de", token="<api key>", prefix="Token"
) as client:
    page = routine_list.sync(client=client)
    for routine in page.results:
        print(routine.id, routine.name)

With a JWT access token, which is the same call with a different prefix:

client = AuthenticatedClient(
    base_url="https://wger.de", token="<access token>", prefix="Bearer"
)

Unauthenticated endpoints, such as the exercise database, work with the plain Client:

from wger_api_client import Client
from wger_api_client.api.exercise import exercise_list

with Client(base_url="https://wger.de") as client:
    page = exercise_list.sync(client=client)

By default a non-2xx response returns None from sync. Pass raise_on_unexpected_status=True to the client to get an errors.UnexpectedStatus exception instead.

Versioning

The major and minor version say which wger release this client targets, so 2.6.x is meant for a 2.6 server.

Since we try to keep the API as compatible as possible, an older client generally keeps working against a newer server, specially for endpoints such as the exercises. However it is recommended that you use the version that matches your server's

Development

The generated package under wger_api_client/ is checked in, so that a schema change shows up as a reviewable diff. Do not edit it by hand.

Updating the client after the server's API changed is two steps, refresh the schema and regenerate from it. The schema is read from a running wger instance, by default the upstream one at https://wger.de:

# 1. refresh schema/wger-openapi.yaml
uv run scripts/sync_schema.py [--base-url https://my.server]

# 2. regenerate the client from the refreshed schema
./scripts/generate.sh

uv run pytest

To pick up API changes that are not released yet, point it at a local instance (./manage.py runserver in the server checkout) with --base-url or $WGER_BASE_URL:

uv run scripts/sync_schema.py --base-url http://localhost:8000

Then commit both diffs together. A schema that moved without a regenerated client is exactly what CI rejects.

Two things to keep in mind when refreshing:

The instance must be backed by PostgreSQL, the way real deployments are. Django derives the bounds of its integer fields from the database backend, so the schema is backend-dependent. The default instance already satisfies this, so it only matters when syncing from a local checkout configured for SQLite.

Also note that the schema endpoint does not report the warnings that ./manage.py spectacular prints on the server side. Those warnings mean the schema might be misdescribing the API somewhere, and the mistake gets baked into the client, so check them in the server checkout whenever its serializers changed.

To verify without changing anything:

# does the committed client still match the committed schema?
./scripts/generate.sh --check

# has the server's schema moved since the snapshot was taken?
uv run scripts/sync_schema.py --check

tests/test_contract.py pins the parts of the contract that are easy to get wrong when the calls are written by hand: which endpoints are read-only, which methods each URL allows, the valid enum values and the writable field sets.

tests/test_smoke_live.py runs against a real instance and is skipped unless WGER_SMOKE_URL and WGER_SMOKE_TOKEN are set.

License

Apache-2.0, see LICENSE.txt and NOTICE.

The wger server itself is AGPL-3.0-or-later. This client is licensed permissively so that it can be used as an ordinary dependency. The endpoint and field descriptions carried in the generated docstrings come from the server's source code and are attributed in the NOTICE file.

Download files

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

Source Distribution

wger_api_client-2.6.0b1.tar.gz (177.3 kB view details)

Uploaded Source

Built Distribution

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

wger_api_client-2.6.0b1-py3-none-any.whl (633.1 kB view details)

Uploaded Python 3

File details

Details for the file wger_api_client-2.6.0b1.tar.gz.

File metadata

  • Download URL: wger_api_client-2.6.0b1.tar.gz
  • Upload date:
  • Size: 177.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for wger_api_client-2.6.0b1.tar.gz
Algorithm Hash digest
SHA256 b3f8f3ecc22ced0e23224e0d44558859bc01f1b52d6186c6618f585c988c2435
MD5 f3a456221968e0a6e5bcdd4f49f38a65
BLAKE2b-256 d40d2af94d876e291326beba6cc3289c7417cc2854ae5a04b91de078c2f32f49

See more details on using hashes here.

Provenance

The following attestation bundles were made for wger_api_client-2.6.0b1.tar.gz:

Publisher: publish.yml on wger-project/api-client

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

File details

Details for the file wger_api_client-2.6.0b1-py3-none-any.whl.

File metadata

File hashes

Hashes for wger_api_client-2.6.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 e336602c6862c7c3f2a2cb57011a24527fae15fc2012b3c36f0d9b633ac84e40
MD5 df1be1cc71ffeb003f39fa1d5e787fb1
BLAKE2b-256 cf3f2f239bdef737db63e8dc398c70a2dcd7716fcf90f1fdb02c7c9eb7ea07c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for wger_api_client-2.6.0b1-py3-none-any.whl:

Publisher: publish.yml on wger-project/api-client

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

Release history Release notifications | RSS feed

2.6.1

2 files

2.6.0

2 files

This release

2.6.0b1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page