NordSecurity / nordvpn-linux

NordVPN Linux client
GNU General Public License v3.0
306 stars 42 forks source link

Feature Requests. Nord Public API deprecated. #294

Open ph202107 opened 7 months ago

ph202107 commented 7 months ago

Hi! The NordVPN Public API was a very useful tool, however parts of the API have now been deprecated: https://support.nordvpn.com/hc/en-us/articles/21586950310801-Discontinuation-of-the-legacy-API-endpoints-on-NordVPN

Would it be possible to add these features to the Linux CLI?

This command has worked for years until recently:
curl --silent https://api.nordvpn.com/server/stats/us9305.nordvpn.com | jq .percent

For just one example, say I would like to connect to the Double_VPN server group in a particular location and from the manual I know that I can specify the first hop with nordvpn connect --group Double_VPN <location> Auto-complete appears to show all the countries, including countries where Double_VPN is not available. How could I determine that Sweden supports Double_VPN, and that Sweden pairs with both Switzerland (se-ch) and Netherlands (se-nl) so that I can choose the server-pair that I prefer?

With the Public API this was trivial, but as of 2024/03/05 there seems to be no method to retrieve this information. Please correct me if I'm wrong, I'm an absolute novice with using any API. The CLI is a great tool and querying the API from the terminal integrated very well, including on remote or headless systems.

I'm sorry to see that these features have been removed, hopefully they can be restored in one form or another. Thank you for your consideration.

hackthis02 commented 7 months ago

Using a custom script I was able to load balance sock5 servers for my BitTorrent client. Without this API, there is no feasible way to do this. Resulting in potentially slower network speeds from the users side and stressed servers on the networks side.

Savolro commented 6 months ago

Hi and sorry for a delayed response.

As announced in this notice (https://support.nordvpn.com/hc/en-us/articles/21586950310801-Discontinuation-of-the-legacy-API-endpoints-on-NordVPN), the legacy API endpoints will no longer be active or recommended for future use. To achieve similar functionality, you can utilize the new API endpoint at https://api.nordvpn.com/v1/servers/recommendations. This endpoint provides detailed information about VPN exit nodes, including server load, and offers a list of servers based on our recommendations. For a comprehensive list of servers, access https://api.nordvpn.com/v1/servers. Remember to include "?limit=[value]" in your request to limit the response output.

Savolro commented 6 months ago

Regarding second location selecting for Double VPN - currently it is not supported. Will update this ticket when there are any updates on this.

Mouseboy007 commented 6 months ago

Hi and sorry for a delayed response.

As announced in this notice (https://support.nordvpn.com/hc/en-us/articles/21586950310801-Discontinuation-of-the-legacy-API-endpoints-on-NordVPN), the legacy API endpoints will no longer be active or recommended for future use. To achieve similar functionality, you can utilize the new API endpoint at https://api.nordvpn.com/v1/servers/recommendations. This endpoint provides detailed information about VPN exit nodes, including server load, and offers a list of servers based on our recommendations. For a comprehensive list of servers, access https://api.nordvpn.com/v1/servers. Remember to include "?limit=[value]" in your request to limit the response output.

Before it was deprecated, querying https://api.nordvpn.com/server/stats would allow seeing current load on the connected Server. Is there a faster way to do this than querying https://api.nordvpn.com/v1/servers and then retrospectively grabbing the data from the large raw data dump. accessing the stats directly would be faster for the end user and less resource intensive for NordVPN I would presume

ph202107 commented 6 months ago

Filtering by hostname (or IP address) would be ideal, that would download only about 3KB for one server record instead of 20MB for all 6300+ servers. I found a filter for "server id", and that works well:

curl "https://api.nordvpn.com/v1/servers?limit=1&filters\[servers.id\]=930119" | jq '.[].load'

It will return the record for "be148.nordvpn.com" and then jq can find the load. The problem is I wouldn't know the server id until I download the entire 20MB json, and the json is subject to change as servers are added and removed.

Is there an equivalent filter for hostname? I can't seem to find one. Thanks!

Mouseboy007 commented 6 months ago

Filtering by hostname (or IP address) would be ideal, that would download only about 3KB for one server record instead of 20MB for all 6300+ servers. I found a filter for "server id", and that works well:

curl "https://api.nordvpn.com/v1/servers?limit=1&filters\[servers.id\]=930119" | jq '.[].load'

It will return the record for "be148.nordvpn.com" and then jq can find the load. The problem is I wouldn't know the server id until I download the entire 20MB json, and the json is subject to change as servers are added and removed.

Is there an equivalent filter for hostname? I can't seem to find one. Thanks!

If it helps, how I've ended up doing it in a script is:

CurrentVPNServer=nordvpn status | grep -E "Hostname" | awk -F ": " '{print $2}' CountryCode=echo $CurrentVPNServer | awk -F"[0-9]+" '{print $1;}' | awk -F": " '{print $1}'

curl --silent "https://api.nordvpn.com/v1/servers?filters\[country_id\]=$CountryCode&\[servers_groups\]\[identifier\]=legacy_standard&limit=16354" | jq --raw-output '.[] | select(.hostname | contains("'$CurrentVPNServer'")) | [.hostname, .load] | "(.[0]): (.[1])"'

^ As you say, the catch 22 is you have to pull a large amount of data before you can get the data you need to query the data ...

mike-sirs commented 6 months ago

https://api.nordvpn.com/v1/servers/recommendations returns a sorted list of recommended servers simple script to update wg on openwrt https://raw.githubusercontent.com/mike-sirs/openwrt-configs/main/nordvpn-wireguard.sh

bengalih commented 5 months ago

Regarding second location selecting for Double VPN - currently it is not supported. Will update this ticket when there are any updates on this.

Please provide proper filter syntax to query only for SOCKS servers using the https://api.nordvpn.com/v1/servers/ endpoint. It is inefficient to request the download of all 6300+ servers per query.

Tuinslak commented 5 months ago

Apologies for asking here, but I can't find an answer anywhere.

Is anything replacing https://api.nordvpn.com/vpn/check/full? A simple query to return whether you're currently protected by NordVPN?

mariusSincovici commented 5 months ago

hi @Tuinslak, you could use https://api.nordvpn.com/v1/helpers/ips/insights.

znbaboy commented 5 months ago

Hi and sorry for a delayed response.

As announced in this notice (https://support.nordvpn.com/hc/en-us/articles/21586950310801-Discontinuation-of-the-legacy-API-endpoints-on-NordVPN), the legacy API endpoints will no longer be active or recommended for future use. To achieve similar functionality, you can utilize the new API endpoint at https://api.nordvpn.com/v1/servers/recommendations. This endpoint provides detailed information about VPN exit nodes, including server load, and offers a list of servers based on our recommendations. For a comprehensive list of servers, access https://api.nordvpn.com/v1/servers. Remember to include "?limit=[value]" in your request to limit the response output.

Hi. Thank you for this.

I am kind of new to this stuff but I've been using https://api.nordvpn.com/v2/servers to get a list of servers.

Everything works great after your explanation on how to retrieve the entire list of servers (limit value).

The question I had was, I am trying to get a full list of US only servers. Is there a parameter I can use (like the limit) at the end of the URL so the API only serves me what I need?

Thanks!

mariusSincovici commented 5 months ago

hi, there are parameters for limits and to restrict results to a country, filters[country_id] and limit. Setting the limit very high will give you all the servers, e.g.: https://api.nordvpn.com/v2/servers?filters[country_id]=228&limit=10000

znbaboy commented 5 months ago

hi, there are parameters for limits and to restrict results to a country, filters[country_id] and limit. Setting the limit very high will give you all the servers, e.g.: https://api.nordvpn.com/v2/servers?filters[country_id]=228&limit=10000

thank you. this works on browsers, but for some reason my curl -s command returns nothing

mariusSincovici commented 5 months ago

does curl -g -s https://api.nordvpn.com/v2/servers\?filters\[country_id\]\=228\&limit=10000 work? if not try to remove -s to see the errors.

znbaboy commented 4 months ago

does curl -g -s https://api.nordvpn.com/v2/servers\?filters\[country_id\]\=228\&limit=10000 work? if not try to remove -s to see the errors.

All i get is HTML title and head saying "301 moved permanently"

Manwithpants812 commented 4 months ago

Just so people don't waste time, will "https://api.nordvpn.com/v1/servers" be eventually deprecated for "https://api.nordvpn.com/v2/servers"? I ask as the jsons returned have different structures.

lacherogwu commented 1 month ago

Do you know how its possible to use NordVPN servers to route a request thru their servers using curl

something like

curl -x pl128.nordvpn.com https://checkip.amazonaws.com/
mike-serchenia commented 1 month ago

Do you know how its possible to use NordVPN servers to route a request thru their servers using curl

something like

curl -x pl128.nordvpn.com https://checkip.amazonaws.com/

different OSI level L4 vs l7 what you're asking resolve ip for checkip.amazonaws.com route resolved ip via vpn gw

lacherogwu commented 1 month ago

Do you know how its possible to use NordVPN servers to route a request thru their servers using curl something like

curl -x pl128.nordvpn.com https://checkip.amazonaws.com/

different OSI level L4 vs l7 what you're asking resolve ip for checkip.amazonaws.com route resolved ip via vpn gw

I asked if its possible to use NordVPN server to route requests thru proxy using curl.