Authentication overview

IP2Proxy provides IP intelligence services primarily through downloadable databases and a Web Service API. Access to the IP2Proxy Web Service requires authentication using a unique API key, referred to as a 'License Key' in their documentation. This key identifies the user and authorizes their requests to retrieve data such as proxy type, country, region, city, ISP, domain, usage type, and threat level associated with an IP address, as detailed in the IP2Proxy Web Service API reference. The authentication mechanism is straightforward, designed for ease of integration across various programming environments.

For downloadable databases, authentication is handled implicitly through the subscription model; users download database files directly from their account after purchase. The focus of this page is on authenticating with the IP2Proxy Web Service.

The API key ensures that only authorized applications can consume the service's resources, allowing IP2Proxy to manage usage quotas and provide accurate billing for usage-based plans. Developers integrate the API key directly into their HTTP requests, typically as a query parameter. This approach is common among many web services for its simplicity and broad compatibility with HTTP clients and SDKs.

Understanding the proper handling and security of this API key is crucial for maintaining the integrity and security of applications that integrate with IP2Proxy. Mismanagement of API keys can lead to unauthorized access, potential service abuse, and unintended costs.

Supported authentication methods

IP2Proxy primarily supports API key authentication for its Web Service. This method involves including a unique License Key with each API request. The key serves as a token, verifying the identity of the requesting application or user.

API Key (License Key)

The API key is a string value that you obtain after subscribing to an IP2Proxy Web Service plan or signing up for a free trial. It acts as a client identifier and is passed directly in the URL of the API request. For instance, an API call might look like https://api.ip2proxy.com/?key=YOUR_API_KEY&ip=IP_ADDRESS&format=json. This is the sole method for authenticating with the IP2Proxy Web Service.

The following table summarizes the authentication method:

Method When to Use Security Level
API Key (License Key) Accessing the IP2Proxy Web Service for real-time IP intelligence lookups. Moderate (Requires secure handling of the key to prevent unauthorized access).

While API keys offer simplicity, it's important to recognize their security implications. Unlike more complex mechanisms like OAuth 2.0, API keys alone do not provide granular permission control or built-in token expiration. Therefore, developers must implement additional security measures to protect these keys, as outlined in the security best practices section.

Getting your credentials

To obtain your IP2Proxy API key (License Key), follow these steps:

  1. Sign Up/Log In: Navigate to the IP2Proxy website and either create a new account or log in to an existing one.
  2. Choose a Plan: Select a suitable IP2Proxy Web Service plan. IP2Proxy offers a variety of pricing tiers, including a free tier for basic usage, and paid subscriptions for higher query volumes and more detailed data.
  3. Access Your Account Dashboard: After signing up and subscribing, proceed to your account dashboard.
  4. Locate License Key: Your unique License Key will be displayed within your account dashboard, specifically under sections related to your Web Service subscription or API access. This key is automatically generated upon subscription activation.

Once you have your License Key, it is ready for use in your API requests. Remember that this key is unique to your account and should be treated as a sensitive credential.

Authenticated request example

IP2Proxy provides SDKs for several programming languages, including PHP, ASP.NET, Java, Python, Ruby, Node.js, Perl, C, and Go, which simplify the process of making authenticated requests. Below is an example using Python to demonstrate how to integrate the API key into a Web Service request.

Python example using the requests library

This example assumes you have installed the requests library (pip install requests).


import requests
import os

# It is highly recommended to store your API key in an environment variable
IP2PROXY_API_KEY = os.environ.get("IP2PROXY_API_KEY")
TARGET_IP = "8.8.8.8"  # Example IP address (Google DNS)

if not IP2PROXY_API_KEY:
    print("Error: IP2PROXY_API_KEY environment variable not set.")
    exit()

# Construct the API endpoint URL with the API key and target IP
# The 'format=json' parameter requests the response in JSON format
api_url = f"https://api.ip2proxy.com/?key={IP2PROXY_API_KEY}&ip={TARGET_IP}&format=json"

