Memi: The next topic we will discuss is the HTTP verbs.
So what are actually the HTTP verbs in REST API?
So the verbs set the action to be performed.
So when REST API receives a request,
it first looks at the verb and can decide
what is the actual action
that should be performed with the resource.
Now, when talking about actions,
there are usually four types of actions
that are made or executed in REST API.
These actions are retrieve a resource,
add a resource, update a resource,
and delete a resource.
Now these four actions are so common
in data-oriented applications
that they have their own acronym, which is CRUD.
And CRUD stands for create, read, update, and delete.
These are the four actions that you will usually execute
on data or information in information systems,
and you will probably stumble across this acronym, the CRUD.
So if you do, then simply remember what it means.
Again, create, read, update, and delete.
Now, HTTP verbs are not an invention
made specifically for REST API.
It's actually part of the HTTP standard.
You can take a look here,
and I know it's quite a long paragraph
and a little bit complicated,
but you can look here at the HTTP standard,
and you can find it at the URL at the bottom of the page.
And in this case,
this is the paragraph that deals with the GET verb.
There are actually a lot more verbs,
although GET is the most common one.
So you can see that the verbs
are actually part of the HTTP standard,
and this is actually one of the design goals of the REST
because REST, from the start,
tried to take advantage of existing standards
and not invent new ones.
So it uses the HTTP verb as a sign
of the action that should be made.
Now HTTP verbs are extremely important
and you should always, always use the correct verb.
One of the most common mistakes of Juno developers
is to always use the GET verb,
even when it's not relevant
and completely misses the mark on the specific action
that should be made.
So when creating REST API, always use the correct verb,
and we will explore those verbs later in this section.
Now also remember that HTTP verbs improve readability.
For example, if you look at URL in REST API,
and you note the verb at the beginning of it,
then you have a general idea of what this API should do.
So for example, if you see a REST API beginning
with GET as the HTTP verb,
then you already know without looking at the code
what this specific API is expected to do.
And that will be probably retrieving or getting a resource.
So HTTP verb must be treated as part of the URL.
It's not some bizarre detail that no one is talking about.
It is an extremely important part of the URL
and should be treated like that.
So with that in mind,
let's deep dive into the various verbs
that we will use in REST,
and we will begin with the GET verb.