Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gearplug/mailerlite-python
mailerlite-python is an API wrapper for MailerLite, written in Python
https://github.com/gearplug/mailerlite-python
api groups mailer mailerlite notifications python requests subscribers webhook wrapper
Last synced: 3 days ago
JSON representation
mailerlite-python is an API wrapper for MailerLite, written in Python
- Host: GitHub
- URL: https://github.com/gearplug/mailerlite-python
- Owner: GearPlug
- License: mit
- Created: 2022-12-07T16:57:44.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-30T13:27:01.000Z (almost 2 years ago)
- Last Synced: 2023-03-22T08:09:28.166Z (over 1 year ago)
- Topics: api, groups, mailer, mailerlite, notifications, python, requests, subscribers, webhook, wrapper
- Language: Python
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![](https://img.shields.io/badge/version-0.1.1-success) ![](https://img.shields.io/badge/code-Python-4B8BBE?logo=python&logoColor=white)
# mailerlite-pythonmailerlite-python is an API wrapper for MailerLite, written in Python
## Installing
```
pip install mailerlite-python
```
## Usage
```
from mailerlite.client import Client
client = Client('API_KEY')
```
### Subscribers
#### List Subscribers
```
subs = client.list_subscribers(params=None)
# Optional params (dict):
# filter[status] = Must be one of the possible statuses: active, unsubscribed, unconfirmed, bounced or junk.
# limit = Defaults to 25
# page = Defaults to 1
```
#### Create Subscriber
```
subscriber = {
"email": "[email protected]",
"fields": {
"name": "Carlos",
"last_name": "Burgos",
"city": "Bogotá",
}
}
sub = client.create_subscriber(subscriber)
# If user email already exists, updates existing subscriber.
```
#### Fetch Subscriber
```
# Reference can be either email or ID
subscriber = client.fetch_subscriber(reference)
```
#### Delete Subscriber
```
client.delete_subscriber(subscriber_id)
```
#### Subscribe Subscriber
```
client.activate_subscriber(subscriber_id)
```
#### Unsubscribe Subscriber
```
client.unsubscribe_subscriber(subscriber_id)
```
#### Assign Subscriber to a Group
```
client.assign_to_group(subscriber_id, group_id)
```
#### List Subscriber fields
```
fields = client.list_subscriber_fields()
```
#### List Groups
```
groups = client.list_groups(params=None)
# Optional params (dict):
# filter[name] = Returns partial matches
# limit = An account can have at most a 250 groups
# page = Defaults to 1
# sort = Can be one of: name, total, open_rate, click_rate, created_at. Defaults to ascending order; prepend (-)
```### Webhooks
#### List all webhooks
```
webhooks = client.list_webhooks()
```
#### Create webhook
```
webhook = {
"name": "first webhook",
"events": ["subscriber.created"],
"url": "http://www.cartwright.info/eligendi-soluta-corporis-in-quod-ullam"
}
webhook_created = client.create_webhook(webhook)
```
#### Delete webhook
```
client.delete_webhook(webhook_id)
```