Developer API documentation

The sentiment analyzer

Request Format

This service directly exposes our text sentiment analyzer. It is best suited to analysing larger bodies of text about music (e.g. an album review), though gives potentially useful data on smaller messages as well (e.g. tweets). To score some text either send a form POST request or a GET request to:

http://api.semetric.com/sentiment?token=YOURTOKEN

With each text chunk to be evaluated submitted as the value of a text key. A maximum of 100 text chunks can be submitted in a single call with each text chunk having a maximum length of 10,000 characters.

You will receive a JSON list of dictionaries (in the same order as the submitted text, one per submitted item) in the response envelope containing a key score. The value for this key is an integer response between 1 and 5. 1 indicates negative sentiment, 5 is most positive, and 3 is neutral. There is also a key confidence, with the raw confidence score associated with the sentiment score. This can be quite small (< 0.01) while still providing meaningful scores.

Note: It is best to strip any formatting from text submitted to this service (e.g. HTML tags) and this service works best with longer bodies of text, but short snippets e.g. tweets that express some sentiment will generally work too.

Example (as a form POST):

$ curl -F "text=I love Lady Gaga, she is the best ever" \
-F "text=This gig is terrible, I'm getting outta here" \
http://api.semetric.com/sentiment?token=YOURTOKEN
{
    "response": [
        {
            "confidence": 0.021626673019788045,
            "score": 5
        },
        {
            "confidence": 0.01697893560345428,
            "score": 1
        }
    ],
    "success": true
}
$

Example (as a GET):

$ curl "http://api.semetric.com/sentiment?token=YOURTOKEN\
&text=I%20love%20Lady%20Gaga%20she%20is%20the%20best%20ever&\
text=This%20gig%20is%20terrible%20Im%20getting%20outta%20here"
{
    "response": [
        {
            "confidence": 0.021626673019788045,
            "score": 5
        },
        {
            "confidence": 0.01697893560345428,
            "score": 1
        }
    ],
    "success": true
}
$

As can be seen, both formations return the same result.

How does it work?!

Our sentiment analysis service uses a statistical machine learning model trained on millions of music related documents (reviews, interviews, etc). It regularly re-trains itself to keep up to date with changing language trends.

Check out http://www.musicmetric.com/2010/01/musicmetrics-sentiment-analysis-v1-0-beta/ for more details on how it works.