Javscript wrapper for the Infusionsoft API
A promise-driven, fluent-style Node.js wrapper for the XML-RPC Infusionsoft API.
Write badass Infusionsoft apps on the server that are fully and natively asynchronous.
It's pretty dope.
$ npm install infusionsoft-api
Do cool stuff:
var api = ;var infusionsoft = 'myapp' 'MY_API_KEY';infusionsoftContacts;
You can also use the API Services directly:
All asynchronous methods return a Promise that represents the eventual value that will be returned.
Promises are glorious and make writing heavily asynchronous code much less awful than it would otherwise be.
See the More Examples section to see them in action.
This project creates interfaces and classes for the API services and tables via
the grunt-infusionsoft grunt
plugin. To recreate the generated files, run
Check out the
infusionsoft directory to see the output.
All examples use
infusionsoft as an instantiated DataContext with your app
name and API key. ie:
var infusionsoft = 'myAppName' 'MY_API_KEY';
And an example of using the
fail method to catch any problems.
Same as above, but use the
spread function to wait on 2 promises to get the
corresponding product names. The API hits for querying both the
Invoice table will actually fire off at the same time.
var products = infusionsoftProducts;var invoices = infusionsoftInvoices;Q;
Okay, take a deep breath. We can do (inner) joins. We fake it though... the
inner part of the join has to be loaded entirely and then we do a
iteration to make it, but we can still do it. If the
inner is cheap, this
isn't too bad. Especially when the SDK will handle loading, paging, waiting,
etc... all for you.
Syntax (stolen from C#'s LINQ):
Let's do this:
var pc = infusionsoftProductCategories;var pca = infusionsoftProductCategoryAssigns;var plans = infusionsoftSubscriptionPlans;// Join the categories onto itself for creating the full category name// (category parent name + category name)var categories = pc;var subPlans = plans// Join the sub plan (which only has product Id) onto the PCA table to get// the product category ID// Join our categories object we made above onto the projection from the// most recent join to get the full category name + subscription plan Id;subPlans;
What happens magically behind the scenes is pretty nice. When we call
toArray() at the end, we first query the SubscriptionPlan table (aliased as
plans). It then knows we need to join the
ProductCategoryAssign table on
there, so it fetches that (which may be more than one page). It finally gets
ProductCategory table (in its entirety), and joins them all up.
The syntax looks nasty, but that is somewhat unavoidable with a
Copyright 2013 Brandon Valosek
Infusionsoft API is released under the MIT license.