Skip to main content

Python Nintendo Parental Controls

A simple, Python API to connect to Nintendo Switch Parental Controls.

Test Status Coverage Status PyPi Licence

buymeacoffee-yellow-badge

Install

# Install tool
pip3 install pynintendoparental

# Install locally
just install

Usage

Authentication

This library requires authentication with Nintendo's servers. The pynintendoparental.Authenticator class handles this. There are two ways to authenticate:

Method 1: Using a Session Token

If you already have a session_token, you can pass it to the Authenticator:

import aiohttp
from pynintendoparental.authenticator import Authenticator

async with aiohttp.ClientSession() as session:
    session_token = "YOUR_SESSION_TOKEN"
    auth = Authenticator(session_token, session)
    await auth.async_complete_login(use_session_token=True)

Method 2: Interactive Login

If you don't have a session_token, you can perform an interactive login to obtain one. The library will provide a login URL. You need to open this URL in your browser, log in to your Nintendo Account, and then copy the URL of the "Select this person" button and paste it back into your application.

Here is an example of how to do this:

import asyncio
import aiohttp
from pynintendoparental.authenticator import Authenticator

async def interactive_login():
    """Performs an interactive login to get a session token."""
    async with aiohttp.ClientSession() as session:
        auth = Authenticator(client_session=session)
        print("Please open the following URL in your browser:")
        print(auth.login_url)
        
        response_url = input("Please paste the URL you were redirected to: ")
        await auth.async_complete_login(response_url)
        
        print(f"Login successful! Your session token is: {auth.session_token}")
        print("You can save this token to avoid logging in next time.")
        return auth

async def main():
    auth = await interactive_login()
    # You can now use the 'auth' object with NintendoParental
    # nintendo = await NintendoParental.create(auth)

if __name__ == "__main__":
    asyncio.run(main())

Basic Usage

Here's a simple example of how to use pynintendoparental:

import asyncio
import aiohttp

from pynintendoparental import NintendoParental
from pynintendoparental.authenticator import Authenticator

async def main():
    """The main function."""
    session_token = "YOUR_SESSION_TOKEN"  # Replace with your session token

    async with aiohttp.ClientSession() as session:
        auth = Authenticator(session_token, session)
        await auth.async_complete_login(use_session_token=True)
        nintendo = await NintendoParental.create(auth)

        # Iterate through all devices
        for device in nintendo.devices.values():
            print(f"Device: {device.name}")
            print(f"  ID: {device.device_id}")
            print(f"  Model: {device.model}")
            print(f"  Playtime limit: {device.limit_time} minutes")
            print(f"  Today's playing time: {device.today_playing_time} minutes")
            print(f"  Time remaining: {device.today_time_remaining} minutes")

            # Update the daily playtime limit
            # await device.update_max_daily_playtime(180) # Set to 3 hours

if __name__ == "__main__":
    asyncio.run(main())

Updating devices one by one

update() logs and skips a device that fails to update. To handle each device yourself, fetch the device list with discover_devices() and update the devices one by one:

await nintendo.discover_devices()
for device in nintendo.devices.values():
    try:
        await device.update()
    except Exception as err:
        print(f"Updating {device.name} failed: {err}")

The NintendoParental object

The main entry point is the NintendoParental object. You create it using the asynchronous class method create:

nintendo = await NintendoParental.create(auth, timezone="Europe/London", lang="en-GB")
  • auth: An Authenticator instance.
  • timezone: (Optional) The timezone to use for API requests. Defaults to "Europe/London".
  • lang: (Optional) The language to use for API requests. Defaults to "en-GB".

After creation, the NintendoParental object will have a devices property, which is a dictionary of Device objects, keyed by their device ID.

Call await nintendo.update() to refresh every device. Pass monthly_summary=False to skip the monthly summaries, for example on frequent polls; devices without one still fetch it.

The Device object

The Device object contains information about a specific Nintendo Switch console and allows you to control it.

Properties

  • name (str): The name of the device.
  • device_id (str): The unique ID of the device.
  • model (str): The model of the device (e.g., "Switch").
  • limit_time (int): The daily playtime limit in minutes. -1 if no limit is set.
  • today_playing_time (int): The total playing time for the current day in minutes.
  • today_time_remaining (int): The remaining playtime for the current day in minutes.
  • players (dict): A dictionary of Player objects associated with the device, keyed by player ID.
  • applications (dict): A dictionary of Application objects that have been played on the device.
  • timer_mode (DeviceTimerMode): The current timer mode (DAILY or EACH_DAY_OF_THE_WEEK).
  • bedtime_alarm (datetime.time): The time when the bedtime alarm will sound.
  • bedtime_end (datetime.time): The time when the bedtime restrictions end. Set to datetime.time(0, 0) if disabled.
  • forced_termination_mode (bool): True if the software will be suspended when the playtime limit is reached.
  • alarms_enabled (bool): True if alarms are enabled.
  • last_sync (float): The timestamp of the last sync with the device.

Methods

