{ "info": { "author": "starenka", "author_email": "starenka0@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Utilities" ], "description": "[api_credential]: https://app.mailjet.com/account/api_keys\n[doc]: http://dev.mailjet.com/guides/?python#\n[api_doc]: https://github.com/mailjet/api-documentation\n[smsDashboard]: https://app.mailjet.com/sms?_ga=2.81581655.1972348350.1522654521-1279766791.1506937572\n[smsInfo]: https://app.mailjet.com/docs/transactional-sms?_ga=2.183303910.1972348350.1522654521-1279766791.1506937572#trans-sms-token\n\n\n\n# Official Mailjet Python Wrapper\n\n[](https://travis-ci.org/mailjet/mailjet-apiv3-python)\n\n### API documentation\n\nAll code examples can be found on the [Mailjet Documentation][doc].\n\n(Please refer to the [Mailjet Documentation Repository][api_doc] to contribute to the documentation examples)\n\n## Installation\n\n``` bash\n(sudo) pip install mailjet_rest\n```\n\n## Getting Started\n\nGrab your API and Secret Keys [here][api_credential]. You need them for authentication when using the Email API:\n\n```bash\nexport MJ_APIKEY_PUBLIC='your api key'\nexport MJ_APIKEY_PRIVATE='your api secret'\n```\n\n## API Versioning\n\nThe Mailjet API is spread among three distinct versions:\n\n- `v3` - The Email API\n- `v3.1` - Email Send API v3.1, which is the latest version of our Send API\n- `v4` - SMS API\n\nSince most Email API endpoints are located under `v3`, it is set as the default one and does not need to be specified when making your request. For the others you need to specify the version using `version`. For example, if using Send API `v3.1`:\n\n``` python\n# import the mailjet wrapper\nfrom mailjet_rest import Client\nimport os\n\n# Get your environment Mailjet keys\nAPI_KEY = os.environ['MJ_APIKEY_PUBLIC']\nAPI_SECRET = os.environ['MJ_APIKEY_PRIVATE']\n\n\n# Initialize the client with API URL (default is 'https://api.eu.mailjet.com/')\nmailjet = Client(auth=(API_KEY, API_SECRET), version='v3', api_url='https://api.eu.mailjet.com/')\n\n\n```\n\nFor additional information refer to our [API Reference](https://dev.preprod.mailjet.com/reference/overview/versioning/).\n\n## Make a `GET` request:\n``` python\n# get all contacts\nresult = mailjet.contact.get()\n```\n\n## `GET` request with filters:\n``` python\n# get the first 2 contacts\nresult = mailjet.contact.get(filters={'limit': 2})\n```\n## `POST` request\n``` python\n# Register a new sender email address\nresult = mailjet.sender.create(data={'email': 'test@mailjet.com'})\n```\n\n## Combine a resource with an action\n``` python\n# Get the contacts lists of contact #2\nresult = mailjet.contact_getcontactslists.get(id=2)\n```\n\n## Send an Email\n``` python\n\nfrom mailjet_rest import Client\nimport os\napi_key = os.environ['MJ_APIKEY_PUBLIC']\napi_secret = os.environ['MJ_APIKEY_PRIVATE']\nmailjet = Client(auth=(api_key, api_secret), version='v3.1')\ndata = {\n 'Messages': [\n {\n \"From\": {\n \"Email\": \"pilot@mailjet.com\",\n \"Name\": \"Mailjet Pilot\"\n },\n \"To\": [\n {\n \"Email\": \"passenger1@mailjet.com\",\n \"Name\": \"passenger 1\"\n }\n ],\n \"Subject\": \"Your email flight plan!\",\n \"TextPart\": \"Dear passenger 1, welcome to Mailjet! May the delivery force be with you!\",\n \"HTMLPart\": \"