Memi: The next part in the URL
is the entity.
But first, a quick reminder:
As you probably remember,
REST deals with resources or entities.
So REST API should represent a resource,
and not an action, or a method-ing.
And the main part of REST API
is always the entity that it deals with.
So, with that in mind,
the next part of the URL
is the entity we are going to deal with.
Now, to make the URL
as simple as possible,
we will always strive to use only one word
as the entity name.
We don't want to make it a complicated
and incomprehensible URL,
and we would like the developer
to be able to understand immediately
what entity is the URL dealing with.
Now, another thing to keep in mind,
is that never use a verb
in the URL,
instead of the entity.
So, we don't want to see things like,
"do that"
or "go there"
or "save this".
Only nouns,
entities, resources,
never verb.
And, why is that?
Because, the verb part of the URL
is actually implemented with the HTTP verb,
which we discussed earlier.
So the HTTP verb
provides the action that we want to run,
and the URL provides the entity
that we want to execute the action on.
So, let's see some examples of valid URL.
So, this is the first one,
and what we see here
is "api/v1/order",
so in this case, the entity is "order".
In this example, the entity is "employees".
And also in this example,
the entity is "travel".
Now, notice that in all those examples,
we prefix the entity with the API
in the version just as discussed earlier.
Okay,
so let's add the entity
to the URL we are building.
So here, we are in Beeceptor,
and this is the URL text box;
we already have the API and the version,
and now we will add the entity,
and let's use the "order" entity.
So, when a developer sees this URL,
she immediately understands
that this API deals with the order entity,
and together with the method here,
then she immediately sees that this API
gets an order.
Note how simple and how readable this URL is,
and always try to make your URLs
as simple as that.