Skip to main content

A Python wrapper for the AddThis Analytics API

Project description

Latest Version https://travis-ci.org/creafz/python-addthis.svg?branch=master https://coveralls.io/repos/creafz/python-addthis/badge.png?branch=master

A Python wrapper for the AddThis Analytics API.

Requirements

Installation

Install from PyPI:

pip install addthis

Usage

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
print addthis.shares.day()

# get the number of shares by day for the last week
print addthis.shares.day(period="week")

You can see a full description of all supported metrics and dimensions at http://support.addthis.com/customer/portal/articles/381264-addthis-analytics-api

A few more examples

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

>>> addthis.shares.day(period="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")

Exceptions

AddthisValidationError

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

addthis.<metric>.<dimension>()

For example:

>>> addthis.shares.day() # "shares" is a metric and "day" is a dimension

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

AddthisError

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).

Project details


Download files

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

Source Distribution

addthis-0.1.1.tar.gz (6.1 kB view details)

Uploaded Source

File details

Details for the file addthis-0.1.1.tar.gz.

File metadata

  • Download URL: addthis-0.1.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for addthis-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a122a80f70211c6bbfb6fff8931a44496f27ee22a4d5c5466d9722cda1974943
MD5 193b0deb8125264c1deaaeba0b7d3cbf
BLAKE2b-256 ea67a44c64b9499f71defbcb7f7c88593f7657b49be06982b4331bcc4c7e533c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page