REST API structure for multiple countries -


i'm designing rest api can search data in different countries, since can search same thing, @ same time, in different countries (max 4), unsure of best/correct way it.

this work start data (i'm using cars example):

/api/uk,us,nl/car/123 

that request return different ids different countries (uk=1,us=2,nl=3), do when data requested 3 countries? nice structure data 1 @ time:

/api/uk/car/1 /api/us/car/2 /api/nl/car/3 

but not efficient since hits backend 3 times.

i this:

/api/car/?uk=1&us=2&nl=3 

but doesn't work if want add path:

/api/uk/car/1/owner 

because turn into:

/api/car/owner/?uk=1&us=2&nl=3 

which doesn't good.

anyone got suggestions on how structure in way?

i answered similar question before, stick idea: have set of elements -cars- , want filter in way. advice add filter field. if field not present, choose 1 country based on locale of client:

mydomain.com/api/v1/car?countries=uk,us,nl 

this field should dissapear when specific car or owner

mydomain.com/api/v1/car/1/owner 

because country not needed (unless car id 1 reused each country)

update:

i did not expect id of car can shared several cars, id should unique (like primary key in database). then, makes sense keep country parameter owner's search:

mydomain.com/api/v1/car/1/owner?countries=uk,us 

this should return list of people own car id 1... me makes little sense functionality, in search i'll allow 1 country:

mydomain.com/api/v1/car/1/owner?country=uk 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -