# Review Analysis API

## API Server

[nlu-api.allganize.ai](https://nlu-api.allganize.ai) is Allganize's NLU API endpoint. If you are using on-prem, please use your API endpoint.

## **Getting API KEY**

The NLU API uses API keys to authenticate requests that you can find in the [Allganize NLU API dashboard](https://nlu.allganize.ai/projects). Go to Settings > General to find your API key. If you don't have an account yet, you can create one [here](https://nlu.allganize.ai/signup).

#### &#x20;Provide your `API KEY` in the request header `API-KEY`.

## Review Analysis API

<mark style="color:green;">`POST`</mark> `https://nlu-api.allganize.ai/api/inference`

#### Headers

| Name    | Type   | Description                                                                       |
| ------- | ------ | --------------------------------------------------------------------------------- |
| API-KEY | string | Your API Key can be found on your dashboard Settings menu, under the General tab. |

#### Request Body

| Name | Type   | Description                                                                                                              |
| ---- | ------ | ------------------------------------------------------------------------------------------------------------------------ |
| text | string | Input text you want to analyze. You can enter up to 2000 characters, after which the entered characters will be ignored. |

{% tabs %}
{% tab title="200 The response contains a list of the sentiments of each category.

category: The category of the sentiment. Categories are defined in your NLU API dashboard.
sentiment: The sentiment analysis result. Please contact Allganize to define sentiments." %}

```
{
  "inputText": STRING,
  "reviewSentiments": [
    { 
      "category": STRING, 
      "sentiment": STRING 
    }, ...
  ]
}
```

{% endtab %}
{% endtabs %}

### Request Example

Please replace YOUR\_API\_KEY with your one in the example below. Please see [getting-api-key](https://docs.allganize.ai/review-conversion-api#getting-api-key) section.

```
curl https://nlu-api.allganize.ai/api/inference \
-d '{"text": "Cannot recommend highly enough! Absolutely fantastic apartment in a fantastic area! Great thoughtful touches and close amenities! Good vibes all round!"}' \
-H "Content-Type: application/json" \
-H "API-KEY: YOUR_API_KEY" 
```

### Response Example

```
{
  "inputText": "Cannot recommend highly enough! Absolutely fantastic apartment in a fantastic area! Great thoughtful touches and close amenities! Good vibes all round!"
  "reviewSentiments": [
    {"category": "location", "sentiment": "2", "keywords": [{"text": "in a fantastic area","index": 63}]},
    {"category": "rooms", "sentiment": “3”, “keywords": [{"text": “Absolutely fantastic apart”ment, ”index": 32}]},
    {"category": "service", "sentiment": “1”, "keywords": [{"text": “Great thoughtful touches”, ”index": 84}]}
  ]
}
```

## Error Messages

Please read the error message you get if you don't get the response that you expected.&#x20;

| Status Code | Error Code | Name              | Message                                              | Description                                                                                       |
| ----------- | ---------- | ----------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| 500         | 7000       | API Error         | Something went wrong                                 | Default API error message for any uncategorized errors.                                           |
| 403         | 7001       | Invalid API Key   | API-KEY is not valid.                                | When the API Key requested to the header is invalid.                                              |
| 403         | 7002       | Invalid JSON      | Cannot decode the requested JSON body.               | When the requested JSON is not decodable.                                                         |
| 400         | 7003       | Invalid Parameter | Requested parameters are not valid. 'text' is empty. | When the requested parameter is invalid (for example, when requesting inference with empty text). |
| 403         | 7004       | Payment error     | billing error.                                       | Overall payment related errors, e.g., payment is overdue                                          |
| 405         | -          | Wrong HTTP Method | -                                                    | When the HTTP method used is not valid.                                                           |

### Error Response example

```
{
    "type": "APIError",
    "code": 7000,
    "message": "Something went wrong."
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.allganize.ai/api-reference/review-conversion-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
