UNPKG

asn-from-ip

Version:

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...

14 lines 334 B
function ipToASN(ip) { return new Promise(function (resolve) { fetch(`https://api.ipapi.is/?q=${ip}`) .then(res => res.json()) .then(function (parsed) { try { if (parsed && parsed.asn) { resolve(parsed.asn); } } catch (err) { } resolve(null); }); }); }