ipatlas

Hard-coding country lists to detect EU visitors is brittle and error-prone

Many websites need to show different shipping options, regional notices or support details when a visitor connects from the European Union — without forcing the same banners onto visitors elsewhere.

Maintaining a list of 27 EU country codes across front-end and back-end code is easy to get wrong, and browser language headers (Accept-Language) only reflect a user's language preference, not where they are connecting from. Note: this page is a technical guide, not legal advice. Privacy and consumer rules often depend on more than a visitor's IP address, and IP geolocation is approximate — consult a lawyer about what your business is required to show or collect.

Every lookup response from https://api.ipatlas.dev/v1/me and /v1/{ip} includes the boolean is_eu field (true for EU member states, false otherwise) alongside the two-letter country_code (so you can also check EEA countries such as "NO", "IS" and "LI", or non-EU neighbours such as "GB" and "CH"). Lookups are served from the EU (Germany), never log the looked-up IP address, and include 50,000 free lookups a month with no credit card.

Example: check is_eu in JavaScript

const EEA_EXTRA = new Set(["IS", "LI", "NO"]);

async function checkEuVisitor() {
  const res = await fetch("https://api.ipatlas.dev/v1/me");
  if (!res.ok) return { isEu: true, isEea: true }; // safe default if lookup fails
  const geo = await res.json();
  const isEu = geo.is_eu === true;
  const isEea = isEu || EEA_EXTRA.has(geo.country_code);
  return { isEu, isEea, countryCode: geo.country_code || null };
}

Related resources

Get your free API key

Start with 50,000 free lookups a month — no credit card required. Paid plans start at $9/month with hard caps and no surprise bills.

Get your free API key Compare plans