Skip to main content

Cakemail Next-gen API client

Project description


Install the cakemail package using pip

pip install cakemail


Create an object from the CakemailApi class with your Cakemail username and password. The object will take care of all authorization mechanisms automatically.

import cakemail

api = cakemail.Api(username='', password='somepassword')

Call one of the API operations (refer to the online documentation)

my_account = api.account.get_self()

API operations

API operations accept the OpenAPI models as well as python dictionaries.

from cakemail.models import CreateSender

sender = api.sender.create(
        name='My Sender',
sender = api.sender.create(
        'name': 'My Sender',
        'email': ''    

Operation Examples

Create a Sender

from cakemail.models import CreateSender, ConfirmSender

sender = api.sender.create(
    CreateSender(name='My Sender', email='')

Look for a confirmation email in your inbox; click to the link to activate the sender.

Create a Contact List

from cakemail.models import List, Sender

my_new_list = api.list.create(
        name='my new list',

Send a transactional email

from cakemail.models import Email, EmailContent

# expressed as OpenAPI models
            subject='Subject line',
            text='Email body',

# expressed as a dictionary
        'email': '',
        'sender': sender,
        'content': {
            'subject': 'Subject line',
            'text': 'Email body',
            'encoding': 'utf-8' 

Accessing data

The CakemailAPI always return its data under the data object. For simplicity, the resource data is accessible from the returned response directly:

my_user = api.user.get_self()

print(f'id: {}, email: {}')

Iterate through lists

Some methods return a list of resources on which you can iterate directly:

campaigns = api.campaign.list()
for campaign in campaigns:
    html = api.campaign.render(
    print(f'id: {}, name: {}, html: {html}')


Pagination is stored in the pagination property of all methods returning a list of resources:

campaigns = api.campaign.list(with_count=True)

  page: {},
  per_page: {campaigns.pagination.per_page},
  count: {campaigns.pagination.count}

Dictionary representation

The API methods return response objects; if you prefer to work with a python dict representation, use the to_dict method:

campaign_dict = api.campaign.get(campaign_id=123).to_dict()

for campaign in api.campaign.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

cakemail-1.10.1.tar.gz (9.8 kB view hashes)

Uploaded source

Built Distribution

cakemail-1.10.1-py3-none-any.whl (15.7 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page