Get Intelligence on an IP Address with Java

Cloudmersive
2 min readMay 11, 2022

--

It’s never a bad idea to boost your application’s threat profile, and you can easily do so by incorporating our IP Intelligence API. It can keep you ahead of the curve on suspicious IPs, providing key info including whether a given IP is a known threat, known bot, or Tor exit node. Additionally, it lets you know where that IP address is located geographically, including details about the country code, region code, zip code, and much more.

Take advantage of this API in just a few steps by following the instructions included below for Java.

To start, let’s install the Maven SDK by first adding a reference to the repository in pom.xml:

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

And then adding one to the dependency:

<dependencies>
<dependency>
<groupId>com.github.Cloudmersive</groupId>
<artifactId>Cloudmersive.APIClient.Java</artifactId>
<version>v4.25</version>
</dependency>
</dependencies>

Once that’s done, it’s time to add the import classes and call the IP validation function. You’ll need a Cloudmersive API key for this step, which you can obtain easily by registering a free account on our website (Home — Cloudmersive APIs).

// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.IpAddressApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//Apikey.setApiKeyPrefix("Token");
IpAddressApi apiInstance = new IpAddressApi();
String value = "value_example"; // String | IP address to process, e.g. \"55.55.55.55\". The input is a string so be sure to enclose it in double-quotes.
try {
IPIntelligenceResponse result = apiInstance.iPAddressIpIntelligence(value);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling IpAddressApi#iPAddressIpIntelligence");
e.printStackTrace();
}

That’s it — you’re all done, simple as can be.

--

--

Cloudmersive

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