Pollster

Pollster API


Keywords
Pollster, API
License
Other
Install
pip install Pollster==2.0.2

Documentation

pollster

Pollster - the Ruby gem for the Pollster API

Download election-related polling data from Pollster.

HuffPost Pollster is a website that tracks public opinion. Pollster's editors enter polling data for the "Questions" they care about -- questions the public answers in "Polls".

The Pollster website is organized into "Charts" and Pollster-calculated trendlines (descriptions of how the public felt each day, based on the polls and public algorithms). Each Chart is based on a single Question. The Pollster API provides every point plotted on all the "Charts" on the Pollster website. Furthermore, it provides the raw polling data that went into those charts: every response to every Question, at whichever level of detail the developer requests.

This SDK was originally generated by the Swagger Codegen project:

  • API version: 2.0.0
  • Package version: 2.0.0
  • Build package: class io.swagger.codegen.languages.PythonClientCodegen

For more information, please visit https://groups.google.com/forum/#!forum/pollster-users

Requirements.

Python 2.7 and 3.4+

Installation & Usage

pip install

If the python package is hosted on Github, you can install directly from Github

pip install pollster

(you may need to run pip with root permission: sudo pip install pollster)

Then import the package:

import pollster 

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import pollster

Getting Started

Please follow the installation procedure and then run the following:

from __future__ import print_function
import time
import pollster
from pollster.rest import ApiException
from pprint import pprint

api = pollster.Api()

cursor = None                # str | Special string to index into the Array (optional)
tags = ''                    # str | Comma-separated list of tag slugs. Only Charts with one or more of these tags and Charts based on Questions with one or more of these tags will be returned. (optional)
election_date = '2013-10-20' # date | Date of an election

try:
    # Charts
    charts = api.charts_get(cursor=cursor, tags=tags, election_date=election_date)
    pprint(charts)
except ApiException as e:
    print("Exception when calling DefaultApi->charts_get: %s\n" % e)

API documentation

Perhaps the best documentation is example.py: it shows how to use all API endpoints and how to paginate.

See https://elections.huffingtonpost.com/pollster/api/v2 for more details.

See https://app.swaggerhub.com/api/huffpostdata/pollster-api/2.0.0 for full API documentation. The Python-specific warts:

  • The TSV endpoints return pandas.DataFrame objects, simply parsing the TSV files Pollster returns.
  • Python API method names are snake-cased versions of the API endpoints and end with _get. For example, the Python method to access questions/{slug}/poll-responses-clean.tsv is api.questions_slug_poll_responses_clean_tsv_get(slug).

Author

Adam Hooper, adam.hooper@huffingtonpost.com.

Copyright

Copyright © 2016 The Huffington Post. See LICENSE for details.