virtuagym
A typed Python client for the Virtuagym API — v1 (api key + club secret) and v3 (OAuth client credentials) — with sync and async clients.
- Typed models — every response is validated onto frozen pydantic models: responses that don't match the schema fail loudly instead of corrupting your data.
- Battle-tested against the live API — the behavior of every endpoint (pagination cursors, envelope quirks, type inconsistencies) was verified live; see API-FINDINGS for everything the docs don't tell you.
- Pagination handled — iterate lazily page by page, or fetch everything with one call. Duplicate rows caused by the API's inclusive cursors are deduplicated for you.
- Sync and async —
VirtuaGymClientV1/VirtuaGymClientV3on httpx's sync client,AsyncVirtuaGymClientV1/AsyncVirtuaGymClientV3on its async client, identical method surfaces. - Sibling packages: Node.js/TypeScript and PHP.
Installation
pip install virtuagym
Requires Python 3.10+.
API v1 (api key + club secret)
You need three values, all found in Virtuagym under Business settings → Business Info → Advanced: your API key, the "Club Key" (club secret), and your club id.
from virtuagym import VirtuaGymClientV1
client = VirtuaGymClientV1(
api_key="...",
club_secret="...",
club_id=12345,
)
# Lazily, page by page — each HTTP request only happens when you ask for the next page
for page in client.members():
print(f"received {len(page)} members")
# Or collect every page into a single list
members = client.all_members()
# Incremental sync (timestamp in ms)
changed = client.all_members(sync_from=last_sync_timestamp)
# Single member with membership instances embedded
member = client.member(7302399, with_="memberships")
# Mutations re-fetch and return the canonical record
created = client.create_member(
{"firstname": "John", "lastname": "Doe", "email": "john@example.com"}
)
updated = client.update_member(created.member_id, {"gender": "f"})
upserted = client.create_or_update_member(
{"external_id": "1ABC234567", "firstname": "John", "lastname": "Doe"}
)
The full v1 surface: employees, members, activate_user, events, membership_instances / membership_definitions / create_membership_instance, event_participants (bookings), club_taxes, income_categories, invoices, visits, member_notes, member_credits / add_member_credits, assign_workout, bodymetrics. Every list endpoint has a lazy iterator (members()) and a collector (all_members()). Mutation payloads are plain dicts with the API's wire-format keys.
Worth knowing (all verified live): single-resource GETs 404 with statuscode 420; the notes endpoint is capped at the newest 500 rows; notes and credits use seconds for sync_from while most endpoints use milliseconds; credits rows have no unique id and page-boundary duplicates are deduplicated for you.
API v3 (OAuth)
The v3 API is a separate stack behind gateway.services.virtuagym.com, authenticated with OAuth client credentials (register via api@virtuagym.com). Tokens are requested and renewed automatically (club-bound, ~30 min lifetime). Which v3 resources you can reach depends on the scopes Virtuagym registered for your client — without the right scope the API answers a misleading 401 Token not valid..
import time
from virtuagym import VirtuaGymClientV3
client = VirtuaGymClientV3(
client_id="...",
client_secret="...",
club_id=12345,
)
# Leads — the live API serializes EVERY lead field as a string
leads = client.all_leads()
lead = client.lead(751563)
created = client.create_lead({"firstname": "Jane", "lastname": "Doe", "email": "jane@example.com"})
client.update_lead(created.lead_id, {"status_id": 12}) # Closed won
# Schedule (requires the schedule_public_api_club_<club_id> scope)
now = int(time.time() * 1000)
week = 7 * 24 * 3600 * 1000
events = client.all_events(date_start=now, date_end=now + week, event_type="appointment")
bookings = client.all_event_bookings(date_start=now, date_end=now + week, member_id=42)
result = client.create_booking(events[0].event_id, {"member_id": 42})
# Inspect result.bookings[0].reason — see BOOKING_REASON_CODES in
# virtuagym.v3.models. NOTE: a member without the required credit type is
# booked UNPAID rather than rejected — check payment_info if payment matters.
client.update_booking(events[0].event_id, {"member_id": 42, "presence": True})
client.cancel_booking(events[0].event_id, member_id=42, refund=False)
Note: occurrences of a recurring event share the same event_id and differ only in datetime_start — use event_id + datetime_start as the occurrence key.
Async
Both clients have async twins with identical surfaces:
from virtuagym import AsyncVirtuaGymClientV1
client = AsyncVirtuaGymClientV1(api_key="...", club_secret="...", club_id=12345)
async for page in client.members():
...
members = await client.all_members()
Error handling
from virtuagym import VirtuaGymApiError, VirtuaGymV3ApiError
try:
client.member(999)
except VirtuaGymApiError as e:
# v1: in-band API errors (reported with HTTP 200), real-HTTP-status
# errors, and envelope failures.
print(e.statuscode, e.statusmessage) # e.g. 420 'Not found.'
VirtuaGymApiError(v1) —statuscode,statusmessage, optionalerrorspayload.VirtuaGymV3ApiError(v3) — real HTTP status inhttp_status, invalid field names infields. On a 401 the client refreshes the token and retries once before raising.pydantic.ValidationError— the response did not match the documented schema, naming the exact offending field.
Development
pip install -e .[dev]
pytest # unit tests (offline, mocked HTTP)
ruff check . && ruff format --check . && mypy
# Smoke tests against the live API (read-only):
cp .env.example .env # then fill in your credentials
pytest -m smoke
License
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 virtuagym-1.0.0.tar.gz.
File metadata
- Download URL: virtuagym-1.0.0.tar.gz
- Upload date:
- Size: 28.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be8b324e8a023298f936f3fda53e82d45c1590c8273fcf3e1b1dafc3e2a76225
|
|
| MD5 |
f5dd9eb6ef5723f0c7788183bb53a050
|
|
| BLAKE2b-256 |
71712c814c0edc46e1578db68c935cca9bca396fe4f6536dc1357df16f03cd1b
|
Provenance
The following attestation bundles were made for virtuagym-1.0.0.tar.gz:
Publisher:
publish.yml on gold-development/virtuagym-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
virtuagym-1.0.0.tar.gz -
Subject digest:
be8b324e8a023298f936f3fda53e82d45c1590c8273fcf3e1b1dafc3e2a76225 - Sigstore transparency entry: 2437402973
- Sigstore integration time:
-
Permalink:
gold-development/virtuagym-python@0d234838d935ed3af0c6f78af0411a27293326e2 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/gold-development
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0d234838d935ed3af0c6f78af0411a27293326e2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file virtuagym-1.0.0-py3-none-any.whl.
File metadata
- Download URL: virtuagym-1.0.0-py3-none-any.whl
- Upload date:
- Size: 31.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42ac66b8ed0ee480ce48efa6477ce6c971a3e431016f7471ba054c91b29ef62e
|
|
| MD5 |
7b2cbbcc1a7694acd47358d2f42aa54d
|
|
| BLAKE2b-256 |
ef559eb2195fb8c4db4b5bdd68d4e83efc50d7fa41822f0b64b1928326eee3f8
|
Provenance
The following attestation bundles were made for virtuagym-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on gold-development/virtuagym-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
virtuagym-1.0.0-py3-none-any.whl -
Subject digest:
42ac66b8ed0ee480ce48efa6477ce6c971a3e431016f7471ba054c91b29ef62e - Sigstore transparency entry: 2437403016
- Sigstore integration time:
-
Permalink:
gold-development/virtuagym-python@0d234838d935ed3af0c6f78af0411a27293326e2 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/gold-development
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0d234838d935ed3af0c6f78af0411a27293326e2 -
Trigger Event:
push
-
Statement type: