Free IP and Country API

No key, no sign-up. Plain text for scripts, JSON for apps.

Try it

curl https://whatismycountry.com/ip 216.73.217.140
curl https://whatismycountry.com/country US

That's what you'd get right now. Each line ends with a newline, and nothing else is printed.

Plain text: /ip and /country

One line, text/plain; charset=utf-8, never cached. GET and HEAD work; anything else gets 405.

GET/ip

The address your request came from.

$ curl https://whatismycountry.com/ip
203.0.113.7

GET/country

Your country as an ISO 3166-1 alpha-2 code. When there's none (a private address, or no data for it) the answer is 404 with the body unknown, so curl -f fails instead of printing an empty line.

$ curl https://whatismycountry.com/country
US

IPv4 or IPv6, on purpose

ipv4.whatismycountry.com has only an IPv4 address and ipv6.whatismycountry.com only an IPv6 one, so asking either shows that address type even on a machine that prefers the other. curl -4 and curl -6 do the same against the main hostname.

$ curl https://ipv6.whatismycountry.com/ip
2001:db8::7

Your connection as JSON

GET/api/v1/me

Everything this site knows about the request: address, location, network, device and language. Never cached.

$ curl https://whatismycountry.com/api/v1/me
{
  "ip": "203.0.113.7",
  "country": {
    "code": "US",
    "name": "United States",
    "flag": "🇺🇸",
    "dial_code": 1,
    "capital": "Washington, D.C."
  },
  "location": {
    "city": "Chicago",
    "region": "Illinois",
    "postal_code": "60601",
    "latitude": 41.8835,
    "longitude": -87.6305,
    "timezone": "America/Chicago"
  },
  "network": {
    "verdict": "isp",
    "isp": "Example Broadband",
    "asn": 64496,
    "is_vpn": false,
    "is_tor": false
  },
  "device": {
    "browser": "Firefox",
    "browser_version": "133",
    "os": "Windows",
    "os_version": "10/11",
    "type": "desktop"
  },
  "language": {
    "code": "en",
    "name": "English"
  },
  "visitor": {
    "is_returning": false
  }
}
FieldTypeMeaning
ipstringThe address this request came from, IPv4 or IPv6.
country.codestringISO 3166-1 alpha-2 code. Empty when unknown.
country.namestringCountry name in English.
country.flagstringFlag emoji.
country.dial_codenumberInternational calling code.
country.capitalstringCapital city.
location.citystringCity, when the database has one. Often empty for mobile and VPN addresses.
location.regionstringState, province or region.
location.postal_codestringPostal code, when known.
location.latitudenumberApproximate latitude of the address's network, not of the device.
location.longitudenumberApproximate longitude, as above.
location.timezonestringIANA time zone, e.g. America/Chicago.
network.verdictstringOne label for the connection: tor, vpn, hosting or isp (first match wins; see below).
network.ispstringThe organisation that announces the address (from the ASN database).
network.asnnumberAutonomous system number.
network.is_vpnbooleanThe address is on our VPN list.
network.is_torbooleanThe address is a current Tor exit.
device.browserstringBrowser, from the User-Agent header.
device.browser_versionstringBrowser major version.
device.osstringOperating system.
device.os_versionstringOperating system version, when the User-Agent still reports one.
device.typestringdesktop, mobile, tablet or bot.
language.codestringFirst language in Accept-Language.
language.namestringThat language's English name.
visitor.is_returningbooleanOnly meaningful in a browser on this site. Always false for API clients.
visitor.idstringThis site's visitor cookie, when the request carries it. (may be absent)
visitor.visit_countnumberPage views from this browser, when it carries the cookie. (may be absent)
visitor.last_countrystringNot sent to API calls. (may be absent)

network.verdict

ValueMeaning
torThe address is a current Tor exit.
vpnThe address is on our VPN list.
hostingA data-centre address: on a cloud or hosting provider's published ranges, or announced by a hosting network. Often a VPN or proxy we don't list, or a server.
ispNone of the above. Not a claim that the connection is residential or mobile: our data has no connection type.

The first that matches wins, in that order. is_vpn and is_tor are kept for older clients.

Country data

GET/api/v1/country/{code}

Facts about one country, by ISO 3166-1 alpha-2 code (any case). The same data as the country pages.

