{"_id":"591021f9d4cd662d00c82fa3","user":"5434326ae532ff0800e185ab","__v":0,"version":{"_id":"591021f7d4cd662d00c82f9e","project":"54343293fa5527080064f472","__v":1,"createdAt":"2017-05-08T07:44:55.941Z","releaseDate":"2017-05-08T07:44:55.941Z","categories":["591021f8d4cd662d00c82f9f","591021f8d4cd662d00c82fa0"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Engagement","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"591021f8d4cd662d00c82fa0","__v":0,"version":"591021f7d4cd662d00c82f9e","project":"54343293fa5527080064f472","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-16T06:03:53.832Z","from_sync":false,"order":1,"slug":"api","title":"API"},"parentDoc":null,"project":"54343293fa5527080064f472","updates":["56c6dc96197f9f1700c811b5"],"next":{"pages":[],"description":""},"createdAt":"2014-10-16T05:46:47.033Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[]},"method":"get","results":{"codes":[{"language":"json","code":"{\"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}","name":"Success"},{"language":"json","code":"{\"Error\": \"Error message here\", \"Type\": \"error_type\"}\n","name":"Failure"}]},"settings":"","auth":"never","params":[{"_id":"543f5bc7baae8a08005f62a9","ref":"","in":"query","required":true,"desc":"The URL you're querying.","default":"","type":"string","name":"url"},{"_id":"543f5c0abaae8a08005f62ac","ref":"","in":"query","required":true,"desc":"Your API key.","default":"[[app:key]]","type":"string","name":"apikey"},{"_id":"543f5c0abaae8a08005f62ab","ref":"","in":"query","required":false,"desc":"For JSONP, the callback function name.","default":"","type":"string","name":"callback"},{"_id":"547e7edab3f56708000b8f2d","ref":"","in":"query","required":false,"desc":"Number of seconds you'd like the results to be cached. (Available only on the Dedicated Plan).","default":"","type":"int","name":"custom_ttl"}],"url":"/v1.0/"},"isReference":false,"order":0,"body":"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. \n\nGenerally 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).\n\nThis 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.\n\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"jQuery.sharedCount = function(url, fn) {\\n\\turl = encodeURIComponent(url || location.href);\\n\\tvar domain = \\\"//[[app:plan]].sharedcount.com/v1.0/\\\"; /* SET DOMAIN */\\n\\tvar apikey = \\\"[[app:key]]\\\" /*API KEY HERE*/\\n\\tvar arg = { \\n\\t\\tdata: {\\n\\t\\t\\turl: url,\\n\\t\\t\\tapikey: apikey\\n\\t\\t},\\n\\t\\turl: domain + \\\"/url\\\",\\n\\t\\tcache: true,\\n\\t\\tdataType: \\\"json\\\"\\n\\t};\\n\\tif ('withCredentials' in new XMLHttpRequest) {\\n\\t\\targ.success = fn;\\n\\t} else {\\n\\t\\tvar cb = \\\"sc_\\\" + url.replace(/\\\\W/g, '');\\n\\t\\twindow[cb] = fn;\\n\\t\\targ.jsonpCallback = cb;\\n\\t\\targ.dataType += \\\"p\\\";\\n\\t}\\n\\treturn jQuery.ajax(arg);\\n};\\n$.sharedCount(location.href, function(data){\\n\\t console.log(data.Twitter);\\t\\n \\t\\t\\t console.log(data.Facebook.like_count);\\n});\\n\",\n \"language\": \"javascript\"\n }\n ]\n}\n[/block]\n\n\nNot seeing your domain and API key below? [Try logging in](https://admin.sharedcount.com/admin/login.php).\n\n\n###Custom Cache Times\n\nUsers on Dedicated Plans may specify a custom cache time for a given URL by passing `custom_ttl` as 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. \n\nTo disable any kind of caching, set `custom_ttl` to `0`.\n\nBy setting `custom_ttl`, you have the effect of altering the `Expires` and `Cache-Control` header, as well as configuring how long the application itself will cache the data for that URL. \n\nSetting the `custom_ttl` parameter only affects subsequent requests for that given URL. If previous requests for that URL set a different `custom_ttl` value, those original values may continue to be respected.","excerpt":"Return share counts for a URL.","slug":"url","type":"endpoint","title":"/v1.0/"}

Parameters

Query Params

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

Result Format

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.
[block:code]
{
"codes": [
{
"code": "jQuery.sharedCount = function(url, fn) {\n\turl = encodeURIComponent(url || location.href);\n\tvar domain = \"//[[app:plan]].sharedcount.com/v1.0/\"; /* SET DOMAIN */\n\tvar apikey = \"[[app:key]]\" /*API KEY HERE*/\n\tvar arg = { \n\t\tdata: {\n\t\t\turl: url,\n\t\t\tapikey: apikey\n\t\t},\n\t\turl: domain + \"/url\",\n\t\tcache: true,\n\t\tdataType: \"json\"\n\t};\n\tif ('withCredentials' in new XMLHttpRequest) {\n\t\targ.success = fn;\n\t} else {\n\t\tvar cb = \"sc_\" + url.replace(/\\W/g, '');\n\t\twindow[cb] = fn;\n\t\targ.jsonpCallback = cb;\n\t\targ.dataType += \"p\";\n\t}\n\treturn jQuery.ajax(arg);\n};\n$.sharedCount(location.href, function(data){\n\t console.log(data.Twitter);\t\n \t\t\t console.log(data.Facebook.like_count);\n});\n",
"language": "javascript"
}
]
}
[/block]
Not seeing your domain and API key below? [Try logging in](https://admin.sharedcount.com/admin/login.php).
###Custom Cache Times
Users on Dedicated Plans may specify a custom cache time for a given URL by passing `custom_ttl` as 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, set `custom_ttl` to `0`.
By setting `custom_ttl`, you have the effect of altering the `Expires` and `Cache-Control` header, as well as configuring how long the application itself will cache the data for that URL.
Setting the `custom_ttl` parameter only affects subsequent requests for that given URL. If previous requests for that URL set a different `custom_ttl` value, those original values may continue to be respected.