Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A Python wrapper for the AddThis Analytics API

Project description

Latest Version

A Python wrapper for the AddThis Analytics API.



Install from PyPI:

pip install addthis


from addthis import Addthis

# create an AddThis instance using userid and password from your AddThis account and optionally provide a pubid
addthis = Addthis(userid="YOUR_USER_ID", password="YOUR_PASSWORD", pubid="YOUR_PUB_ID")

# get the number of shares for the last day

# get the number of shares by day for the last week

You can see a full description of all supported metrics and dimensions at

A few more examples

How many times was my content shared on Twitter, by day, over the last week?

>>>"week", service="twitter")

What were my top shared urls for the pubid=”MY_PUB_ID”?

>>> addthis.shares.url(pubid="MY_PUB_ID")

How many users shared my content this month, broken down by their interests?

>>> addthis.sharers.interest(period="month")

Which sharing services sent the most clicks back to my site this week?

>>> addthis.clicks.service(period="week")



Addthis object expects to be called with 2 parameters - “metric” and “dimension”:


For example:

>>> # "shares" is a metric and "day" is a dimension

If it gets another number of parameters (e.g. addthis.shares() or it will raise an AddthisValidationError.

from addthis import Addthis, AddthisValidationError

addthis = Addthis(userid="YOUR_USER_ID", password="YOUR_PASSWORD", pubid="YOUR_PUB_ID")

except AddthisValidationError as e:
    print e # "Incorrect number of parameters are given. Expected 2 but got 1."


AddthisError is raised when AddThis service returns a response with a HTTP status code other than 200. The exception object has 4 attributes:

  • status_code: Code from the HTTP response.
  • code, message, attachment: Error attributes from the AddThis response body. (see the “Error” section in the AddThis Analytics API documentation for more information).
from addthis import Addthis, AddthisError

addthis = Addthis(userid="INCORRECT_USER_ID", password="INCORRECT_PASSWORD", pubid="INCORRECT_PUB_ID")

except AddthisError as e:
    print e # "401 Error (code = '80', message='authentication failed', attachment='{u'nonce': None, u'realm': u'AddThis', u'opaque': None})'."
    print e.status_code # 401
    print e.code # 80
    print e.message # "authentication failed"
    print e.attachment # {u'nonce': None, u'realm': u'AddThis', u'opaque': None}

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for addthis, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size addthis-0.1.2.tar.gz (6.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page