Parse User-Agents and Identify Robots in Java

To help you improve your organization’s online security, this Cloudmersive API will allow you to parse HTTP User-Agent strings. This action will retrieve all device information, operating system, and browser data, as well as identifying whether the input user-agent is a robot.

Image for post
Image for post

Our first step in implementing this API is to install our SDK and add a reference to the repository in pom.xml:


Then, we can add a reference to the dependency in pom.xml:


After this, we can call our function, UserAgentParse:

// 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.UserAgentApi;
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)
UserAgentApi apiInstance = new UserAgentApi();
UserAgentValidateRequest request = new UserAgentValidateRequest(); // UserAgentValidateRequest | Input parse request
try {
UserAgentValidateResponse result = apiInstance.userAgentParse(request);
} catch (ApiException e) {
System.err.println("Exception when calling UserAgentApi#userAgentParse");

Now, you can ensure that your online programs are secure, and you can track and monitor what users access your website. You can retrieve your free API Key from the Cloudmersive website. This will give you access to 800 monthly calls across our library of APIs.

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store