Customizer API

If you're trying to access the Bitbucket features, the following JavaScript API can be used to help you. For more details about Bitbucket's rest api please see https://confluence.atlassian.com/display/BITBUCKET/Use+the+Bitbucket+REST+APIs or http://restbrowser.bitbucket.org.

 

Customizer object

A customizer object is added to the script runtime. From this you can access a set of help functions.

customizer.fetchJSON('/restapi-call', cb)

This call execute a xhr GET request for the /restapi-call on bitbucket.org. The return content will be converted to a JavaScript object and passed to the cb function. The cb function will be passed 2 args (err, data). If there's an error with the request, err is true.

Sample call

Call to fetch pull requests
<div id="sample-content"></div>
<script type="text/javascript">
   customizer.fetchJSON("/api/2.0/repositories/wittified/webfragment-finder/pullrequests/",
    	function(err,data)
       {
			var html = "";
		    if(!err)
	    	{
    			html = "There are " + data.values.length+" pull requests outstanding";
		    }
           $("#sample-content").html( html );
       }
    );
</script>