Skip to content

Get information about detectors

The API provides a self-documentation resource to programmatically discover available detectors and their features. It has this path:

detectors

Therefore, the complete URL is:

https://nlapi.expert.ai/v2/detectors

It must be requested with the GET method.
It returns the list of available detectors along with the supported languages and, possibly, the Web address of a specific OpenAPI contract.

In the reference section of this manual you will find all the information you need to use this resource, specifically:

Note

Even if you use the API through a client that hides the REST interface, whether it is made by you or is one of those provided by expert.ai, knowing the output format helps you understand and navigate the results.

Here is an example of obtaining detectors information:

This example is based on the Python client you can find on GitHub.

The client gets user credentials from two environment variables:

EAI_USERNAME
EAI_PASSWORD

Set those variables with your account credentials before running the sample program below.

The program prints the list of taxonomies with the language they support.

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

output = client.detectors()

# Detectors

print("Detectors:\n")

for detector in output.detectors:
    print(detector.name)
    print("\tLanguages:")
    for language in detector.languages:
        print("\t\t{}".format(language.code))
    print("\tContract: {}".format(detector.contract))

This example is based on the Java client you can find on GitHub.

The client gets user credentials from two environment variables:

EAI_USERNAME
EAI_PASSWORD

Set those variables with your account credentials before running the sample program below.

The program prints the JSON response.

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.message.TaxonomiesResponse;
import ai.expert.nlapi.v2.InfoAPI;
import ai.expert.nlapi.v2.InfoAPIConfig;

public class Main {

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

    public static void main(String[] args) {
        try {
            InfoAPI infoAPI = new InfoAPI(InfoAPIConfig.builder()
               .withAuthentication(createAuthentication())
               .withVersion(API.Versions.V2)
               .build());

            TaxonomiesResponse taxonomies = infoAPI.getTaxonomies();
            taxonomies.prettyPrint();
        }
        catch(Exception ex) {
            ex.printStackTrace();
        }
    }
}

The following curl command gets the taxonomies documentation resource of the API's REST interface.
Run the command from a shell after replacing token with the actual authorization token.

curl -X GET https://nlapi.expert.ai/v2/taxonomies \
    -H 'Authorization: Bearer token'

The server returns a JSON object.

The following curl command gets the detectors documentation resource of the API's REST interface.
Open a command prompt in the folder where you installed curl and run the command after replacing token with the actual authorization token.

curl -X GET https://nlapi.expert.ai/v2/detectors -H "Authorization: Bearer token"

The server returns a JSON object.