API Documentation
Integrate with our IP lookup services
v2.1Stable
Authentication
REQUIREDInclude 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
GETRetrieve 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
Code | Error | Description | Solution |
---|---|---|---|
400 | Bad Request | Missing or invalid parameters | Check request parameters |
401 | Unauthorized | Invalid or missing API token | Verify your API token |
429 | Too Many Requests | Rate limit exceeded | Wait 30 seconds or upgrade |
500 | Server Error | Internal server issue | Contact support |
Rate Limiting
Plan | Requests/30s | Requests/Month |
---|---|---|
Free | 5 | 100 |
Basic | 30 | 5,000 |
Pro | 100 | 50,000 |
Enterprise | Custom | Custom |
Rate Limit Exceeded?
You'll receive a 429 error. Wait 30 seconds before making more requests or consider upgrading your plan for higher limits.