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.
If your connection has IPv6, that is the address you get. ipv4.showmyip.dev is reachable only over IPv4, so it always answers with your IPv4 address, and works with every path below:
curl -L ipv4.showmyip.dev # your IPv4 address
curl -6 https://www.showmyip.dev # your IPv6 address; fails without IPv6Add a field to print just that value, one line of plain text, or get everything as JSON:
curl -L showmyip.dev/country # Lithuania
curl -L showmyip.dev/asn # AS8764
curl -L showmyip.dev/json # same as /api/me| Path | Prints |
|---|---|
/ip | 81.7.98.1 |
/hostname | 81-7-98-1.static.zebra.lt |
/city | Vilnius |
/region | Vilnius |
/country | Lithuania |
/country-code | LT |
/continent | Europe |
/timezone | Europe/Vilnius |
/location | 54.6876,25.2806 (latitude,longitude) |
/postal | 01001 |
/asn | AS8764 |
/org | Telia Lietuva AB |
/network | 81.7.96.0/21 |
When a value isn't known for your address, the response is 404 with an explanation, so curl --fail can detect it in scripts.
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 |
GET /api/asn/{number}
An autonomous system's name, handle and registration country, and all the address ranges mapped to it, the same data as the AS pages. The number can be written as 15169 or AS15169.
curl https://www.showmyip.dev/api/asn/15169{
"asn": 15169,
"organization": "Google LLC",
"handle": "GOOGLE",
"country_code": "US",
"country_name": "United States",
"flag_emoji": "πΊπΈ",
"ipv4": [
{ "start": "8.8.4.0", "end": "8.8.4.255", "cidr": "8.8.4.0/24" },
{ "start": "34.0.16.0", "end": "34.0.63.255" },
β¦
],
"ipv6": [ β¦ ],
"ipv4_addresses": 2491392
}Ranges are listed in address order with adjacent ones merged; cidr is included when a range is exactly one block. 400 means the number isn't valid, 404 that no data is known for it.
POST /api/bulk
Up to 1,000 addresses in one request, the same data as the bulk lookup. Send a JSON array (or {"ips": [...]}), or plain text with one address per line or separated by commas or spaces.
curl -X POST https://www.showmyip.dev/api/bulk -H "Content-Type: application/json" -d '["8.8.8.8", "1.1.1.1"]'{
"count": 2,
"results": [
{ "ip": "8.8.8.8", "country_code": "US", "asn": { "id": 15169, "company": "Google LLC" }, ... },
{ "ip": "1.1.1.1", ... }
],
"invalid": [],
"duplicates": 0
}Each result has the same fields as /api/{ip} except hostname, in the order sent and without duplicates; an address with no data has an error field instead. Entries that aren't addresses are listed in invalid. 400 means no valid address was sent, 413 that there are more than 1,000.
Response
Fields are omitted when unknown, so check for their presence. Example for 81.7.98.1:
{
"ip": "81.7.98.1",
"hostname": "81-7-98-1.static.zebra.lt",
"hostname_verified": false,
"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",
"country_code": "LT",
"country_name": "Lithuania"
},
"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",
"is_hosting": false,
"is_tor": false,
"continent_code": "EU",
"continent_name": "Europe"
}| Field | Description |
|---|---|
ip | The address that was looked up |
hostname | Reverse DNS name of the address, when it has one (/api/{ip} only, not /api/me) |
hostname_verified | Whether the hostname points back to the address (forward-confirmed). Anyone controlling an address block can publish any name, so only a verified one is trustworthy. Omitted when the check couldn't be done |
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 |
asn.country_code, asn.country_name | Where the network is registered, which can differ from the address's location |
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 |
is_hosting | Whether the network is a hosting, cloud or data-centre provider: likely a server, VPN or proxy. A VPN or proxy on a home connection isn't detected |
is_tor | Whether the address is a current Tor exit node (from the Tor Project's list, updated hourly) |
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.