API Documentation

Integrate with our IP lookup services

v2.1Stable
Authentication
REQUIRED

Include your API token directly in the request URL:

GET https://whomyip.com/api/lookup/{api_token}/{ip_address}
Security Notice:Never expose your API token in client-side code. Always make requests from your backend server.
IP Lookup
GET

Retrieve geolocation and network information for any IP address.

Endpoint
GET https://whomyip.com/api/lookup/{api_token}/{ip_address}
Response Example
{
      "ip": "8.8.8.8",
      "country": "United States",
      "country_code": "US",
      "country_flag": "https://whomyip.com/api/flag/us",
      "currency_code": "USD",
      "currency_symbol": "$",
      "continent_code": "NA",
      "continent_name": "North America",
      "latitude": "37.7510",
      "longitude": "-97.8220",
      "location": "37.7510,-97.8220",
      "city": "Los Angeles",
      "postal": "90001",
      "region": "California",
      "org": "Google LLC",
      "timezone": "America/Los_Angeles"
    }
Code Examples
// PHP Example
    $token = 'your-api-token';
    $ip = '8.8.8.8';
    $url = "https://whomyip.com/api/lookup/{$token}/{$ip}";
    
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    
    if ($httpCode === 200) {
        $data = json_decode($response, true);
        print_r($data);
    } else {
        echo "Error: HTTP Code $httpCode";
    }
# Python Example
    import requests
    
    token = "your-api-token"
    ip = "8.8.8.8"
    url = f"https://whomyip.com/api/lookup/{token}/{ip}"
    
    response = requests.get(url)
    if response.status_code == 200:
        print(response.json())
    else:
        print(f"Error: HTTP Code {response.status_code}")
// JavaScript Example
    const token = 'your-api-token';
    const ip = '8.8.8.8';
    const url = `https://whomyip.com/api/lookup/${token}/${ip}`;
    
    fetch(url)
      .then(response => {
        if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
        return response.json();
      })
      .then(data => console.log(data))
      .catch(error => console.error('Error:', error));
Error Codes
CodeErrorDescriptionSolution
400Bad RequestMissing or invalid parametersCheck request parameters
401UnauthorizedInvalid or missing API tokenVerify your API token
429Too Many RequestsRate limit exceededWait 30 seconds or upgrade
500Server ErrorInternal server issueContact support
Rate Limiting
PlanRequests/30sRequests/Month
Free5100
Basic305,000
Pro10050,000
EnterpriseCustomCustom
Rate Limit Exceeded?

You'll receive a 429 error. Wait 30 seconds before making more requests or consider upgrading your plan for higher limits.

Upgrade Plan