Skip to main content

Social shares

Build Status

A command-line utility and Python library to access the social share counts for a particular URL.

Note: unfortunately this utility can no longer be used to fetch tweet and retweet counts, as Twitter has removed the API this functionality relied on. Facebook and other platforms still work.

Usage

Usage:
  socialshares <url> [<platforms>...] [options]

Options:
  -h, --help  Show this screen.
  -p, --plain  Plain output.
  -r <attempts>, --retry <attempts>  Retry fetching up to <attempt> times [default: 1]
  -e, --exit  Exit with an error code when not all counts could be fetched.

Some examples:

# fetch count for all supported platforms,
# try again once (the default) for platforms that fail
$ socialshares http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/

# fetch only facebook
$ socialshares http://www.theguardian.com/politics facebook     --retry 2

Supported platforms

Platform

Description

facebook

facebook shares and comments

linkedin

linkedin shares

google

google +1’s

pinterest

pinterest pins

reddit

reddit ups and downs (summed across posts)

Platforms are fetched in parallel and retried (once by default.) If no platforms are specified, just facebook and twitter will be returned.

Unsupported platforms

The following APIs unfortunately no longer exist, and have been removed from the interface.

Platform

Description

twitter

twitter tweets and retweets containing the URL

facebookfql

facebook likes, shares and comments

Output

By default, socialshares outputs JSON:

{
  "reddit": {
    "downs": 0,
    "ups": 6
  },
  "google": 20,
  "facebook": 1498,
  "twitter": 300,
  "pinterest": 1
}

Use the --plain flag if instead you’d like space-separated output.

$ socialshares http://www.theguardian.com/politics twitter
57

Usage from Python

import socialshares
counts = socialshares.fetch(url, ['facebook', 'pinterest'])

Installation

pip install socialshares
# optionally, for asynchronous fetching
pip install grequests

If requests_futures and (for Python 2.x) futures are installed, social-shares will use these packages to speed up share count fetching, by accessing the various social media APIs in parallel.

Metadata

Release files for socialshares 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for socialshares 1.1.0
File Size Uploaded
socialshares-1.1.0.tar.gz 7.1 kB Details

Release files / socialshares-1.1.0.tar.gz

Download URL socialshares-1.1.0.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bcf9f6e3b1a663f6edae6d6eaaef7f0595680c7f9872b7631fb0927e23edda03
BLAKE2b-256 checksum
How to use checksums
7997dde9d18c5530e45ed87dbd066ba3f137a4939180eace18a0373a43e6f8b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.1.0 This release

1 release file

1.0.0

1 release file

0.4.0

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page