Skip to content

[API v1] Mailjet API implementation in Python - /!\ [DEPRECATED - SEE README] /!\ -

License

Notifications You must be signed in to change notification settings

mailjet/python-mailjet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

READ THIS FIRST!!
This repository isn't compatible with the current Mailjet API (v3) and, as a consequence, is considered deprecated and won't undergo further development. As such, this repository isn't under active maintenance.

[API v1] Mailjet Python API Wrapper

mailjet is a library to access the Mailjet REST API.

Install

To install simply execute python setup.py install.

The settings can be configured from a Django settings file through MAILJET_API_KEY and MAILJET_SECRET_KEY. Or through environment variables the same name.

i.e.

export MAILJET_API_KEY=something
export MAILJET_SECRET_KEY=something_else

It is also possible to inject your API keys in the constructor, like so:

api = mailjet.Api(access_key='499c...6a8f4', secret_key='7bb4...c821')

Usage

To fetch data:

>>> import mailjet
>>> print mailjet.Api().user.infos()
{
    u'status': u'OK',
    u'infos': {
        u'username': u'user@domain.com',
        u'firstname': u'firstname',
        u'locale': u'en_US',
        u'lastname': u'lastname',
        u'company_name': u'company_name',
        u'contact_phone': None,
    },
}

To put data:

>>> import mailjet
>>> api = mailjet.Api()
>>> list_ = api.lists.create(label='Test', name='test')
>>> print list_
{u'status': u'OK', u'list_id': ...}
>>> print api.user.addcontact(
    contact='user@domain.com',
    id=list_['list_id'],
    method='POST',
)

FAQ

How do I give reserved python keywords as parameters?

As expained in #1:

c = dict()
c['method'] ='POST'
c['subject'] = 'Test'
c['list_id'] = list_['list_id']
c['lang'] = 'en'
c['from'] = 'noreply@foo.com'
c['from_name'] = 'foo'
c['footer'] = 'default'
campaign_ = api.message.createcampaign(**c)

About

[API v1] Mailjet API implementation in Python - /!\ [DEPRECATED - SEE README] /!\ -

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%