-: Our next topic is the URL structure of the API.
So a quick reminder, if you remember
this is how a typical API request looks like.
We have the method which we discussed
in the previous section,
we have the headers, and we have the URL,
and the URL is the part
we are going to discuss in this section.
So when talking about URL structure,
we actually talking about the definition
of the structure of the API's URL
meaning what data should it contain, and in which order,
and what is the importance of all this?
So actually the URL is the most important part of the API.
This is the first thing a developer using your API will see.
And it will often be used to judge your API
and it will be a major factor
in the decision of whether to use it or not.
So for these reasons, the URL must be well thought of.
You cannot just slap some URL on your API
and hope that users will come, because they simply won't.
So what you should know about the URL is that
it should be self-explanatory.
So if a developer will look at the URL of the API
he will be able to understand
what exactly this API is doing,
even without looking at the documentation.
And, between us, nobody likes to read documentation.
In addition, the URL should be consistent across the API.
So if you decide on a specific template
of how the API should look like,
then all your APIs should be compliant with this template,
and the URL should be predictable.
So if a developer used your API
for a specific result or specific action,
and now she wants to use it for another action,
then she should be able to roughly predict
how the URL will look like for the other action.
And when making the URL predictable,
you will make your client's life much more easier,
and you will have a better chance of them using it.
So to summarize, your URL should be self explanatory,
consistent, and predictable
or no one will use it, because no one likes
to use something that is incomprehensible
or difficult to use.
Okay, so now let's analyze the various components
of the URL and explain how
and well should they be implemented.