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. from flask import Flask, request import json import sendgrid app = Flask(__name__) sg = sendgrid.SendGridClient('username', 'password') @app.route('/',methods=['POST']) def foo(): data = json.loads(request.data) body = "" for x in data['results']['collection1']: body = body + format(x['TV Name']['text']) body = body + '<br>' body = body + format(x['TV Price']) body = body + '<br>' body = body + format(x['Savings']) body = body + '<br><br><br>' subject = "Changes to Best Buy Black Friday TV DEALS!!!" sender = "email@example.com" to = "firstname.lastname@example.org" message = sendgrid.Mail() message.add_to(to) message.set_subject(subject) message.set_html(body) message.set_text(body) message.set_from(sender) status, msg = sg.send(message) return "OK" if __name__ == '__main__': app.run() 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.