Support

Sentiment Analysis API reference

This API analyses a text and tells whether the expressed opinion is positive, negative, or neutral. Given a short sentence, it returns a label representing the identified sentiment, along with a numeric score ranging from strongly positive (1.0) to extremely negative (-1.0).

Endpoint

https://api.dandelion.eu/datatxt/sent/v1

We support both GET and POST methods to query the API.

Parameters

Remember to authenticate yourself specifying the token parameter (or the legacy $app_id and $app_key pair). See the API doc about authentication for any questions.

text|html|html_fragment required
These parameters define how you send to the Sentiment Analysis API the text you want to analyze. Only one of them can be used in each request, following these guidelines:
  • use "text" when you have plain text that doesn't need any pre-processing;
  • use "html" when you have an HTML document and you want the Sentiment Analysis API to work on its main content. It will use an AI algorithm to extract the relevant part of the document to work on; in this case, the main content will also be returned by the API to allow you to properly use the annotation offsets;
  • use "html_fragment" when you have an HTML snippet and you want the Sentiment Analysis API to work on its content. It will remove all HTML tags before analyzing it.
Type string
lang optional
The language of the text to be annotated; currently only English and Italian are supported. Leave this parameter out to let the Sentiment Analysis API automatically detect the language for you.
Type string
Default value auto
Accepted values en | it | auto
Hint: Keep-alive
If you need to send many requests to the server api, it is suggested to use keep-alive to avoid the connection overhead. To know how to enable it, please refer to your http client documentation (eg: python-requests, ruby, php).

Response

The response is structured in JSON as follow:

{
  "timestamp": "Date and time of the response generation process",
  "time": "Time elapsed for generating the response (milliseconds)",
  "lang": "The language used to analyze the input text",
  "langConfidence": "Accuracy of the language detection, from 0.0 to 1.0. Present only if auto-detection is on",
  "text": "The annotated text. Present only if the 'html' parameter has been used",
  "sentiment": {
    "score": "strength of sentiment detected, from -1.0 (totally negative) to 1.0 (absolutely positive)",
    "type": "either 'positive', 'neutral' or 'negative'"
  }
}

For more information about status codes and error handling please refer to the dandelion generic API documentations. The cost of each request can be found in the response headers as described here.

Example

Request

https://api.dandelion.eu/datatxt/sent/v1/?lang=en&text=I%20really%20love%20your%20APIs&token=<YOUR_TOKEN>

Response

Connection: keep-alive
Content-Length: 104
Content-Type: application/json;charset=UTF-8
Date: Wed, 21 Oct 2015 16:29:37 GMT
Server: Apache-Coyote/1.1
X-DL-units: 1
X-DL-units-left: 999
X-DL-units-reset: 2015-10-22 00:00:00 +0000
{
  "timestamp": "2015-10-21T16:29:37",
  "time": 1,
  "lang": "en",
  "sentiment": {
      "score": 0.9,
      "type": "positive"
  }
}
SpazioDati Via A. Olivetti 13, 38122, Trento (TN) -


Dandelion API built with by
Company subject to management and coordination of Cerved Group S.p.A.

site privacy | api privacy | tos | cookies | consent preferences

Contact Us

@dandelionapi

Need more info or a custom project? Write us: hello@dandelion.eu

About Us

We're a startup based in Italy, specialized in Semantics & Big Data.
Find out more about us at spaziodati.eu