IP geolocation API

A free JSON API for IP address geolocation and network details, the same data shown on this site. No API key or sign-up needed.

Your IP address in a terminal

curl -L showmyip.dev

Prints just your public IP address. Works with curl, wget, HTTPie, xh and PowerShell. The -L flag follows the redirect to https://www.showmyip.dev.

Endpoints

GET /api/me

Geolocation data for the IP address making the request.

curl https://www.showmyip.dev/api/me

Always returns 200 with at least { "ip": "..." }; location fields are included when known.

GET /api/{ip}

Geolocation data for any IPv4 or IPv6 address.

curl https://www.showmyip.dev/api/8.8.8.8
StatusMeaning
200Data found
400Not a valid IP address
404No data for this address, e.g. private or reserved ranges

Response

Fields are omitted when unknown, so check for their presence. Example for 81.7.98.1:

{
  "ip": "81.7.98.1",
  "city": "Vilnius",
  "is_eu": true,
  "postal": "01001",
  "latitude": 54.6876,
  "longitude": 25.2806,
  "timezone": "Europe/Vilnius",
  "asn": {
    "id": 8764,
    "handle": "TELIA-LIETUVA",
    "company": "Telia Lietuva AB"
  },
  "network": "81.7.96.0/21",
  "registered_country_code": "LT",
  "registered_country_name": "Lithuania",
  "accuracy_radius": 100,
  "region_code": "VL",
  "region_name": "Vilnius",
  "country_code": "LT",
  "country_name": "Lithuania",
  "country_capital": "Vilnius",
  "currency_code": "EUR",
  "currency_name": "Euro",
  "currency_symbol": "€",
  "phone_code": "370",
  "flag_emoji": "🇱🇹",
  "tld": ".lt",
  "continent_code": "EU",
  "continent_name": "Europe"
}
FieldDescription
ipThe address that was looked up
city, postalCity name and postal code
latitude, longitudeApproximate coordinates of the location
timezoneIANA time zone, e.g. Europe/Vilnius
is_euWhether the address is located in an EU member state
asn.id, asn.handle, asn.companyAutonomous system (network) number, registry handle and operator
networkThe routed block the address belongs to, in CIDR notation
registered_country_code, registered_country_nameWhere the address block is registered; can differ from the location (e.g. mobile or cloud networks)
accuracy_radiusEstimated accuracy of the location in kilometres; country-level records are typically 1000
region_code, region_nameState, province or region (ISO 3166-2 code and name), when known
country_code, country_nameISO 3166-1 alpha-2 code and English name
country_capital, currency_*, phone_code, flag_emoji, tldCountry details
continent_code, continent_nameContinent

Using it from a website

CORS is enabled, so you can call the API directly from browser JavaScript on any site:

const res = await fetch("https://www.showmyip.dev/api/me");
const { ip, country_name } = await res.json();

Caching and fair use

Responses for /api/{ip} are cached for a day; /api/me is never cached. Location data is refreshed weekly. Please keep request rates reasonable; heavy automated use may be rate-limited.

You can also look up any address on the site, e.g. /ip/8.8.8.8.

Data sources

Location data from MaxMind GeoLite2 (maxmind.com); network names from ipverse/as-metadata. IP geolocation is approximate, typically accurate to the country and often the city, never to a street address.