Register to Better Coder! It's free.
Enjoy the premium features and succeed at every job interview.

BP139: Use sub-resources for relations

Good API is well understood by the other developers. It should be as clear as possible what the API endpoint does when you read the URL from left to right.

If there is a resource that is related to other resource, communicate it via the URL.



The URL above is communicating that there are orders that have order items. The entities on the left are more important than the entities on the right. The entities on the left usually need to exist before it makes sense for the entities on the right to exist.


No Comments Yet.
Be the first to tell us what you think.

Download Better Coder application to your phone and get unlimited access to the collection of enterprise best practices.

Get it on Google Play