
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
A TypeScript/JavaScript library to query IP addresses using the ipquery.io API.
A TypeScript/JavaScript library to query IP addresses using the ipquery.io API. This package provides detailed information about IP addresses, including ISP details, geolocation, and risk assessment.
axios
for HTTP requests.Install the package using npm:
npm install enrichip
Or using yarn:
yarn add enrichip
You can import the package using ES Modules:
import { queryIP, queryOwnIP, queryBulk } from 'enrichip';
Or using CommonJS:
const { queryIP, queryOwnIP, queryBulk } = require('enrichip');
Retrieve detailed information about a specific IP address:
import { queryIP } from 'enrichip';
async function getIPInfo() {
try {
const ipInfo = await queryIP('8.8.8.8');
console.log(ipInfo);
} catch (error) {
console.error('Error fetching IP info:', error);
}
}
getIPInfo();
{
"ip": "8.8.8.8",
"isp": {
"asn": "AS15169",
"org": "Google LLC",
"isp": "Google LLC"
},
"location": {
"country": "United States",
"country_code": "US",
"city": "Mountain View",
"state": "California",
"zipcode": "94035",
"latitude": 37.386,
"longitude": -122.0838,
"timezone": "America/Los_Angeles",
"localtime": "2024-11-09T12:45:32"
},
"risk": {
"is_mobile": false,
"is_vpn": false,
"is_tor": false,
"is_proxy": false,
"is_datacenter": true,
"risk_score": 0
}
}
Retrieve the public IP address of the machine running your code:
import { queryOwnIP } from 'enrichip';
async function getOwnIP() {
try {
const ip = await queryOwnIP();
console.log('Your IP:', ip);
} catch (error) {
console.error('Error fetching own IP:', error);
}
}
getOwnIP();
Your IP: 203.0.113.45
Fetch details for multiple IP addresses in one go:
import { queryBulk } from 'enrichip';
async function getBulkIPInfo() {
try {
const ips = ['8.8.8.8', '1.1.1.1'];
const results = await queryBulk(ips);
console.log(results);
} catch (error) {
console.error('Error fetching bulk IP info:', error);
}
}
getBulkIPInfo();
[
{
"ip": "8.8.8.8",
"isp": { "asn": "AS15169", "org": "Google LLC", "isp": "Google LLC" },
"location": { "country": "United States", "city": "Mountain View" }
},
{
"ip": "1.1.1.1",
"isp": { "asn": "AS13335", "org": "Cloudflare, Inc.", "isp": "Cloudflare" },
"location": { "country": "Australia", "city": "Sydney" }
}
]
queryIP(ip: string): Promise<IPInfo>
Fetches detailed information about a specific IP address.
ip
: The IP address to query.IPInfo
object.queryOwnIP(): Promise<string>
Fetches the public IP address of the current machine.
queryBulk(ips: string[]): Promise<IPInfo[]>
Fetches information for multiple IP addresses.
ips
: An array of IP addresses to query.IPInfo
objects.IPInfo
interface ISPInfo {
asn?: string;
org?: string;
isp?: string;
}
interface LocationInfo {
country?: string;
country_code?: string;
city?: string;
state?: string;
zipcode?: string;
latitude?: number;
longitude?: number;
timezone?: string;
localtime?: string;
}
interface RiskInfo {
is_mobile?: boolean;
is_vpn?: boolean;
is_tor?: boolean;
is_proxy?: boolean;
is_datacenter?: boolean;
risk_score?: number;
}
interface IPInfo {
ip: string;
isp?: ISPInfo;
location?: LocationInfo;
risk?: RiskInfo;
}
To run the tests, use:
npm test
Ensure that ts-node
and jest
are properly configured before running the tests.
This project is licensed under the MIT License. See the LICENSE file for details.
FAQs
A TypeScript/JavaScript library to query IP addresses using the ipquery.io API.
The npm package enrichip receives a total of 2 weekly downloads. As such, enrichip popularity was classified as not popular.
We found that enrichip demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.