AbuseIPDB Node.js Client

2.0.90 · active · verified Tue Apr 21

The `abuseipdb-client` is an unofficial Node.js client library designed to interact with the AbuseIPDB API v2. It provides a robust, promise-based interface for checking IP addresses, reporting malicious activity, and managing API interactions. Currently stable at version 2.0.90, the library maintains a frequent release cadence, often issuing multiple patch updates monthly to keep dependencies current. Key differentiators include its TypeScript-first design, comprehensive runtime type checking powered by Zod, and full support for both ECMAScript Modules (ESM) and CommonJS (CJS) environments, though ESM is preferred. It standardizes API responses into a structured object containing headers, results, and explicit error handling properties, abstracting away raw HTTP responses.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates initializing the `AbuseIPDBClient` with an API key from environment variables and performing an IP check, including structured error handling.

import { AbuseIPDBClient } from 'abuseipdb-client';
import 'dotenv/config'; // Ensure environment variables are loaded if using .env

const API_KEY = process.env.ABUSEIPDB_API_KEY ?? '';

if (!API_KEY) {
  console.error('ABUSEIPDB_API_KEY environment variable is not set.');
  process.exit(1);
}

const client = new AbuseIPDBClient(API_KEY);

async function checkIp() {
  try {
    const response = await client.check('127.0.0.1', { maxAgeInDays: 15 });

    const { headers, result, error } = response;

    console.log('API Headers:', headers);

    if (error) {
      console.error('API Error:', error);
    } else if (result) {
      console.log('API Result:', result.data);
    }
  } catch (err) {
    console.error('Client execution error:', err);
  }
}

checkIp();

view raw JSON →