What are good examples of REST API client libraries in JavaScript
api, javascript, rest
Solution
I watched a really good video on good API Design. Definitely worth the watch.
RESTful API Design - Second Edition
You can also get a free book Web API Design - Crafting Interfaces that Developers Love in addition to the above video by going to https://offers.apigee.com/ebook-api-design-yt/
Regarding wrappers it may be worth thinking about the following:
- Make your wrapper consistent.
Adopt the standards, naming conventions, etc of the programming language or community you are working with to make the wrapper feel as natural as possible to those using it.
- To wrap or to abstract? That is the question.
By Wrapping you mimic the REST API methods and structure as much as possible but simply make some of the hard things easier. One of the biggest advantages of this approach is that it makes it easier to upgrade when the target REST API upgrades.
Abstracting is useful when the target REST API is complex or behaves and looks in non-standard ways. In this case your wrapper methods and calls may not resemble your target REST API methods at all but will ultimately simplify the life ( hopefully ) of those using your wrapper.
Problem
I'm looking for best-practise styles for wrapping a REST API in a light-weight JavaScript client. In the past I've seen libraries which are implemented in a style like: ``` var request = new SearchRequest(apikey); request.query = "search term"; request.send(function(results) { console.log(results); }); ``` Or that embrace HTTP more explicitly like: ``` api.get("search", "search term", function(results) { console.log(results); }); api.post("comment", comment, function(results) { console.log(results); }); ``` Or that wrap at an even higher level: ``` api.search("search term", function(results) { console.log(results); }); api.createComment(comment, function(results) { console.log(results); }); ``` What good examples of modern JavaScript client libraries wrapping REST APIs have you seen recently. Not worried about implementation details, just the API design. Thanks!