I am stuck on how I should be structuring my URLs for a RESTful API I am developing.
My problem comes from the fact that sometimes I need to get several joined tables from a single call.
In one instance, I need to get two tables. I have a table named courses, and a table named topics. I need to get the course_name row and then all the topics that belong to that course.
In another instance, I need to get three tables. I need to join the topics to the parts to the bullet_points table
How should I refer to these in the urls?
Should it be something like this?
To get a single course:
courses/:course_id/
To get a course and it’s topics:
courses/:course_id/topics
To get a topic and it’s parts and it’s bullet points:
courses/:course_id/topics/:topic_id/parts
I am new to this and so am wondering how I should really be approaching the structure of the urls.
I think your suggested URL structure is good. It also corresponds nicely to a good resource layout.