Sentiment
Similar to the Emotions API, this model tries to determine the general sentiment of a given text based on how it was written.
Prediction labels
Limits
The maximum length accepted is 512 characters.
| Emotion | Emoji | Example | 
|---|---|---|
| positive | โ | this was an incredible achievement | 
| negative | โ | this wasn't an incredible achievement | 
| neutral | ๐ฐ | this is just a text | 
Invokation
- cURL
- Python
- PHP
curl -L -G 'http://api.textkit.ai/detect/sentiment' \
    --data-urlencode 'text=yeah, man! Go!' \
    --header 'X-API-Key: your_api_key_here' 
import requests
url = "https://api.textkit.ai/detect/sentiment?text=this was an incredible achievement"
payload={}
headers = {
  'X-API-Key': 'your_api_key_here'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
<?php
$curl = curl_init();
$url = "https://api.textkit.ai/detect/sentiment?text=" . urlencode("this was an incredible achievement");
curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'X-API-Key: your_api_key_here'
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Response
{
    "prediction": {
        "sentiment": "positive",
        "emoji": "โ"
    },
    "confidence": "0.942",
    "time_ms": 778
}
| Field | Meaning | 
|---|---|
| prediction | The predicted label. See above for reference | 
| confidence | Value between 0and1that indicates how confident the model is | 
| time_ms | Time in milliseconds the model took to predict the label. It does not account for the network round trip time between request and response |