0

I registered for the semantics3 API so that I could use their UPC/EAN Product Search feature and I received my APIkey and APIsecret. Now, I want to make a propper Get request to test it and then eventually incorporate it in my own application. I downloaded the semantics3 java project from their GitHub page..

Anyways, how do I actually make an UPC/EAN query with my own UPC or EAN code, so that I could get the JSON response for the product I'm searching for?

The constructor of the Semantics3Request looks like this:

public Semantics3Request(String apiKey, String apiSecret, String endpoint) {
    if (apiKey == null) { 
        throw new Semantics3Exception(
                "API Credentials Missing",
                "You did not supply an apiKey. Please sign up at https://semantics3.com/ to obtain your api_key."
            );
    }
    if (apiSecret == null) { 
        throw new Semantics3Exception(
                "API Credentials Missing",
                "You did not supply an apiSecret. Please sign up at https://semantics3.com/ to obtain your api_key."
            );
    }

    this.apiKey    = apiKey;
    this.apiSecret = apiSecret;
    this.endpoint  = endpoint;
    this.consumer = new DefaultOAuthConsumer(apiKey, apiSecret);
    consumer.setTokenWithSecret("", "");
}

One mroe important thing is that I do not understand what should I put in the String endpoint so that I can later call the methods from the Sematics3Request class: add , runQuery, fetch and get methods which returns a JSON response.

Emir
  • 13
  • 9

1 Answers1

0

You could try this code for UPC search

    //To include, Github: https://github.com/Semantics3/semantics3-java
import com.semantics3.api.Products;

Products products = new Products(
    "SEM3xxxxxxxxxxxxxxxxxxxxxx",
    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
);

products
    .productsField( "upc", "934586730023" )
JSONObject results = products.getProducts();
System.out.println(results);

You could also visit http://semantics3.com for more help

Mounarajan
  • 1,357
  • 5
  • 22
  • 43