What is the best way to maintain a API wrapper class across multiple languages?
25th October 2010
My answer to What is the best way to maintain a API wrapper class across multiple languages? on Quora
1. Use JSON for your API. That takes away a lot of the necessity for an API wrapper, since it means you’re automatically returning native data types (hashes, lists, strings etc) for most programming languages.
2. Build a RESTful API which is self describing—for example, one that returns URLs to other items represented by the API. That way you can write client libraries that work against the conventions used by the API, rather than hard-coding knowledge of the API in to the library.
3. If you can’t get #2 to work (which can be quite tricky), make your client-libraries data driven—ship them with a JSON file describing the API endpoints, then you can update all of the libraries just by updating that JSON file. You could even have the client libraries pull and cache the JSON API description over HTTP so you don’t have to ship a copy with the libraries.
More recent articles
- Using pip to install a Large Language Model that's under 100MB - 7th February 2025
- OpenAI o3-mini, now available in LLM - 31st January 2025
- A selfish personal argument for releasing code as Open Source - 24th January 2025