Does your Python application or website ever witness any users using a VPN, proxies, or Tor network users? If so, have they ever caused harm to your service? If so, you are in the reading the right tutorial.
Using Python and our security API, you can easily block VPN, proxy, and Tor users. This allows you to block these types of users from ever entering your application or website.
import requests, json ip_address = "188.8.131.52" API_key = "YOUR API KEY HERE" response = requests.get("https://vpnapi.io/api/" + ip_address + "?key=" + API_key) data = json.loads(response.text) print(data) # Outputs everything print(data["security"] # Outputs just the security details
The code above gives will display the API results within your Python application. In this case, the API will print out the whole API result, then it will print out just the security.
If you were to copy the additional code below and input it to the existing code snippet above, your Python application will have the ability to determine if an IP address is a VPN or not.
if data["security"]["vpn"] == False: # Not a VPN else: # This is a VPN
From there you can add in the functions or actions that you want to perform within the if-else statement. In fact, implementing the proxy and TOR detection is quite similar as well.
if data["security"]["proxy"] == False: # Not a Proxy Server else: # This is a Proxy Server
Quite similar to the VPN if-else statement above, all you have to do is change the if statement. Which is just changing the “vpn” portion to “proxy”. From there, place the code or function that you want perform if a user is not using a proxy within the first part of the statement. And place the code that you want on the second portion of the statement for those who are using a proxy. In fact, implementing the proxy checker is quite similar with detecting a VPN.
if data["security"]["tor"] == False: # Not a Tor IP address else: # This is a Tor IP address
Just like the VPN and proxy examples above, just change the if statement to tor and you have gotten a Tor detection system in a matter of seconds, thanks to our API. The first part of the if-else statement, will perform the actions that you want if the user does not have a Tor IP address. The second part of the statement will perform actions if the user does have a Tor IP address.
All in all, our goal for our API is to help websites stay protected from malicious users and at the same time give developers an easy way to achieve that goal as well.
For more information, feel free to visit us at: vpnapi.io