This chapter covers
- Constructing an API with Express.js
- Building REST endpoints
- Connecting to a relational database
Although most people are familiar with the internet by way of their web browser, most activity and data transfer happens behind the scenes. Some data, like real-time train schedules, is made available not as just a standalone web app, but as a resource others can use and implement into their own apps. This resource is called an Application Programming Interface (API), and it allows its users to view all or some available data belonging to a restricted environment (like the Railroad authority). Some APIs allow the addition, modification, and deletion of data, especially if it’s your own data or if you are the authority over that resource itself.
In this chapter, you’ll build a RESTful API, meaning it will support access and modification of data through a standard protocol. You’ll also connect the API to a database—to which you can add new information and from which you can access older records. In the end, you’ll have the translatable skills needed to build an API for just about any type of data.