Use case — Geolocation

Location and network context for any IP.

Localise content, default the right currency and timezone, enrich logs and sign-ups, or route requests by country. One GET returns location and network data for an IPv4 address, IPv6 address or domain.

Free plan 1,000 requests / day free · IPv4, IPv6 and domains

01 — The problem

Why it's harder than it looks.

01

One provider is never right about everything

IP databases disagree, especially at city level. Relying on a single source bakes its gaps into your product.

02

Inconsistent formats

Country names, codes, timezones and ASNs come back in different shapes from different services.

03

Speed matters

Geolocation often sits on the request path, so lookups need to be fast and cacheable.

02 — How it works

One lookup, one answer.

  1. Each uncached lookup asks several independent data providers and merges their answers.
  2. Results are normalised: two-letter country codes, IANA timezones and plain ASN numbers.
  3. Results are cached, so repeated lookups for the same address return quickly.
GET /api/lookup/{ip}Response (abridged)
{
  // …
  "country": "Greece",
  "country_code": "GR",
  "city": "Athens",
  "timezone": "Europe/Athens",
  "isp": "…",
  "asn": "…"
}

03 — Recipe

Drop-in example.

Call the API from your server, never from the browser, so your key stays private. Cache answers per IP on your side to save requests.

JavaScript (Node.js)
// Pick sensible defaults for a new visitor from their IP (works with a free key).
const LOOKUP = 'https://fast.ipapi.gr/api/lookup/';

async function visitorDefaults(ip) {
  const r = await fetch(LOOKUP + encodeURIComponent(ip) + '?key=' + process.env.IPAPI_KEY,
    { signal: AbortSignal.timeout(1500) });
  const geo = r.ok ? await r.json() : {};
  const known = (v) => (v == null || v === 'No Data' ? null : v); // missing fields are "No Data"
  return {
    country: known(geo.country_code),        // e.g. "GR"
    timezone: known(geo.timezone) ?? 'UTC',  // IANA, e.g. "Europe/Athens"
    city: known(geo.city)                    // approximate; may be unknown
  };
}

04 — Honest limits

What it won't tell you.

  • IP geolocation is approximate. Country is usually reliable; city and coordinates are estimates.
  • A field is null or missing when none of the sources has a value for that address.
  • VPNs, proxies and mobile carriers can place a user far from where they are.

05 — Questions

Good to know.

More in the FAQ and the docs.

Is the IP geolocation API free?

Yes. Free keys include geolocation and network data for a daily number of requests shown on the pricing page. Pro raises the limit and adds the bot-signal flags.

Does it support IPv6 and domains?

Yes. Pass an IPv4 address, an IPv6 address or a domain name. Domains are resolved and the resulting address is looked up.

Can I look up the caller's own IP?

Yes. GET /api/lookup/self returns data for the address the request comes from.

Make your first lookup in two minutes.

Free: 1,000 requests a day, up to 20 API keys.