API Docs

Version:  1.0

GET/v1.0/

Return share counts for a URL.


Definition

https://api.sharedcount.com/v1.0/


Parameters

Query Params
url:
required
string
The URL you're querying.

apikey:
required
stringYOUR_APP_KEY
Your API key.

callback:	string
For JSONP, the callback function name.

custom_ttl:	integer
Number of seconds you'd like the results to be cached. (Available only on the Dedicated Plan).


Result Format

Success
Failure
{"StumbleUpon":1,"Pinterest":9,"LinkedIn":3744,"Facebook":{"total_count":168,"comment_count":53,
"reaction_count":14,"share_count":101,"comment_plugin_count":0},"GooglePlusOne":189}
{"Error": "Error message here", "Type": "error_type"}

Documentation

This endpoint returns null (instead of 0) when a service fails to report a number. It removes values from the responses that SharedCount no longer queries, like Buzz, Reddit and Delicious.

Generally speaking, it does not guarantee the presence of particular network's data in every response, which may be removed without notice. (For example, Buzz is still shown in normal API responses, despite not existing for several years).

This means that usage of this API requires ensuring that the particular attribute you're accessing is available on the object, and handling null values for when it is available.

JavaScript

jQuery.sharedCount = function(url, fn) {
  url = encodeURIComponent(url || location.href);
  var domain = "//api.sharedcount.com/v1.0/"; /* SET DOMAIN */
  var apikey = "YOUR_APP_KEY" /*API KEY HERE*/
  var arg = {
    data: {
      url: url,
      apikey: apikey
    },
    url: domain + "/url",
    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);
};
$.sharedCount(location.href, function(data){
     console.log(data.Twitter);
       console.log(data.Facebook.like_count);
});

Custom Cache Times

Users on Dedicated Plans may specify a custom cache time for a given URL by passingcustom_ttlas a parameter with a non-negative integer representing the number of seconds you'd like the value to be cached. The default is 1200, which corresponds to 20 minutes.

To disable any kind of caching, setcustom_ttlto0.

By settingcustom_ttl, you have the effect of altering theExpiresandCache-Controlheader, as well as configuring how long the application itself will cache the data for that URL.

Setting thecustom_ttlparameter only affects subsequent requests for that given URL. If previous requests for that URL set a differentcustom_ttlvalue, those original values may continue to be respected.