BotBlocker.Pro - Bot Detection, Visitor Filtering & IP Address Intelligence
BotBlocker.Pro is a powerful Node.js and TypeScript module designed to enhance web security, filter traffic, and provide valuable analytics. It protects your application by identifying and blocking potentially harmful traffic based on IP addresses, user agents, and visitor behaviors. With BotBlocker.Pro, you can effectively defend your website against bots, competitors, and unwanted visitors while also gaining valuable insights into your audience.
To get started with BotBlocker.Pro, you'll need an API key and a subscription to our BotBlocker.Pro service. For further information, please check our comprehensive documentation.
Installation
Install BotBlocker.Pro using npm:
npm install botblocker.pro
Usage
Method 1: Using Express Middleware
import express from 'express';
import { BotBlocker } from 'botblocker.pro';
const app = express();
const port = 3000;
const apiKey = 'YOUR-API-KEY';
const botBlocker = new BotBlocker(apiKey);
app.get('/', async (req, res) => {
try {
const result = await botBlocker.checkReq(req);
let info = result.data.info;
let location = info.ipinfo;
if (result.data.block_access) {
res.status(403).json({message: 'Access denied'});
} else {
res.json({message: 'Welcome', location: location});
}
} catch (error) {
console.error('Error:', error.message);
res.status(500).json({error: 'Internal Server Error', details: error.message});
}
});
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}`);
});
Method 2: Manually Providing IP, User-Agent, URL (Page)
const { BotBlocker } = require('botblocker.pro');
const apiKey = 'YOUR-API-KEY';
const botBlocker = new BotBlocker(apiKey);
const userIP = '1.1.1.1';
const userAgent = 'Mozilla/5.0 ...';
const url = 'blog/slug?query=';
botBlocker.check(userIP, userAgent, url)
.then(result => {
let info = result.data.info;
let location = info.ipinfo;
console.log('Check result:', result);
if (result.data.block_access) {
console.log('Block the user');
} else {
console.log('Allow the user');
}
})
.catch(error => {
console.error('Error:', error);
});
Replace YOUR-API-KEY
with your actual BotBlocker.Pro API credentials in both methods.
Contributing
We appreciate your contributions! If you're planning to make significant changes, please start by opening an issue to discuss your proposed modifications. Additionally, ensure that you update any relevant tests as needed.
License
This project is licensed under the MIT license.