Hi there everyone!
First time posting here and I'm still in the early stages of my learning journey with everything backend…
I really like human friendly RESTful API design and want to figure out how best to create an endpoint whose response changes depending on a querystring / or param value?
I've got a URI named /courses. I'd like the default response to return just a minimal list of course info e.g. ID and Name. Fine on it's own, but I'm struggling to figure out if an optional parameter was suppled e.g. /courses?expanded=true then I'd like to return a list of courses with all the course fields: ID, Name, Description, Created_at etc.
Alternatively, an approach similar to what Google offer works well: REST calls for partial responses take this format: e.g. GET https://library.googleapis.com/v1/shelves?$fields=shelves.name
which returns only a list of shelves.name values.
What are my options?
Looking forward to your responses and congrats on such a great platform!
Antony