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/ipThat returns your address and a newline, nothing else:
203.0.113.42Endpoints
| Request | Returns |
|---|---|
GET https://webiptool.com/ip | Your address as plain text, over whichever protocol your client chose |
GET https://webiptool.com/api/ip | Your 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.
| Field | Type | Meaning |
|---|---|---|
ip | string | Your public IP address. |
version | number | 4 or 6. |
isp | string | The organization that operates your network. |
asn | number | Autonomous system number of that network. |
city | string | Approximate city. |
region | string | Approximate region or state. |
region_code | string | Region code, such as TX. |
country | string | Country name in English. |
country_code | string | Two-letter ISO 3166-1 country code. |
postal_code | string | Approximate postal code. |
latitude | number | Approximate latitude. |
longitude | number | Approximate longitude. |
timezone | string | IANA timezone name, such as America/Chicago. |
colo | string | Airport 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/ipIf 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
| Status | Meaning |
|---|---|
200 | Success |
404 | The family hostnames serve only / and /json |
429 | Rate limit exceeded. Wait for the time in Retry-After |
503 | The 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.