API Documentation
Get started with IPDrift in minutes. Simple REST API with comprehensive documentation and examples.
Quick Start Examples
cURL
1curl "https://geo.ipdrift.com/v1/lookup?ip=8.8.8.8&api_key=YOUR_API_KEY" \2-H "Accept: application/json"
JavaScript
1// Using our official NPM package (recommended)2import { IpDriftClient } from 'ipdrift-client';34const client = new IpDriftClient({5apiKey: 'YOUR_API_KEY'6});78const result = await client.lookup({ ip: '8.8.8.8' });9console.log(result.country_name); // "United States"1011// Using fetch12const response = await fetch(13'https://geo.ipdrift.com/v1/lookup?ip=8.8.8.8&api_key=YOUR_API_KEY'14);15const data = await response.json();16console.log(data);1718// Using axios19import axios from 'axios';20const { data } = await axios.get(21'https://geo.ipdrift.com/v1/lookup?ip=8.8.8.8&api_key=YOUR_API_KEY'22);
Python
1import requests23response = requests.get(4'https://geo.ipdrift.com/v1/lookup?ip=8.8.8.8&api_key=YOUR_API_KEY'5)6data = response.json()7print(data)89# With error handling10try:11response = requests.get(12'https://geo.ipdrift.com/v1/lookup?ip=8.8.8.8&api_key=YOUR_API_KEY',13timeout=1014)15response.raise_for_status()16data = response.json()17print(f"Country: {data['country_name']}")18except requests.exceptions.RequestException as e:19print(f"Error: {e}")
PHP
1<?php2$response = file_get_contents(3'https://geo.ipdrift.com/v1/lookup?ip=8.8.8.8&api_key=YOUR_API_KEY'4);5$data = json_decode($response, true);6print_r($data);78// Using cURL9$ch = curl_init();10curl_setopt($ch, CURLOPT_URL, 'https://geo.ipdrift.com/v1/lookup?ip=8.8.8.8&api_key=YOUR_API_KEY');11curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);12$response = curl_exec($ch);13curl_close($ch);14$data = json_decode($response, true);15?>
Response Format
JSON Response
1{
2 "ip": "8.8.8.8",
3 "type": "ipv4",
4 "continent_code": "NA",
5 "continent_name": "North America",
6 "country_code": "US",
7 "country_name": "United States",
8 "region_code": "CA",
9 "region_name": "California",
10 "city": "Mountain View",
11 "zip": "94043",
12 "latitude": 37.4056,
13 "longitude": -122.0775,
14 "time_zone": {
15 "id": "America/Los_Angeles",
16 "current_time": "2025-09-20T15:30:00-07:00",
17 "gmt_offset": -25200,
18 "code": "PDT",
19 "is_daylight_saving": true
20 },
21 "currency": {
22 "code": "USD",
23 "name": "US Dollar",
24 "symbol": "$"
25 },
26 "connection": {
27 "asn": 15169,
28 "isp": "GOOGLE",
29 "carrier": "GOOGLE"
30 },
31 "security": {
32 "is_tor": false,
33 "threat_level": "low",
34 "hosting_facility": true
35 }
36}
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