I’m building a website where users can sell products. I’m beginning with a RESTful api, so far I have:
/Product (Accepts, post)
/Product/[product_id] (Accepts, get, put, delete)
I also want to list all of the products for all users, so I’m thinking of having:
/Products (Accepts, get)
and here’s my problem, I also want the user to view their own products, so I’m also thinking of having:
/MyProducts (Accepts, get)
I just think that having /Products & /MyProducts are kind of the same, except they are filtered on the user, so what method should I use to do this?
I’ve thought about the below, but don’t know if this is frowned upon:
/Products (Accepts, get) <- returns all products
/Products/[user_id] (Accepts, get) <- returns all products for a user id.
Any help, pointers or guidance extremely welcomed!
Thanks
Chris
Simplify drastically. There are really only two resources you need:
/products/products/{id}All your needs can be met with just those two resources:
GET /productsGET /products?showOnlyMine=truePOST /productswhich returns aLocationof/products/{id}GET /products/{id}Feel free to use a different URI parameter than
showOnlyMine, of course.