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.

Free users utilizing API Keys have a quota of 10,000 queries per day.

Unauthenticated API calls (only available on api.sharedcount.com) have a quota of 1,000 queries per day on a per IP or domain basis. api.sharedcount.com is a deprecated endpoint and will be permanently discontinued on January 15, 2015.

For API keys, IPs or Domains sending more than their allocated quota in a day will 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 /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 SharedCount data from a JSON/JSONP API. The domain you should use depends on the API key you have and the plan you're on. Users without an API key can only use api.sharedcount.com, or signup for an API key and use free.sharedcount.com.
Older Free Plan API keys: http://api.sharedcount.com/
Free Plan: http://free.sharedcount.com/
Plus Plan: http://plus.sharedcount.com/
Business Plan: http://business.sharedcount.com/

Users currently assigned to api.sharedcount.com can migrate their API key to free.sharedcount.com from the User Center. All accounts will be forcibly migrated on October 1, 2014.
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

Domain Whitelist

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. You can toggle this feature from the User Center.

Sample Code - PHP 5+

Logged in users will see their API key and domain auto-populate in the below sample code.
<?php
$url = ((!empty($_SERVER['HTTPS'])) ? "https://": "http://" ) . $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$apikey = "XXXXXXXXX";
$json = file_get_contents("http://free.sharedcount.com/?url=" . rawurlencode($url) . "&apikey=" . $apikey); $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 15 tweets, 11 likes, and 17+1's

Sample Code - JSONP

jQuery Plugin:

Logged in users will see their API key and domain auto-populate in the below sample code.

jQuery.sharedCount = function(url, fn) {
    url = encodeURIComponent(url || location.href);
    var domain = "//sample.sharedcount.com/"; /* SET DOMAIN */
    var apikey = "" /*API KEY HERE*/
    var arg = {
	    data: {
	    	url : url,
	    	apikey : apikey
	    },
        url: domain,
        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.