Logo Devoh

Heavyweight Wrapper APIs

When developing wrapper APIs for web service APIs, there are two patterns typically found in Ruby: using concrete classes to abstract the underlying web service, and using method_missing to automatically build requests to pass on to the web service. While working on my Amazon FPS API, Remit, I've taken the former approach, despite some hesitation along the way about whether it really makes sense to use such a heavyweight API.

I've worked with some APIs before that use the method_missing approach, but I've always found them to feel a bit kludgey. One of my biggest gripes with these sorts of APIs is the usage of action and parameter names carried over directly from the service, as they often don't follow the typical Ruby naming conventions. For me, this alone is enough to warrant a heavier API.

Coincidentally, Chad Fowler posted an entry on his blog yesterday about "Writing APIs to Wrap APIs." His philosophy on the matter seems to mirror mine in a lot of ways, and his point about a wrapper API being less brittle especially resounded with me. The fact that concrete APIs are easier to test is also hard to ignore.

I'm glad I took the time to think through the architecture before proceding to far, but with my uncertainties allayed, I'll stick with writing concrete APIs from here on out.