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 🙏

© 2026 – Pkg Stats / Ryan Hefner

nuip

v1.0.1

Published

Node.js package to get user details from IP address

Readme

nuip

nuip is a lightweight Node.js package that fetches user location details based on their IP address. It uses ip-api.com to retrieve the data and supports both real and development modes.

📞 Installation

Install nuip using npm:

npm install nuip

If you're using TypeScript, you might also want to install the necessary types:

npm install --save-dev @types/node

🚀 Usage

Import the Package

You can import getNuip in both JavaScript and TypeScript:

import { getNuip } from "nuip";

🔍 Fetching IP Information

Basic Usage

import { getNuip } from "nuip";

async function fetchIpInfo() {
  const ipInfo = await getNuip();
  console.log(ipInfo);
}

fetchIpInfo();

By default, this will return the IP details of the requesting client.


🌍 Using in an Express Server

If you're using Express, you can create an API endpoint:

import express, { Request, Response } from "express";
import { getNuip } from "nuip";

const app = express();
const port = 3000;

app.get("/getNuip", async (req: Request, res: Response) => {
  try {
    const ipInfo = await getNuip(req);
    res.json(ipInfo);
  } catch (error) {
    res.status(500).json({ error: "Failed to fetch IP info" });
  }
});

app.listen(port, () => {
  console.log(`Server running on http://localhost:${port}`);
});

⚙️ Advanced Options

You can pass an options object to getNuip:

const ipInfo = await getNuip(req, { devMode: true, includeDetails: false });

Options:

| Option | Type | Default | Description | | ---------------- | --------- | ------- | -------------------------------------------------------- | | req | Request | - | (Optional) Express request object to get real client IP. | | devMode | boolean | false | If true, returns mock data (0.0.0.0). | | includeDetails | boolean | true | If false, fetches only basic details. |


📝 Response Format

By default, getNuip returns an object like this:

{
  "devMode": false,
  "ip": "0.0.0.0",
  "continent": "Unknown",
  "continentCode": "XX",
  "country": "Unknown",
  "countryCode": "XX",
  "region": "X",
  "regionName": "Unknown Region",
  "city": "Unknown City",
  "district": "",
  "zip": "0000",
  "lat": 0.0,
  "lon": 0.0,
  "timezone": "UTC",
  "offset": 0,
  "currency": "XXX",
  "isp": "Unknown ISP",
  "org": "Unknown Organization",
  "as": "AS00000 Unknown ASN",
  "asname": "UNKNOWN-ASN"
}

If devMode: true, it returns mock data:

{
  "devMode": false,
  "ip": "0.0.0.0",
  "continent": "Unknown",
  "continentCode": "XX",
  "country": "Unknown",
  "countryCode": "XX",
  "region": "X",
  "regionName": "Unknown Region",
  "city": "Unknown City",
  "district": "",
  "zip": "0000",
  "lat": 0.0,
  "lon": 0.0,
  "timezone": "UTC",
  "offset": 0,
  "currency": "XXX",
  "isp": "Unknown ISP",
  "org": "Unknown Organization",
  "as": "AS00000 Unknown ASN",
  "asname": "UNKNOWN-ASN"
}

⚖️ Development Mode

When running in a development environment, you can use:

const ipInfo = await getNuip(null, { devMode: true });
console.log(ipInfo);

This will return mock IP data (0.0.0.0) instead of making an API request.


🗃️ License

This project is licensed under the MIT License.


👯️ Contact

For questions or suggestions, feel free to open an issue on GitHub.