This is the post for Day 2 of my 15 Days of Code Challenge. In it, I’ll be looking at the Kimono Labs API and mashing it up with the SendGrid Web API.

I’ve wanted to play around with the Kimono Labs API for a while, but never got the time. We’ve talked about the difference between webhooks and APIs on the blog before, so you can head there for a refresher. I thought this would be perfect for Day 2 of my blog series. Plus, Black Friday is this week and what better way to show off another cool API than with a mashup?

What is the Kimono Labs API ?

According to the website, their technology turns any website from a user’s browser into a structured API. This sounds pretty interesting and possibly a much better experience than using a module for a web scraper and customizing that for your project.

Installation

From the Kimono website, I’ve registered and installed the Chrome extension. From here, it looks like I can just click on the Kimono button to start the process of turning a website into an API. 

Create Properties / API

Next, I go to the website I want to turn into an API. In this case, I’m going to visit the Black Friday TV deals section of the Best Buy website: http://www.bestbuy.com/site/home-solutions-promotions/samsung-tv-savings/pcmcat348700050013.c?id=pcmcat348700050013

Then I’m going to click on the Kimono button to launch the Kimono chrome extension:

From here, we can just select elements on the webpage to create into properties that will be in our API. For this Best-Buy-Black-Friday-TV API, I’m going to select three properties: TV Name, Price, and Savings.

Once I’m done selecting the properties I want for my API, I just click on the “done” button. I’m then presented with a screen to name the API. That’s it, I’ve just created an API quickly and seamlessly using their extension! It’s a really great experience.

Here is a little image on how the JSON looks like:

Creating the Mashup

Kimono has a webhook functionality that will keep checking the data from the API for changes in a set interval of time. If there are any changes, it will post the data to a URL of your choice. So what we are going to do is email the changed data to my personal email using SendGrid. The benefit of this mashup is I’ll get notified by email when Best Buy edits a deal or adds a new one!

In the code below I created a quick Python app that will get the posted json of changed data and email that to my address using the SendGrid Python lib.

You can sign up for a free SendGrid account if you want to copy this API or make a new one of your own. Over the next few weeks, I’m going to continue writing about different technologies, so check back every Monday, Wednesday, and Friday for new tech posts! You can also visit my intro post that will have an updated list of everything I’ve written.



Meet Kunal, Developer Evangelist at-large for SendGrid and home-grown New Jersey hacker. He previously ran General Machines, which developed Deaftel - a phone service for the deaf that converts voice to text and text back into voice over a phone call. Since March 2013, Kunal has been working as a Developer Evangelist at SendGrid, helping enable developers to get the tools and resources they need to make awesome, creative stuff.