Powerful tool for real-time monitoring of Sony PlayStation (PSN) players' activities.
pip install psn_monitor- Real-time tracking of PlayStation users' gaming activity (including detection when a user gets online/offline or plays games)
- Basic statistics for user activity (duration in different states, time spent playing a game, overall time and number of games played in a session etc.)
- Detailed user information display mode providing comprehensive PlayStation profile insights, including PlayStation/PSN IDs, online status and availability to play, platform information, PS+ subscription status, verification status, about me section, languages, friendship relation and mutual friends count, profile URL, recently played games with last played date and total play time, and optionally trophy summary and last earned trophies
- Email notifications for various events (player gets online/offline, starts/finishes/changes a game, errors)
- Saving all user activities with timestamps to a CSV file
- Status persistence - automatically saves last status to JSON file to resume monitoring after restart
- Smart session continuity - handles short offline interruptions and preserves session statistics
- Flexible configuration - support for config files, dotenv files, environment variables and command-line arguments
- Possibility to control the running copy of the script via signals
- Functional, procedural Python (minimal OOP)
- Python 3.10 or higher
- Libraries: PSNAWP,
requests,python-dateutil,pytz,tzlocal,python-dotenv
Tested on:
- macOS: Ventura, Sonoma, Sequoia, Tahoe
- Linux: Raspberry Pi OS (Bullseye, Bookworm, Trixie), Ubuntu 24/25, Rocky Linux 8.x/9.x, Kali Linux 2024/2025
- Windows: 10, 11
It should work on other versions of macOS, Linux, Unix and Windows as well.
pip install psn_monitorDownload the psn_monitor.py file to the desired location.
Install dependencies via pip:
pip install PSNAWP requests python-dateutil pytz tzlocal python-dotenvAlternatively, from the downloaded requirements.txt:
pip install -r requirements.txtTo upgrade to the latest version when installed from PyPI:
pip install psn_monitor -UIf you installed manually, download the newest psn_monitor.py file to replace your existing installation.
- Grab your PSN npsso code and track the
psn_user_idgaming activities:
psn_monitor <psn_user_id> -n "your_psn_npsso_code"Or if you installed manually:
python3 psn_monitor.py <psn_user_id> -n "your_psn_npsso_code"To get the list of all supported command-line arguments / flags:
psn_monitor --helpMost settings can be configured via command-line arguments.
If you want to have it stored persistently, generate a default config template and save it to a file named psn_monitor.conf:
psn_monitor --generate-config > psn_monitor.conf
Edit the psn_monitor.conf file and change any desired configuration options (detailed comments are provided for each).
Log in to your My PlayStation account.
In another tab, go to: https://ca.account.sony.com/api/v1/ssocookie
Copy the value of npsso code.
Provide the PSN_NPSSO secret using one of the following methods:
- Pass it at runtime with
-n/--npsso-key - Set it as an environment variable (e.g.
export PSN_NPSSO=...) - Add it to .env file (
PSN_NPSSO=...) for persistent use
Fallback:
- Hard-code it in the code or config file
Tokens expire after 2 months. The tool alerts on expiration.
If you store the PSN_NPSSO in a dotenv file you can update its value and send a SIGHUP signal to the process to reload the file with the new npsso value without restarting the tool. More info in Storing Secrets and Signal Controls (macOS/Linux/Unix).
In order to monitor PlayStation user activity, proper privacy settings need to be enabled on the monitored user account.
The user should go to PlayStation account management.
The value in Privacy Settings → Personal Info | Messaging → Online Status and Now Playing should be set set to Friends only or Anyone.
By default, time zone is auto-detected using tzlocal. You can set it manually in psn_monitor.conf:
LOCAL_TIMEZONE='Europe/Warsaw'You can get the list of all time zones supported by pytz like this:
python3 -c "import pytz; print('\n'.join(pytz.all_timezones))"If you want to use email notifications functionality, configure SMTP settings in the psn_monitor.conf file.
Verify your SMTP settings by using --send-test-email flag (the tool will try to send a test email notification):
psn_monitor --send-test-emailIt is recommended to store secrets like PSN_NPSSO or SMTP_PASSWORD as either an environment variable or in a dotenv file.
Set environment variables using export on Linux/Unix/macOS/WSL systems:
export PSN_NPSSO="your_psn_npsso_code"
export SMTP_PASSWORD="your_smtp_password"On Windows Command Prompt use set instead of export and on Windows PowerShell use $env.
Alternatively store them persistently in a dotenv file (recommended):
PSN_NPSSO="your_psn_npsso_code"
SMTP_PASSWORD="your_smtp_password"By default the tool will auto-search for dotenv file named .env in current directory and then upward from it.
You can specify a custom file with DOTENV_FILE or --env-file flag:
psn_monitor <psn_user_id> --env-file /path/.env-psn_monitorYou can also disable .env auto-search with DOTENV_FILE = "none" or --env-file none:
psn_monitor <psn_user_id> --env-file noneAs a fallback, you can also store secrets in the configuration file or source code.
The tool provides a detailed user information display mode that shows comprehensive PlayStation profile insights. This mode displays information once and then exits (it does not run continuous monitoring).
To get detailed user information for PlayStation (PSN) user's id (psn_user_id in the example below), use the -i or --info flag:
psn_monitor <psn_user_id> -iIf you have not set PSN_NPSSO secret, you can use -n flag:
psn_monitor <psn_user_id> -i -n "your_psn_npsso_code"This displays:
- PlayStation/PSN IDs
- Online status and availability to play
- Platform information
- PS+ subscription status
- Verification status
- About me section
- Languages
- Friendship relation and mutual friends count
- Profile URL
- Recently played games with last played date and total play time
To also display trophy summary and list of most recently earned trophies, add the --trophies flag:
psn_monitor <psn_user_id> -i --trophiesTo disable fetching the recently played games list (faster execution), use the --no-recent-games flag:
psn_monitor <psn_user_id> -i --no-recent-gamesYou can combine both flags:
psn_monitor <psn_user_id> -i --trophies --no-recent-gamesTo monitor specific user activity, just type the PlayStation (PSN) user's id (psn_user_id in the example below):
psn_monitor <psn_user_id>If you have not set PSN_NPSSO secret, you can use -n flag:
psn_monitor <psn_user_id> -n "your_psn_npsso_code"By default, the tool looks for a configuration file named psn_monitor.conf in:
- current directory
- home directory (
~) - script directory
If you generated a configuration file as described in Configuration, but saved it under a different name or in a different directory, you can specify its location using the --config-file flag:
psn_monitor <psn_user_id> --config-file /path/psn_monitor_new.confThe tool runs until interrupted (Ctrl+C). Use tmux or screen for persistence.
You can monitor multiple PSN players by running multiple instances of the script.
The tool automatically saves its output to psn_monitor_<psn_user_id>.log file. It can be changed in the settings via PSN_LOGFILE configuration option or disabled completely via DISABLE_LOGGING / -d flag.
The tool also saves the timestamp and last status (after every change) to psn_<psn_user_id>_last_status.json file, so the last status is available after the restart of the tool.
To enable email notifications when a user gets online or offline:
- set
ACTIVE_INACTIVE_NOTIFICATIONtoTrue - or use the
-aflag
psn_monitor <psn_user_id> -aTo be informed when a user starts, stops or changes the played game:
- set
GAME_CHANGE_NOTIFICATIONtoTrue - or use the
-gflag
psn_monitor <psn_user_id> -gTo disable sending an email on errors (enabled by default):
- set
ERROR_NOTIFICATIONtoFalse - or use the
-eflag
psn_monitor <psn_user_id> -eMake sure you defined your SMTP settings earlier (see SMTP settings).
Example email:
If you want to save all reported activities of the PSN user to a CSV file, set CSV_FILE or use -b flag:
psn_monitor <psn_user_id> -b psn_user_id.csvThe file will be automatically created if it does not exist.
If you want to customize polling intervals, use -k and -c flags (or corresponding configuration options):
psn_monitor <psn_user_id> -k 30 -c 120PSN_ACTIVE_CHECK_INTERVAL,-k: check interval when the user is online (seconds)PSN_CHECK_INTERVAL,-c: check interval when the user is offline (seconds)
The tool has several signal handlers implemented which allow to change behavior of the tool without a need to restart it with new configuration options / flags.
List of supported signals:
| Signal | Description |
|---|---|
| USR1 | Toggle email notifications when user gets online or offline (-a) |
| USR2 | Toggle email notifications when user starts/stops/changes the game (-g) |
| TRAP | Increase the check timer for player activity when user is online (by 30 seconds) |
| ABRT | Decrease check timer for player activity when user is online (by 30 seconds) |
| HUP | Reload secrets from .env file |
Send signals with kill or pkill, e.g.:
pkill -USR1 -f "psn_monitor <psn_user_id>"As Windows supports limited number of signals, this functionality is available only on Linux/Unix/macOS.
You can use GRC to color logs.
Add to your GRC config (~/.grc/grc.conf):
# monitoring log file
.*_monitor_.*\.log
conf.monitor_logs
Now copy the conf.monitor_logs to your ~/.grc/ and log files should be nicely colored when using grc tool.
Example:
grc tail -F -n 100 psn_monitor_<psn_user_id>.logSee RELEASE_NOTES.md for details.
Licensed under GPLv3. See LICENSE.


