TargetSmart
Overview
TargetSmart provides access to voter and consumer data for the progressive community. Currently, there are two TargetSmart services that are supported by two Parsons classes, each requiring separate credentials:
TargetSmartAPI
: Single record lookup with HTTPS. This class provides methods to support searching for individual people, voters, and district information for a geographic location.TargetSmartAutomation
: Bulk record matching with SFTP. This class provides general methods for processing files instead of individual records.
Note
- Authentication
Log in to My TargetSmart to access authentication credentials. You will need an API key to use the
TargetSmartAPI
class, and an SFTP username and password to use theTargetSmartAutomation
class.For more information, see the API documentation.
TargetSmart
Quickstart
To instantiate TargetSmartAPI
, you can either store your API Key as the environmental variable
TS_API_KEY
, or pass it in as an argument:
from parsons import TargetSmartAPI
# First approach: Store API key as an environmental variable
ts_api = TargetSmartAPI()
# Second approach: Pass API key as an argument
ts_api = TargetSmartAPI(api_key='my_api_key')
You can then call various endpoints:
# Search for a person record using an email address
ts_api.data_enhance(search_id='test@email.com', search_id_type='email')
# Search for district information using an address
ts_api.district(search_type='address', address='123 test st, Durham NC 27708')
API
:inherited-members:
Automation
Quickstart
To instantiate TargetSmartAutomation
, you can either store your SFTP username and password
as the environmental variables TS_SFTP_USERNAME
and TS_SFTP_PASSWORD
, or pass them in as
keyword arguments:
from parsons import TargetSmartAutomation
# First approach: Store SFTP username and password as environmental variables
ts_auto = TargetSmartAutomation()
# Second approach: Pass SFTP username and password as arguments
ts_auto = TargetSmartAutomation(username='my_sftp_username', password='my_sftp_password')
You can then call various endpoints:
# Check the status of a match job
ts_auto.match_status(job_name='my_job_name')
# Remove all files for the match job
ts_auto.remove_files(job_name='my_job_name')