PDI

Overview

PDI is a political data provider that is primarily active in California. `The PDI class allows you to interact with an `PDI’s API .

In order to instantiate the class you must pass valid kwargs or store the following environmental variables:

  • 'PDI_USERNAME'

  • 'PDI_PASSWORD'

  • 'PDI_API_TOKEN'

Quickstart

from parsons import PDI

pdi = PDI()

#Get all contacts (flag IDs) available from PDI
pdi.get_flag_ids()

#Get all flags since the beginning of 2020
pdi.get_flags(start_date='2020-01-01')

PDI Class

class parsons.PDI(username=None, password=None, api_token=None, qa_url=False)[source]
create_flag_id(flag_id, is_default, flag_description=None, compile=None)

Save a new flag id.

Args:
flag_id: str

The flag id type. One of: “AMM”, “BNH”, “BNM”, “DEAD”, “DNC”, “DNR”, “ENDR”, “GTD”, “HH”, “L2VT”, “LBO”, “LM”, “LO”, “LS”, “LSD”, “LSR”, “MAYBE”, “MOV”, “NAH”, “NO”, “REF”, “SO”, “SS”, “SUP”, “U”, “UL2VT”, “VL2VT”, “VOL”, “VTD”.

is_default: bool

The default.

flag_description: str

(Optional) The flag id description.

compile: str

(Optional) The compile.

Returns:
str

The identifier for the new flag id.

delete_flag_id(id)

Delete a flag id.

NOTE: The function returns True (even if the id doesn’t exist) unless there is an error.

Args:
id: str

The flag id identifier.

Returns:
bool

True if the operation is successful.

get_acquisition_types(limit=None)

Get a list of Acquisition Types.

Args:
limit: int

Specify limit to return.

Returns:
parsons.Table

A Parsons table of all the data.

get_flag_id(id)

Get a specified flag id.

Args:
id: str

The flag id identifier.

Returns:
dict

FlagID object.

get_flag_ids(limit=None)

Get a list of flag ids.

Args:
limit: int

Specify limit to return.

Returns:
parsons.Table

A Parsons table of all the data.

get_flags(start_date, end_date, limit=None)

Get a list of flags.

Args:
start_date: str

A start date formatted like yyyy-MM-dd.

end_date: str

An end date formatted like yyyy-MM-dd.

limit: int

Specify limit to return.

Returns:
parsons.Table

A Parsons table of all the data.

get_questions(limit=None)

Get a list of Questions.

Args:
limit: int

Specify limit to return.

Returns:
parsons.Table

A Parsons table of all the data.

get_universes(limit=None)

Get a list of Universes.

Args:
limit: int

The number of universes to return.

Returns:
parsons.Table

A Parsons table of all the data.

update_flag_id(id, flag_id, is_default, flag_description=None, compile=None)

Update a flag id.

Args:
id: str

The flag id identifier.

flag_id: str

The flag id type. One of: “AMM”, “BNH”, “BNM”, “DEAD”, “DNC”, “DNR”, “ENDR”, “GTD”, “HH”, “L2VT”, “LBO”, “LM”, “LO”, “LS”, “LSD”, “LSR”, “MAYBE”, “MOV”, “NAH”, “NO”, “REF”, “SO”, “SS”, “SUP”, “U”, “UL2VT”, “VL2VT”, “VOL”, “VTD”.

is_default: bool

The default.

flag_description: str

(Optional) The flag id description.

compile: str

(Optional) The compile.

Returns:
str

The identifier for the udpated flag id.