Skip to main content

Python client for the PlayStation Family (PSN parental controls) API

Project description

psnfamily

Async Python client for the PlayStation Family parental-controls API — the cloud API behind Sony's PS Family mobile app (com.playstation.ohana.android). It lets you read your family roster, children's online presence and now-playing game, and read and change a child's daily play-time limit, plus content and communication parental controls.

⚠️ Unofficial. Reverse-engineered from the PS Family Android app; not affiliated with or endorsed by Sony. The API is undocumented and may change or break at any time. Excessive use may risk your PSN account — the client self-limits to 1 request / 3 s. Use at your own risk.

For turnkey use the library ships the PS Family app's own OAuth client credentials (the ones carrying the mobile:family scope), recovered from the app. Sony may rotate or revoke these at any time, which would require an update. You can override them via OAuthClient(...).

Auth

PSN uses OAuth; this library authenticates headlessly with an npsso cookie:

  1. Sign in at https://www.playstation.com as the Family Manager account.
  2. Open https://ca.account.sony.com/api/v1/ssocookie — copy the 64-char npsso value.
  3. Pass it to OhanaClient.authenticate(npsso). The library exchanges it for an access token (~1 h) and a refresh token (~60 days) and refreshes automatically. Persist client.tokens to avoid re-entering the npsso.

Usage

import asyncio
from psnfamily import OhanaClient

async def main():
    async with OhanaClient() as client:
        await client.authenticate("<npsso>")

        children = await client.get_children()
        for child in children:
            pt = await client.get_playtime(child.identity.account_id)
            print(child.identity.display_name,
                  "limit", pt.today_limit_seconds, "used", pt.used_today_seconds)

        kid = children[0]
        # Set a 2-hour daily play-time limit:
        await client.set_daily_limit(kid.member_id, 2 * 3600)
        # Remove the limit (unlimited):
        await client.set_daily_limit(kid.member_id, None)

asyncio.run(main())

Play-time is governed by a recurring weekly schedule of PlaytimeDaySetting { maxPlaytimeDuration, windowStart, windowEnd }. set_daily_limit applies a uniform limit across the week (quantized to 15 min); set_playtime_schedule gives full per-day control. Durations are ISO-8601 (PT2H, P0D = no limit); the playable-hours window is in minutes from local midnight (full day = 0..1440).

Capabilities

  • authenticate(npsso) / token refresh; persist client.tokens to reuse
  • get_family_members() / get_children() — roster, roles, ids
  • get_presences(account_ids) — online status + now-playing game
  • get_playtime(account_id) — limits, usage, timezone, on-limit action
  • set_daily_limit(member_id, seconds) / set_playtime_schedule(...) — set play-time limits
  • get_supported_parental_controls() and other read operations
  • execute(operation, variables) — any reverse-engineered operation by name

Some write operations the app contains (e.g. updateTodaysPlaytimeLimit and the updateParentalControls family) are not in Sony's gateway allowlist for the current app version and will raise PsnFamilyApiError ("not whitelisted").

Auth client

The library ships the PS Family app's OAuth client (the one carrying the mobile:family scope), recovered from the app, analogous to how psn-api / PSNAWP ship the public PSN mobile client. You only provide the npsso.

See research/PROTOCOL.md in the repository for the full reverse-engineering reference and the list of facts still pending live confirmation.

License

MIT

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

psnfamily-0.1.0.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

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

psnfamily-0.1.0-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: psnfamily-0.1.0.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for psnfamily-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d50e1a7ef8791f8db63704173629afa6fb56789539b587e4baa2b5cf264b05a3
MD5 3355c5063d3875daf73e12e9ab05d03a
BLAKE2b-256 e6c4a83af17cde437783ceb1bb5714f2fa9ca65686b98c59558246bbe91f59fe

See more details on using hashes here.

Provenance

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

Publisher: workflow.yaml on parkee/psnfamily

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

File details

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

File metadata

  • Download URL: psnfamily-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for psnfamily-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b4826de03bbd1703093da6cda33ec1e0e884efe3fafd485ddbe86cb26f1eeb2a
MD5 9ad2181efbaf0f6fc3a55fd25fb3240a
BLAKE2b-256 41c0bf0a1deb23c09b2ec589e9320c4b9297c58f70475caefb09631055756312

See more details on using hashes here.

Provenance

The following attestation bundles were made for psnfamily-0.1.0-py3-none-any.whl:

Publisher: workflow.yaml on parkee/psnfamily

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