A Notes API

Suppose a person keeps their notes in an app. They write a grocery list in the client on their phone, and later they read it in the client in their web browser. Both clients have to show the same notes. So the notes cannot be stored on the phone or in the browser. They are stored on a server, and each client reads and changes them by sending requests to the server’s API.

We will design a RESTful HTTP API for the notes app, just as we did for the registrar in Chapter 7. The registrar API is read-only (by design), so every request is a GET. A notes app has to change data. A person adds a note, corrects a typo in it, and deletes it when they no longer need it. A request that changes data on the server is a write.

Requirements

  • The API must let a client create a note with a title and a body. The server assigns the note’s identifier and records when the note was created.
  • The API must let a client list all notes.
  • The API must let a client read one note.
  • The API must let a client replace a note’s title and body.
  • The API must let a client change only the title of a note, or only the body.
  • The API must let a client delete a note.

Limits

For simplicity, we focus only on the notes and not on other aspects of the app, such as authentication, authorization, and user accounts. We also leave out sharing, folders, tags, and search. We do not paginate the list of notes, because we have already seen how to do that for the course catalog.