Lookup EAN Barcode Value & Return Product Data with Java: Barcode Lookup API

Barcodes make it easy to get key details about a product, but you still need a way to search the barcode. Our EAN Lookup API will return key details about a product based on an EAN barcode number input — just that simple. Easily implement this into your project using code provided in Java below, or head to our API console page to find code available in 12 additional programming languages.

Start by installing the Java SDK with Maven. Add a reference to the repository in pom.xml:

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

After that, add one to the dependency in pom.xml:

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

Now finish up by adding the import classes and calling the function:

// 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.BarcodeLookupApi;
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");
BarcodeLookupApi apiInstance = new BarcodeLookupApi();
String value = "value_example"; // String | Barcode value
try {
BarcodeLookupResponse result = apiInstance.barcodeLookupEanLookup(value);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BarcodeLookupApi#barcodeLookupEanLookup");
e.printStackTrace();
}

--

--

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