ActionKit
Overview
The ActionKit class allows you to interact with an ActionKit.
Quickstart
Retrieve a User
from parsons import ActionKit
ak = ActionKit()
user_data = ak.get_user(123)
API
- class parsons.ActionKit(domain=None, username=None, password=None)[source]
Instatiate the ActionKit class
- Args:
- domain: str
The ActionKit domain (e.g.
myorg.actionkit.com
) Not required ifACTION_KIT_DOMAIN
env variable set.- username: str
The authorized ActionKit username. Not required if
ACTION_KIT_USERNAME
env variable set.- password: str
The authorized ActionKit user password. Not required if
ACTION_KIT_USERNAME
env variable set.
- get_user(user_id)[source]
Get a user.
- Args:
- user_id: int
The user id of the record to get.
- Returns:
User json object
- get_user_fields()[source]
Get list of valid user fields that can be passed with the
ActionKit.create_user()
method.- Returns:
List of user fields
- create_user(email, **kwargs)[source]
Create a user.
- Args:
- email: str
Email for the user
- user_dict: dict
Optional; Additional user fields
- Returns:
User json object
- update_user(user_id, **kwargs)[source]
Update a user.
- Args:
- user_id: int
The user id of the person to update
- user_dict: dict
A dictionary of fields to update for the user.
- Returns:
None
- delete_user(user_id)[source]
Delete a user.
- Args:
- user_id: int
The user id of the person to delete
- Returns:
None
- get_campaign(campaign_id)[source]
Get a campaign.
- Args:
- campaign_id: int
The campaign id of the record.
- Returns:
Campaign json object
- get_campaign_fields()[source]
Get list of valid campaign fields that can be passed with the
ActionKit.create_campaign()
andActionKit.update_campaign()
methods.- Returns:
List of campaign fields
- create_campaign(name, **kwargs)[source]
Create a campaign.
- Args:
- name: str
The name of the campaign to create
- Returns:
API location of new resource
- get_event_create_page(event_create_page_id)[source]
Get a event create page.
- Args:
- event_create_page_id: int
The event create page id of the record to get.
- Returns:
Event create page json object
- get_event_create_page_fields()[source]
Get list of event create page fields that can be passed with the
ActionKit.create_event_create_page()
.- Returns:
List of event create page fields
- create_event_create_page(name, campaign_id, title, **kwargs)[source]
Add an event page to a campaign.
- Args:
- campaign_id: int
The campaign to assoicate page with
- name: str
The name of the page to create
- title: str
The title of the page to create
- Returns:
API location of new resource
- get_event_create_form(event_create_form_id)[source]
Get a event create form.
- Args:
- event_create_form_id: int
The event create form id of the record to get.
- Returns:
Event create form json object
- get_event_create_form_fields()[source]
Get list of valid event create form fields that can be passed with the
ActionKit.create_event_create_form()
method.- Returns:
List of event create form fields
- create_event_create_form(page_id, thank_you_text, **kwargs)[source]
Create a event create form.
- Args:
- page_id: int
The page to associate the form with
- thank_you_text: str
Free form thank you text
- Returns:
API location of new resource
- get_event_signup_page(event_signup_page_id)[source]
Get event signup page.
- Args:
- event_signup_page_id: int
The event signup page id of the record to get.
- Returns:
Event signup page json object
- get_event_signup_page_fields()[source]
Get list of valid event signup page fields that can be passed with the
ActionKit.create_event_signup_page()
method.- Returns:
List of event signup page fields
- create_event_signup_page(name, campaign_id, title, **kwargs)[source]
Add an event signup page to a campaign.
- Args:
- campaign_id: int
The campaign to assoicate page with
- name: str
The name of the page to create
- title: str
The title of the page to create
- Returns:
API location of new resource
- get_event_signup_form(event_signup_form_id)[source]
Get a user.
- Args:
- event_signup_form_id: str
The event signup form id of the record to get.
- Returns:
Event signup form json object
- get_event_signup_form_fields()[source]
Get list of valid event signup form fields that can be passed with the
ActionKit.create_event_signup_form()
method.- Returns:
List of event signup form fields
- create_event_signup_form(page_id, thank_you_text, **kwargs)[source]
Create a event signup form.
- Args:
- page_id: int
The page to associate the form with
- thank_you_text: str
Free form thank you text
- Returns:
API location of new resource
- get_page_followup(page_followup_id)[source]
Get a page followup.
- Args:
- page_followup_id: int
The user id of the record to get.
- Returns:
Page followup json object
- get_page_followup_fields()[source]
Get list of valid page followup fields that can be passed with the
ActionKit.create_page_followup()
method.- Returns:
List of page followup fields
- create_page_followup(signup_page_id, url, **kwargs)[source]
Add a page followup.
- Args:
- signup_page_id: int
The signup page to associate the followup page with
- url: str
URL of the folloup page
- Returns:
API location of new resource
- create_generic_action(page, email=None, ak_id=None, **kwargs)[source]
Post a generic action. One of
ak_id
oremail
is a required argument.- Args:
- page:
The page to post the action. The page short name.
- email:
The email address of the user to post the action.
- ak_id:
The action kit id of the record.
- **kwargs:
Optional arguments and fields that can sent. A full list can be found in the ActionKit API Documentation.
- Returns:
- dict
The response json
- bulk_upload_csv(csv_file, import_page, autocreate_user_fields=False, user_fields_only=False)[source]
Bulk upload a csv file of new users or user updates. If you are uploading a table object, use bulk_upload_table instead. See ActionKit User Upload Documentation Be careful that blank values in columns will overwrite existing data.
If you get a 500 error, try sending a much smaller file (say, one row), which is more likely to return the proper 400 with a useful error message
- Args:
- import_page: str
The page to post the action. The page short name.
- csv_file: str or buffer
The csv (optionally zip’d) file path or a file buffer object A user_id or email column is required. ActionKit rejects files that are larger than 128M
- autocreate_user_fields: bool
When True columns starting with “user_” will be uploaded as user fields. See the autocreate_user_fields documentation.
- user_fields_only: bool
When uploading only an email/user_id column and user_ user fields, ActionKit has a fast processing path. This doesn’t work, if you upload a zipped csv though.
- Returns:
- dict
success: whether upload was successful progress_url: an API URL to get progress on upload processing res: requests http response object
- bulk_upload_table(table, import_page, autocreate_user_fields=0, no_overwrite_on_empty=False)[source]
Bulk upload a table of new users or user updates. See ActionKit User Upload Documentation Be careful that blank values in columns will overwrite existing data.
Tables with only an identifying column (user_id/email) and user_ user fields will be fast-processed – this is useful for setting/updating user fields.
Note
If you get a 500 error, try sending a much smaller file (say, one row), which is more likely to return the proper 400 with a useful error message
- Args:
- import_page: str
The page to post the action. The page short name.
- table: Table Class
A Table of user data to bulk upload A user_id or email column is required.
- autocreate_user_fields: bool
When True columns starting with “user_” will be uploaded as user fields. ActionKit. See the autocreate_user_fields documentation.
- no_overwrite_on_empty: bool
When uploading user data, ActionKit will, by default, take a blank value and overwrite existing data for that user. This can be undesirable, if the goal is to only send updates. Setting this to True will divide up the table into multiple upload batches, changing the columns uploaded based on permutations of empty columns.
- Returns:
- dict
success: bool – whether upload was successful (individual rows may not have been) results: [dict] – This is a list of the full results.
progress_url and res for any results