The railway API
Now that we have a working knowledge of what an API is, let us turn to something more concrete.
Before we show you the code, allow us to stress that this code is not production-ready, as that would have been too long and needlessly complex for a book’s chapter. However, this code is fully functional, and it should provide you with a good starting point to learn more, especially if you experiment with it. We will leave suggestions on how to do so at the end of this chapter.
We have a database with some entities that model a railway application. We want to allow an external system to perform CRUD operations on the database, so we are going to write an API to serve as the interface to it.
CRUD stands for Create, Read, Update, and Delete. These are the four basic database operations. Many HTTP services also model CRUD operations through REST or REST-like APIs.
Let us start by looking at the project files, so you will have an idea of where...