Python Wrapper for Mailerlite API
Project description
Mailerlite-api-python
Python Wrapper for Mailerlite API v2
Getting Started
Installation
This client is hosted at PyPi under the name mailerlite-api-python, to install it, simply run
pip install mailerlite-api-python
Examples
Initialization
First, Grab YOUR_API_KEY from your Mailerlite account (Profile > Integrations > Developer Api).
from mailerlite import MailerLiteApi
api = MailerLiteApi('YOUR_API_KEY')
Campaigns
Get all campaigns or a specific one
all_campaigns = api.campaigns.all()
draft = api.compaings.all(status='draft')
Modify a campaign
one_campaign = all_campaigns[0]
html = '<h1>Title</h1><p>Content</p><p><small><a href=\"{$unsubscribe}\">Unsubscribe</a></small></p>'
plain = "Your email client does not support HTML emails. "
plain += "Open newsletter here: {$url}. If you do not want"
plain += " to receive emails from us, click here: {$unsubscribe}"
api.campaigns.update(one_campaign.id, html=html, plain=plain)
Create /Delete a campaign
data = {"subject": "Regular campaign subject",
"groups": [2984475, 3237221],
"type": "regular"}
api.campaign.create(data)
api.campaign.delete(campaign_id=3971635)
count campaign
api.campaign.count()
api.campaign.count(status='draft')
Subscribers
Get all subscribers
api.subscribers.all()
api.subscribers.all(stype='active')
api.subscribers.active()
Get one subscriber
api.subscribers.get(email='demo@mailerlite.com')
api.subscriber.get(id=1343965485)
search
api.subscriber.search(search='demo@mailerlite.com')
subscribers groups
api.subscriber.groups(id=1343965485)
subscribers activity
subscriber.activity(id='1343965485')
Create subscriber
data = {'name': 'John',
'email': 'demo-678@mailerlite.com',
'fields': {'company': 'MailerLite'}
}
api.subscriber.create(data)
Groups
Need documentation...
Segments
Get list of Segments.
api.segments.all()
Get countof Segments.
api.segments.count()
Fields
Get list of Fields.
api.fields.all()
Get one Field
api.fields.get(field_id=123456)
Create/update/delete one Field
api.fields.create(title="my custom title")
api.fields.update(field_id=123456, title="my new title 2")
api.fields.delete(field_id=123456)
Webhooks
Get list of Webhooks.
api.webhooks.all()
Get one webhook
api.webhooks.get(webhook_id=123456)
Create/update/delete one webhook
api.webhooks.create(url="https://yoursite/script-is-here",
event="subscriber.create")
api.webhooks.update(webhook_id=123456,
url="https://yoursite/script-is-here",
event="subscriber.create")
api.webhooks.delete(webhook_id=123456)
Account
# Get some info or stats
api.account.info()
api.account.stats()
api.account.double_optin()
# Set up the double_optin
api.account.set_double_optin(True)
Batch
batch_requests = {"requests": [{"method":"GET",
"path": "/api/v2/groups"
},
{"method":"POST",
"path": "/api/v2/groups",
"body": {"name": "New group"}
}
]
}
api.batch(batch_requests)
Contribute
We love contributions!
You've discovered a bug or something else you want to change - excellent! Create an issue!
You've worked out a way to fix it – even better! Submit a Pull Request!
Start with the contributing guide!
License
Project under 3-clause BSD license, more informations here
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for mailerlite-api-python-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a5e971bb731d3bd3324311ed7c683321af32d8653a5533445bf466dca1fed04 |
|
MD5 | 4eb2006c86d0b336e8e06bf10c008de1 |
|
BLAKE2b-256 | 3562990b6b05cd8dd05835545870b106888572c3127343384d8f36cd0d24af05 |
Close
Hashes for mailerlite_api_python-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 554e71c917fa80d893ca9671847171c82f116291b650c20d64034aa07c41e563 |
|
MD5 | 7e239d35c109abb96240fd5caa5a0a37 |
|
BLAKE2b-256 | da70d091fe362888459f01c965f6c9a6af5528a05c3edf1b296f9faf13a2cd33 |