API Information
At this time, there are no rate limits. Values are cached for 5 minutes at a time. So, values may be up to 5 minutes old for repeated queries.
You can retrieve the counts from a JSON and JSONP API:
HTTP Endpoint: http://api.sharedcount.com/
HTTPS Endpoint: https://sharedcount.appspot.com/
Parameters
- url: The URL of the page, including http, and www., if applicable. At this time, we do not provide canonicalization services. URL Encode to minimize errors.
- callback (optional): define a callback function for JSONP
Sources
We retrieve the data from the official 'Share' buttons provided by these major services. All of the services provide a JSON API for accessing the shared counts for particular URLs.
- Facebook*: http://api.ak.facebook.com/restserver.php?v=1.0&method=links.getStats&urls=%%URL%%&format=json&callback=fb_sharepro_render
- Twitter: http://urls.api.twitter.com/1/urls/count.json?url=%%URL%%&callback=twttr.receiveCount
- Google Buzz: http://www.google.com/buzz/api/buzzThis/buzzCounter?url=%%URL%%
- LinkedIn: http://www.linkedin.com/cws/share-count?url=%%URL%%
- Digg: http://widgets.digg.com/buttons/count?url=%%URL%%
- Delicious: http://feeds.delicious.com/v2/json/urlinfo/data?url=%%URL%%
- StumbleUpon: http://www.stumbleupon.com/services/1.01/badge.getinfo?url=%%URL%%
- Google +1
+1 counts are retrieved via a JSON-RPC POST call.
POST URL:
https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ
POST Body:
Sample Code - PHP 5+
<?php
$url = ((!empty($_SERVER['HTTPS'])) ? "https://": "http://" ) . $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$json = file_get_contents("http://api.sharedcount.com/?url=" . rawurlencode($url));
$counts = json_decode($json, true);
echo "This page has " . $counts["Twitter"] ." tweets, " . $counts["Facebook"]["like_count"] . " likes, and ". $counts["GooglePlusOne"] . "+1's";
?>
Result:
This page has 10 tweets, 0 likes, and 0+1'sSample Code - JSONP
Using jQuery:
<div style="display:none;" id="sharedcount"> This page has <span id="tweets">0</span> tweets, <span id="likes">0</span> likes, and <span id="plusones">0</span> +1's.
<div> <script>
jQuery(document).ready(function($){
$.getJSON("//sharedcount.appspot.com/?url="+encodeURIComponent(location.href)+"&callback=?", function(data){ $("#tweets").text(data.Twitter); $("#likes").text(data.Facebook.like_count); $("#plusones").text(data.GooglePlusOne); $("#sharedcount").fadeIn(); });
});
</script>