Trendrr – Daylife mashup

I saw a demo of Trendrr at the Apr 1st New York Tech meetup. Seemed like an easy way to throw all your data at one place and get some graphs in basic layouts (line,bar,area charts). Mark Ghuneim well utilized his 5 minute demo slot to show what trendrr can do and how their users have used their API. The best graph I liked was the one tracking someone’s CPU usage. You can then embed these graphs anywhere you want or export the data as xml, json or even an excel spreadsheet.

So I got my hands dirty today playing with the Trendrr API to push trending data in news from daylife about any topic. Signed up on trendrr.com, read some documentation about how to use the API and jumped right in. I have written a php script that is calling the daylife API to get the data and the trendrr api to publish it.

I have hosted the script for you to create your own trendrr graphs (more details below) or download it to customize the data that you send to trendrr.

Here are some of the graphs:

Here is my feedback to the Trendrr folks:

  1. The API is great because its simple
  2. Its always tricky to keep things simple and introduce advanced features. The graph currently is exported as an image. If it could be exported as HTML, I would love to have the capability to click on the data point and go to the real source of that data. In that case, the trendrr API will need to accept a link along with each data point. The timeline widget on the daylife.com topic pages support similar functionality.
  3. The delay between sending the data through the API and it showing up on the graphs is pretty significant. It would be great if does not take more than a minute.

Read more below about how I implemented the mashup of Trendrr and Daylife APIs.

The Trendrr API is a simple HTTP GET request with a very few parameters sent in the query string.

A sample URL looks like this:

http://www.trendrr.com/api/simple?key=<your trendrr key for the graph>&value=<value you want to graph on the y-axis>&date=<time in microseconds since the epoch on the x-axis>

Here is the step-by step process that I followed to create my mashup:

a. From trendrr home page:

  1. Log in
  2. Click ‘Add Data’ on left hand side
  3. Click ‘Add Custom Data Set’

b. Fill in ‘Data Set Title’ and ‘Legend Text’. In this case I used:

Data Set Title = ‘Hillary Clinton’
Legend Text = ‘Number of mentions in news for Hillary Clinton

c. Select the time scale for your graph. I left the it to be the default 2 weeks. Once you have submitted this information, you get an API key for this particular graph/dataset. You then use this key in the API call above.

d. Collect your data. I wrote a php script that would take ‘Hillary Clinton’ (or any other topic) as an input and get the number of mentions for her in news per day in the last 14 days from the Daylife API.

e. Send that data to trendrr to track on the graph I just created for Hillary by calling the trendrr API. So now I have a trend graph for Hillary’s coverage in news in the last 2 weeks.

Here is my script that you can use to create your own trends using the Daylife API:

http://develop.daylife.com/demos/trendrr/trendrr.php?query=Hillary+Clinton&trendrr_key=<your trendrr key>&days_back=14&interval_days=1


As you can see the script accepts the following parametrs:

i. query – the topic in news that you want to track

ii. trendrr_key – your key for the trendrr graph that you want to track this data on

iii. days_back – number of days in past that the data was sent to trendrr.

iv. interval_days – number of days over which the mentions were counted for every data point sent to trendrr

The URL above sends number of mentions for Hillary Clinton per day in the last 14 days to trendrr.

If you want to send number of mentions for Hillary Clinton every 3 days in the last 21 days to trendrr, you call my script as follows:

http://develop.daylife.com/demos/trendrr/trendrr.php?query=Hillary+Clinton&trendrr_key=<your trendrr key>&days_back=21&interval_days=3

f. Schedule a cron job to call the following URL once every day:

http://develop.daylife.com/demos/trendrr/trendrr.php?query=Hillary+Clinton&trendrr_key=<your trendrr key>

Remember, if you are trying to trend data every X days, you schedule the job every X days and provide interval_days=X in the URL above for the job.

If you do not know how to schedule a cron job or do not have access to your server, use Webcron

g. Make the graph public from the trendrr site by going to My Graphs. You can then pick the embed code or the Permalink to distribute your graph.

About these ads

5 thoughts on “Trendrr – Daylife mashup

  1. guru says:

    Brother TechEvangelist, so how many have you converted to the dark side…
    So how is this different from charts in Excel?. What’s do trendy anyway…

  2. vangelist says:

    Guru,

    Dark is the new bright!

    The way trendrr differ from regular excel graphs is that it can programatically refresh the data from a data source without having to update spreadsheets manually.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s