0

I need to come up with best practices for API development where we have more than 100 endpoints to be developed and each endpoint need to have below mentioned properties which are common to be passed as request to the server

  1. Every request must have language-code (en-us or en-ca), division (hr or finance) and country (US or CANADA) parameters
  2. Two versions of apis needs to be created for web(v1) & ipad(v2)

Would like to know what is the best way to frame the api urls by taking above 2 points into considerations

I am planing to do the versioning mentioned below, but confused how to incorporate the above mentioned 2 points in the request (request params or through headers or in the request body itself)

app/v1/api/url
app/v2/api/url
Helen
  • 87,344
  • 17
  • 243
  • 314
  • 1
    Why do you need a different API for web and ipad? You could use the `Accept-Language` header to switch between languages – Evert Sep 15 '20 at 05:17

1 Answers1

0

I think there are a lot of good resources about REST API design e.g. 1 2. You should read them.

So I would use a query parameter for your language, division and country. These are like meta data shared across most of your apis.

app/v1/api/url?lang=en&div=hr&country=es

Regarding your second point I am not sure if you should distinct between the different device types. But it might be necessary. If so start with your device type. Because it might help you with your permission framework.

app/v1/api/url
web/v1/api/url

or

app/api/v1/url
web/api/v1/url

Hope this helps a bit.

Update 1 I like @Evert idea to use the Accept-Language, I think it is better as it is a standard http header field.

Christian
  • 1,664
  • 1
  • 23
  • 43
  • Thanks for swift response @Christian, indeed considering Accept-Language as part of headers is a good idea.What about "Division" property can it be passed in headers as well ? – user12757795 Sep 15 '20 at 05:56
  • I guess not. Please have a look at the standard http header fields link I posted. – Christian Sep 15 '20 at 06:41