Using CrunchBase with Codenvy

Instantly create CrunchBase API project off a Codenvy Factory:

This tutorial will explain the details of integrating the CrunchBase API into Codenvy. CrunchBase is the free database of technology companies, people, and investors that anyone can edit. With the CrunchBase API, you will be able to retrieve and edit information about companies like Facebook, Youtube into your application. The explanation has been done with a very basic Java servlet project that makes use of the CrunchBase API to explain some basic features provided by the API.

Register at CrunchBase

Before proceeding to the creation of the Java project, please register at with your email id and then create a CrunchBase application specifying the purpose for the application that will generate keys which will be used for the integration:


On registering the application, you can see your keys at the ‘My Account’ section:


The CrunchBase API has different methods to integrate with Crunchbase,each accepting different input parameters for various different information from the Crunchbase website. You can get more information about the API methods at

To assist the integration with the different methods, the Crunchbase website has a IO Docs section at which will give you the HTTP Request URL that will be required to invoke the method from your Codenvy application and the response that you would get. For example, if you want to invoke the CrunchBase API, you would do the following steps in your CrunchBase account under your registered application –

a) Navigating to this section will list all methods for the CrunchBase API:


b) Let us take the Entity Information related method for integration. Now expand the Entity Information related method. This will have the option to enter the entity for which we will retrieve information such as ‘company’ and the name of the entity such as ‘facebook’ and the response will be in the JSON format containing all the information about Facebook:

c) On clicking Try it, you will get the Request URL generated that will be used from your application in Codenvy and the request and response headers and response body in JSON format that you will capture in your Codenvy application:

Create a Project in Codenvy

Now, login to your Codenvy workspace and create a WAR project named as ‘CrunchBaseSample’. This will have the following structure :


Create pom.xml File

To make use of the CrunchBase API through HttpClient as a servlet, please update the pom.xml to include the HttpClient and Java EE Web API jars and the servletapi jar into your project as Maven dependencies –

  <project xmlns="" xmlns:xsi=""
      <name>Maven Repository Switchboard</name>

Create Java Class

Now create a Java servlet class named ‘’ that will talk to the CrunchBase website with the Http request URL that was generated above in the CrunchBase IO Docs section and then get a Http response back with the response header and the response body in the JSON format which will be then displayed on the browser through a JSP. All this is done inside the method doGet() in the sample source Java class.

package com.codenvy;

import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;


import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CrunchBaseServlet extends HttpServlet{

  private HttpClient client = new DefaultHttpClient();

  protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

        StringBuffer sb = null;
        try {
            String getURL = "";

            HttpGet req = new HttpGet(getURL);
            req.addHeader("X-Originating-Ip", "");
            HttpResponse res = client.execute(req);
            HttpEntity entity = res.getEntity();
            String responseString = new BasicResponseHandler().handleResponse(res);
            if (entity != null) {

            sb = new StringBuffer("<br/>Simple GET request to url : "+ getURL +"<br/><br/>");
            sb.append("*** Request headers ***").append("<br/>");
            Header[] requestHeaders = req.getAllHeaders();
            for (Header header : requestHeaders) {

            sb.append("*** Response headers ***").append("<br/>");
            Header[] headers = res.getAllHeaders();
            for (Header header : headers) {

            sb.append("*** Response Body ***").append("<br/>");

        } catch (Exception ex) {
            sb = new StringBuffer(ex.toString());

        request.setAttribute("data", sb.toString());
        RequestDispatcher rd = request.getRequestDispatcher("/success.jsp");
        rd.forward(request, response);

Create index.jsp File

Your Codenvy project will have an index.jsp which will invoke the Servlet class -


Create success.jsp File

Your Codenvy project will have a success.jsp which will be invoked from the CrunchBaseServlet class to display the response on the browser -

<p>Data : <br/><%=request.getAttribute("data") %></p>

Create web.xml File

The servlet mapping ‘/hello’ is defined in the web.xml as follows –

<display-name>CrunchBase Servlet App</display-name>


Run Application

Now you build and run your Codenvy project and the Http response from the CrunchBase website with the information about Facebook will be displayed in the browser:

You can use this JSON format response in a way that you would like to meet your needs for your custom application.

The CrunchBase API provides more methods that can be used in a similar way as above to retrieve various types of information. More details would be available on their website – and