Skip to content

Globobeet/sociare-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sociare Counter Build Status Coverage Status

A small NodeJS utility for fetching share counts of a given URL across many popular social networks.

Installation

Sociare Counter can be installed with npm

$ npm install --save sociare-counter

Usage Example

const sociare = require('sociare-counter');

sociare.getCounts('http://google.com', {
	networks: ['facebook', 'linkedin', 'pinterest']
}).then((counts) => {
	// Do something with the counts
});

ExpressJS endpoint

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));
});

API

Sociare Counter has only one method: sociare.getCounts(url, [options]), which returns a Promise.

Configurable Options:

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

Motivation

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:

  • Facebook
  • Pinterest
  • LinkedIn
  • Google+

Why no Twitter??

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.

Contributing

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

License

Sociare Counter is distributed under the MIT license.

About

NodeJS utility for getting share counts for a given url

Resources

License

Stars

Watchers

Forks

Packages

No packages published