Look up country by ip

When the user asks "what country is this IP address in?" or needs to map an IPv4 or IPv6 address to its ISO 3166-1 alpha-2 country code — reach for country.is. No auth, no key, one GET.

look-up-country-by-ip · v1 · updated 2026-04-16

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

When to use this skill

When the user asks "what country is this IP address in?" or needs to map an IPv4 or IPv6 address to its ISO 3166-1 alpha-2 country code — reach for country.is. No auth, no key, one GET. For anything beyond country (city, region, ASN, timezone), this is the wrong skill — use a fuller geolocation service instead.

Your best first call

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

No auth. No key. The response has two fields: ip (the address you queried) and country (ISO 3166-1 alpha-2 — always two uppercase letters, never a full name, never alpha-3). If you need "Germany" rather than "DE", pair with a country reference API like REST Countries. Both IPv4 and IPv6 work in the same path structure.

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

Fallbacks (when the best call isn't enough)

Pitfalls

One-line summary for the user

I can look up the country for any IPv4 or IPv6 address using country.is — no key required, but the response is only a two-letter ISO country code.

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: look-up-country-by-ip
description: When the user asks "what country is this IP address in?" or needs to map an IPv4 or IPv6 address to its ISO 3166-1 alpha-2 country code — reach for country.is. No auth, no key, one GET.
---

## When to use this skill

When the user asks "what country is this IP address in?" or needs to map an IPv4 or IPv6 address to its ISO 3166-1 alpha-2 country code — reach for country.is. No auth, no key, one GET. For anything beyond country (city, region, ASN, timezone), this is the wrong skill — use a fuller geolocation service instead.

## Your best first call

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

No auth. No key. The response has two fields: `ip` (the address you queried) and `country` (ISO 3166-1 alpha-2 — always two uppercase letters, never a full name, never alpha-3). If you need "Germany" rather than "DE", pair with a country reference API like REST Countries. Both IPv4 and IPv6 work in the same path structure.

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

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

- **Need to detect the visitor's country without passing their IP through app code** → `GET /` (no path parameter) returns the country for the requesting IP — but only works correctly behind Cloudflare, which injects the `CF-IPCountry` header. Without Cloudflare, this returns your server's country, not the visitor's.
- **Need to verify GeoIP data freshness** → `GET /info` returns when the underlying GeoIP data sources were last updated. Reach for it if you suspect stale results for recently-reassigned IP blocks.
- **Need city, region, ASN, or timezone** → country.is does not provide sub-country data. Use a fuller geolocation service.

## Pitfalls

- **`country` is alpha-2 only.** You get `"DE"`, not `"Germany"`. Resolve display names separately.
- **`GET /` without Cloudflare returns your server's country**, not your visitor's. Extract the visitor's IP from `X-Forwarded-For` and call `GET /{ip}` explicitly.
- **No sub-country data.** City, region, ASN, and timezone are not available — `country` is the terminal resolution, not a starting point for deeper geolocation.

## One-line summary for the user

I can look up the country for any IPv4 or IPv6 address using country.is — no key required, but the response is only a two-letter ISO country code.

« Back to all skills