# AI Text Sentiment Analysis API

## About

This Utility API uses AI to identify prevailing emotional opinions, classifying them as positive, negative, or neutral within any textual content.

This API aids in understanding public sentiment towards any brand or topic. By mining text for clues about sentiment and associating them with specific aspects of the content, the Sentiment Analysis API offers valuable insights into how people perceive and react to information.

The atoms cost is subjected to change depending on the size of the input file and the provider selected. The list of providers and the atoms cost for each provider is given below:

| Provider (requested_service) | Atoms |
| --- | --- |
| Azure | 500 |
| Google | 500 |
| ApyHub | 2000 |

## API Playground

ApyHub AI

This API endpoint does not have a playground. You can test it with Voiden.

## API Documentation

input json: output json

POST

`https://api.apyhub.com/ai/text/sentiment/analysis`

#### Request example

```bash
curl --location --request POST 'https://api.apyhub.com/ai/text/sentiment/analysis' \
--header 'apy-token: {{token}}' \
--header 'Content-Type: application/json' \
--data '{\n    "text": "Great atmosphere. Close to plenty of restaurants, hotels, and transit! Staff are friendly and helpful.",\n    "language":"en",\n    "requested_service": "azure",\n    "azure": {\n        "key": "your-azure-key",\n        "endpoint": "your-azure-endpoint"\n    }\n}'
```

| Attribute | Type | Mandatory | Description |
| --- | --- | --- | --- |
| text | String | Yes | Provide the textual content for which you want to perform sentiment analysis. The max content size is 125,000 characters. |
| language | String | Yes (if `azure` is selected in requested_service) | the language supported by `azure` check list of supported language link - [Language Support](https://learn.microsoft.com/en-gb/azure/ai-services/language-service/sentiment-opinion-mining/language-support). |
| encoding | String | No (use if `google` is selected in requested_service) | Provide the textual content encoding format it can be `UTF8`, `UTF16`, `UTF32` default to `UTF8`. |
| requested_service | String | Yes | Enter the name of service provider. Supported providers are `azure`, `google`, `apyhub`. Defaults to `apyhub`. |
| azure.key | String | Yes (if `azure` is selected in requested_service) | Input service key provided by azure. |
| azure.endpoint | String | Yes (if `azure` is selected in requested_service) | Enter the endpoint provided by azure. |
| google.key | String | Yes (if `google` is selected in requested_service) | Input service key provided by google. |

### HTTP Response Codes

| Status Code | Description |
| --- | --- |
| 200 | The request was successful. |
| 400 | Invalid input - the file is corrupt or the supported inputs are not provided. |
| 401 | Required authentication information is either missing or not valid for the resource. |
| 500 | If any unexpected error occurs while processing the request. |

## Authentication

All API requests to ApyHub services need to be authenticated. Currently we support `tokens` or `basic authentication` mechanisms. You can generate and view your existing credentials from your workspace settings and go to “API Keys".

## Error codes

```
{\n  "error": {\n    "code": 105,\n    "message": "Invalid URL"\n  }\n}
```

### Reviews

3.9
/
5
99 ratings

5
4
3
2
1

### **Points to note:**

Credential secrets are generated on the fly and are not stored in plain text, so on generating a credential please save the secrets somewhere safe.  
Use the `apy-token` as the header parameter to pass the token.  
Use the `Authorization` header to send the basic authentication credentials.