All methods are asynchronous.

  • update(monthly_summary: bool = True): Refreshes the device data from the Nintendo API. Pass monthly_summary=False to skip the monthly summary and keep the last one.
  • add_device_callback(callback): Adds a callback that will be called when the device state changes.
  • remove_device_callback(callback): Removes a previously added callback.
  • set_new_pin(pin: str): Sets a new PIN for the parental controls.
  • add_extra_time(minutes: int): Adds extra playing time for the current day (-1 for unlimited). Raises ExtraPlayingTimeRequestError if Nintendo rejects the request (e.g. NO_EFFECT when play time can't be extended any further today, or OVERTIME_ERROR when it would run past bedtime).
  • cancel_extra_time(): Revokes today's extra playing time.
  • update_max_daily_playtime(minutes: int): Sets the daily playtime limit. Use -1 to remove the limit.
  • set_restriction_mode(mode: RestrictionMode): Sets the restriction mode.
    • RestrictionMode.FORCED_TERMINATION: The software will be suspended when the playtime limit is reached.
    • RestrictionMode.ALARM: An alarm will be shown, but the software will not be suspended.
  • set_bedtime_alarm(value: datetime.time): Sets the bedtime alarm.
  • set_bedtime_end_time(value: datetime.time): Sets the time when bedtime restrictions end. Pass datetime.time(0, 0) to disable.
  • set_timer_mode(mode: DeviceTimerMode): Sets the timer mode.
    • DeviceTimerMode.DAILY: A single playtime limit for all days.
    • DeviceTimerMode.EACH_DAY_OF_THE_WEEK: Different playtime limits for each day of the week.
  • set_daily_restrictions(...): Sets the restrictions for a specific day of the week (when timer_mode is EACH_DAY_OF_THE_WEEK).
  • set_functional_restriction_level(level: FunctionalRestrictionLevel): Sets the content restriction level based on age ratings.
    • FunctionalRestrictionLevel.CHILD, TEEN, YOUNG_ADULT, CUSTOM.
  • get_monthly_summary(search_date: datetime = None): Gets the monthly summary for a given month.
  • get_date_summary(input_date: datetime = datetime.now()): Gets the usage summary for a given date.
  • get_application(application_id: str): Gets an Application object by ID.
  • get_player(player_id: str): Gets a Player object by ID.

The Player object

The Player object holds information about a single user on the Nintendo Switch. Player objects are accessed via the players dictionary on a Device object.

Properties

  • player_id (str): The player's unique ID.
  • nickname (str): The player's nickname.
  • player_image (str): URL to the player's Mii image.
  • playing_time (int): The player's total playing time for the current day in minutes.
  • apps (list): A list of applications that the player has played today. Each entry is a dictionary containing details about the played application, including the applicationId.

The Application object

The Application object contains information about a specific game or application on the Nintendo Switch. Application objects are accessed via the applications dictionary on a Device object.

Properties

  • application_id (str): The application's unique ID.
  • name (str): The name of the application.
  • image_url (str): URL to the application's icon.
  • safe_launch_setting (SafeLaunchSetting): The application's status on the console's Allow List. This allows an application to bypass general age/content restrictions. (NONE, ALLOW).
  • today_time_played (int): The total time the application has been played today by all players in minutes.

Methods

All methods are asynchronous.

  • set_safe_launch_setting(safe_launch_setting: SafeLaunchSetting): Updates the application's status on the console's Allow List. This allows an application to bypass general age/content restrictions.
  • add_application_callback(callback): Adds a callback that will be called when the application's state changes.
  • remove_application_callback(callback): Removes a previously added callback.

Full Example

This example demonstrates how to log in, list devices, and view player and application information.

import asyncio
import aiohttp

from pynintendoparental import NintendoParental
from pynintendoparental.authenticator import Authenticator
from pynintendoparental.enum import RestrictionMode

async def main():
    """The main function."""
    session_token = "YOUR_SESSION_TOKEN"

    async with aiohttp.ClientSession() as session:
        auth = Authenticator(session_token, session)
        await auth.async_complete_login(use_session_token=True)
        nintendo = await NintendoParental.create(auth)

        # Get the first device
        device = list(nintendo.devices.values())[0]
        print(f"Device: {device.name}")

        # Change the restriction mode to suspend the software when playtime is up
        await device.set_restriction_mode(RestrictionMode.FORCED_TERMINATION)
        print("Restriction mode set to forced termination.")

        # Print today's summary for each player
        for player in device.players.values():
            print(f"Player: {player.nickname}")
            print(f"  Playing time: {player.playing_time} minutes")
            
            # Print applications played by the player
            for app in player.apps:
                app_id = app['applicationId']
                # Get the application object from the device
                application = device.get_application(app_id)
                print(f"  - Played {application.name} for {app['playingTime']} minutes")

if __name__ == "__main__":
    asyncio.run(main())

Metadata

Release files for pynintendoparental 2.7.0

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

Source distribution (sdist)

Source distribution for pynintendoparental 2.7.0
File Size Uploaded Provenance Actions
pynintendoparental-2.7.0.tar.gz 47.0 kB Without provenance Details for pynintendoparental-2.7.0.tar.gz

Built distribution (wheel)

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

Total release size: 80.5 kB

Release files / pynintendoparental-2.7.0.tar.gz

Download URL pynintendoparental-2.7.0.tar.gz
Size 47.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2e16514aab2d45f196a1575d9b2f97c097f4af15fb145ed2b23b3df4661d350a
BLAKE2b-256 checksum
How to use checksums
6fdafd4c5286a4fc1f80f76d131296bb50ea9b26f527769275145e2342446ee3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pynintendoparental-2.7.0-py3-none-any.whl

Download URL pynintendoparental-2.7.0-py3-none-any.whl
Size 33.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba8385fef8dd39f943c76c98b6594334f549ab6b2ca0fb0c6c2ac0c87c10f1ff
BLAKE2b-256 checksum
How to use checksums
4451b9dbd51890166eb4484a7619106eef48dc0b561c1cfc11d5f6d8d5fea57f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for pynintendoparental 2.7.0

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

2.7.0 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