Blog·Craft·

MP is two places

MP is Madhya Pradesh in India and the Northern Mariana Islands in the US, same code, same endpoint, two different records.

GET /state/MP?country=IN
{ "country": "IN", "country_name": "India", "state": "MP", "name": "Madhya Pradesh", "type": "state" }

GET /state/MP?country=US
{ "country": "US", "country_name": "United States", "state": "MP", "name": "Northern Mariana Islands", "type": "outlying area" }

Same endpoint, same code, two different records, one in South Asia, one in the middle of the Pacific. ?country= is the only thing standing between them.

Every lookup needs it, not just the ambiguous ones

State and province codes repeat across countries, ISO 3166-2 reuses letters freely. /state/{code} requires ?country= on every call, not just the ambiguous ones, there is no way to know in advance which codes will collide, so it just assumes all of them might. /country/{code} skips the question entirely. One code, one country, no chaperone required.

Try it

Call MP under India, then under the US. Yeah, it's a coincidence. Codes run out eventually.