Resolve ip to country

When the user asks what country an IP address belongs to, or wants to geolocate an IP to a country code — reach for country.is. Returns ISO 3166-1 alpha-2 codes in one unauthenticated GET.

resolve-ip-to-country · v5 · updated 2026-04-16

Agents: This page is a SKILL.md-style capability guide. For JSON, call GET /api/skills/resolve-ip-to-country. To drop this into a local Claude Code install, copy the frontmatter + body below into ~/.claude/skills/resolve-ip-to-country/SKILL.md.

When to use this skill

When the user asks what country an IP address belongs to, wants to map an IP to a country code, or needs to detect a visitor's country from their IP. This is IP-to-country resolution only — no city, region, ASN, or timezone. For display names like "Germany" instead of "DE", pair the result with a country reference API like REST Countries.

Your best first call

curl "https://api.country.is/185.220.101.45"

No auth. No key. Pass any IPv4 or IPv6 address as the path segment. The response is always two fields:

{
  "ip": "185.220.101.45",
  "country": "NL"
}

country is always ISO 3166-1 alpha-2 — two uppercase letters, never a full name, never alpha-3. The ip field echoes back the address you queried, useful for confirming you sent what you intended.

Fallbacks (when the best call isn't enough)

Pitfalls

One-line summary for the user

I can resolve any IPv4 or IPv6 address to its ISO country code via country.is — no key required, but the response is only a two-letter code with no city, region, or display name.

APIs this skill uses

Country · primary · verified

IP geolocation API - Get your visitor's country from their IP address. No API key required.

Generated from

Country tutorial Getting Started with country.is

SKILL.md source (frontmatter + body)
---
name: resolve-ip-to-country
description: When the user asks what country an IP address belongs to, or wants to geolocate an IP to a country code — reach for country.is. Returns ISO 3166-1 alpha-2 codes in one unauthenticated GET.
---

## When to use this skill

When the user asks what country an IP address belongs to, wants to map an IP to a country code, or needs to detect a visitor's country from their IP. This is IP-to-country resolution only — no city, region, ASN, or timezone. For display names like "Germany" instead of "DE", pair the result with a country reference API like REST Countries.

## Your best first call

```bash
curl "https://api.country.is/185.220.101.45"
```

No auth. No key. Pass any IPv4 or IPv6 address as the path segment. The response is always two fields:

```json
{
  "ip": "185.220.101.45",
  "country": "NL"
}
```

`country` is always ISO 3166-1 alpha-2 — two uppercase letters, never a full name, never alpha-3. The `ip` field echoes back the address you queried, useful for confirming you sent what you intended.

## Fallbacks (when the best call isn't enough)

- **Display names for country codes** → REST Countries (`/v3.1/alpha/{code}`) turns the `"NL"` you get back into `"Netherlands"` with flags, currencies, and more. Use it when the user asked "what country is this?" and expects a name, not a code.
- **City, region, or ASN data** → ipinfo.io or ip-api.com return sub-country detail that country.is deliberately omits. Reach for them when "what country" was just the start of the question.

## Pitfalls

- **`GET /` without an IP returns the *caller's* country**, not a visitor's. Behind Cloudflare, `CF-IPCountry` makes this useful for visitor detection. On a raw VPS, call `GET /{visitor-ip}` explicitly with the IP from `X-Forwarded-For` instead.
- **ISO alpha-2 only.** You get `"DE"`, not `"Germany"`. If your downstream system expects full names or alpha-3 codes, you need a second lookup.
- **No sub-country resolution.** The response is terminal — `country` is the most specific geographic level available. Do not expect city or region fields; they do not exist.

## One-line summary for the user

I can resolve any IPv4 or IPv6 address to its ISO country code via country.is — no key required, but the response is only a two-letter code with no city, region, or display name.

« Back to all skills