Integration Cookbook Viralheat

Hey everyone, thanks for continuing to read my coverage on integration. This week is Viralheat’s turn in the spotlight. In case you missed it, I covered Chatterbox, Semantria, and AlchemyAPI in my last posts. Go check them out if you’re interested. Once again, I will try to be as objective as possible and highlight all aspects of the integration from my personal experience.


Viralheat’s main business is in social media marketing, however along with their main product, Viralheat offers several APIs for 3rd party integrators. For this project I used their sentiment API (

The API itself is simple and doesn’t require any specific knowledge or skills for its usage. Viralheat offers two dedicated end-points, one for sentiment analysis, another for training. For my purposes I was interested in testing out of the box accuracy so the training end-point was not necessary for this project. The integration with Viralheat API was the simplest amongst the tested services; I did everything within a couple of hours including the additional tests and benchmarks I built for measurement purposes.

When I started the integration I did not find any ready-to-use code so I decided to implement everything myself. Fortunately, the Viralheat sentiment analysis API is quite simple. The code for Sentiment API execution looks like:

StringBuilder builder = new StringBuilder();
builder.AppendFormat("api_key={0}&", context.Key);
builder.AppendFormat("text={0}", HttpUtility.UrlEncode(document.Value.Source));
WebRequest request = WebRequest.Create(builder.ToString());
HttpWebResponse response = request.GetResponse() as HttpWebResponse;

As with any other service, I wanted to work with native objects rather than with raw output so I implemented a small auxiliary class for deserialization from JSON output, which is the default data format used by Viralheat APIs.

[DataContract(Name = "sentiment")]
public sealed class ViralheatSentiment
[DataMember(Name = "text")]
public string Text { get; set; }

[DataMember(Name = "prob")]
public double Prob { get; set; }

[DataMember(Name = "mood")]
public string Mood { get; set; }

Overall Opinion

Viralheat doesn’t offer any SDKs for integration with their API, however; it’s easy to integrate because of the simplicity of their exposed API. Based on my experience, the integration with Viralheat API was the easiest among the integrated services. Even deserialization into the native objects is not a big deal.


Check in next week for my integration experience with Bitext.

George Kozlov is a software engineering guru. He specializes in software research, architecture and maintenance. He co-founded Semantria, and is currently their CTO and go-to guy when things need improving.