npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

myip-foo

v1.0.0

Published

Official client library for myip.foo - free IP lookup API with geolocation

Readme

myip-foo

Official JavaScript/TypeScript client for myip.foo - a free, privacy-focused IP lookup API.

npm version License: MIT

Features

  • Full TypeScript support
  • Works in Node.js and browsers
  • React hooks included
  • Dual-stack IPv4/IPv6 support
  • No API key required
  • Zero dependencies (React is optional)

Installation

npm install myip-foo

Quick Start

Node.js / Browser

import { getIP, getIPData, getDualStack } from 'myip-foo';

// Get plain IP
const ip = await getIP();
console.log(ip); // "203.0.113.42"

// Get full data with geolocation
const data = await getIPData();
console.log(data.ip);                    // "203.0.113.42"
console.log(data.location.city);         // "Amsterdam"
console.log(data.location.country);      // "NL"
console.log(data.network.isp);           // "KPN B.V."
console.log(data.connectionType);        // "residential"

// Get both IPv4 and IPv6
const dualStack = await getDualStack();
console.log(dualStack.ipv4); // "203.0.113.42"
console.log(dualStack.ipv6); // "2001:db8::1" or null

React

import { useIPData, useDualStack, useIP } from 'myip-foo';

function MyComponent() {
  const { data, loading, error, refetch } = useIPData();

  if (loading) return <p>Loading...</p>;
  if (error) return <p>Error: {error}</p>;

  return (
    <div>
      <p>IP: {data?.ip}</p>
      <p>Location: {data?.location.city}, {data?.location.country}</p>
      <p>ISP: {data?.network.isp}</p>
      <button onClick={refetch}>Refresh</button>
    </div>
  );
}

API Reference

Functions

getIP(): Promise<string>

Returns your IP address as plain text.

getIPData(): Promise<IPData>

Returns full IP data including geolocation.

getDualStack(): Promise<DualStackData>

Returns both IPv4 and IPv6 addresses (uses dedicated endpoints).

getConnectionType(): Promise<ConnectionTypeData>

Detects if connection is residential, VPN, or datacenter.

getHeaders(): Promise<Record<string, string>>

Returns all HTTP headers as seen by the server.

getUserAgent(): Promise<string>

Returns your user agent string.

React Hooks

useIPData()

Hook for fetching full IP data.

const { data, loading, error, refetch } = useIPData();

useDualStack()

Hook for fetching IPv4 and IPv6.

const { data, loading, error, refetch } = useDualStack();
// data.ipv4, data.ipv6

useIP()

Hook for fetching plain IP.

const { ip, loading, error, refetch } = useIP();

Types

interface IPData {
  ip: string;
  type: 'IPv4' | 'IPv6';
  hostname?: string;
  connectionType?: 'residential' | 'vpn' | 'datacenter' | 'tor';
  location: {
    country: string;
    city: string;
    region: string;
    postalCode: string;
    timezone: string;
    latitude: string;
    longitude: string;
  };
  network: {
    asn: number;
    isp: string;
  };
  cloudflare: {
    colo: string;
    ray: string;
  };
}

interface DualStackData {
  ipv4: string | null;
  ipv6: string | null;
}

interface ConnectionTypeData {
  ip: string;
  type: 'residential' | 'vpn' | 'datacenter' | 'unknown';
}

Dual-Stack Endpoints

The getDualStack() function uses dedicated subdomains with direct DNS records:

  • ipv4.myip.foo/ip - Returns IPv4 only (A record)
  • ipv6.myip.foo/ip - Returns IPv6 only (AAAA record)

This bypasses Cloudflare's dual-stack routing for accurate results.

Privacy

myip.foo does not log IP addresses or use cookies. See Privacy Policy.

Links

License

MIT License - see LICENSE for details.