API Documentation
Get started with IPDrift in minutes. Simple REST API with comprehensive documentation and examples.
Quick Start Examples
cURL
curl "https://geo.ipdrift.com/v1/lookup?ip=8.8.8.8&api_key=YOUR_API_KEY" \ -H "Accept: application/json"
JavaScript
// Using our official NPM package (recommended)
import { IpDriftClient } from 'ipdrift-client';
const client = new IpDriftClient({
apiKey: 'YOUR_API_KEY'
});
const result = await client.lookup({ ip: '8.8.8.8' });
console.log(result.country_name); // "United States"
// Using fetch
const response = await fetch(
'https://geo.ipdrift.com/v1/lookup?ip=8.8.8.8&api_key=YOUR_API_KEY'
);
const data = await response.json();
console.log(data);
// Using axios
import axios from 'axios';
const { data } = await axios.get(
'https://geo.ipdrift.com/v1/lookup?ip=8.8.8.8&api_key=YOUR_API_KEY'
);Python
import requests
response = requests.get(
'https://geo.ipdrift.com/v1/lookup?ip=8.8.8.8&api_key=YOUR_API_KEY'
)
data = response.json()
print(data)
# With error handling
try:
response = requests.get(
'https://geo.ipdrift.com/v1/lookup?ip=8.8.8.8&api_key=YOUR_API_KEY',
timeout=10
)
response.raise_for_status()
data = response.json()
print(f"Country: {data['country_name']}")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")PHP
<?php
$response = file_get_contents(
'https://geo.ipdrift.com/v1/lookup?ip=8.8.8.8&api_key=YOUR_API_KEY'
);
$data = json_decode($response, true);
print_r($data);
// Using cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://geo.ipdrift.com/v1/lookup?ip=8.8.8.8&api_key=YOUR_API_KEY');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
?>Response Format
JSON Response
{
"ip": "8.8.8.8",
"type": "ipv4",
"continent_code": "NA",
"continent_name": "North America",
"country_code": "US",
"country_name": "United States",
"region_code": "CA",
"region_name": "California",
"city": "Mountain View",
"zip": "94043",
"latitude": 37.4056,
"longitude": -122.0775,
"time_zone": {
"id": "America/Los_Angeles",
"current_time": "2025-09-20T15:30:00-07:00",
"gmt_offset": -25200,
"code": "PDT",
"is_daylight_saving": true
},
"currency": {
"code": "USD",
"name": "US Dollar",
"symbol": "$"
},
"connection": {
"asn": 15169,
"isp": "GOOGLE",
"carrier": "GOOGLE"
},
"security": {
"is_tor": false,
"threat_level": "low",
"hosting_facility": true
}
}API Features
Rate Limiting
120 requests per minute
JSON Format
Consistent response structure
IPv4 & IPv6
Full dual-stack support
API Key Auth
Secure API key authentication