r/learnjava • • Feb 08 '23

API, REST & RESTfull

what is the difference between API, REST and RESTful?

I was researching articles, blog and what I understood was: API is a ready-made application that can be implemented in your project. REST, an architecture that contains functions: PUT, DELETE, POST, GET, etc. RESTfull, and the application of REST.

But I'm still trying to understand what exactly an API would be? any coding that contains controller, service and model and an API?

Can I create a workshop API and then implement a front end layer on top?

44 Upvotes

17 comments sorted by

View all comments

35

u/PMmeYourFlipFlops Feb 08 '23
  • API: Service that listens to requests and returns JSON data to be consumed by a frontend.

  • REST is a design pattern where such requests have a distinctive type and function, like PUT, DELETE and the such.

  • RESTFUL means that the service is compliant with the REST specification.

So let's say you have a blog. You have a React frontend and a Spring Boot backend. If you were to create a new blog post, you would send a POST request from react to /posts, which is your RESTful service and it triggers the create method in the Post model using the data you sent it as the payload.

If you want to update your post, you can send a PUT or PATCH request with the new data.

If you want to delete your post, you send a DELTE request.

Look into RESTular and Postman.

3

u/[deleted] Feb 08 '23

I understand now. Thanks!!