0

How should I set up my API so that it can return resources in all languages instead of just one language?

Example of response:

{
  "id": 1,
  "name_en-CA": "Routes",
  "name_fr-CA": "Circuits",
  "active": true,
  "type": "A",
  "effective_from": "2016-04-24T03:00:00",
  "effective_from": "2016-09-04T02:59:59",
}

I know there's the Accept-Language request header, but is it appropriate to respond with all languages in the absence of an Accept-Langauge header? And would I not send the Content-Language header in this case?

rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156

1 Answers1

0

In usual circumstances lack of Accept-Language is highly unlikely. However, as this seems to be REST API you may expect hand-crafted requests, so it seems your question is valid.

Personally, I wouldn't send all the possible languages responding to incorrectly formed request. Instead I would probably respond 400 Bad Request.
You may decide to respond anyway. In this case I would suggest to respond with default language (i.e. en-US).

Paweł Dyda
  • 18,366
  • 7
  • 57
  • 79
  • Some applications that consume the API needs the response in all languages and I don't think it is feasible for them to make many requests with different `Accept-Language` headers so what should I do about that case? – rink.attendant.6 Jul 03 '16 at 21:22