Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

REST Resources?  RSS feed

 
Rj Ewing
Ranch Hand
Posts: 120
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the best practice when creating rest resources? If I need an aggregate of a few domain objects, is it better to fetch them with multiple REST calls or to create a single REST endpoint that returns everything I need?

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think there's any problem with having hierarchical REST resources. Keep it logical, of course.
 
Junilu Lacar
Sheriff
Posts: 11144
160
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to consider that it's generally recommended that you use the plural form for REST resource names, e.g. /orders instead of order/

REST api best practices resource names

From there, you'd want to search for REST API best practices for subset of collections
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:You might want to consider that it's generally recommended that you use the plural form for REST resource names, e.g. /orders instead of order/

True, but by "aggregate" I assumed (perhaps incorrectly) that he was talking about compositing resources rather than a simple list.
 
Rj Ewing
Ranch Hand
Posts: 120
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

I was talking about multiple hierarchical REST resources.

I was wondering about creating a new endpoint for getting a specialized composite resource vs hitting multiple endpoints to get the same data.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to get a Car resource, it doesn't seem to make sense to make four requests for the Tires, two for the SideMirrors, one for the SteeringWheel, and so on, does it?

Again, just make sure you are keeping it logical and not combining things in an illogical manner for supposed convenience.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!