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
Looks ok to me
Ok cool, I was worried everything nested under courses seemed weird
But I guess it is all related to a course
Yeah
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?
Yeah
Chat gpt says otherwise but I think its tripping 😆
For a simple reference, you can check discord api
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.
DELETE /courses/:course_id/members gives me the vibe that it deletes all members, but I guess it is up to me to decide
That doesn’t really make sense as a feature though
deleting all memebrs?
Yeah?
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)