Good day. I’m learning JSON API and trying to implement it in our new project. I need your opinion about URL design.
In our app we have “books” and “pages” resources.
“Page” resource can not exist outside of “book”.
Is it ok to have such set of URLs to manage books and pages?
GET /books - Get books
GET /books/:id - Get book
POST /book - Create new book
PUT /book/:id - Replace book
PATCH /book/:id - Update book
DELETE /book/:id - Delete book
GET /books/:id/pages - Get book pages
GET /books/:id/pages/:id - Get book page
POST /book/:id/pages - Create new book page
PUT /book/:id/pages/:id - Replace book page
PATCH /book/:id/pages/:id - Update book page
DELETE /book/:id/pages/:id - Delete book page
According to JSON API recommendations /books/:id/pages URLs are “related resource URL” (https://jsonapi.org/recommendations/#urls-relationships). But I didn’t find info if it is ok to be able to create\update resources using related resource URLs.
Thanks for help