Skip to content

Quick start

In order to use the API you must have an expert.ai developer account. Visit the developer portal and sign up for free to get one.

To create a client application in Python or in Java, install the Python client library or declare a dependency for the Java client library following the instructions you can find in README files of the corresponding GitHub repositories.

To quickly test the API you can then use one of the code samples available inside the GitHub repository or take inspiration from the sample code below, which carries out named entity recognition on a short English text.

Ready-to-use Python and Java client libraries need your account credentials and they get them from two environment variables:

EAI_USERNAME
EAI_PASSWORD
So, before starting your application, set those variables.

When your test application is ready, open Studio then follow the instructions you can find in Studio IDE documentation to start the Local Deployment Agent.

Once Studio LDA is running, you can launch your application.

from expertai.nlapi.edge.client import ExpertAiClient
client = ExpertAiClient()

text = "Michael Jordan was one of the best basketball players of all time. Scoring was Jordan's stand-out skill, but he still holds a defensive NBA record, with eight steals in a half."

output = client.named_entity_recognition(text)

print (f'{"ENTITY":{50}} {"TYPE":{10}}')
print (f'{"------":{50}} {"----":{10}}')

for entity in output.entities:
    print (f'{entity.lemma:{50}} {entity.type_:{10}}')
import ai.expert.nlapi.security.Authentication;
import ai.expert.nlapi.security.Authenticator;
import ai.expert.nlapi.security.BasicAuthenticator;
import ai.expert.nlapi.security.DefaultCredentialsProvider;
import ai.expert.nlapi.v2.API;
import ai.expert.nlapi.v2.edge.Analyzer;
import ai.expert.nlapi.v2.edge.AnalyzerConfig;
import ai.expert.nlapi.v2.message.AnalyzeResponse;

public class Main {

    public static Authentication createAuthentication() throws Exception {
        DefaultCredentialsProvider credentialsProvider = new DefaultCredentialsProvider();
        Authenticator authenticator = new BasicAuthenticator(credentialsProvider);
        return new Authentication(authenticator);
    }

    public static Analyzer createAnalyzer() throws Exception {
        return new Analyzer(AnalyzerConfig.builder()
                                          .withVersion(API.Versions.V2)
                                          .withHost(API.DEFAULT_EDGE_HOST)
                                          .withAuthentication(createAuthentication())
                                          .build());
    }

    public static void main(String[] args) {
        try {
            String text = "Michael Jordan was one of the best basketball players of all time. Scoring was Jordan's stand-out skill, but " +
                          "he still holds a defensive NBA record, with eight steals in a half.";

            Analyzer analyzer = createAnalyzer();

            AnalyzeResponse entities = analyzer.entities(text);


            // Output JSON representation

            entities.prettyPrint();
        }
        catch(Exception ex) {
            ex.printStackTrace();
        }
    }
}

If you want to use other languages or want to learn more about low-level use of the API, read the in-depth article.