Skip to main content

playmind

PlayMind Labs — Behavioral Stability Intervention SDK for Python

PyPI version

Server-side client for sportsbook operators integrating PlayMind's real-time tilt detection. Score a player's session and determine the right behavioral intervention — no manual API handling required.

Installation

pip install playmind

Quick Start

import asyncio
from playmind import PlayMindSDK

pm = PlayMindSDK(
    endpoint="https://api.playmindlabs.com",
    api_key="pm_live_abc123",
)

# Call on every bet placed or significant session event
async def main():
    result = await pm.check({
        "player_id": "sha256:...",           # one-way hash — never send raw IDs
        "session_id": "sess_abc123",
        "baseline": {
            "avg_stake_cents": 1000,
            "avg_bets_per_session": 5,
            "avg_session_duration_minutes": 30,
        },
        "events": [
            {"type": "bet_placed", "timestamp": "2026-01-01T10:00:00Z", "stake_cents": 1000, "odds": -110},
            {"type": "bet_settled", "timestamp": "2026-01-01T10:05:00Z", "outcome": "win"},
        ],
    })

    if result.state != "stable":
        print(f"Intervention: {result.intervention.type} — {result.intervention.message}")

asyncio.run(main())

States

state Meaning
stable No action needed
moderate Gentle nudge recommended
high_risk Cooldown recommended (5 min)
critical Session pause recommended (30 min)

Configuration

from playmind import PlayMindSDK

pm = PlayMindSDK(
    endpoint="https://api.playmindlabs.com",
    api_key="pm_live_abc123",
    timeout=30,        # request timeout in seconds (default: 30)
    max_retries=3,     # retries on transient errors (default: 3)
)

API Reference

PlayMindSDK(endpoint, api_key, timeout=30, max_retries=3)

Creates a new SDK client. Validates that api_key is non-empty.

await pm.check(payload) -> TiltScoreResponse

Scores the session against the PlayMind API.

Payload fields:

  • player_id (required) — Anonymized player identifier
  • session_id (optional) — Current session identifier
  • baseline (required) — 7-day behavioral baseline
  • events (required for operator context) — Array of event objects
  • context (optional) — "operator" (default) or "bookie"
  • bets (required for bookie context) — Array of bet objects

Error Handling

Exception When
PlayMindAuthError 401 response — invalid API key
PlayMindAPIError Non-2xx response
PlayMindTimeoutError Request timed out
PlayMindValidationError Invalid parameters provided to the SDK
import asyncio
from playmind import PlayMindSDK, PlayMindAuthError, PlayMindAPIError, PlayMindTimeoutError

pm = PlayMindSDK(endpoint="...", api_key="...")

async def main():
    try:
        result = await pm.check(payload)
    except PlayMindAuthError:
        print("Check your API key")
    except PlayMindTimeoutError:
        print("PlayMind unreachable — fail open, continue without intervention")
    except PlayMindAPIError as e:
        print(f"API error {e.status_code}: {e.body}")

asyncio.run(main())

Async Support

The SDK uses httpx.AsyncClient internally and supports the async context manager:

import asyncio
from playmind import PlayMindSDK

async def main():
    async with PlayMindSDK(endpoint="...", api_key="...") as pm:
        result = await pm.check(payload)

asyncio.run(main())

License

MIT

Metadata

Release files for playmind 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for playmind 0.1.1
File Size Uploaded Provenance Actions
playmind-0.1.1.tar.gz 11.5 kB Without provenance Details for playmind-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for playmind 0.1.1
File Interpreter ABI Platform Actions
playmind-0.1.1-py3-none-any.whl Python 3 none any Details for playmind-0.1.1-py3-none-any.whl

Total release size: 20.8 kB

Release files / playmind-0.1.1.tar.gz

Download URL playmind-0.1.1.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f99aec166bda2345a6b581fc44730991619dd66c23afa3d36793085976785743
BLAKE2b-256 checksum
How to use checksums
719013aaed2cd24c7b723dd64e2b1946f86018e1fbe955152214209709ef7646
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / playmind-0.1.1-py3-none-any.whl

Download URL playmind-0.1.1-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c5f671c99e58c9ee2cb9ac74eac8460bde1af41cf8356925a8ed10deb019bf1
BLAKE2b-256 checksum
How to use checksums
20b3964d100f2fa730f739cf7b4aeeb8227bc69bf0eb4c332befa9117acca289
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for playmind 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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