try:
    response = requests.get(api_url)
    response.raise_for_status()  # Raise an HTTPError for bad responses (4xx or 5xx)

    data = response.json()
    print(f"IP: {TARGET_IP}")
    print(f"Proxy Type: {data.get('proxyType', 'N/A')}")
    print(f"Country Code: {data.get('countryCode', 'N/A')}")
    print(f"Region Name: {data.get('regionName', 'N/A')}")
    print(f"City Name: {data.get('cityName', 'N/A')}")
    print(f"ISP: {data.get('isp', 'N/A')}")
    print(f"Is Proxy: {data.get('isProxy', 'N/A')}")

except requests.exceptions.HTTPError as http_err:
    print(f"HTTP error occurred: {http_err}")
except requests.exceptions.ConnectionError as conn_err:
    print(f"Connection error occurred: {conn_err}")
except requests.exceptions.Timeout as timeout_err:
    print(f"Timeout error occurred: {timeout_err}")
except requests.exceptions.RequestException as req_err:
    print(f"An unexpected error occurred: {req_err}")
except ValueError:
    print("Error: Could not decode JSON response.")

Key elements in the example:

  • Environment Variables: The API key is retrieved from an environment variable (IP2PROXY_API_KEY). This is a critical security practice to avoid hardcoding sensitive credentials directly in your code.
  • URL Query Parameter: The API key is passed as a query parameter named key in the URL.
  • Error Handling: The example includes basic error handling for network issues and HTTP errors, which is essential for robust application development.

For more examples and specific SDK integrations, refer to the IP2Proxy developer documentation.

Security best practices

Securing your IP2Proxy API key is essential to prevent unauthorized usage, protect your account, and avoid unexpected costs. Adhere to these best practices:

1. Store API Keys Securely

  • Environment Variables: Never hardcode API keys directly into your source code. Instead, store them as environment variables. This keeps the keys out of your version control system (e.g., Git).
  • Secrets Management Services: For production environments, consider using dedicated secrets management services like AWS Secrets Manager, Google Cloud Secret Manager, Azure Key Vault, or HashiCorp Vault. These services provide centralized management, encryption at rest, and fine-grained access control for sensitive credentials. AWS Secrets Manager documentation provides details on how to use this service securely.
  • Configuration Files: If environment variables aren't feasible for local development, use a local configuration file (e.g., .env) that is explicitly excluded from version control (e.g., via .gitignore).

2. Restrict Access and Permissions

  • Least Privilege: Ensure that only necessary applications and personnel have access to the API key. Implement role-based access control (RBAC) where possible.
  • Avoid Client-Side Exposure: Never embed your API key directly in client-side code (e.g., JavaScript running in a web browser or mobile app). This would expose the key to end-users, allowing them to inspect your code and potentially abuse your API access. All API calls using your key should originate from a secure backend server.

3. Monitor Usage and Set Alerts

  • Monitor API Usage: Regularly check your IP2Proxy account dashboard for API usage statistics. This helps detect unusual activity that might indicate a compromised key.
  • Set Usage Alerts: Configure alerts within your IP2Proxy account (if available) or your monitoring systems to notify you when API usage exceeds expected thresholds.

4. Rotate API Keys

  • Regular Rotation: Periodically rotate your API keys. If a key is compromised, frequent rotation limits the window of exposure. IP2Proxy's dashboard typically provides functionality to generate new keys and revoke old ones.
  • Immediate Rotation on Compromise: If you suspect an API key has been compromised, revoke it immediately and generate a new one.

5. Secure Your Infrastructure

  • Network Security: Ensure the servers and environments making API requests are secure, with appropriate firewalls, intrusion detection systems, and regular security updates.
  • Secure Communication: Always use HTTPS for all communication with the IP2Proxy API. This encrypts the data in transit, protecting your API key and other sensitive information from eavesdropping. The Mozilla Developer Network's guide to HTTPS provides a comprehensive overview of its importance.

By diligently applying these security best practices, developers can significantly reduce the risk associated with API key authentication for IP2Proxy services.