eragon-2006
eragon-2006

Reputation: 317

clean REST routes

i´m not sure about my REST naming.

I have 3 routes:

GET and DELETE and PUT /book/:bookId/translation/:translationId

With GET I get the translation of a book. With DELETE I delete the translation of one book. And with PUT I change the translation.

But how about the naming for the POST route? With POST I will create a new translation for a book.

Should it better be /book/:bookId or /book/:bookId/translation

Thanks´s a lot for your feedback!

Upvotes: 0

Views: 40

Answers (1)

jfriend00
jfriend00

Reputation: 707218

Should it better be /book/:bookId or /book/:bookId/translation

It seems that /book/:bookId/translation would make the most sense for the POST of a new translation for the following reasons:

  1. You are properly specifying what you are posting (a translation to a specific book id).
  2. This is consistent with how you query a translation with /book/:bookId/translation/:translationId.
  3. It would be consistent with how you would query a list of translations by doing a GET on /book/:bookId/translation.
  4. This overall scheme makes sense in that it is what type of object, followed by an object id, followed by what type of sub-object.

Upvotes: 1

Related Questions