Skip to content

Commit 43d3424

Browse files
Merge pull request #194 from sendgrid/mail-send-docs-update
README documentation improvements
2 parents b073b78 + 3de36c9 commit 43d3424

File tree

1 file changed

+74
-28
lines changed

1 file changed

+74
-28
lines changed

README.md

Lines changed: 74 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
11
[![Travis Badge](https://travis-ci.org/sendgrid/sendgrid-python.svg?branch=master)](https://travis-ci.org/sendgrid/sendgrid-python)
22

3-
**This library allows you to quickly and easily use the SendGrid Web API via Python.**
3+
**This library allows you to quickly and easily use the SendGrid Web API v3 via Python.**
44

5-
# Announcements
6-
7-
**BREAKING CHANGE as of 2016.06.14**
8-
9-
Version `3.X.X` is a breaking change for the entire library.
10-
11-
Version 3.X.X brings you full support for all Web API v3 endpoints. We
12-
have the following resources to get you started quickly:
5+
Version 3.X.X of this library provides full support for all SendGrid [Web API v3](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html) endpoints, including the new [v3 /mail/send](https://sendgrid.com/blog/introducing-v3mailsend-sendgrids-new-mail-endpoint).
136

14-
- [SendGrid
15-
Documentation](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html)
16-
- [Usage
17-
Documentation](https://github.com/sendgrid/sendgrid-python/tree/master/USAGE.md)
18-
- [Example
19-
Code](https://github.com/sendgrid/sendgrid-python/tree/master/examples)
20-
- [Migration from v2 to v3](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/how_to_migrate_from_v2_to_v3_mail_send.html)
7+
This library represents the beginning of a new path for SendGrid. We want this library to be community driven and SendGrid led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/sendgrid/sendgrid-python/issues) and [pull requests](https://github.com/sendgrid/sendgrid-python/blob/master/CONTRIBUTING.md) or simply upvote or comment on existing issues or pull requests.
218

22-
Thank you for your continued support!
9+
Please browse the rest of this README for further detail.
2310

24-
All updates to this library is documented in our [CHANGELOG](https://github.com/sendgrid/sendgrid-python/blob/master/CHANGELOG.md).
11+
We appreciate your continued support, thank you!
2512

2613
# Installation
2714

@@ -32,7 +19,7 @@ All updates to this library is documented in our [CHANGELOG](https://github.com/
3219

3320
## Setup Environment Variables
3421

35-
Update your environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys).
22+
Update the development environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys), for example:
3623

3724
```bash
3825
echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
@@ -60,31 +47,85 @@ easy_install sendgrid
6047

6148
## Hello Email
6249

50+
The following is the minimum needed code to send an email with the [/mail/send Helper](https://github.com/sendgrid/sendgrid-python/tree/master/sendgrid/helpers/mail) ([here](https://github.com/sendgrid/sendgrid-python/blob/master/examples/helpers/mail/mail_example.py#L20) is a full example):
51+
52+
### With Mail Helper Class
53+
6354
```python
6455
import sendgrid
6556
import os
6657
from sendgrid.helpers.mail import *
6758

6859
sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY'))
6960
from_email = Email("[email protected]")
70-
subject = "Hello World from the SendGrid Python Library"
61+
subject = "Hello World from the SendGrid Python Library!"
7162
to_email = Email("[email protected]")
72-
content = Content("text/plain", "some text here")
63+
content = Content("text/plain", "Hello, Email!")
7364
mail = Mail(from_email, subject, to_email, content)
7465
response = sg.client.mail.send.post(request_body=mail.get())
7566
print(response.status_code)
7667
print(response.body)
7768
print(response.headers)
7869
```
7970

80-
## General v3 Web API Usage
71+
The `Mail` constructor creates a [personalization object](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/personalizations.html) for you. [Here](https://github.com/sendgrid/sendgrid-python/blob/master/examples/helpers/mail/mail_example.py#L16) is an example of how to add to it.
72+
73+
### Without Mail Helper Class
74+
75+
The following is the minimum needed code to send an email without the /mail/send Helper ([here](https://github.com/sendgrid/sendgrid-python/blob/master/examples/mail/mail.py#L27) is a full example):
76+
77+
```python
78+
import sendgrid
79+
import os
80+
81+
data = {
82+
"personalizations": [
83+
{
84+
"to": [
85+
{
86+
"email": "[email protected]"
87+
}
88+
],
89+
"subject": "Hello World from the SendGrid Python Library!"
90+
}
91+
],
92+
"from": {
93+
"email": "[email protected]"
94+
},
95+
"content": [
96+
{
97+
"type": "text/plain",
98+
"value": "Hello, Email!"
99+
}
100+
]
101+
}
102+
response = sg.client.mail.send.post(request_body=data)
103+
print(response.status_code)
104+
print(response.body)
105+
print(response.headers)
106+
```
107+
108+
## General v3 Web API Usage (With Fluent Interface)
109+
110+
```python
111+
import sendgrid
112+
import os
113+
114+
sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY'))
115+
response = sg.client.suppression.bounces.get()
116+
print(response.status_code)
117+
print(response.body)
118+
print(response.headers)
119+
```
120+
121+
## General v3 Web API Usage (Without Fluent Interface)
81122

82123
```python
83124
import sendgrid
84125
import os
85126

86127
sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY'))
87-
response = sg.client.api_keys.get()
128+
response = sg.client._("suppression/bounces").get()
88129
print(response.status_code)
89130
print(response.body)
90131
print(response.headers)
@@ -93,17 +134,22 @@ print(response.headers)
93134
# Usage
94135

95136
- [SendGrid Documentation](https://sendgrid.com/docs/API_Reference/index.html)
96-
- [Usage Documentation](https://github.com/sendgrid/sendgrid-python/tree/master/USAGE.md)
137+
- [Library Usage Documentation](https://github.com/sendgrid/sendgrid-python/tree/master/USAGE.md)
97138
- [Example Code](https://github.com/sendgrid/sendgrid-python/tree/master/examples)
139+
- [How-to: Migration from v2 to v3](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/how_to_migrate_from_v2_to_v3_mail_send.html)
98140
- [v3 Web API Mail Send Helper](https://github.com/sendgrid/sendgrid-python/tree/master/sendgrid/helpers/mail) - build a request object payload for a v3 /mail/send API call.
99141

100-
## Roadmap
142+
# Announcements
143+
144+
All updates to this library is documented in our [CHANGELOG](https://github.com/sendgrid/sendgrid-python/blob/master/CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-python/releases).
145+
146+
# Roadmap
101147

102-
If you are intersted in the future direction of this project, please take a look at our [milestones](https://github.com/sendgrid/sendgrid-python/milestones). We would love to hear your feedback.
148+
If you are interested in the future direction of this project, please take a look at our open [issues](https://github.com/sendgrid/sendgrid-python/issues) and [pull requests](https://github.com/sendgrid/sendgrid-python/pulls). We would love to hear your feedback.
103149

104-
## How to Contribute
150+
# How to Contribute
105151

106-
We encourage contribution to our libraries, please see our [CONTRIBUTING](https://github.com/sendgrid/sendgrid-python/blob/master/CONTRIBUTING.md) guide for details.
152+
We encourage contribution to our libraries (you might even score some nifty swag), please see our [CONTRIBUTING](https://github.com/sendgrid/sendgrid-python/blob/master/CONTRIBUTING.md) guide for details.
107153

108154
Quick links:
109155

0 commit comments

Comments
 (0)