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


Example

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('http://foo.net/api/identify/' + input);    
  },
  record_action_on_item: function(firstInput, secondInput){
    return Http.put('http://foo.net/api/record_action_on_item/' + firstInput + '&' + secondInput);    
  }
}

Meteor supports Http.get(), Http.post(), Http.put(), etc, so that's undoubtably the best way to call your REST API. http://docs.meteor.com/#http_get

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'). https://github.com/mikeal/request