I asked ChatGPT the following:
Could you explain to me, as if I was a child, what a Restful API is?
The answer is amazingly simple and understandable. Glad I asked .
Sure! So, you know how you can ask your parents to give you things, like a toy or a snack? Well, a computer program can also ask for things, but instead of asking your parents, it asks another computer. And the way it asks is by sending a special message called a "request."
And just like how your parents might have a certain way they like to give you things, like in a certain bag or box, the other computer also has a certain way it likes to give things back, called a "response."
A RESTful API is a set of rules for how a computer program can send a request and get a response from another computer program. It's like a special language that those computers use to talk to each other.
For example, imagine you have a toy box with lots of toys in it and you want to allow your friends to pick and choose which toy they want to play with from that box, you will have to have a set of rules for them to follow, like when they can pick a toy, how they can pick it and what they can pick, this is what an API do, it's a set of rules that allows other programs to interact with the data and functionality of a program.
ok, but what is the REST part of a Restful API?
REST stands for Representational State Transfer. It's a set of rules and principles for how a web-based system should be built.
In a RESTful API, the basic idea is that, when a program sends a request, it's asking for a specific "resource" from the other computer. A resource is just some data or information that the other computer has.
And the way that the program asks for that resource is by using a "method." There are a few different methods that a program can use, but the most common ones are GET, POST, PUT, and DELETE.
GET is like asking for something to read, like a book. POST is like asking to create something, like a drawing. PUT is like asking to change something, like editing a story. DELETE is like asking to remove something, like throwing away a toy.
So, RESTful APIs use these methods to interact with resources, and the rules of REST help to make sure that all of the different parts of the system work together in a consistent and predictable way.
Hope it's more clear for you now.
why would I want to build a Restful API?
There are many reasons why you might want to build a RESTful API. Some of the most common include:
In summary, building a RESTful API allows you to share your data, functionality and capabilities with other systems and developers, in a flexible, efficient and secure way.