You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every code examples can be find on the [Mailjet Documentation][doc]
15
+
All code examples can be found on the [Mailjet Documentation][doc].
11
16
12
17
(Please refer to the [Mailjet Documentation Repository][api_doc] to contribute to the documentation examples)
13
18
@@ -19,14 +24,23 @@ Every code examples can be find on the [Mailjet Documentation][doc]
19
24
20
25
## Getting Started
21
26
22
-
First, make sure you have an API key, and an API secret.
23
-
Once you got them, save them in your environment:
27
+
Grab your API and Secret Keys [here][api_credential]. You need them for authentication when using the Email API:
24
28
25
-
```
29
+
```bash
26
30
export MJ_APIKEY_PUBLIC='your api key'
27
31
export MJ_APIKEY_PRIVATE='your api secret'
28
32
```
29
33
34
+
## API Versioning
35
+
36
+
The Mailjet API is spread among three distinct versions:
37
+
38
+
-`v3` - The Email API
39
+
-`v3.1` - Email Send API v3.1, which is the latest version of our Send API
40
+
-`v4` - SMS API
41
+
42
+
Since 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`:
**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).
57
+
For additional information refer to our [API Reference](https://dev.preprod.mailjet.com/reference/overview/versioning/).
44
58
45
59
## Make a `GET` request:
46
60
```python
47
-
# get every contacts
61
+
# get all contacts
48
62
result = mailjet.contact.get()
49
63
```
50
64
51
65
## `GET` request with filters:
52
66
```python
53
-
# get the 2 first contacts
67
+
# get the first 2 contacts
54
68
result = mailjet.contact.get(filters={'limit': 2})
55
69
```
56
70
## `POST` request
@@ -61,25 +75,45 @@ result = mailjet.sender.create(data={'email': '[email protected]'})
61
75
62
76
## Combine a resource with an action
63
77
```python
64
-
# Get the contact lists of contact #2
78
+
# Get the contacts lists of contact #2
65
79
result = mailjet.contact_getcontactslists.get(id=2)
"TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
105
+
"HTMLPart": "<h3>Dear passenger 1, welcome to Mailjet!</h3><br />May the delivery force be with you!"
106
+
}
107
+
]
77
108
}
78
-
79
-
mailjet.send.create(email)
109
+
result = mailjet.send.create(data=data)
110
+
print result.status_code
111
+
print result.json()
80
112
81
113
```
82
114
115
+
You can also use the previous version of Mailjet's Send API (v3). You can find the documentation explaining the overall differences and code samples [here](https://dev.mailjet.com/guides/?python#sending-a-basic-email-v3).
0 commit comments