RESTful API routes design: nested vs. non-nested
My question is about the advantages of nesting resources when building URLs for API purposes. Consider the following two alternatives for accessing an employee resource: /api/employees?department=1 # flat Vs. /api/departments/1/employees # nested Now consider the task of developing a general purpose library to access REST resources from an API. If all routes were flat, such a REST wrapper library would only need to know the name of the resource being accessed: store.query('employees', {department_id:1}) => /api/employees?department=1 However, if we were to support nested routes, this wrapper