Is it a good idea to create an API in such a way that clients can post different shaped JSON documents to the same Resource? Let me give you an example and and explanation to why I am asking this.

I am hoping to create an API that is supposed to serve clients in the US as well as other clients across the globe. I have one specific resource in my api which looks like this:

POST /api/addresses/validate

Clients call this API resource when they want to validate a shipping address. The only problem is that address structure for US clients is completely different than other countries in the world. Since most web api frameworks map the json serialized address from the http request to a controller or service, I have to specify the JSON address structure for my clients to know how to correctly use my API. What do i do when the address structure is different for different regions of the world? Do I make one generic object with a bunch of fields that handles all regions? Do I create a seperate resource for address validation for each region? Would it be better to create a completely seperate hosted API with different object structures for each region of the world?

Any ideas would be helpful!

Related posts

Recent Viewed