Search code examples
httphttp-verbs

HTTP verb for 'translate'


I'm writing a REST web service that translates texts from one language to another. The text can be fairly large, up to a few megabytes.

What HTTP verb is best to use?

My first thought was to use GET because it gets you the translation for the given text. But the 4K URL length restriction will not do for large texts. The use of the message body with GET is discouraged.

My second thought was to use POST so I can pass the text in the request body. But it doesn't seem to agree with the spirit of HTTP. POST is used to create things; it updates the state of the server while in my case no state is being updated.

What verb would you use?

N.B. Google Translate uses POST.


Solution

  • I'm learning towards POST, as i see PUT, PATCH, DELETE etc. as specific options.

    GET would be the 'appropriate', as its origin is "GET a given resource", eg. fetch my a translation, based on some data you parse along.

    However I believe it can be argued, that the translation does not exist, but is merely generated, therefore you POST your string, and the webservice creates the translations, and returns it. Also, as you mention, GET requests are blocked by the URL Length.