Sign up for a free account at theipapi.com to get your API key. The free plan includes 1,000 requests per day.
Use your API key to make a request to our geolocation endpoint:
curl "https://api.theipapi.com/v1/ip/8.8.8.8?api_key=YOUR_API_KEY"
The API returns JSON data with geolocation information:
{
"status": "OK",
"body": {
"asn": {
"asn": 13335,
"asn_description": "CLOUDFLARENET, US",
"country": "AU",
"created": "2010-07-15",
"network": "1.1.1.0/24",
"org_name": "Cloudflare, Inc.",
"rir": "ARIN",
"updated": "2021-07-01"
},
"company": {
"address": "101 Townsend Street, San Francisco, CA, US",
"name": "APNIC and Cloudflare DNS Resolver project",
"network": "1.1.1.0 - 1.1.1.255",
"route": "1.1.1.0/24"
},
"ip": "1.1.1.1",
"location": {
"city": "Los Angeles",
"country": "United States of America",
"country_code": "US",
"latitude": 34.052571,
"longitude": -118.243907,
"region": "California",
"timezone": "America/Los_Angeles"
},
"is_bogon": false,
"is_datacenter": false,
"is_vpn": false
},
"response_time_ms": 10
}
GET /v1/ip/{ip_address}
Returns geolocation data for a specific IP address.
ip_address (required) - The IP address to look upapi_key (required) - Your API keycurl "https://api.theipapi.com/v1/ip/8.8.8.8?api_key=YOUR_API_KEY"
status - Response status ("OK" for successful requests)body.ip - The queried IP addressbody.location.country_code - Two-letter country codebody.location.country - Full country namebody.location.city - City namebody.location.region - State/region namebody.location.latitude - Latitude coordinatebody.location.longitude - Longitude coordinatebody.location.timezone - Timezone informationbody.asn.asn - Autonomous System Numberbody.asn.org_name - ASN organization namebody.asn.asn_description - ASN descriptionbody.company.name - Company namebody.company.address - Company addressbody.is_bogon - Whether IP is a bogon (private/invalid)body.is_datacenter - Whether IP belongs to a datacenterbody.is_vpn - Whether IP belongs to a VPN serviceresponse_time_ms - API response time in millisecondsGET /v1/asn/{asn_number}
Returns information about an Autonomous System Number (ASN).
asn_number (required) - The ASN to look upapi_key (required) - Your API keycurl "https://api.theipapi.com/v1/asn/15169?api_key=YOUR_API_KEY"
{
"status": "OK",
"body": {
"asn": {
"asn": 15169,
"asn_description": "Google LLC",
"country": "US",
"created": "2005-11-23",
"org_name": "Google LLC",
"rir": "ARIN",
"updated": "2019-10-31"
}
},
"response_time_ms": 0
}
status - Response status ("OK" for successful requests)body.asn.asn - The Autonomous System Numberbody.asn.asn_description - ASN description/namebody.asn.country - Country code where ASN is registeredbody.asn.created - Date when ASN was createdbody.asn.org_name - Organization namebody.asn.rir - Regional Internet Registry (ARIN, RIPE, APNIC, etc.)body.asn.updated - Last update dateresponse_time_ms - API response time in millisecondsPOST /v1/ip/batch
Look up geolocation data for multiple IP addresses in a single request. Up to 100 IPs per request. Each unique IP counts as one request against your API quota.
api_key (required) - Your API key (query parameter)ips (required) - JSON array of IP addresses (request body)curl -X POST "https://api.theipapi.com/v1/ip/batch?api_key=YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"ips": ["8.8.8.8", "1.1.1.1", "192.168.1.1"]}'
{
"status": "OK",
"results": {
"8.8.8.8": {
"status": "OK",
"body": {
"ip": "8.8.8.8",
"location": {
"city": "Mountain View",
"country": "United States of America",
"country_code": "US",
"latitude": 37.386,
"longitude": -122.0838,
"region": "California",
"timezone": "America/Los_Angeles"
},
"asn": { "asn": 15169, "org_name": "Google LLC", ... },
"company": { "name": "Google LLC", ... },
"is_bogon": false,
"is_datacenter": true,
"is_vpn": false
},
"response_time_ms": 12
},
"1.1.1.1": {
"status": "OK",
"body": { ... },
"response_time_ms": 8
},
"192.168.1.1": {
"status": "OK",
"body": {
"ip": "192.168.1.1",
"is_bogon": true
},
"response_time_ms": 1
}
},
"total_ips": 3,
"response_time_ms": 15
}
status - Overall request status ("OK" if the batch was accepted)results - Dictionary keyed by IP address, each containing the same response format as the single IP endpointtotal_ips - Number of unique IPs processedresponse_time_ms - Total batch processing time in milliseconds400 - Invalid JSON body, no IPs provided, more than 100 IPs, or invalid IP address401 - Missing or invalid API key405 - Method not allowed (must use POST)429 - Insufficient API quota for the batch sizeconst https = require('https');
const options = {
hostname: 'api.theipapi.com',
path: '/v1/ip/8.8.8.8?api_key=YOUR_API_KEY',
method: 'GET'
};
const req = https.request(options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
const result = JSON.parse(data);
console.log(result);
});
});
req.on('error', (error) => {
console.error(error);
});
req.end();
import requests
url = "https://api.theipapi.com/v1/ip/8.8.8.8"
params = {"api_key": "YOUR_API_KEY"}
response = requests.get(url, params=params)
data = response.json()
print(data)
<?php
$url = "https://api.theipapi.com/v1/ip/8.8.8.8?api_key=YOUR_API_KEY";
$response = file_get_contents($url);
$data = json_decode($response, true);
print_r($data);
?>
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.theipapi.com/v1/ip/8.8.8.8?api_key=YOUR_API_KEY"
resp, err := http.Get(url)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
var result map[string]interface{}
json.Unmarshal(body, &result)
fmt.Println(result)
}
import requests
url = "https://api.theipapi.com/v1/ip/batch"
params = {"api_key": "YOUR_API_KEY"}
payload = {
"ips": ["8.8.8.8", "1.1.1.1", "9.9.9.9"]
}
response = requests.post(url, params=params, json=payload)
data = response.json()
for ip, result in data["results"].items():
location = result["body"]["location"]
print(f"{ip}: {location['city']}, {location['country_code']}")
const response = await fetch(
"https://api.theipapi.com/v1/ip/batch?api_key=YOUR_API_KEY",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
ips: ["8.8.8.8", "1.1.1.1", "9.9.9.9"]
})
}
);
const data = await response.json();
for (const [ip, result] of Object.entries(data.results)) {
console.log(`${ip}: ${result.body.location.city}`);
}
curl -X POST "https://api.theipapi.com/v1/ip/batch?api_key=YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"ips": ["8.8.8.8", "1.1.1.1", "9.9.9.9"]}'
API requests are rate limited based on your subscription plan:
Rate limits reset daily for the Free plan and monthly for paid plans. For batch requests, each unique IP address counts as one request. Check your usage in the dashboard.
The API returns standard HTTP status codes:
200 - Success400 - Bad Request (invalid parameters)401 - Unauthorized (invalid API key)429 - Too Many Requests (rate limit exceeded)500 - Internal Server Error{
"error": {
"code": "INVALID_API_KEY",
"message": "The provided API key is invalid"
}
}
If you need additional assistance or have questions about the API: