Get a public IP address with curl
This public IP address API returns the address observed for the connection making the request. Use it for a support check, a command-line script or an application diagnostic. No account or API key is required. It does not look up an arbitrary address or identify a person.
For a quick terminal check, use the default command or select an address family:
curl myip.dog
curl -4 myip.dog
curl -6 myip.dog
The homepage recognizes curl and returns one address followed by a newline; browsers receive the website. -4 selects an IPv4 connection, while -6 selects IPv6. The selected protocol must be available on your network. These bare-host commands use HTTP. For encrypted, predictable text output regardless of User-Agent, use:
curl --fail --silent --show-error --max-time 8 https://myip.dog/ip
For JSON with an address family, source and observation time:
curl --fail --silent --show-error --max-time 8 https://myip.dog/api/v1/ip
Run the request where you need to measure the connection. A browser observes its own exit; a backend request observes the backend's exit. Displaying a server's result as a visitor's address answers a different question. The homepage shortcut recognizes GET and HEAD requests whose User-Agent starts with curl/, case-insensitively.
JSON and plain-text response formats
The following is a documentation example, not a live observation. The address belongs to a reserved example range:
{
"code": 0,
"message": "ok",
"data": {
"ip": "203.0.113.10",
"version": 4,
"source": "cloudflare",
"observedAt": "2026-09-28T00:00:00.000Z"
}
}
Check the HTTP status and envelope. Success uses code: 0 with data; handled errors use code: -1, a message and no data. ip is a normalized string, version is the number 4 or 6, and observedAt is an ISO timestamp. Preserve IPv6 strings intact rather than splitting them on colons.
The source is cloudflare when the supported edge request provides trusted visitor information, or direct for a usable direct peer. Arbitrary forwarded headers alone cannot establish trust. If no trusted public address is available, the endpoint returns an error rather than substituting an external service or sample address.
The /ip endpoint returns the normalized address and a newline on success, or a readable error with a non-success status. Validate status before parsing the body. The OpenAPI contract describes both formats. Additional response fields may appear; validate the fields you consume.
Use the public IP address API from JavaScript
A deliberate support action usually needs one request and a refresh control. Avoid background polling or requests on every render.
async function observePublicIp() {
const response = await fetch('https://myip.dog/api/v1/ip', {
credentials: 'omit',
cache: 'no-store',
signal: AbortSignal.timeout(8000),
});
if (!response.ok) {
throw new Error(`Address check failed: HTTP ${response.status}`);
}
const result = await response.json();
if (
result.code !== 0 ||
typeof result.data?.ip !== 'string' ||
![4, 6].includes(result.data?.version)
) {
throw new Error('Unexpected address response');
}
return result.data;
}
This example checks transport and envelope; use a maintained address parser for input validation and catch failures where the action is handled. Older environments may need an AbortController timeout.
Both endpoints support GET, HEAD and OPTIONS, with wildcard CORS and no credentials. OPTIONS returns 204 without measuring an address. Retry-After is exposed to browser callers. Wildcard CORS does not support credentialed cross-origin responses, and some network failures provide no readable HTTP response.
Keep personalized results out of shared caches, including service workers. Responses send private, no-store cache controls; proxies must preserve them. A previous successful result should be labelled as previous while a new request is pending or has failed.
IP API rate limits and error handling
The runtime-local burst guard allows sixty successful GET or HEAD observations per trusted address in a fixed sixty-second window. JSON, text and homepage curl requests share that counter. People sharing a gateway may share a bucket. This is not a globally coordinated quota, guaranteed allowance or uptime commitment; infrastructure can impose additional restrictions.
| Status | Meaning and next action |
| ------ | ---------------------------------------------------------------------------------------------- |
| 200 | A public observation succeeded. HEAD has no address body. |
| 400 | Query parameters are unsupported; remove them. |
| 405 | Use GET or HEAD. OPTIONS is available for method discovery. |
| 429 | Respect the Retry-After duration before retrying. |
| 503 | A trusted public address or runtime capacity is unavailable. Follow a retry hint when present. |
Handle timeouts, DNS or TLS failures and non-JSON infrastructure errors too. Retry temporary failures with a small attempt budget, increasing waits and jitter. Do not retry malformed requests unchanged. HEAD uses the same checks and counter as GET; it is not an unlimited health probe. A localhost request can correctly return 503 because it has no trusted public caller address.
IPv4 and IPv6 responses from the IP API
Each response describes one connection. An IPv4 result does not establish that IPv6 is unavailable, and an IPv6 result does not enumerate all device addresses. Proxies, VPNs, routing and destination DNS can affect the selected path.
curl -4 --fail --silent --show-error --max-time 8 https://myip.dog/ip
curl -6 --fail --silent --show-error --max-time 8 https://myip.dog/ip
The same options work on the homepage shortcut and JSON endpoint. curl selects the connection protocol before sending the HTTP request; -6 is not an API query parameter. An IPv6 request returns the public IPv6 source observed for that connection, which may belong to a VPN or proxy exit.
These commands require corresponding destination DNS records and a working route. When IPv6 is unavailable, -6 fails rather than falling back to IPv4. A forced-family failure does not by itself identify a client fault. No dedicated protocol-only hostname is promised here. Use the IPv6 test for separate browser probes, or the outbound IP tool to compare named website exits.
Verify a public address endpoint integration
Test success, error statuses, malformed bodies, cancellation and slow responses in the environment where the integration will run. Confirm loading states end, copied output is correct, and stale observations remain clearly labelled. Use fixtures to exercise rate-limit handling rather than exhausting the public service.
Behind a proxy, verify the client-address handoff and test two independent connections for cache separation. Keep the address family and timestamp with a support report. These observations are connection information, not authentication credentials, permanent identities or proof that a VPN has no leaks.
Minimize retained data. The product database does not store these observations, but the burst guard temporarily keeps addresses in memory and hosting providers may maintain logs. Do not append secrets or account identifiers to endpoint URLs. This is not a zero-logging promise.
For human-readable results, open the homepage. For arbitrary address registration and approximate location, use IP lookup. The methodology and data sources explain evidence boundaries.
Contract and platform references
The response contract reflects this project's implementation. Platform references are the curl manual, MDN CORS guide, AbortSignal timeout documentation and Cloudflare request headers. They explain the underlying mechanisms and do not certify this deployment's availability.