Skip to main content

mailchimp api v3 client

Project description

[![Coverage Status](https://coveralls.io/repos/github/vikingco/wingmonkey/badge.svg?branch=master)](https://coveralls.io/github/vikingco/wingmonkey?branch=master)
[![CI Status](https://travis-ci.org/vikingco/wingmonkey.svg?branch=master)](https://travis-ci.org/vikingco/wingmonkey)

# wingmonkey
mailchimp api v3 client

mailchimp v3 api reference documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/overview/


### Settings

To be able to make calls to mailchimp without having to initialize a custom MailChimpSession yourself make sure that at least following environment variable is set (or added to a .env file):

```python
DEFAULT_MAILCHIMP_API_KEY=<YOUR MAILCHIMP API KEY>


```

For more advanced usage you can pass a custom MailChimpSession to the serializers and functions:

```
from wingmonkey.mailchimp_session import MailChimpSession
from wingmonkey.lists import ListSerializer

session = MailChimpSession(api_endpoint=<YOUR MAILCHIMP BASE URL>, api_key=<YOUR MAILCHIMP API KEY>)
list_serializer = ListSerializer(session=session)

```

### Some more usage examples:

#### getting list info

```python
from wingmonkey.lists import ListSerializer

list_serializer = ListSerializer()
list_id = 'A_VALID_LIST_ID'

my_list = list_serializer.read(list_id=list_id)

name = my_list.name
total_subscribers = my_list.stats['member_count']
unsubscribe_count = my_list.stats['unsubscribe_count']
```
#### creating new member

```python
from wingmonkey.members import Member, MemberSerializer

email_address = 'monkeysee@monkey.do'
merge_fields = {FNAME: 'Ceasar', LNAME: 'Chimp'}
language = 'en'
list_id = 'A_VALID_LIST_ID'

member_to_add = Member(
email_address=email_address,
merge_fields=merge_fields,
language=language,
list_id=list_id
)

member_serializer = MemberSerializer()

newly_added_member = member_serializer.create(list_id=list_id, instance=member_to_add)
```

#### get all members of a list

```python

from wingmonkey.async_operations import get_all_members_async
from datetime import datetime, timedelta

list_id = 'A_VALID_LIST_ID'
```

* all members
```python
all_list_members = get_all_members_async(list_id=list_id)
```

* all members updated since specific date (take care to use the correct string format for datetime)
```python
date_since = datetime.strftime(datetime.now() - timedelta(days=1), '%Y-%m-%dT%H:%M:%S')
extra_params = {'since_last_changed': date_since }
all_updated_members_since_yesterday = get_all_members_async(list_id=list_id, extra_params=extra_params)
```

#### batch update of a large list of members
* This will return a list of corresponding batch operation resources (1 for every 500 members)
http://developer.mailchimp.com/documentation/mailchimp/reference/batches/#create-post_batches
http://developer.mailchimp.com/documentation/mailchimp/reference/lists/#create-post_lists_list_id

```python
from wingmonkey.async_operations import batch_update_members_async
list_id = 'A_VALID_LIST_ID'
member_list = [A_LIST_OF_MEMBER_INSTANCES]

batch_operation_resource_list = batch_update_members_async(list_id=list_id, member_list=member_list)
```


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wingmonkey-0.1.18.tar.gz (28.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wingmonkey-0.1.18-py3-none-any.whl (39.7 kB view details)

Uploaded Python 3

File details

Details for the file wingmonkey-0.1.18.tar.gz.

File metadata

  • Download URL: wingmonkey-0.1.18.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for wingmonkey-0.1.18.tar.gz
Algorithm Hash digest
SHA256 3e85a0fc96bf415763b70e0e8d0be2f8d494deabbbacadf6f4f667a951294111
MD5 c2094af39ccebb3e16b6aa0315331bf6
BLAKE2b-256 6fcad91451dc7a65756baac59b64dcd4b862f3a612bdaac01639b1843ee79e3d

See more details on using hashes here.

File details

Details for the file wingmonkey-0.1.18-py3-none-any.whl.

File metadata

  • Download URL: wingmonkey-0.1.18-py3-none-any.whl
  • Upload date:
  • Size: 39.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for wingmonkey-0.1.18-py3-none-any.whl
Algorithm Hash digest
SHA256 f768993a71de4a37d58410d1c5762ac54871d3e9a264f9c86aabc61a87dc1d2c
MD5 9ad110717f0fc9b2e5f106da018ecb95
BLAKE2b-256 042a17b474fc2a5a91df2615e91a39a1b039202dd8dfee4253d2211cf0a66cac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page