How to Identify Known Threat IP Addresses with a Free API in Node.js

Cloudmersive
2 min readDec 26, 2023

--

There’s at least one easy way to check if our servers are receiving requests from malicious actors: we just need to reference visiting IP addresses against a regularly updated list of known IP threats.

Using the below code, we can take advantage of a free API that references IP addresses against a growing database of known IP threats and identifies the threat type for us (if applicable). We can simply pass IP addresses to the underlying service as a string, and we’ll receive a simple response object in return.

We can structure our API call in a few quick steps, starting with installing the SDK. We can either install using the below command:

npm install cloudmersive-security-api-client --save

Or we can install by adding the following snippet to our package.json:

  "dependencies": {
"cloudmersive-security-api-client": "^1.2.0"
}

We can then pass our IP addresses through the below function to identify potential threats. To authorize our API requests, we’ll just need a free-tier API key, and this will allow us to make up to 800 API calls per month with no commitment:

var CloudmersiveSecurityApiClient = require('cloudmersive-security-api-client');
var defaultClient = CloudmersiveSecurityApiClient.ApiClient.instance;

// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';



var apiInstance = new CloudmersiveSecurityApiClient.NetworkThreatDetectionApi();

var value = "value_example"; // String | IP address to check, e.g. \"55.55.55.55\". The input is a string so be sure to enclose it in double-quotes.


var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.networkThreatDetectionIsThreat(value, callback);

Just like that, we can easily improve our network security with minimal code.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet