The package supports APIv2. No other API is currently available. Uploading a CSV report of abusive IP addresses is not yet implemented.
pip install abuseipdb
To choose between the API versions, you pass the version as the second parameter. Use the string APIv2 to select the API version.
from abuseipdb import AbuseIpDb
abuse_v2 = AbuseIpDb(api_key='APIv2key', api_version='APIv2') # Using API v2
abuse = AbuseIpDb(api_key='APIv2key') # Also using API v2
If you have a subscription plan with Abuse IP DB, you can indicate this with an additional parameter. This has only an effect for the APIv2.
from abuseipdb import AbuseIpDb
abuse = AbuseIpDb(api_key='APIv2key', subscriber=True)
abuse.check(ip_address="192.0.2.123")
abuse.check(ip_address="192.0.2.123", max_age_in_days=90)
abuse.check_block(cidr_network="192.0.2.0/24")
abuse.check_block(cidr_network="192.0.2.0/24", max_age_in_days=90)
All the following calls result in the same call to AbuseIpDb. If yyou pass in
an unkonwn category, it will raise a ValueError
.
abuse.report(ip_address="192.0.2.123", categories="15,22")
abuse.report(ip_address="192.0.2.123", categories="15, 22")
abuse.report(ip_address="192.0.2.123", categories="HACKING, SSH")
abuse.report(ip_address="192.0.2.123", categories=(15, 22))
abuse.report(ip_address="192.0.2.123", categories=("15", "22"))
abuse.report(ip_address="192.0.2.123", categories=[15, "SSH"])
This adds a comment to the report.
abuse.report(ip_address="192.0.2.123", categories=("13", "22"),
comment="Some comment about the abusive IP address")
### Report a list of abusive IP addresses
Please refer to [IP Bulk Reporter](https://www.abuseipdb.com/bulk-report)
for the exact specification of the CSV file.
```python
abuse.bulk_report(file_name="report.csv")
abuse.blacklist()
abuse.blacklist(limit=10) # Only get 10 entries
abuse.blacklist(confidence_level=90) # Only available for subscribers
You can invoke the module on the command line. It supports all the commands
listed above. For the explicit syntax and the required configuration call it
with the --help
parameter.
abuseipdb --help
- AbuseIpDB Repository
- Abuse IP DB APIv1 Documentation
- Abuse IP DB APIv2 Documentation
- IPv4 Address Blocks Reserved for Documentation