Last active
January 10, 2020 16:24
-
-
Save octern/64427c1d306a14f60434b64bac70b129 to your computer and use it in GitHub Desktop.
Add MailChimp subsciber via API using Python with mailchimp3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# to install module: pip install mailchimp3 | |
from mailchimp3 import MailChimp as mc | |
api_key = "" #your api key | |
username = "" #username you use to log in to mailchimp | |
audience_id = "" #hex audience ID, as string, from Audience > Manage Audience > Settings > Audience name and defaults (some documentation refers to these as "lists"; the name seems to have been changed to "audiences") | |
subscriber_email = "" #email address | |
status = "" #"pending" to send an opt-in email, "subscribed" if the user already opted in, or "transactional" if they don't need to opt in | |
client=mc(mc_api=api_key, mc_user=username) | |
client.lists.members.create(list_id=list_id, data={"email_address":subscriber_email, "status":status}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment