Convergence API v1.0

Ready to take your site to the next level?  Welcome to the Convergence API. 

NOTE: The API is in alpha - certain functions/options may change in the future.

Basics

Version 1 of the API uses JSON over AJAX. The easiest way to learn this is to get familiar with jQuery's getJSON function.  If you're new to it, we think you'll love it when you get the hang of it. Specifically the Convergence API helps you get more information about:

  • Products
  • Categories
  • Item Lists
  • Item List Items
  • Blogs and Articles
  • Calendars and Events

Examples

We've always disliked API's that don't have clear examples right up front - so here's our attempt to fix that:

First things first. The api_url() function. 

function api_url(type,finder){
	var url = "http://YOURSITEFOLDER."+CMS_DOMAIN+"/resources/api/1/?type="+type+"&";
	url+= (typeof(finder)=='number'&&parseInt(finder)==finder) ? "id" : "slug";
	return url+"="+finder+"&callback=?";
}

You can use this in your global js file, it is simply a helper function to help you with your API calls. The first paramater is the type, currently you can use:
product, category, item-list, item
The second parameter is EITHER the ID or the slug.. note that if you are passing the ID make sure you are passing an integer (the parseInt() function is helpful here).

Now, get details about a product using the slug "product-tee-shirt"

$(document).ready(function() {
	var url = api_url('product','product-tee-shirt');
	jQuery.getJSON(url, function(data){
		if(data.success){
			alert('The product name is '+data.product.name);	
		}
	});			
});

Or get details about an item using the ID

$(document).ready(function() {
	var url = api_url('item',2911);
	jQuery.getJSON(url, function(data){
		if(data.success){
			alert('The item slug is '+data.item.fields.slug);	
		}
	});			
});