A small NodeJS utility for fetching share counts of a given URL across many popular social networks.
Sociare Counter can be installed with npm
$ npm install --save sociare-counter
const sociare = require('sociare-counter');
sociare.getCounts('http://google.com', {
networks: ['facebook', 'linkedin', 'pinterest']
}).then((counts) => {
// Do something with the counts
});
This example is helpful if you are using the Sociare button generator in browser:
const sociare = require('sociare-counter');
const app = express();
app.get('/share-counts', (req, res) => {
sociare.getCounts(req.query.url, {
networks: req.query.networks.split(','),
omitQuery: req.query.omitQuery === 'true'
})
.then(counts => res.send(counts));
});
Sociare Counter has only one method: sociare.getCounts(url, [options])
, which returns a Promise.
Property | Type | Description |
---|---|---|
networks |
Array[String] | Networks to fetch counts from. Defaults to ['facebook', 'pinterest', 'linkedin', 'googleplus'] |
omitQuery |
Boolean | Whether query strings should be stripped from the URL before getting counts. Defaults to false |
Getting share counts from all the different social networks is... a pain, to say the least. Wouldn't it be great to have one way to get said counts, and have it always return a standard, known format? Yeah, we thought so too, which is where Sociare Counter comes into play! Simply specify the networks you want counts from and give it a url, it's easy as that!
Sociare Counter currently supports the following networks:
- Google+
In November of 2015, Twitter shut down it's public API access to share count data, in favor of it archiving service, GNIP. Until a suitable replacement is found (that does not require additional authentication), this plugin will not be able to return share counts from Twitter.
Pull requests for bug-fixes and additions of other services are always welcome! Please be sure to include any tests for new code & follow the current coding style as best you can.
You can run the test suite with the following command:
$ npm test
Sociare Counter is distributed under the MIT license.