Public IP address

Public IP address API for developers
5ms

About

Have you ever needed to programmatically obtain your public IP address? Whether you’re provisioning new cloud servers and need to identify your IP, or you’re behind a corporate firewall and need to tunnel information, having access to a public IP address API can be incredibly useful for various reasons!
by GLOBUS.studio

Endpoint

				
					/**
 * My IP Address API
 * GET https://api.globus.studio/v2/ip?format=json
 * GET https://api.globus.studio/v2/ip?v=6&format=json  (IPv6)
 * Response: { ip: "..." }
 */

async function getMyIp(v) {
    const url = new URL('https://api.globus.studio/v2/ip');
    url.searchParams.set('format', 'json');
    if (v) url.searchParams.set('v', v);

    const res = await fetch(url);
    return (await res.json()).ip;
}

// IPv4
getMyIp().then(ip => console.log(ip));

// IPv6
getMyIp(6).then(ip => console.log(ip));