NAV Navbar

Workflow

Lang.ai algorithm adapts to any language, industry or business case given the adequate training data. The typical workflow for using lang.ai API is the following:

The API

The API is organized around REST. It has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which are understood by off-the-shelf HTTP clients. JSON is returned by all API responses, including errors, although the API libraries convert responses to appropriate language-specific objects.

The service is available at "https://company.lang.ai/api/v1". Replace the example domain with the one you are using in your Lang.ai instance.

Authentication

curl https://company.lang.ai/api/v1/analyze \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -X POST -d '{"text": "The Text", "projectId": "YOUR_PROJECT_ID"}'

Authenticate your account when using the API by including your secret API token in every request. You can create a new API token from the Settings section in your Lang.ai instance. Do not share your secret API tokens in publicly accessible areas such GitHub, client-side code, and so forth.

Keep in mind that generating a new token will invalidate the previously issued ones.

Every request must be authenticated with the your API token.

Rate Limit

To avoid abuse and ensure that the system remains online for every user, every API request will need to provide valid credentials and the requests can be rate limited if they exceed the limitations.

Analyze documents

Returns the classification for a given document and the specified project.

HTTP Request

POST https://company.lang.ai/api/v1/analyze

Request Body

{
  "text": "The text to be analyzed",
  "projectId": "Your project id"
}
Parameter Required Default Type Description
text true - string The text to be classified.
projectId true - string The project to be used to classify the text.

Response Body

The response returns a list of zero, one or more tags and intents. Each intent contains the following fields:

Field Type Description
name string The name of the intent.
features string[] The list of features. The sign “>” indicates a second-level feature.
{
  "tags": ["Tag 1", "Tag 2"]
  "intents": [
    {
        "name": "intent",
        "features": ["feature", "feature>feature"],
    }
  ]
}

Save documents

Saves a given document into the specified project. It supports passing metadata that can be later used in the project's Dashboard. New metadata values passed via API will be available to use in the project's setup section.

HTTP Request

POST https://company.lang.ai/api/v1/documents

Request Body

{
  "text": "The text to be analyzed",
  "projectId": "Your project id",
  "metadata": {"key": "value"}, // Optional
  "date": "2019-20-12" // Optional
}
Parameter Required Default Type Description
text true - string The text to be classified.
projectId true - string The project to be used to classify the text.
metadata false - object The metadata information of the document.
date false now string The date of the document. It supports valid IS0 8601 dates. If not passed, the request time is used.

Response Body

The request returns a 201 HTTP code when the document is saved successfully.

Errors

If the request succeeded, the response status will be 200 OK. Otherwise the response status will be 4xx or 5xx as described in the following table:

Error Code Meaning
400 Bad request / Missing fields
401 Unauthorized
404 Project not found
429 Too many requests / Rate limited
500 Internal server error