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.

Sign up Read the docs

Free: 1,000 req/day · HTTPS · commercial OK

Example

Look up one IP and keep only the country fields with jq:

GET /v0/ip/{ip}
$ 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 code
  • country — country name
  • continent_code — NA, SA, EU…
  • is_eu — whether the country is in the European Union
  • accuracy_radius_km and confidence (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_eu as 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) and is_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_relay and is_hosting help you decide how to treat that traffic; more on the VPN detection API.
  • Some IPs can’t be placed. country_code and country can be null, 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.

Sign up Read the docs

Related APIs