Proper REST API Nesting

I feel like I am doing too much nesting. Do these routes look semantically correct overall? thanks! GET /courses (get course details of courses you are enrolled in) GET /courses/:course_id (get specific course details, should this get everything related to the course?) POST /courses (create new course) POST /courses/enroll (attempt to join class only using course code) DELETE /courses/:course_id (delete entire course) GET /courses/:course_id/members (owner gets all members of their course) PATCH /courses/:course_id/members/:user_id (change role of user in course) DELETE /courses/:course_id/members/:user_id (leave a course) PATCH /courses/:course_id/meetings/:meeting_id (updated details of a meeting) POST /courses/:course_id/meetings (create a new meeting) POST /courses/:course_id/meetings/:meeting_id (join the queue for this meeting) GET /courses/:course_id/meetings/:meeting_id (get specific meeting details)
13 Replies
Sylte
Sylte•2y ago
Looks ok to me
Perfect
PerfectOP•2y ago
Ok cool, I was worried everything nested under courses seemed weird But I guess it is all related to a course
Sylte
Sylte•2y ago
Yeah
Perfect
PerfectOP•2y ago
DELETE /courses/:course_id/members (users leaves course on their own) DELETE /courses/:course_id/members/:user_id (owner kicks user from course) Do these make sense?
Sylte
Sylte•2y ago
Yeah
Perfect
PerfectOP•2y ago
Chat gpt says otherwise but I think its tripping 😆
Sylte
Sylte•2y ago
For a simple reference, you can check discord api
Sylte
Sylte•2y ago
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Perfect
PerfectOP•2y ago
DELETE /courses/:course_id/members gives me the vibe that it deletes all members, but I guess it is up to me to decide
Sylte
Sylte•2y ago
That doesn’t really make sense as a feature though
Perfect
PerfectOP•2y ago
deleting all memebrs?
Sylte
Sylte•2y ago
Yeah?
Perfect
PerfectOP•2y ago
yeah agreed Ok cool if its the user itself leaving, I can use the auth on the request so no user id required I could also just make a request to the one using the userid but thats doing a kick check (should probably just modify to handle both cases)
Want results from more Discord servers?
Add your server