I have a database of surveys responses and I'm trying to build a RESTful API to expose this data. API should be able to return the following information:
- Available surveys
- Questions
- Answers
- Report (sum of responses for every type of answer per survey question)
I have a problem with identifying how should the resources be structured in this case.
For surveys, questions and responses it's fairly simple:
GET /surveys
GET /questions // filter by surveyId possible
GET /responses // filter by questionId and SurveyId possible
What would be the best approach to fit the reports in this structure? Do I set up a separate route, e.g.:
GET /reports/responses-by-question?surveyId=1
or do I add it as next level in the responses path? E.g.
GET /responses/by-question?surveyId=1
Or do I get this completely wrong and there's some better approach?