New ask Hacker News story: Ask HN: How would you an API to handle request variability by US state?

Ask HN: How would you an API to handle request variability by US state?
2 by ortne | 1 comments on Hacker News.
I have been struggling with determining a sane approach to building a REST API for servicing each state within the United States. Effectively, it would be creating the same semantic resource/operation for each state, but the input/attributes of that resource slightly vary by state. Some states are nearly identical and others are drastically different. One option I have tried in the past is having a super operation with a large interface for supporting all states, then the application handles the state variability within the application code. However, this makes the interface confusing for consumers as it quickly becomes unclear which attributes apply to which state. Another option, which I have been rather hesitant of pursuing, could involve separate operations for each state with concrete contracts (i.e. an API path /my-service/ca/my-operation). This seems like it would introduce a maintainability issue within the code to support 50 operations and lead to code redundancy. Curious if others have encountered a similar problem.

Comments