Choose an explicit endpoint
For a text response, use /api/raw-ip. For JSON, use /api/ip. The home page also returns plain text to curl and wget, but explicit API paths make a script independent of user-agent detection. The JSON response includes family, ip, and available.
The returned IP is the public source used for that request. A script running on a VPS reports the VPS connection, not your laptop. A container, VPN, proxy, or NAT gateway can also affect what appears.
# Plain text, with HTTP errors and timeouts handled
curl --fail --silent --show-error --max-time 10 https://myip.dk/api/raw-ip
# JSON over a chosen transport family
curl -4 --fail --max-time 10 https://myip.dk/api/ip
curl -6 --fail --max-time 10 https://myip.dk/api/ip
# PowerShell
(Invoke-RestMethod -Uri "https://myip.dk/api/ip" -TimeoutSec 10).ip Worked example: keep the last good address
Suppose a scheduled job updates a DNS record when your address changes. If the lookup returns HTTP 429 or times out, replacing the record with an empty string would turn a temporary lookup problem into a service outage. Treat failure as “no new observation,” preserve the last known value, and try again later.
Validate the returned address with your language’s IP parser, compare it with the stored value, and update only when it has changed. The commands above exit unsuccessfully on HTTP errors; check that status before consuming their output.
Budget for shared limits
Address endpoints share an in-memory token bucket per observed client IP: a burst capacity of 20 requests and a refill of 60 requests per hour. Text and JSON address requests use that bucket. DNS and IP lookups share a separate bucket with a burst of 60 and a refill of six requests per minute. Browsers, scripts, and other people behind the same public IPv4 share each applicable allowance. A DNS overview consumes ten tool requests and a resolver comparison consumes two.
A 429 response includes Retry-After in seconds. Wait at least that long before another request. Use a timeout, back off after repeated failures, and avoid tight polling loops. A network-change event or a modest scheduled interval is usually more useful than checking every second.
Do not confuse filtering with transport selection
The /api/ip/v4 and /api/ip/v6 routes validate the observed address family. A path suffix cannot force your HTTP client to choose IPv4 or IPv6. Use curl -4 or curl -6 for that. Browser checks use separate hostnames whose DNS must isolate the intended family.
If a proxy makes the outbound request on your behalf, forcing the client’s connection to that proxy may not determine the proxy’s connection to our service. Interpret the result in the context of your configured network path.