Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Writing Your Own REST API | RESTful API
Backend con Spring Boot

bookWriting Your Own REST API

Well, let’s move on to the most exciting part and write our own REST API. I recommend coding along as you watch the video for a better understanding.

Let’s create a simple RESTful API for a bookstore using Spring Boot. We will include all the necessary components: models, repositories, services, controllers. The API will support creating, reading, updating, and deleting books.

Short Clip From the Video

In our REST API, we defined the model we’ll be working with (Book model), which includes the following fields:

Main.java

Main.java

copy
123456
public class Book { private String id; private String name; private String author; private String price; }

We also implemented endpoints for our application, which we will test in the following chapters.

Examples of the endpoints:

  • GET /books — retrieves all books (findAllBooks() method);
  • POST /bookscreates a new book (createBook() method);
  • PUT /books/{id}updates a book with the specified ID (updateBook() method);
  • DELETE /books/{id}deletes a book with the specified ID (deleteBook() method).

Lombok Dependency

If you want to learn more about Lombok, you can read about it here. Also, here’s a link to the dependency.

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 3

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

Awesome!

Completion rate improved to 3.45

bookWriting Your Own REST API

Desliza para mostrar el menú

Well, let’s move on to the most exciting part and write our own REST API. I recommend coding along as you watch the video for a better understanding.

Let’s create a simple RESTful API for a bookstore using Spring Boot. We will include all the necessary components: models, repositories, services, controllers. The API will support creating, reading, updating, and deleting books.

Short Clip From the Video

In our REST API, we defined the model we’ll be working with (Book model), which includes the following fields:

Main.java

Main.java

copy
123456
public class Book { private String id; private String name; private String author; private String price; }

We also implemented endpoints for our application, which we will test in the following chapters.

Examples of the endpoints:

  • GET /books — retrieves all books (findAllBooks() method);
  • POST /bookscreates a new book (createBook() method);
  • PUT /books/{id}updates a book with the specified ID (updateBook() method);
  • DELETE /books/{id}deletes a book with the specified ID (deleteBook() method).

Lombok Dependency

If you want to learn more about Lombok, you can read about it here. Also, here’s a link to the dependency.

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 3
some-alt