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
- Gemini 2.0 Flash: An outstanding multi-modal LLM with a sci-fi streaming mode - 11th December 2024
- ChatGPT Canvas can make API requests now, but it's complicated - 10th December 2024
- I can now run a GPT-4 class model on my laptop - 9th December 2024