Shared Count

Track URL shares, likes, tweets, and more.

API Information

Quota

Please see pricing page for detailed quota information and information on paid plans with extra API quota.

Unauthenticated API calls have a rate limit of 10,000 queries per day.

For API keys, IPs or Domains sending more than their allocated quota in a day may see their queries rejected with an HTTP Status Code of 401.

To sign up for an API key, create an account here.

You can monitor your API usage by inspecting the response headers X-Quota-Remaining. Note that cached queries may return stale quota results.

Users with API keys can check their current API quota by querying the end-point /get_quota?apikey={{ your_api_key }}

Values of queries may be cached for up to an hour for repeated queries.

Signup to get an API key

API Calls

You can retrieve the counts from a JSON and JSONP API:
HTTP Endpoint (for Free plan): http://api.sharedcount.com/
HTTPS Endpoint (for Free plan): https://sharedcount.appspot.com/
Note that users paying for Plus, Business or Dedicated Plans will be assigned different endpoint domains. You can see your assigned endpoints by logging in to your account.

Parameters

The way in which you pass the URL will effect the results, depending on the service. Some services will return different results, depending on if you include a trailing slash on the URL.

Sample Response

{"StumbleUpon":603192,"Reddit":0,"Facebook":{"commentsbox_count":15,"click_count":27523,"total_count":335835,"comment_count":100278,"like_count":84709,"share_count":150848},"Delicious":11969,"GooglePlusOne":76352,"Buzz":0,"Twitter":22199,"Diggs":0,"Pinterest":16081,"LinkedIn":1532}

Errors

When an error occurs, we'll return an object with a key "Error" with a message, and a "Type" with a classification. For JSONP calls, we'll always return a 200 code.

Sources

Generally, 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.

Securing your API key

For users using SharedCount from the client-side, we offer the ability to whitelist specific domains that can be queried using your API key. For example, if your site is foo.com, and the only domains you query from SharedCount are on foo.com and sub.foo.com, then you can secure your API key by only allowing these domains to utilize your API key. This is useful for sites that use SharedCount for reporting their own sites' data within the browser. If you'd like to enable this feature, please contact us.

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) . "&apikey=XXXXXXX");
$counts json_decode($jsontrue);
echo 
"This page has " $counts["Twitter"] ." tweets, " $counts["Facebook"]["like_count"] . " likes, and "$counts["GooglePlusOne"] . "+1's";
?>

Result:

This page has 14 tweets, 11 likes, and 14+1's

Sample Code - JSONP

jQuery Plugin:

jQuery.sharedCount = function(url, fn) {
url = encodeURIComponent(url || location.href);
var arg = {
data: {
url : url,
apikey : "" //API KEY HERE
},
url: "//" + (location.protocol == "https:" ? "sharedcount.appspot" : "api.sharedcount") + ".com/",
cache: true,
dataType: "json"
};
if ('withCredentials' in new XMLHttpRequest) {
arg.success = fn;
}
else {
var cb = "sc_" + url.replace(/\W/g, '');
window[cb] = fn;
arg.jsonpCallback = cb;
arg.dataType += "p";
}
return jQuery.ajax(arg);
};

Example: Using the jQuery plugin:
jQuery(document).ready(function($){
$.sharedCount(location.href, function(data){
$("#tweets").text(data.Twitter); $("#likes").text(data.Facebook.like_count);
$("#plusones").text(data.GooglePlusOne);
$("#sharedcount").fadeIn();
});
});

Result:

This page has 0 tweets, 0 likes, and 0 +1's.