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.devPrints 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/meAlways 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| Status | Meaning |
|---|---|
200 | Data found |
400 | Not a valid IP address |
404 | No 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"
}| Field | Description |
|---|---|
ip | The address that was looked up |
city, postal | City name and postal code |
latitude, longitude | Approximate coordinates of the location |
timezone | IANA time zone, e.g. Europe/Vilnius |
is_eu | Whether the address is located in an EU member state |
asn.id, asn.handle, asn.company | Autonomous system (network) number, registry handle and operator |
network | The routed block the address belongs to, in CIDR notation |
registered_country_code, registered_country_name | Where the address block is registered; can differ from the location (e.g. mobile or cloud networks) |
accuracy_radius | Estimated accuracy of the location in kilometres; country-level records are typically 1000 |
region_code, region_name | State, province or region (ISO 3166-2 code and name), when known |
country_code, country_name | ISO 3166-1 alpha-2 code and English name |
country_capital, currency_*, phone_code, flag_emoji, tld | Country details |
continent_code, continent_name | Continent |
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.