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 🙏

© 2024 – Pkg Stats / Ryan Hefner

asn-from-ip

v1.0.5

Published

This tiny module allows you to get ASN information for each IP address. The output includes IP suffixes, AS type, AS country, AS organisation and so on...

Downloads

30

Readme

IP to ASN

Npm package version Npm package yearly downloads

This tiny package allows you to obtain ASN meta information for any IP address. Some IP addresses are of course not assigned to an ASN.

Installation

npm install asn-from-ip

If you want to clone the repository directly from GitHub instead:

git clone [email protected]:ipapi-is/ip_to_asn.git

Usage from Node.js

Lookup the IP address 95.91.211.148:

const { ipToASN } = require('asn-from-ip');

(async () => {
  console.log(await ipToASN('95.91.211.148'));
})();

which outputs (at the time of writing):

{
  asn: 3209,
  route: '95.88.0.0/14',
  descr: 'VODANET International IP-Backbone of Vodafone, DE',
  country: 'de',
  active: true,
  org: 'Vodafone GmbH',
  domain: 'vodafone.com',
  abuse: '[email protected]',
  type: 'isp',
  created: '2002-09-11',
  updated: '2023-10-12',
  rir: 'ripe',
  whois: 'https://api.ipapi.is/?whois=AS3209'
}

Most IP addresses can be associated with an Autonomeous System (AS). The return value of ipToASN() is an object with the following attributes:

  • asn - int - The AS number
  • route - string - The IP route as CIDR in this AS
  • descr - string - An informational description of the AS
  • country - string - The country where the AS is situated in (administratively)
  • active - string - Whether the AS is active (active = at least one route administred by the AS)
  • domain - string - The domain of the organization to which this AS belongs
  • org - string - The organization responisible for this AS
  • type - string - The type for this ASN, this is either hosting, education, goverment, banking, business or isp
  • created - string - When the ASN was established
  • updated - string - The last time the ASN was updated
  • rir - string - To which Regional Internet Registry the ASN belongs
  • whois - string - An url to the whois information for this ASN

For inactive autonomeous systems, most of the above information is not available.

Usage from the Browser

Copy the browser JavaScript bundle to your preferred location. After installing the module with

npm install asn-from-ip

you can find the minified JavaScript here: node_modules/asn-from-ip/dist/ipToASN.min.js

<!doctype html>

<html lang="en">

<head>
  <meta charset="utf-8">
  <title>IP to ASN Example Browser</title>
  <meta name="description" content="IP to ASN Example">
  <meta name="author" content="ipapi.is">
</head>

<body>
  <pre id="asn"></pre>
  <script type="text/javascript" src="dist/ipToASN.min.js"></script>
  <script type="text/javascript">
    ipToASN('95.91.211.148').then((res) => {
      document.getElementById('asn').innerText = JSON.stringify(res, null, 2);
    });
  </script>
</body>

</html>

Use the Database Directly

This package uses the ipapi.is API in order to avoid shipping a huge database in the npm module. If you have a large volume of IP addresses to lookup, you can download the full & free ASN Database.

GitHub mirror of the database: ASN Database Mirror