IP Geolocation API
Look up the country, region, city, coordinates, ASN and ISP of any IPv4 or IPv6 address – or your own IP – in one fast JSON call.
The IP Geolocation API returns location and network data for an IPv4 or IPv6 address: country code and name, flag emoji, EU membership, international calling code, continent, region, city, latitude/longitude, autonomous system number (ASN) and organisation (ISP or hosting company). Call /v1/ip/8.8.8.8 or /v1/ip?ip=8.8.8.8.
Without an IP the API describes the caller’s own address using Cloudflare’s edge data, which adds postal code and timezone – perfect for a “what is my IP” feature or to pre-fill a country selector. Private, loopback, link-local and other reserved addresses are recognised and returned with reserved: true and the range name instead of a location.
Arbitrary IPs are looked up in the DB-IP Lite database (IP geolocation by DB-IP, licensed CC BY 4.0), city-level precision, refreshed monthly; results are cached for 24 hours. As with every IP database, city-level results are approximate, while country and ASN are highly accurate.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
ip | path | string | no | IPv4 or IPv6 address, in the path (/v1/ip/8.8.8.8) or as ?ip=. Omit it to look up your own IP. |
Example
curl "https://apibox.io.vn/v1/ip/8.8.8.8" \
-H "Authorization: Bearer YOUR_API_KEY"const res = await fetch('https://apibox.io.vn/v1/ip/8.8.8.8', {
method: 'GET',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
});
const data = await res.json();
console.log(data);import requests
res = requests.get(
"https://apibox.io.vn/v1/ip/8.8.8.8",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/ip/8.8.8.8');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"ip": "8.8.8.8",
"version": 4,
"country_code": "US",
"country": "United States",
"flag": "🇺🇸",
"is_eu": false,
"calling_code": "+1",
"continent": "North America",
"region": "California",
"city": "Mountain View",
"latitude": 37.4223,
"longitude": -122.085,
"asn": 15169,
"organization": "Google LLC",
"source": "db-ip.com lite",
"database_version": "2026-11"
}
Use cases
- Pre-select the country and currency in sign-up and checkout forms
- Show “what is my IP” and location on a support page
- Flag logins from unusual countries or hosting providers
- Enrich server logs and analytics with country and ISP
FAQ
How do I get my own public IP address?
Call /v1/ip with no ip parameter. The response contains the IP the request came from plus its country, city, timezone and ASN as seen by Cloudflare.
How accurate is IP geolocation?
Country is correct for the vast majority of addresses and ASN/organisation comes from routing data. City and coordinates are approximate (often the ISP’s hub), and VPNs or mobile carriers can place users far from their real location.
Does it support IPv6?
Yes, both IPv4 and IPv6 are supported, including IPv4-mapped IPv6 addresses such as ::ffff:8.8.8.8.
Related APIs
DNS Lookup
Query A, AAAA, MX, TXT, NS, CNAME, SOA, CAA, SRV and more for any domain, or reverse-lookup an IP (PTR), via DNS over HTTPS. Clean JSON output.
@Email Validator
Validate e-mail addresses: syntax, MX/A records, ~120k disposable domains, role accounts, free providers and typo hints like gmial.com → gmail.com.
☎Phone Number Validator
Validate and format phone numbers for 240+ countries: E.164, international and national formats, country, calling code and line type (mobile, fixed line…).