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
- Visualizing local election results with Datasette, Observable and MapLibre GL - 9th November 2024
- Project: VERDAD - tracking misinformation in radio broadcasts using Gemini 1.5 - 7th November 2024
- Claude 3.5 Haiku - 4th November 2024