Rock the Vote

Overview

Rock the Vote is an online registration tool.

The Parsons Connector makes use of Rock the Vote’s Rocky API. In order to authenticate with the API, users will need to specify the ID and the API key of the RTV partner organization for the data.

QuickStart

To use the RockTheVote class you can either store the partner ID and API key as an environmental variable (RTV_PARTNER_ID and RTV_PARTNER_API_KEY, respectively), or you can pass them in as arguments to the class.

from parsons import RockTheVote

rtv = RockTheVote()  # If specified as environment variables, no need to pass them in

rtv = RockTheVote(partner_id='123', partner_api_key='supersecretkey') # Pass credentials directly

To fetch a list of registrations submitted for the partner ID, use the run_registration_report method. It is possible to filter the results by providing a parameter to specify a start date for the registrations.

from parsons import RockTheVote

rtv = RockTheVote()

registrants = rtv.run_registration_report(since='2020-01-01')

The run_registration_report will block as the report is being generated and downloaded from the Rocky API. For larger reports, this can take a long time. If you have other things you want to do while the report is running, you can break up the creation of the report from the fetching of the data.

from parsons import RockTheVote

rtv = RockTheVote()

report_id = rtv.create_registration_report(since='2020-01-01')

# Do some other stuff here

registrants = rtv.get_registration_report(report_id)

API

class parsons.rockthevote.rtv.RockTheVote(partner_id=None, partner_api_key=None)[source]
Args:
partner_id: str

The RockTheVote partner ID for the RTV account

partner_api_key: str

The API Key for the partner

Returns:

RockTheVote class

create_registration_report(before=None, since=None)[source]

Create a new registration report.

Args:
before: str

Date before which to return registrations for

since: str

Date for filtering registrations

Returns:
int

The ID of the created report.

get_registration_report(report_id, block=False, poll_interval_seconds=60, report_timeout_seconds=3600)[source]

Get data from an existing registration report.

Args:
report_id: int

The ID of the report to get data from

block: bool

Whether or not to block execution until the report is complete

poll_interval_seconds: int

If blocking, how long to pause between attempts to check if the report is done

report_timeout_seconds: int

If blocking, how long to wait for the report before timing out

Returns:
Parsons Table

Parsons table with the report data.

run_registration_report(before=None, since=None, poll_interval_seconds=60, report_timeout_seconds=3600)[source]

Run a new registration report.

This method will block until the report has finished generating, or until the specified timeout is reached.

Args:
before: str

Date before which to return registrations for

since: str

Date for filtering registrations

poll_interval_seconds: int

If blocking, how long to pause between attempts to check if the report is done

report_timeout_seconds: int

If blocking, how long to wait for the report before timing out

Returns:
int

The ID of the created report.