Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ip-details-fetcher

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip-details-fetcher

Best NPM package to fetch IP details

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Best NPM package to fetch IP details using the ipinfo.io API.

Installation

npm install ip-details-fetcher

Usage

import { getIPDetails } from 'ip-details-fetcher';

const token = 'YOUR_TOKEN_HERE'; // Replace with your actual token

getIPDetails(token).then(ipDetails => {
  console.log('IP Details:', ipDetails);
}).catch(error => {
  console.error('Error fetching IP details:', error);
});

Getting Your API Token

To use this package, you need an API token from ipinfo.io. Follow these steps to get your token:

  1. Visit the ipinfo.io website.
  2. Sign up for an account or log in if you already have one.
  3. Once logged in, you will find your API token on the account home page.
  4. Copy the token and replace 'YOUR_TOKEN_HERE' in the usage example above with your actual token.

Example

import React, { useEffect, useState } from 'react';
import { getIPDetails, IPDetails } from 'ip-details-fetcher';

const App = () => {
  const [ipDetails, setIpDetails] = useState<IPDetails | null>(null);
  const token = 'YOUR_TOKEN_HERE'; // Replace with your actual token

  useEffect(() => {
    getIPDetails(token).then(setIpDetails).catch(error => console.error('Error fetching IP details:', error));
  }, [token]);

  if (!ipDetails) return <div>Loading...</div>;

  return (
    <div>
      <h1>Your IP Details</h1>
      <p><strong>IP:</strong> {ipDetails.ip}</p>
      <p><strong>City:</strong> {ipDetails.city}</p>
      <p><strong>Region:</strong> {ipDetails.region}</p>
      <p><strong>Country:</strong> {ipDetails.country}</p>
      <p><strong>Latitude and Longitude:</strong> {ipDetails.latitude}, {ipDetails.longitude}</p>
      <p><strong>Timezone:</strong> {ipDetails.timezone}</p>
      <p><strong>ISP:</strong> {ipDetails.org}</p>
    </div>
  );
};

export default App;

License

This package is licensed under the ISC License.


This README.md provides clear instructions on how to install, use the package, and obtain the necessary API token from ipinfo.io.

Keywords

FAQs

Package last updated on 15 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc