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

ipflare

v2.0.0

Published

IP Geolocation API, our API enables you to effortlessly obtain precise geolocation data for any IP address through a single endpoint. Benefit from ultra-fast responses—typically between 50-100ms—and enjoy reliable performance with 99.9% uptime.

Readme

IP Flare

IP Geolocation API, our API enables you to effortlessly obtain precise geolocation data for any IP address through a single endpoint. Benefit from ultra-fast responses—typically between 50-200ms—and enjoy reliable performance with 99.9% uptime.

Visit our website: www.ipflare.io

Installation

Install the library using npm:

npm install ipflare

Getting Started

To use the library, you'll need an API key. You can obtain your API key from the IP Flare Dashboard.

Usage

Initialize the Library

import { IPFlare } from "ipflare";

// Initialize with your API key (required)
const geolocator = new IPFlare({
  apiKey: "your-api-key",
});

Result-Based API - No Try-Catch Required

The API methods return a Result object with an ok property, eliminating the need for try-catch blocks:

Single IP Lookup

// Result-based lookup - no try-catch needed
const result = await geolocator.lookup("178.238.11.6");

if (!result.ok) {
  // Handle different error types
  switch (result.error.type) {
    case 'INVALID_IP_ADDRESS':
      console.log('Invalid IP:', result.error.message);
      break;
    case 'RESERVED_IP_ADDRESS':
      console.log('Reserved IP:', result.error.message);
      break;
    case 'UNAUTHORIZED':
      console.log('API key issue:', result.error.message);
      break;
    case 'NO_API_KEY_PROVIDED':
      console.log('No API key provided:', result.error.message);
      break;
    case 'QUOTA_EXCEEDED':
      console.log('Quota exceeded:', result.error.message);
      break;
    case 'GEOLOCATION_NOT_FOUND':
      console.log('Geolocation not found:', result.error.message);
      break;
    case 'INTERNAL_SERVER_ERROR':
      console.log('Server error:', result.error.message);
      break;
    default:
      console.log('Error:', result.error.message);
  }
  return;
}

// TypeScript knows result.data is IPGeolocationResponse
console.log('Location:', result.data.city, result.data.country_name);

Bulk IP Lookup

// Result-based bulk lookup
const bulkResult = await geolocator.bulkLookup({
  ips: ["178.238.11.6", "1.1.1.1"],
  include: {
    asn: true,
    isp: true,
  },
});

if (!bulkResult.ok) {
  console.log('Bulk lookup failed:', bulkResult.error.message);
  return;
}

// Process results
for (const item of bulkResult.data) {
  if (item.status === 'success') {
    console.log(`${item.data.ip}: ${item.data.city}, ${item.data.country_name}`);
  } else {
    console.log(`${item.ip}: Error - ${item.error_message}`);
  }
}

Error Types

The Result-based API provides structured error types that match the actual API responses:

  • INVALID_IP_ADDRESS - Invalid IP address format
  • RESERVED_IP_ADDRESS - IP address is reserved (private/local)
  • GEOLOCATION_NOT_FOUND - Geolocation data not available for this IP
  • INTERNAL_SERVER_ERROR - Server-side error occurred
  • INVALID_INPUT - Invalid input parameters
  • UNAUTHORIZED - Invalid or missing API key
  • QUOTA_EXCEEDED - API quota exceeded
  • NO_API_KEY_PROVIDED - No API key was provided
  • NETWORK_ERROR - Network connectivity issues
  • VALIDATION_ERROR - Client-side input validation errors
  • UNKNOWN_ERROR - Unexpected errors

Additional Examples

Lookup with Additional Fields

const resultWithFields = await geolocator.lookup("178.238.11.6", {
  include: {
    asn: true,
    isp: true,
  },
});

if (resultWithFields.ok) {
  console.log('ASN:', resultWithFields.data.asn);
  console.log('ISP:', resultWithFields.data.isp);
} else {
  console.error('Lookup failed:', resultWithFields.error.message);
}

Using Type Guards

import { isSuccess, isError } from 'ipflare';

const result = await geolocator.lookup("8.8.8.8");

if (isSuccess(result)) {
  // TypeScript knows this is a success result
  console.log(`IP ${result.data.ip} is in ${result.data.country_name}`);
} else if (isError(result)) {
  // TypeScript knows this is an error result
  console.log(`Error: ${result.error.message}`);
}

Documentation

For more detailed information, please refer to our documentation:

Features

  • Result-based API: No try-catch required, all methods return Result types
  • Structured Error Handling: Comprehensive error types with detailed information
  • Single IP Lookup: Fast geolocation lookup for individual IP addresses
  • Bulk IP Lookup: Process up to 500 IPs in a single request
  • IPv4 & IPv6 Support: Full support for both IPv4 and IPv6 addresses
  • Optional Fields: ASN, ISP, and other additional data fields
  • TypeScript Support: Full type definitions with type guards
  • Input Validation: Client-side validation prevents invalid API calls
  • Production Ready: Comprehensive testing and enterprise-grade reliability