I’m trying to design a RESTful API where the users can fetch a single product or list of products in a single GET request. Each product has a unique id.
The single product URL is simple enough:
http://mycompany.com/api/v1/product/id
This returns the information for a single product. I’m confused as to how the URL for multiple product information should look like.
How about
http://mycompany.com/api/v1/product/ids
where ids is a comma separated list of ids?
Your suggestion of ids separated with commas is good enough.
It would be instructive to examine some public REST APIs to see how they handle. For ex, the StackExchange API separates ids with a semi-colon – https://api.stackexchange.com/docs/answers-by-ids