Using Zeit with Codenvy

Talk to Zeit API using Codenvy Factory:

ZEIT is one of the biggest German newspapers. They provide ZEIT ONLINE Content API which gives developers access to hundreds of thousands of ZEIT articles and their corresponding metadata. The API provides the information about author search, articles, newspaper departments, keywords, products and series. The API uses RESTful calls and responses will be in JSON. Before accessing the Rest API a developer needs a API key . Developers can get he API Key at

API Request:
API Key we have requested:


More info on API Documentation regarding methods and parameters is available here. Method details are presented below:

In this Tutorial we are going to Use “department” Method to access the all Departments Information. The department method has 4 parameters:

Create a Project

Project structure in Codenvy:

Create Java Class

Create a servlet to access the REST API Provided by ZEIT. In the REST call we are limiting the result data to 2 (limit=2) and search parameter is “*” (q=*) which looks for the entire department Information, remaining parameters will be initialize to default.

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 ZeitOnlineServlet extends HttpServlet{

private static final long serialVersionUID = 1L;
private HttpClient client = new DefaultHttpClient();

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

        StringBuffer sb = null;
        try {
            String getURL = "*&limit=2";

            HttpGet req = new HttpGet(getURL);
            req.addHeader("X-Authorization", "1d78b3a9bd4ad4c8bf5c1b461410c8df20a494e08c722c0360f4");
            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/>");
            String[] str=responseString.split(",");
            for(String s:str){
           // sb.append(responseString).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);

In this servlet we are calling the Rest API of ZEIT Online for retrieving the Department Information. In response we’ll receive information in JSON Objects as shown below.

Create index.jsp and success.jsp Files

We’ll call the Servlet from a Jsp.
Index.jsp :

<%    response.sendRedirect("/zeitonline");%>

We’ll retrieve the information in success.jsp
Success.jsp :

<%=request.getAttribute("data") %>

Create pom.xml File

We need to specify the dependencies in pom.xml as shown below

<project xmlns="" xmlns:xsi=""