IP to Country API
Send an IPv4 or IPv6 address, get back the ISO country code, country name, continent and an EU flag.
Every lookup also includes accuracy_radius_km and confidence, so you know how much to trust it.
Free: 1,000 req/day · HTTPS · commercial OK
Example
Look up one IP and keep only the country fields with jq:
$ curl -s https://api.networkdatalabs.com/v0/ip/8.8.8.8 \ -H "Authorization: Bearer YOUR_API_KEY" \ | jq '.location | {country_code, country, continent_code, is_eu, accuracy_radius_km, confidence}' { "country_code": "US", "country": "United States", "continent_code": "NA", "is_eu": false, "accuracy_radius_km": 50.0, "confidence": "medium" }
8.8.8.8 is an anycast public DNS resolver, answered from many places at once, so the radius is wide and confidence is low: the response tells you when it can’t be precise.
Have a list? POST /v0/bulk takes up to 100 IPs per request with the same schema; a bad IP shows up under errors without failing the batch, and each IP counts toward the daily quota.
Response fields
country_code— ISO 3166-1 alpha-2 country codecountry— country namecontinent_code—NA,SA,EU…is_eu— whether the country is in the European Unionaccuracy_radius_kmandconfidence(high|medium|low|unknown) — how precise the estimate is
The same call also returns region, city, timezone, ASN / network, and Tor exit, known VPN network, privacy relay and hosting/datacenter flags. Need all of it? See the IP geolocation API.
What teams use it for
- Geo-pricing & currency — show local currency and regional prices by
country_code - Localization & compliance — default language and content by country; use
is_euas a signal for EU-specific flows like consent banners - Fraud checks — compare IP country with billing or card country, and pair it with
is_tor(Tor exits),is_vpn(known VPN networks),is_relay(privacy relay) andis_hosting(hosting/datacenter) on signup, login and payments - Analytics — group traffic and signups by country and continent
What it doesn’t do
- Behind a VPN, it’s the exit’s country. The IP belongs to the exit server, so the country is the exit’s, not the user’s.
is_vpn(known VPN networks, including major commercial VPN providers),is_tor,is_relayandis_hostinghelp you decide how to treat that traffic; more on the VPN detection API. - Some IPs can’t be placed.
country_codeandcountrycan benull, so code a fallback.
Treat the country as a strong signal, not proof: pair it with billing or account data when it matters.
FAQ
How accurate is IP to country?
Country is the most reliable level of IP geolocation: an IP block is usually announced and used within one country,
while city is often an educated guess. That’s why we don’t sell “99% city accuracy.” It is still an estimate, not a guarantee:
VPNs, proxies, and anycast or hosting ranges can point somewhere other than the user, so every response carries
accuracy_radius_km, confidence and traits like is_anycast and is_hosting.
Does it support IPv6?
Yes. GET /v0/ip/{ip} and POST /v0/bulk accept both IPv4 and IPv6 addresses
(for example 2001:4860:4860::8888). Malformed IPs return 400 INVALID_IP.
Is there a free plan?
Yes: 1,000 requests per UTC day with the full response schema, commercial use OK. In bulk, each IP counts as one request toward the daily quota.
Start building
Sign up for a free account, or read the quickstart and full reference in the docs.
Related APIs
- Guide: get a visitor’s IP and country in Express
- IP Geolocation API — full location with accuracy radius, network/ASN and traits
- VPN Detection API — known VPN network, Tor exit, privacy relay and hosting flags
- ASN Lookup API — ASN, ISP and organization for any IP, plus Autonomous System detail
- IP Fraud Detection API — VPN, Tor, privacy relay, hosting and geo signals for signup, login and payment risk
- MaxMind & IPinfo alternative — what Network Data Labs offers if you’re comparing IP geolocation APIs
- API Docs — quickstart, endpoints and the full field reference