Sometimes, it can be very confusing on how to name your api endpoint.
This is the tips and guideline for you on how to name your API endpoint
It will be funny if you put action in the endpoint. We will directly straight know, it use a GET request.
Use singular or plural nouns? It depends.
If get more user, preferably use
/users. If one user, then
/user is the answer
For example 3, this would be misleading. It's not clear. What is fn? As for me, I would think it a function
URIs are case sensitive, try to avoid upper case unless it is necessary. And also, avoid unnecessary confusion and inconsistency in naming your endpoint.
You can refer here for list of special character
Your endpoint will looks more cleaner, clearer and user friendly. Google recommend us to use hyphens as it is good for Google search, it make its web crawling job easier, thus creating more consistent results.
Our API will keep changing over the time, the implementation, the request body, the response etc, hence versioning is important to avoid the endpoint from breaking when the user use it. For me, the easiest way to do versioning is the 1st way.
That's all for the tips and how to naming your endpoint!
Thank you for reading :D
Psstt pstt :p
Do consider to love this article ❤️ and follow me! Why not right? It's FREE~
I would really appreciate it 👨🏻💻