0.1.129 • Published 3 months ago

abuseipdb-client v0.1.129

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

License codecov npm npm Workflow

Unofficial AbuseIPDB Node.js client library.

Features

  • Implements API v2
  • Built with TypeScript
  • Runtime type checking (Using Zod)
  • Promise API
  • ESM and CJS builds

Table of Contents

  1. Installation
  2. Usage
  3. About
  4. API
  5. Examples
  6. Running tests
  7. Browser Support
  8. License

Installation

$ npm install -S abuseipdb-client

Usage

import { AbuseIPDBClient } from 'abuseipdb-client';

const client = new AbuseIPDBClient('API_KEY');

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

console.log(response);
{
  headers: {
    url: 'https://api.abuseipdb.com/api/v2/check?ipAddress=127.0.0.1&maxAgeInDays=15',
    status: 200,
    statusText: 'OK',
    'x-ratelimit-limit': '3000',
    'x-ratelimit-remaining': '2999'
  },
  result: {
    data: {
      ipAddress: '127.0.0.1',
      isPublic: false,
      ipVersion: 4,
      // ...
    }
  }
}

About

This library wraps API responses into a single object, providing a standard structure.

const response = await client.check('127.0.0.1');

const { headers, result, error } = response;

The headers structure contains the AbuseIPDB HTTP headers plus some of the Fetch Response information.

headers: {
  url: string;
  status: string;
  statusText: string;
  'x-ratelimit-limit': string;
  'x-ratelimit-remaining': string;
  'retry-after'?: string;
  'x-ratelimit-reset'?: string;
}

The error structure wraps a JSON-API compliant object, as defined by the docs.

error?: {
  errors?: [
    {
      detail?: string;
      status?: number;
      source?: {
        parameter: string
      }
    }
  ]
}

The result structure wraps the API endpoint response.

result?: APIResponse<T>

The headers object is always populated with the data returned from the API. result and error are exclusive, either one of them is defined for a given response.

const response = await client.check('127.0.0.1');

const { headers, result, error } = response;

if (error) {
  // API returned some error message.
  console.log(error);
}

if (result) {
  // API returned a result response.
  console.log(result);
}

// Headers are defined either way.
console.log(headers);

A more detailed explanation can be found at: examples/abstraction.ts.

API

See API Docs

Examples

See Examples

Running tests

In order to run tests, you will need to create an API Key from AbuseIPDB's dashboard.

Then, clone this repo:

$ git clone https://github.com/arthur-melo/abuseipdb-client

Copy the .env.example file to .env, modifying it with your generated API Key.

Install dependencies:

$ npm install

And run the tests:

$ npm run test

Browser Support

This project was built using libraries that allow browser usage, but as of this commit, AbuseIPDB doesn't support CORS.

This limits how you can interact with the API, given that you need a proxy server in order to contact the service.

I'm not generating browser bundles at the moment, but I decided to keep the supporting code nevertheless.

I'll keep an eye whether the team behind AbuseIPDB adds support for this use case in the future.

License

abuseipdb-client is released under the MIT license.

0.1.129

3 months ago

0.1.118

8 months ago

0.1.117

8 months ago

0.1.119

8 months ago

0.1.114

9 months ago

0.1.113

9 months ago

0.1.116

8 months ago

0.1.115

9 months ago

0.1.110

9 months ago

0.1.112

9 months ago

0.1.111

9 months ago

0.1.128

7 months ago

0.1.125

8 months ago

0.1.124

8 months ago

0.1.127

8 months ago

0.1.126

8 months ago

0.1.121

8 months ago

0.1.120

8 months ago

0.1.123

8 months ago

0.1.122

8 months ago

0.1.96

10 months ago

0.1.97

10 months ago

0.1.98

10 months ago

0.1.99

10 months ago

0.1.92

10 months ago

0.1.93

10 months ago

0.1.94

10 months ago

0.1.95

10 months ago

0.1.107

9 months ago

0.1.106

9 months ago

0.1.109

9 months ago

0.1.108

9 months ago

0.1.103

9 months ago

0.1.102

9 months ago

0.1.105

9 months ago

0.1.104

9 months ago

0.1.101

10 months ago

0.1.100

10 months ago

0.1.90

10 months ago

0.1.91

10 months ago

0.1.89

10 months ago

0.1.85

11 months ago

0.1.86

11 months ago

0.1.87

10 months ago

0.1.88

10 months ago

0.1.80

11 months ago

0.1.81

11 months ago

0.1.82

11 months ago

0.1.83

11 months ago

0.1.84

11 months ago

0.1.74

12 months ago

0.1.75

12 months ago

0.1.76

12 months ago

0.1.77

11 months ago

0.1.78

11 months ago

0.1.79

11 months ago

0.1.70

12 months ago

0.1.71

12 months ago

0.1.72

12 months ago

0.1.73

12 months ago

0.1.69

12 months ago

0.1.63

1 year ago

0.1.64

1 year ago

0.1.65

1 year ago

0.1.66

12 months ago

0.1.67

12 months ago

0.1.68

12 months ago

0.1.60

1 year ago

0.1.61

1 year ago

0.1.62

1 year ago

0.1.52

1 year ago

0.1.53

1 year ago

0.1.54

1 year ago

0.1.55

1 year ago

0.1.56

1 year ago

0.1.57

1 year ago

0.1.58

1 year ago

0.1.59

1 year ago

0.1.50

1 year ago

0.1.51

1 year ago

0.1.49

1 year ago

0.1.41

1 year ago

0.1.42

1 year ago

0.1.43

1 year ago

0.1.44

1 year ago

0.1.45

1 year ago

0.1.46

1 year ago

0.1.47

1 year ago

0.1.48

1 year ago

0.1.40

1 year ago

0.1.38

1 year ago

0.1.39

1 year ago

0.1.37

1 year ago

0.1.36

1 year ago

0.1.35

1 year ago

0.1.34

1 year ago

0.1.33

1 year ago

0.1.32

1 year ago

0.1.31

1 year ago

0.1.30

1 year ago

0.1.29

1 year ago

0.1.28

1 year ago

0.1.27

1 year ago

0.1.26

1 year ago

0.1.25

1 year ago

0.1.24

1 year ago

0.1.23

1 year ago

0.1.22

1 year ago

0.1.21

1 year ago

0.1.20

1 year ago

0.1.19

1 year ago

0.1.18

1 year ago

0.1.17

1 year ago

0.1.16

1 year ago

0.1.15

1 year ago

0.1.14

1 year ago

0.1.13

1 year ago

0.1.12

1 year ago

0.1.11

1 year ago

0.1.10

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago