PHPackages                             abuseipdb/laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. abuseipdb/laravel

ActiveLibrary[API Development](/categories/api)

abuseipdb/laravel
=================

Package to easily integrate the AbuseIPDB API with Laravel.

2.0.1(2mo ago)1012.0k↓31.8%6MITPHPPHP ^8.3

Since Mar 18Pushed 2mo ago5 watchersCompare

[ Source](https://github.com/AbuseIPDB/laravel)[ Packagist](https://packagist.org/packages/abuseipdb/laravel)[ Docs](https://github.com/AbuseIPDB/laravel)[ Fund](https://www.abuseipdb.com/donate)[ GitHub Sponsors](https://github.com/AbuseIPDB)[ RSS](/packages/abuseipdb-laravel/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelogDependencies (6)Versions (16)Used By (0)

 [ ![AbuseIPDB Logo](.github/logo.svg) ](https://github.com/AbuseIPDB/laravel)

 [![Total Downloads](https://camo.githubusercontent.com/387c1c79c68160bd57d9c100e0f15745ea414545d4d556dd9f237ab471327027/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f4162757365495044422f6c61726176656c2e737667)](https://packagist.org/packages/AbuseIPDB/laravel) [![Latest Stable Version](https://camo.githubusercontent.com/8bd4bd0e793aa0332b15318f84f03f60ad57d461b8b3d51eefde1c1a5b073e83/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f4162757365495044422f6c61726176656c2e737667)](https://packagist.org/packages/AbuseIPDB/laravel) [![License](https://camo.githubusercontent.com/5c94a9047616d46d2476164c47b91b071ca5559881d665cd08ea6ace847991d4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f4162757365495044422f6c61726176656c2e737667)](https://packagist.org/packages/AbuseIPDB/laravel)

AbuseIPDB
---------

[](#abuseipdb)

Package to easily integrate the AbuseIPDB API with your Laravel project.

Installation
------------

[](#installation)

You can install the package via composer:

```
  composer require abuseipdb/laravel
```

After installing, you need to add `ABUSEIPDB_API_KEY` to your `.env` file.

```
ABUSEIPDB_API_KEY=your_key
```

Note

Register on [abuseipdb.com](https://www.abuseipdb.com/) to get a free API key.

Usage
-----

[](#usage)

### Methods

[](#methods)

All methods are static, and can be called using the `AbuseIPDB` facade.

`Check`

Inspect details regarding the IP address queried.

```
AbuseIPDB::check('127.0.0.1');
```

Optional parameters:

- `maxAgeInDays`: The maximum age of reports to return (1-365), defaults to 30
- `verbose`: Whether to include verbose information (reports), defaults to false

`Report`

Report an IP address to AbuseIPDB. At least one category must be specified.

```
AbuseIPDB::report('127.0.0.1', categories: [18, 22]);
```

Optional parameters:

- `comment`: An optional comment to include with the report, for example a logged indicator of attack
- `timestamp`: An optional timestamp to include with the report indicating the time of attack

`Reports`

Get the reports for a single IP address (v4 or v6).

```
AbuseIPDB::reports('127.0.0.1');
```

Optional parameters:

- `maxAgeInDays`: The maximum age of reports to return (1-365), defaults to 30
- `page`: The page number to get for the paginated response, defaults to 1
- `perPage`: The number of reports to get per page (1-100), defaults to 25

`Blacklist`

Get the AbuseIPDB blacklist.

```
AbuseIPDB::blacklist();
```

Optional parameters:

- `confidenceMinimum`: The minimum confidence score to include an IP in the blacklist (25-100), defaults to 100
- `limit`: The maximum number of blacklisted IPs to return, defaults to 10000
- `plaintext`: Whether to return the blacklist in plaintext (a plain array of IPs), defaults to false
- `onlyCountries`: Only include IPs from these countries (use 2-letter country codes)
- `exceptCountries`: Exclude IPs from these countries (use 2-letter country codes)
- `ipVersion`: The IP version to return (4 or 6), defaults to both

`CheckBlock`

Checks an entire subnet against the AbuseIPDB database.

```
AbuseIPDB::checkBlock('127.0.0.1/28');
```

Optional parameters:

- `maxAgeInDays`: The maximum age of reports to return (1-365), defaults to 30

`BulkReport`

Report multiple IP addresses to AbuseIPDB in bulk from a csv string.

```
AbuseIPDB::bulkReport('bulk-report.csv');
```

`ClearAddress`

Deletes your reports for a specific address from the AbuseIPDB database.

```
AbuseIPDB::clearAddress('127.0.0.1');
```

Note

You can find a complete documentation of the available methods [here](https://docs.abuseipdb.com).

### Exceptions

[](#exceptions)

In the event of an error, this package will throw an exception from the `Abuseipdb\Exceptions` namespace. Those exceptions include the following:

`InvalidParameterException`: Parameter passed in was invalid for the API.

`MissingAPIKeyException`: Your API key in your .env file was not found or invalid.

`PaymentRequiredException`: 402 error was thrown by API, indicating feature needs a higher subscription.

`TooManyRequestsException`: 429 error was thrown by API, indicating request limit has been exceeded.

`UnprocessableContentException`: 422 error was thrown by API, indicating request parameters could not be handled, either missing or incorrect.

`UnconventionalErrorException`: Error code other than 402, 422, or 429 was returned by the API.

Quick start for automatic reporting of suspicious operations
------------------------------------------------------------

[](#quick-start-for-automatic-reporting-of-suspicious-operations)

This package supports automatically reporting instances of Symfony's `SuspiciousOperationException`.

To use this functionality, update your `app\Exceptions\Handler.php` to something like this:

```
