Viktor Jaep
Part of the Furniture
FULL DISCLOSURE: I absolutely SUCK at JQuery...
It's not like SQL at all, which I'm pretty decent with. I think the reason I am no good at this is because the sources this data comes from is always structured very differently in JSON, so there's always a completely different way at getting at the data. If you find a better way of doing something, please feel free to post it and/or correct me.
Current VPN Providers Supported that utilize an API functionality:
This discussion below was created to provide more examples of how CURL + JQ statements can be used to auto-populate custom OVPN Server Lists within VPNMON-R3. For instance, you may want your VPN Client Slot 1 to only connect to servers in New York City. VPN Slot 2 might be populated with all the servers within Canada. Etc. I'm providing examples of what might be possible, and how to craft these statements so you can copy/paste them directly into VPNMON-R3 with minimal effort.
As shown below, the "VPN Client Slot Server List Automation" menu allows you to View/Edit and Execute these statements, which will then pull the required VPN Server IPs from these various VPN Providers, and copy them into local server lists that VPNMON-R3 uses to reconnect your connections to.
NordVPN
(NOTE: Old API URL has been deprecated -- use new methods below)
NordVPN provided a new V1 API URL that continues to work as of Mar 5 2024, and let's hope they continue to support this incredibly helpful feature into the future! Since then, a V2 API URL has been released, and have been slowly converting the statements below to the new structure.
1) All NordVPN Servers in a certain City: In this example, I will show you how to filter all VPN Servers for a certain city... copy and paste the curl statements into an SSH window on your router to test their output.
First, determine a list of all valid countries, along with available city names within that country (Exact spelling is of great importance!)
V1
V2
Once you have found your country/city in the list, replace the city name (exact spelling) in the curl statement below. In this example, I'm using "New York". If the output creates a single list of IP addresses, you can copy/paste this statement into your VPNMON-R3 Server List Automation Slot, and execute it in order to generate a list.
V1
V2
2) All NordVPN Servers in a certain Country: This example shows you how to export all VPN Server IPs for a certain country... copy and paste the curl statements into an SSH window on your router to test their output.
First, determine the name for your country of choice. (Exact spelling is of great importance!)
V1
V2
Once you have found your country name, replace the name in the curl statement below. In this example, I'm using "United States". If the output creates a single list of IP addresses, you can copy/paste this statement into your VPNMON-R3 Server List Automation Slot, and execute it in order to generate a list.
V1
V2
3) Top 5 Recommended NordVPN Servers: This example shows you how to export all recommended NordVPN Server IPs that is based on a NordVPN algorithm per your location, and should be the fastest with the lowest load ... copy and paste the curl statements into an SSH window on your router to test their output.
First, determine the ID for your country of choice. (Exact number is of great importance!). The ID is in [ ] directly next to your country name.
V1
V2
Once you have found your Country ID, replace the ID in the curl statement below. In this example, I'm using United States, which is ID 228. If the output creates a single list of IP addresses, you can copy/paste this statement into your VPNMON-R3 Server List Automation Slot, and execute it in order to generate a list.
V1
V2 - you don't need the ID, but simply insert the Country Name: "United States"
V2 - or if you prefer a City: "New York"
...knowing what you learned above:
4) All NordVPN servers within the US that support OpenVPN UDP protocols
V1
5.) All servers within New York City that support OpenVPN UDP protocols
V1
Here's a list of the technologies/IDs in case you're looking for something other than UDP:
Code:
"technologies": [
{
"id": 1,
"name": "IKEv2/IPSec",
"identifier": "ikev2",
},
{
"id": 3,
"name": "OpenVPN UDP",
"identifier": "openvpn_udp",
},
{
"id": 5,
"name": "OpenVPN TCP",
"identifier": "openvpn_tcp",
},
{
"id": 21,
"name": "HTTP Proxy (SSL)",
"identifier": "proxy_ssl",
},
{
"id": 23,
"name": "HTTP CyberSec Proxy (SSL)",
"identifier": "proxy_ssl_cybersec",
},
{
"id": 35,
"name": "Wireguard",
"identifier": "wireguard_udp",
}
Current VPN Providers Supported that utilize an API functionality:
- NordVPN
- AirVPN
- PerfectPrivacy
- SurfShark
ProtonVPN- PIA
This discussion below was created to provide more examples of how CURL + JQ statements can be used to auto-populate custom OVPN Server Lists within VPNMON-R3. For instance, you may want your VPN Client Slot 1 to only connect to servers in New York City. VPN Slot 2 might be populated with all the servers within Canada. Etc. I'm providing examples of what might be possible, and how to craft these statements so you can copy/paste them directly into VPNMON-R3 with minimal effort.
As shown below, the "VPN Client Slot Server List Automation" menu allows you to View/Edit and Execute these statements, which will then pull the required VPN Server IPs from these various VPN Providers, and copy them into local server lists that VPNMON-R3 uses to reconnect your connections to.
NordVPN
(NOTE: Old API URL has been deprecated -- use new methods below)
NordVPN provided a new V1 API URL that continues to work as of Mar 5 2024, and let's hope they continue to support this incredibly helpful feature into the future! Since then, a V2 API URL has been released, and have been slowly converting the statements below to the new structure.
1) All NordVPN Servers in a certain City: In this example, I will show you how to filter all VPN Servers for a certain city... copy and paste the curl statements into an SSH window on your router to test their output.
First, determine a list of all valid countries, along with available city names within that country (Exact spelling is of great importance!)
V1
Code:
curl --silent "https://api.nordvpn.com/v1/servers/countries" | jq --raw-output '.[] | . as $parent | .cities[] | [$parent.name, $parent.id, .name, .id] | "\(.[0]) [\(.[1])] - \(.[2]) [\(.[3])]"'
V2
Code:
curl --silent "https://api.nordvpn.com/v2/servers?filters&limit=16384" | jq --raw-output '.locations[] | "\(.country.name) [\(.country.id)] - \(.country.city.name) [\(.country.city.id)]"' | sort -u
Once you have found your country/city in the list, replace the city name (exact spelling) in the curl statement below. In this example, I'm using "New York". If the output creates a single list of IP addresses, you can copy/paste this statement into your VPNMON-R3 Server List Automation Slot, and execute it in order to generate a list.
V1
Code:
curl --silent --retry 3 --connect-timeout 3 --max-time 30 --retry-delay 1 --retry-all-errors https://api.nordvpn.com/v1/servers?limit=16354 | jq --raw-output '.[] | select(.locations[0].country.city.name == "New York") | .station'
V2
Code:
curl --silent --retry 3 --connect-timeout 3 --max-time 30 --retry-delay 1 --retry-all-errors "https://api.nordvpn.com/v2/servers?filters&limit=16384" | jq --raw-output '(.locations | map(select(.country.city.name == "New York") | .id)) as $city_ids | .servers[] | select(.location_ids[] as $lid | $city_ids | index($lid)) | .station'
2) All NordVPN Servers in a certain Country: This example shows you how to export all VPN Server IPs for a certain country... copy and paste the curl statements into an SSH window on your router to test their output.
First, determine the name for your country of choice. (Exact spelling is of great importance!)
V1
Code:
curl --silent "https://api.nordvpn.com/v1/servers/countries" | jq --raw-output '.[] | . as $parent | .cities[] | [$parent.name, $parent.id, .name, .id] | "\(.[0]) [\(.[1])] - \(.[2]) [\(.[3])]"'
V2
Code:
curl --silent "https://api.nordvpn.com/v2/servers?filters&limit=16384" | jq --raw-output '.locations[] | "\(.country.name) [\(.country.id)] - \(.country.city.name) [\(.country.city.id)]"' | sort -u
Once you have found your country name, replace the name in the curl statement below. In this example, I'm using "United States". If the output creates a single list of IP addresses, you can copy/paste this statement into your VPNMON-R3 Server List Automation Slot, and execute it in order to generate a list.
V1
Code:
curl --silent --retry 3 --connect-timeout 3 --max-time 30 --retry-delay 1 --retry-all-errors https://api.nordvpn.com/v1/servers?limit=16354 | jq --raw-output '.[] | select(.locations[0].country.name == "United States") | .station''
V2
Code:
curl --silent --retry 3 --connect-timeout 3 --max-time 30 --retry-delay 1 --retry-all-errors "https://api.nordvpn.com/v2/servers?filters&limit=16384" | jq --raw-output '(.locations | map(select(.country.name == "United States") | .id)) as $country_ids | .servers[] | select(.location_ids[] as $lid | $country_ids | index($lid)) | .station'
3) Top 5 Recommended NordVPN Servers: This example shows you how to export all recommended NordVPN Server IPs that is based on a NordVPN algorithm per your location, and should be the fastest with the lowest load ... copy and paste the curl statements into an SSH window on your router to test their output.
First, determine the ID for your country of choice. (Exact number is of great importance!). The ID is in [ ] directly next to your country name.
V1
Code:
curl --silent "https://api.nordvpn.com/v1/servers/countries" | jq --raw-output '.[] | . as $parent | .cities[] | [$parent.name, $parent.id, .name, .id] | "\(.[0]) [\(.[1])] - \(.[2]) [\(.[3])]"'
V2
Code:
curl --silent "https://api.nordvpn.com/v2/servers?filters&limit=16384" | jq --raw-output '.locations[] | "\(.country.name) [\(.country.id)] - \(.country.city.name) [\(.country.city.id)]"' | sort -u
Once you have found your Country ID, replace the ID in the curl statement below. In this example, I'm using United States, which is ID 228. If the output creates a single list of IP addresses, you can copy/paste this statement into your VPNMON-R3 Server List Automation Slot, and execute it in order to generate a list.
V1
Code:
curl --silent --retry 3 --connect-timeout 3 --max-time 6 --retry-delay 1 --retry-all-errors "https://api.nordvpn.com/v1/servers/recommendations?filters\[country_id\]=228&limit=5" | jq --raw-output '.[].station'
V2 - you don't need the ID, but simply insert the Country Name: "United States"
Code:
curl --silent --retry 3 --connect-timeout 3 --max-time 30 --retry-delay 1 --retry-all-errors "https://api.nordvpn.com/v2/servers?filters&limit=16384" | jq --raw-output ' (.locations | map(select(.country.name == "United States"))) as $country_locations | ($country_locations | map(.id)) as $country_ids | [.servers[] | select(any(.location_ids[]; . as $lid | $country_ids | index($lid))) | select(.status == "online")] | sort_by(.load) | limit(5; .[]) | .station'
V2 - or if you prefer a City: "New York"
Code:
curl --silent --retry 3 --connect-timeout 3 --max-time 30 --retry-delay 1 --retry-all-errors "https://api.nordvpn.com/v2/servers?filters&limit=16384" | jq --raw-output ' (.locations | map(select(.country.city.name == "New York"))) as $city_locations | ($city_locations | map(.id)) as $city_ids | [.servers[] | select(any(.location_ids[]; . as $lid | $city_ids | index($lid))) | select(.status == "online")] | sort_by(.load) | limit(5; .[]) | .station'
...knowing what you learned above:
4) All NordVPN servers within the US that support OpenVPN UDP protocols
V1
Code:
curl --silent --retry 3 --connect-timeout 3 --max-time 6 --retry-delay 1 --retry-all-errors https://api.nordvpn.com/v1/servers?limit=16354 | jq --raw-output '.[] | select((.locations[0].country.name == "United States") and (.technologies[0].id = 3)) | .station'
5.) All servers within New York City that support OpenVPN UDP protocols
V1
Code:
curl --silent --retry 3 --connect-timeout 3 --max-time 6 --retry-delay 1 --retry-all-errors https://api.nordvpn.com/v1/servers?limit=16354 | jq --raw-output '.[] | select((.locations[0].country.city.name == "New York") and (.technologies[0].id = 3)) | .station'
Here's a list of the technologies/IDs in case you're looking for something other than UDP:
Code:
"technologies": [
{
"id": 1,
"name": "IKEv2/IPSec",
"identifier": "ikev2",
},
{
"id": 3,
"name": "OpenVPN UDP",
"identifier": "openvpn_udp",
},
{
"id": 5,
"name": "OpenVPN TCP",
"identifier": "openvpn_tcp",
},
{
"id": 21,
"name": "HTTP Proxy (SSL)",
"identifier": "proxy_ssl",
},
{
"id": 23,
"name": "HTTP CyberSec Proxy (SSL)",
"identifier": "proxy_ssl_cybersec",
},
{
"id": 35,
"name": "Wireguard",
"identifier": "wireguard_udp",
}
Last edited: