API

Get your public IP address from a script. Free, no key, and safe to call from a browser.

Quick start

curl https://webiptool.com/ip

That returns your address and a newline, nothing else:

203.0.113.42

Endpoints

RequestReturns
GET https://webiptool.com/ipYour address as plain text, over whichever protocol your client chose
GET https://webiptool.com/api/ipYour address plus network and location details, as JSON

JSON details

curl https://webiptool.com/api/ip
{
  "ip": "203.0.113.42",
  "version": 4,
  "isp": "Example Fiber",
  "asn": 64500,
  "city": "Austin",
  "region": "Texas",
  "region_code": "TX",
  "country": "United States",
  "country_code": "US",
  "postal_code": "78701",
  "latitude": 30.2713,
  "longitude": -97.7426,
  "timezone": "America/Chicago",
  "colo": "DFW"
}

Every field is always present. A field is null when the value is not known, which is common for city and postal code.

FieldTypeMeaning
ipstringYour public IP address.
versionnumber4 or 6.
ispstringThe organization that operates your network.
asnnumberAutonomous system number of that network.
citystringApproximate city.
regionstringApproximate region or state.
region_codestringRegion code, such as TX.
countrystringCountry name in English.
country_codestringTwo-letter ISO 3166-1 country code.
postal_codestringApproximate postal code.
latitudenumberApproximate latitude.
longitudenumberApproximate longitude.
timezonestringIANA timezone name, such as America/Chicago.
colostringAirport code of the Cloudflare data center that answered.

Location fields are estimates based on your IP address. They often point to your provider's equipment and should not be used to locate a person. See what your IP address reveals.

Forcing IPv4 or IPv6

On a connection with both protocols, your client decides which one to use, so /ip may return either. To get a specific one, tell your client which protocol to connect with. In curl that is -4 or -6.

curl -4 https://webiptool.com/ip
curl -6 https://webiptool.com/ip

If your network has no IPv6, the second command fails to connect. That is the expected result, and a useful test in itself.

Examples

Shell

MY_IP=$(curl -s https://webiptool.com/ip)
echo "My address is $MY_IP"

JavaScript

const response = await fetch('https://webiptool.com/api/ip');
const { ip, country } = await response.json();

Python

import json, urllib.request

with urllib.request.urlopen('https://webiptool.com/api/ip') as response:
    data = json.load(response)
print(data['ip'])

Limits

Up to 60 requests per 60 seconds from one IP address. That is generous for a script that checks its address and far too low for anything that hammers the service.

Over the limit you receive HTTP 429 with a Retry-After header giving the number of seconds to wait. Please honor it. Addresses shared by many people, such as mobile networks, share one allowance.

Responses

StatusMeaning
200Success
404The family hostnames serve only / and /json
429Rate limit exceeded. Wait for the time in Retry-After
503The address could not be determined. Rare. Try again

All endpoints send Access-Control-Allow-Origin: *, so they can be called from browser code on any site. Responses are never cached (Cache-Control: no-store).

Using it responsibly

  • Point scripts, monitors, and automated tools at the endpoints on this page, not at the web pages. The endpoints are built for it and carry no ads.
  • Cache the result if you only need it occasionally. Your address rarely changes minute to minute.
  • The service is free and comes with no uptime guarantee. Handle errors gracefully.
  • Nothing you send is stored. See the Privacy Policy and the Terms of Use.