Integration of 3rd Party APIs
Basic HTTP Call
Conceptually, integrate 3rd party REST APIs can be as simple as adding the
http package and making a call to the external endpoint.
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.
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
Create an Atmosphere Package For Your API Wrapper
After creating an API wrapper, it's likely that you may want to create an Atmosphere package to redistribute it and share it between applications. The files of your package will probably look something like this.
In particular, your
foo-api-wrapper/package.js file will want to look something like this:
foo-api-wrapper/foo.api.wrapper.js should contain the
Foo API wrapper object.
Include the API Package in your Application
At this point, you're still building your package, so you'll need to add the package to your application:
And eventually publish it to Atmosphere:
Using the API Wrapper Object in your App
Now that we have all those pieces put together, you should now be able to make calls like the following from within your app:
Obviously you'll want to adjust function names, arguments, urls, and the like, to create the proper syntax for the API.