GithubHelp home page GithubHelp logo

buzzeante / mailjet-apiv3-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mailjet/mailjet-apiv3-python

0.0 2.0 0.0 68 KB

[API v3] Python Mailjet wrapper

Home Page: https://dev.mailjet.com

License: MIT License

Python 100.00%

mailjet-apiv3-python's Introduction

#Simple Mailjet APIv3 wrapper

Build Status

API documentation

Every code examples can be find on the Mailjet Documentation

(Please refer to the Mailjet Documentation Repository to contribute to the documentation examples)

Installation

(sudo) pip install mailjet_rest

Getting Started

First, make sure you have an API key, and an API secret. Once you got them, save them in your environment:

export MJ_APIKEY_PUBLIC='your api key'
export MJ_APIKEY_PRIVATE='your api secret'
# import the mailjet wrapper
from mailjet_rest import Client
import os

# Get your environment Mailjet keys
API_KEY = os.environ['MJ_APIKEY_PUBLIC']
API_SECRET = os.environ['MJ_APIKEY_PRIVATE']

mailjet = Client(auth=(API_KEY, API_SECRET), version='v3')

NOTE: version reflects the api version in the url (https://api.mailjet.com/{{ version }}/REST/). It is 'v3' by default and can be used to select another api version (for example v3.1 for the new send API).

Make a GET request:

# get every contacts
result = mailjet.contact.get()

GET request with filters:

# get the 2 first contacts
result = mailjet.contact.get(filters={'limit': 2})

POST request

# Register a new sender email address
result = mailjet.sender.create(data={'email': '[email protected]'})

Combine a resource with an action

# Get the contact lists of contact #2
result = mailjet.contact_getcontactslists.get(id=2)

Send an Email

email = {
	'FromName': 'Mr Smith',
	'FromEmail': '[email protected]',
	'Subject': 'Test Email',
	'Text-Part': 'Hey there !',
	'Recipients': [{'Email': 'your email here'}]
}

mailjet.send.create(email)

Create a new Contact

# wrapping the call inside a function
def new_contact(email):
	return mailjet.contact.create(data={'Email': email})

new_contact('[email protected]')

mailjet-apiv3-python's People

Contributors

arnaudbreton avatar cheungpat avatar jorgii avatar kidig avatar latanasov avatar malimediagroup avatar starenka avatar weshguillaume avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.