-
-
Save Dreyer/161b920f0d8300ed3bc750ae2f80c339 to your computer and use it in GitHub Desktop.
#!/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" |
the URL='https://api.nordvpn.com/vpn/check/full' is less accurate than the last url https://nordvpn.com/wp-admin/admin-ajax.php?action=get_user_info_data
thanks for sharing
Updated for python 3
#!/bin/bash
URL='https://nordvpn.com/wp-admin/admin-ajax.php?action=get_user_info_data'
JSON=$(curl -s $URL)
printf "\n"
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["status"] is True else "\033[31mUnprotected"));'
printf "\n"
This does not seem to work anymore . From https://nordvpn.com/wp-admin/admin-ajax.php?action=get_user_info_data
I get blocked by cloudflare access
Updated to fix Cloudflare blocking the previous link and not compatible with Python 3.
nice. Thanks @Dreyer. where did you find the new endpoint ?
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);'
They changed their code. The address you used does not always work. This fixes it
#!/bin/bash
URL='https://api.nordvpn.com/vpn/check/full'
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["status"] == "Protected" else "\033[31mUnprotected");'
printf "\n"