O'Reilly logo

RESTful Java Patterns and Best Practices by Bhakti Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Best practices when designing resources

The following section highlights some of the best practices when designing RESTful resources:

  • The API developer should use nouns to understand and navigate through resources and verbs with the HTTP method, for example, the /user/1234/books is better than /user/1234/getBook URI.
  • Use associations in the URIs to identify subresources. For example, to get the authors for book 5678, for user 1234, use the following /user/1234/books/5678/authors URI.
  • For specific variations, use query parameters. For example, to get all the books with 10 reviews, use /user/1234/books?reviews_counts=10.
  • Allow partial responses as part of query parameters if possible. An example of this case is to get only the name and age of a user, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required