Option 1 seems the most restful pattern. This is because the last listed resource in a path should be the returned resource. So since you are trying to get all the orders from a seller or buyer, the orders should be the last resource in the path. Another way of thinking about this is that the nesting structure of your paths should mirror the nesting structure of your models, e.g. orders are within a customer/seller.
So /customers/:customerId/orders
implies that orders of a particular customer will be returned, while /orders/customers/:customerId
implies that all a particular customer (of the possibly many on the order) will be returned.
I do see the logic in your second strategy, since you can group all requests for order objects together whether by customer or seller, however a better way to accomplish this pattern would be to use the path /orders
and specify the customer or seller in the query string. For example, /orders?customer_id=:customerId
and /orders?seller_id=:sellerId
.
Note that there is nothing wrong with allowing a resource to be accessible in more than one way. Check out this post for more discussion on nested RESTful routing: What are best practices for REST nested resources?.