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
}
}
| Field | Type | Meaning |
|---|---|---|
ip | string | The address this request came from, IPv4 or IPv6. |
country.code | string | ISO 3166-1 alpha-2 code. Empty when unknown. |
country.name | string | Country name in English. |
country.flag | string | Flag emoji. |
country.dial_code | number | International calling code. |
country.capital | string | Capital city. |
location.city | string | City, when the database has one. Often empty for mobile and VPN addresses. |
location.region | string | State, province or region. |
location.postal_code | string | Postal code, when known. |
location.latitude | number | Approximate latitude of the address's network, not of the device. |
location.longitude | number | Approximate longitude, as above. |
location.timezone | string | IANA time zone, e.g. America/Chicago. |
network.verdict | string | One label for the connection: tor, vpn, hosting or isp (first match wins; see below). |
network.isp | string | The organisation that announces the address (from the ASN database). |
network.asn | number | Autonomous system number. |
network.is_vpn | boolean | The address is on our VPN list. |
network.is_tor | boolean | The address is a current Tor exit. |
device.browser | string | Browser, from the User-Agent header. |
device.browser_version | string | Browser major version. |
device.os | string | Operating system. |
device.os_version | string | Operating system version, when the User-Agent still reports one. |
device.type | string | desktop, mobile, tablet or bot. |
language.code | string | First language in Accept-Language. |
language.name | string | That language's English name. |
visitor.is_returning | boolean | Only meaningful in a browser on this site. Always false for API clients. |
visitor.id | string | This site's visitor cookie, when the request carries it. (may be absent) |
visitor.visit_count | number | Page views from this browser, when it carries the cookie. (may be absent) |
visitor.last_country | string | Not sent to API calls. (may be absent) |
network.verdict
| Value | Meaning |
|---|---|
tor | The address is a current Tor exit. |
vpn | The address is on our VPN list. |
hosting | A 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. |
isp | None 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"
]
}
}
| Field | Type | Meaning |
|---|---|---|
code | string | ISO 3166-1 alpha-2 code. |
name | string | Name in English. |
altnames[] | string[] | Other names the country goes by. (may be absent) |
dial_code | number | International calling code. |
tld | string | Country-code top-level domain, without the dot. (may be absent) |
population | string | Population, formatted for display. |
area | string | Area in km², sometimes followed by square miles in brackets. |
capital | string | Capital city. |
currency | string | Currency. |
gdp | string | GDP, formatted for display. |
languages[] | string[] | Main languages. |
flag_emoji | string | Flag 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_of | string | Year the figures refer to. Not yet filled for any country. (may be absent) |
sources[].name | string | Where the figures came from. Not yet filled for any country. (may be absent) |
sources[].url | string | Link 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"}
| Status | When |
|---|---|
400 | /api/v1/country/ with no code. |
404 | No such country; or /country with no country for your address. |
405 | /ip or /country with a method other than GET or HEAD. |
429 | Over 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-RemainingandRateLimit-Reset(seconds until the count starts again). Over the limit you get429withRetry-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:
/ipand/country;RateLimit-*headers andRetry-After; JSON errors on/api/v1/meand/api/v1/country/{code};network.verdictin/api/v1/me.