In my final Code Challenge blog post, I’m taking a look at CrunchBase. If you’d like to read more about this Code Challenge, and see a list of other posts, visit my first post: 15 Days of Code Challenge. In my previous blog posts we looked at a Python module and Machine Learning API that let us analyze incoming email by their sentiment and concepts based on the body of the email. In this post, I want to showcase another way to classify and prioritize your incoming email. We’ll look at the CrunchBase API and get information from their database on the sender and their company. Requirements: Create a SendGrid account if you haven’t (http://www.sendgrid.com/free) Get access to the CrunchBase API (https://developer.crunchbase.com/) Getting Started: The first thing we do is create an incoming email address using the Parse Webhook. For more information on how to setup the Parse Webhook, you can check out this post. Next, we create a quick Python app that gets the incoming email, calls the CrunchBase API to extract more information from the senders domain, and lets us know the result. I’ve put the code below. Using the Parse Webhook, I’ve created an email address firstname.lastname@example.org. Any email I forward to that address will be analyzed by the above python code. It then sends us back an email with the corresponding information. Code from flask import Flask, request import sendgrid import requests app = Flask(__name__) @app.route ('/incoming', methods =['POST']) def nextweb(): subject = request.form['subject'] body = request.form['text'] mailfrom = request.form['from'] domain = mailfrom.split("@").rstrip(".com>") print domain url = 'https://api.crunchbase.com/v/2/organization/'+domain+'?user_key=your_crunchbase_key' r = requests.get(url) #print r #print url desc = r.json() comp_info = desc["data"]["properties"]["description"] body = " ### " +domain+ " ### " body = body + comp_info sg = sendgrid.SendGridClient('SG_user', 'SG_pass') message = sendgrid.Mail() message.add_to(mailfrom) message.set_subject('Re: '+subject) message.set_html(body) message.set_text(body) message.set_from('email@example.com') status, msg = sg.send(message) return "OK" if __name__=='__main__': app.run(debug=True) I’ll be putting together a wrap-up post about my favorite APIs and posts from the Code Challenge, so be sure to check back in soon. You can always hit me up on Twitter if you want to talk about these, too!