PDI is a political data provider that is primarily active in California. This class allows you to interact with the PDI API .

This Parsons connector provides methods to fetch lists of acquisition types, flag IDs, questions, universes, and flags given start and end dates.



A user name, password, and API token are required to instantiate the PDI class. To obtain log in credentials, request a PDI API account from support@politicaldata.com. The administrative process usually takes a couple of hours.


To instantiate the PDI class, you can either store your PDI API username, password, and API token as environmental variables (PDI_USERNAME, PDI_PASSWORD, and PDI_API_TOKEN, respectively) or pass them in as arguments:

from parsons import PDI

# First approach: Use API credentials via environmental variables
pdi = PDI()

# Second approach: Pass API credentials as arguments
pdi = PDI(username='my_username', password='my_password', api_token='my_token')

# Get all contacts (flag IDs) available from PDI

# Get all flags since the beginning of 2020

PDI Class