$ curl https://whatismycountry.com/api/v1/country/US
{
  "code": "US",
  "name": "United States",
  "altnames": [
    "United States of America",
    "USA"
  ],
  "dial_code": 1,
  "tld": "us",
  "population": "349,000,000",
  "area": "9,833,517 km² (3,805,927 sq mi)",
  "capital": "Washington, D.C.",
  "currency": "USD (United States Dollar)",
  "gdp": "32.4 trillion USD",
  "languages": [
    "English",
    "Spanish",
    "Chinese",
    "Tagalog",
    "French",
    "Vietnamese",
    "Korean",
    "Russian",
    "Arabic",
    "Hindi",
    "and many others"
  ],
  "flag_emoji": "🇺🇸",
  "description": [
    "Where the only thing we take more seriously than ourselves is our coffee.",
    "United States: Where we drive 4,000 miles for a decent slice of pizza, but won't walk 100 feet for a decent conversation.",
    "United States: Where we can debate the meaning of life, but will still argue over who ate the last donut.",
    "The US has no official national language at the federal level, although English is the most widely spoken.",
    "GPS (Global Positioning System) was developed by the US Department of Defense and is now used worldwide."
  ],
  "additional_info": {
    "time_zones": [
      "UTC-5",
      "UTC-6",
      "UTC-7",
      "UTC-8",
      "UTC-9",
      "UTC-10"
    ],
    "largest_cities": [
      "New York City",
      "Los Angeles",
      "Chicago"
    ]
  }
}
FieldTypeMeaning
codestringISO 3166-1 alpha-2 code.
namestringName in English.
altnames[]string[]Other names the country goes by. (may be absent)
dial_codenumberInternational calling code.
tldstringCountry-code top-level domain, without the dot. (may be absent)
populationstringPopulation, formatted for display.
areastringArea in km², sometimes followed by square miles in brackets.
capitalstringCapital city.
currencystringCurrency.
gdpstringGDP, formatted for display.
languages[]string[]Main languages.
flag_emojistringFlag emoji.
description[]string[]Short, light-hearted descriptions written for this site.
additional_info.time_zones[]string[]UTC offsets in use.
additional_info.largest_cities[]string[]Largest cities.
as_ofstringYear the figures refer to. Not yet filled for any country. (may be absent)
sources[].namestringWhere the figures came from. Not yet filled for any country. (may be absent)
sources[].urlstringLink to that source. (may be absent)

Errors

The JSON endpoints answer errors as JSON, with Content-Type: application/json; the plain-text ones answer in plain text.

$ curl https://whatismycountry.com/api/v1/country/ZZ
{"error":"Country not found"}
StatusWhen
400/api/v1/country/ with no code.
404No such country; or /country with no country for your address.
405/ip or /country with a method other than GET or HEAD.
429Over the daily limit. Wait the number of seconds in Retry-After.

Limits and terms

  • Free for any use, commercial included, within the limit. No key, no account.
  • 1000 requests per 24 hours per IP address, shared with the rest of the site. Every API response says where you stand: RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset (seconds until the count starts again). Over the limit you get 429 with Retry-After.
  • No uptime guarantee. It runs on the same server as this site and is as available as the site is.
  • Attribution is appreciated, not required: a link to whatismycountry.com where you use it.
  • Responses are CORS-enabled (Access-Control-Allow-Origin: *), so a browser on any site can call them.
  • Requests are logged like any other visit to this site, and kept for 90 days. See the privacy policy.

Where the data comes from

  • Location and network: MaxMind's GeoLite2 City and ASN databases. Country is usually right; city is often approximate, and for mobile and VPN addresses often missing. This product includes GeoLite2 data created by MaxMind, available from https://www.maxmind.com.
  • Tor: the Tor Project's own list of exit addresses, refreshed daily.
  • VPN and hosting: community lists of VPN ranges, the ranges cloud and hosting providers publish themselves, and our own list of hosting networks. They are incomplete by nature: an address that isn't on them reads isp.

Code samples

Shell

curl https://whatismycountry.com/ip
curl https://whatismycountry.com/country
curl -s https://whatismycountry.com/api/v1/me | jq .network.verdict

JavaScript

const res = await fetch('https://whatismycountry.com/api/v1/me');
const me = await res.json();
console.log(me.ip, me.country.code, me.network.verdict);

Python

import requests

me = requests.get("https://whatismycountry.com/api/v1/me", timeout=5).json()
print(me["ip"], me["country"]["code"], me["network"]["verdict"])

Go

package main

import (
	"encoding/json"
	"fmt"
	"net/http"
)

func main() {
	resp, err := http.Get("https://whatismycountry.com/api/v1/me")
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	var me struct {
		IP      string `json:"ip"`
		Country struct {
			Code string `json:"code"`
		} `json:"country"`
		Network struct {
			Verdict string `json:"verdict"`
		} `json:"network"`
	}
	if err := json.NewDecoder(resp.Body).Decode(&me); err != nil {
		panic(err)
	}
	fmt.Println(me.IP, me.Country.Code, me.Network.Verdict)
}

Widget

Shows a visitor's flag, country, city and IP on your page. It calls /api/v1/me from their browser, so each visitor sees their own.

<div id="wimc-widget"></div>
<script src="https://whatismycountry.com/widget.js" async></script>

Add data-style="compact" to the div for a single line. Every element whose id starts with wimc-widget is filled, so you can have several.

Changes

Fields in v1 are only ever added, never renamed or removed. A change that breaks that would be /api/v2/, with v1 left running.

  • 2026-11-29: /ip and /country; RateLimit-* headers and Retry-After; JSON errors on /api/v1/me and /api/v1/country/{code}; network.verdict in /api/v1/me.