Module 5
In this module, we will build an API like Hopkin's Class Search API (henceforth SIS API) and deploy it. As with the SIS API, ours will be a RESTful HTTP API. It will be simpler in many ways yet more versatile in other ways.
The SIS API provides several endpoints as well as an advanced search where you can provide search parameters to e.g. get courses offered by a particular department or an instructor. We will simplify all this by providing a single endpoint SERVER_URL/api/courses
. When a client hits this endpoint (visits the URL), it will get a list of the current courses offered by the Computer Science (CS) Department. (We will limit the API to CS courses.)
In contrast to the SIS API, we will provide support for basic CRUD operations so a client can create, delete, and update courses in addition to "reading" them. We will hook our API to a database to provide persistence. The database and the application itself will be deployed to a cloud application platform called Heroku.
We will use a Java micro-framework called SparkJava to build the server that serves our RESTful HTTP API. As for the database, we will use PostgreSQL, one of the most popular open-source relational database systems.
As the first step, create a Gradle Java project in IntelliJ. I called mine course-search-api
. Make sure to create a git repository at the root of your Java project so you can track all changes. (Don't forget to add a .gitignore
file.) As you go through the steps of this module, make sure to commit the changes.