meteor Integration of 3rd Party APIs Create A Package For Your API Wrapper


Basic HTTP calls don't provide code-reusability, however. And they can get confused with all the other features you're trying to implement. For those reasons, it's common to implement an API wrapper.

Foo = {
  identify: function(input){
    return Http.get('' + input);    
  record_action_on_item: function(firstInput, secondInput){
    return Http.put('' + firstInput + '&' + secondInput);    

Meteor supports Http.get(),, Http.put(), etc, so that's undoubtably the best way to call your REST API.

If the API is chatty and verbose, you may receive multiple packets; in which case you'll need to reassemble them. This is a big hassle. If you think the API is returning multiple packets, you're probably going to want to use the 'request' npm module on the server. You'll want to use a Npm.require('request').