Last active
July 21, 2025 15:28
-
-
Save Dreyer/161b920f0d8300ed3bc750ae2f80c339 to your computer and use it in GitHub Desktop.
Check the status of a NordVPN connection from your shell.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
URL='https://web-api.nordvpn.com/v1/ips/info' | |
JSON=$(curl -s $URL) | |
printf "\n" | |
#echo $JSON | python -m json.tool | |
echo $JSON | python -c 'import sys, json; data = json.load(sys.stdin); print("IP: %s (%s)\nStatus: %s" % (data["ip"], data["isp"], "\033[32mProtected" if data["protected"] is True else "\033[31mUnprotected"));' | |
printf "\n" |
https://nordvpn.com/wp-admin/admin-ajax.php?action=get_user_info_data
such a shame it does not work anymore....
I just added an exit code that can be tested upon script end (in Unix it's $? )
#!/bin/bash
URL='https://web-api.nordvpn.com/v1/ips/info'
JSON=$(curl -s $URL)
printf "\n"
#echo $JSON | python -m json.tool
echo $JSON | python -c 'import sys, json; exitCode=0; data = json.load(sys.stdin); print("IP: %s (%s)\nStatus: %s" % (data["ip"], data["isp"], "\033[32mProtected\n" if data["protected"] is True else "\033[31mUnprotected\n")); exitCode= 1 if data["protected"] is False else 0; sys.exit(exitCode);'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice. Thanks @Dreyer. where did you find the new endpoint ?