datadome-client
v0.5.1
Published
Datadome API Client
Downloads
10
Maintainers
Readme
datadome-client
A node.js module for accessing Datadome API.
Datadome ?
« DataDome detects non-human traffic, identifies and categorizes in real time bot operators »
- https://datadome.co/
- https://docs.datadome.co/v1.0/docs/api-server
Prerequisites
Open an account and ask your API Key (free trial 30 days) https://datadome.co/free-signup/
Installation
npm install datadome-client
Usage
Express/Connect
const app = require('express')();
const Datadome = require('datadome-client');
const datadomeClient = new Datadome({apiKey:'YOURAPIKEY'});
app.use(function(req, res, next) {
datadomeClient.isBot(req,(err, result) => {
if (err) {
// if an error occured with datadome,
// let's continue
return next();
}
if (!result.isBot) {
// not a bot, continue
return next();
}
/**
* bot detected, let's handle response.
* in this example, we block the request with a message,
* but in real life, you should log, then make the bad bot wait
* for the response (setTimeout), and/or redirect somewhere else, ...
**/
res
.status(result.response)
.send("Sorry "+result.botname+", you are a "+result.botfamily+", and you are not welcome here.")
.end();
})
});