ShareThis supports an additional JavaScript API for developers that need more control over what is being shared.

It provides programmatic control of display options and supports a function based interface.

Define Your Sharable Objects:

Using the ShareThis API, it is easy to define the sharable objects. As an example, a website that sells products is able to define such detail as title, description, product image. When an item is shared, the recipient will be able to see all the details defined.

Here is an example of code that could be used:

			<script language="javascript" type="text/javascript">
			SHARETHIS.addEntry({
				title:'Best Digital Camera',
				summary:'This digital camera has all the features one would ever need!',
				url:'http://mystore.com/digitalcamera',
				icon: 'http://path.to/icon'
			}, {button:true} );
			</script>


Define embeddable objects:

Another way to implement the ShareThis API is to define the embeddable objects. For example, if you have a video, picture or widget that you would like to be embedded in blog posts, rather than just a link, you are able to accomplish this using the code below.

			<script language="javascript" type="text/javascript">
			SHARETHIS.addEntry({
				title:'Awesome videos!',
				summary:'This is the best video I have ever seen',
				content:'http://myvideosite.com/embededobject',
				icon: 'http://path.to/icon'
			}, {button:true} );
			</script>


Onclick Event Handling:

An optional feature available through our API is the ability to call a custom onclick function every time the button is clicked. Using the API, you can define the onclick callback function by setting the "onclick" option in your addEntry code. The custom callback is passed the object being shared (url, title, description, etc...).

		
			<script type="text/javascript">
				function myCustomCallback(SharedObject){
					/*
				 	* The sharelet is passed to the myCustomCallback callback routine.
				 	* We will aler the title and url
				 	*/
					alert(SharedObject.properties.title + "\n" + SharedObject.properties.url);
					/*
				 	* Return true to show the widget
				 	*/
					return true;
				};
				/*
				 * Create a button and a myCustomCallback onclick handler.
				*/
				SHARETHIS.addEntry({
					title:'ShareThis',
					url:'http://sharethis.com'}, 
					{onclick:myCustomCallback}
				);  
			</script>