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
- My AI/LLM predictions for the next 1, 3 and 6 years, for Oxide and Friends - 10th January 2025
- Weeknotes: Starting 2025 a little slow - 4th January 2025
- I still don't think companies serve you ads based on spying through your microphone - 2nd January 2025