Chapter 6. Library API
This chapter covers the following:
-
Constructing an API with Fastify.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.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access