Make Your First Call

You can run the following commands in your java app to test whether you have successfully installed the client package. Don’t forget, you will need your API key to make your first call. In the code below replace YOUR_API_KEY with your personal API key (the 32-digit alphanumeric sequence assigned to you when you registered with indico). You should get back a number between 0 and 1.

import io.indico.Indico;
import io.indico.api.IndicoResult;
import io.indico.api.BatchIndicoResult;

// single example
Indico indico = new Indico("cc9302ad9499c2280755c0b30e6b9f9e");
IndicoResult single = indico.sentiment.predict(
    "I love writing code!"
);
Double result = single.getSentiment();
System.out.println(result);

// batch example
String[] example = {
    "I love writing code!",
    "Alexander and the Terrible, Horrible, No Good, Very Bad Day"
};
BatchIndicoResult multiple = indico.sentiment.predict(example);
List results = multiple.getSentiment();
System.out.println(results);

Results

# single output
0.9819219949985644

# batch output
[
    0.9819219949985644,
    0.00015202198176385973
]