vh-sentiment
Version:
Module for accessing the Viralheat Sentiment API.
61 lines (48 loc) • 1.33 kB
Markdown
You must have a [Viralheat](http://www.viralheat.com/) account and API key to access the
[](https://app.viralheat.com/developer/sentiment).
*Require the module*
```javascript
var vh_sentiment = require('viralheat-sentiment')('[Your API Key Here]');
```
```javascript
vh_sentiment.get('[text (360 characters or less) that you want to analyze]', function(err, data, status) {
if(err) {
// Error
} else {
console.log(data);
}
});
```
*Successful* response will look like:
```javascript
{
text: 'Hello! I love this product!!',
mood: 'positive',
prob: 0.9372610796240683,
raw: {
status: 200,
error: null,
text: '\'Hello! I love this product!!\'',
mood: '\'positive\'',
prob: '0.93726107962406835'
}
}
```
The object contained in the _raw_ attribute is the response returned directly from the [Viralheat Sentiment API](https://app.viralheat.com/developer/sentiment).
```
vh_sentiment.train('[text you would like analyzed]', ['positive','negative', or 'neutral'], function(err, data, status) {
if(err) {
// Error
} else {
console.log(data);
}
});
```
*Standard response from a train request:*
```javascript
{"status":"ok"}
```