Skip to content

Commit e581bde

Browse files
committed
Update README
1 parent 6431ef1 commit e581bde

File tree

1 file changed

+57
-107
lines changed

1 file changed

+57
-107
lines changed

README.md

Lines changed: 57 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
<p align='center'><img src="https://contiguity.co/assets/icon-black.png" height="150px"/></p>
2-
<h1 align='center'>@contiguity/python</h1>
3-
4-
<p align='center'>
5-
<img display="inline-block" src="https://img.shields.io/pypi/v/contiguity?style=for-the-badge" /> <img display="inline-block" src="https://img.shields.io/badge/Made%20with-Python-green?style=for-the-badge" />
1+
<p align="center"><img src="https://contiguity.co/assets/icon-black.png" height="150px"/></p>
2+
<h1 align="center">@contiguity/python</h1>
3+
<p align="center">
4+
<img display="inline-block" src="https://img.shields.io/pypi/v/contiguity?style=for-the-badge" />
5+
<img display="inline-block" src="https://img.shields.io/badge/Made%20with-Python-green?style=for-the-badge" />
66
</p>
7-
<p align='center'>Contiguity's official Python SDK.</p>
7+
<p align="center">Contiguity's official Python SDK.</p>
8+
9+
## Documentation 📖
10+
11+
[Full documentation](https://docs.contiguity.com/sdk/python)
812

9-
## Installation 🏗 & Setup 🛠
13+
## Installation & setup 🛠
1014

1115
You can install the SDK using pip
1216

@@ -16,161 +20,107 @@ pip install contiguity
1620

1721
Then, import & initialize it like this:
1822

19-
```js
20-
import contiguity
21-
client = contiguity.login("your_token_here")
23+
```python
24+
from contiguity import Contiguity
25+
26+
client = Contiguity(token="your_token_here")
2227
```
2328

24-
You can get your token from the Contiguity [dashboard](https://contiguity.co/dashboard).
29+
> [!TIP]
30+
> It is recommended to set the `CONTIGUITY_TOKEN` environment variable instead of hardcoding your token. The SDK will automatically read this variable if no token is provided during initialization.
31+
32+
You can get your token from the [Contiguity console](https://console.contiguity.com/).
2533

2634
## Sending your first email 📤
2735

2836
As long as you provided Contiguity a valid token, and provide valid inputs, sending emails will be a breeze!
2937

30-
To begin sending an email with an HTML body, you can define a JSON object with all the required fields.
38+
To send an email with an HTML body:
3139

3240
```python
33-
email_object = {
34-
"to": "example@example.com",
35-
"from": "Contiguity",
36-
"subject": "My first email!",
37-
"html": "<b>I sent an email using Contiguity</b>"
38-
}
39-
40-
client.send.email(email_object)
41+
client.email.send(
42+
to="example@example.com",
43+
from_="Contiguity",
44+
subject="My first email!",
45+
body_html="<b>I sent an email using Contiguity</b>",
46+
)
4147
```
4248

43-
To send an email with a text body, it's very similar. Just switch "html" to "text".
49+
To send an email with a text body:
4450

4551
```python
46-
email_object = {
47-
"to": "example@example.com",
48-
"from": "Contiguity",
49-
"subject": "My first email!",
50-
"text": "I sent an email using Contiguity"
51-
}
52-
53-
client.send.email(email_object)
52+
client.email.send(
53+
to="example@example.com",
54+
from_="Contiguity",
55+
subject="My first email!",
56+
body_text="I sent an email using Contiguity",
57+
)
5458
```
5559

5660
### Optional fields
5761

58-
- `replyTo` allows you set a reply-to email address.
59-
- `cc` allows you to CC an email address
60-
61-
You can also fetch a local email template using `client.template.local(file)`:
62-
63-
```python
64-
template = client.template.local('templates/first_email.html')
65-
66-
email_object = {
67-
"to": "example@example.com",
68-
"from": "Contiguity",
69-
"subject": "My first email!",
70-
"html": template,
71-
}
72-
73-
client.send.email(email_object)
74-
```
62+
- `reply_to` allows you to set a reply-to email address.
63+
- `cc` allows you to CC email addresses.
64+
- `bcc` allows you to BCC email addresses.
65+
- `headers` allows you to set custom email headers.
7566

7667
## Sending your first text message 💬
7768

7869
As long as you provided Contiguity a valid token, and will provide valid inputs, sending texts will be a breeze!
7970

80-
To begin sending a text message, you can define a JSON object with all the required fields.
81-
82-
```js
83-
text_object = {
84-
"to": "+15555555555",
85-
"message": "My first text using Contiguity"
86-
}
87-
88-
client.send.text(text_object)
71+
```python
72+
client.text.send(to="+15555555555", message="My first text using Contiguity")
8973
```
9074

9175
**Note**: _Contiguity expects the recipient phone number to be formatted in E.164. You can attempt to pass numbers in formats like NANP, and the SDK will try its best to convert it. If it fails, it will throw an error!_
9276

9377
## Sending your first OTP 🔑
9478

95-
Contiguity aims to make communications extremely simple and elegant. In doing so, we're providing an OTP API to send one time codes - for free (no additional charge, the text message is still billed / added to quota)
79+
Contiguity aims to make communications extremely simple and elegant. In doing so, we're providing an OTP API to send one time codes - for free (no additional charge, the text message is still billed/added to quota)
9680

9781
To send your first OTP, first create one:
9882

9983
```python
100-
otp_id = client.otp.send({
101-
'to': "+15555555555",
102-
'language': "en",
103-
'name': "Contiguity"
104-
})
84+
from contiguity.otp import OTPLanguage
85+
86+
response = client.otp.send("+15555555555", language=OTPLanguage.ENGLISH, name="Contiguity")
87+
otp_id = response.otp_id
10588
```
10689

107-
Contiguity supports 33 languages for OTPs, including `English (en)`, `Afrikaans (af)`, `Arabic (ar)`, `Catalan (ca)`, `Chinese / Mandarin (zh)`, `Cantonese (zh-hk)`, `Croatian (hr)`, `Czech (cs)`, `Danish (da)`, `Dutch (nl)`, `Finnish (fi)`, `French (fr)`, `German (de)`, `Greek (el)`, `Hebrew (he)`, `Hindi (hi)`, `Hungarian (hu)`, `Indonesian (id)`, `Italian (it)`, `Japanese (ja)`, `Korean (ko)`, `Malay (ms)`, `Norwegian (nb)`, `Polish (pl)`, `Portuguese - Brazil (pt-br)`, `Portuguese (pt)`, `Romanian (ro)`, `Russian (ru)`, `Spanish (es)`, `Swedish (sv)`, `Tagalog (tl)`, `Thai (th)`, `Turkish (tr)`, and `Vietnamese (vi)`
90+
Contiguity supports 33 languages for OTPs, see the [OTPLanguage enum](src/contiguity/otp.py) for the full list.
10891

10992
_The `name` parameter is optional, it customizes the message to say "Your \[name] code is ..."_
11093

11194
To verify an OTP a user has inputted, simply call `client.otp.verify()`:
11295

11396
```python
114-
verify = client.otp.verify({
115-
'otp_id': otp_id # you received this when you called client.otp.send(),
116-
'otp': input # the 6 digits your user inputted.
117-
})
97+
response = client.otp.verify(otp_id, otp=user_input)
98+
is_verified = response.verified # True or False
11899
```
119100

120-
It will return a boolean (true/false). The OTP expires 15 minutes after sending it.
101+
The OTP expires 15 minutes after sending it.
121102

122103
Want to resend an OTP? Use `client.otp.resend()`:
123104

124-
```py
125-
resend = client.otp.resend({
126-
'otp_id': otp_id # you received this when you called client.otp.send(),
127-
})
105+
```python
106+
response = client.otp.resend(otp_id)
128107
```
129108

130109
OTP expiry does not renew.
131110

132-
## Verify formatting
111+
## More examples 📚
133112

134-
Contiguity provides two functions that verify phone number and email formatting, which are:
113+
The SDK also supports sending iMessages, WhatsApp messages, managing email domains, and leasing phone numbers.
135114

136-
```py
137-
client.verify.number("number")
138-
```
139-
140-
and
141-
142-
```py
143-
client.verify.email("example@example.com")
144-
```
145-
146-
They return a boolean (true/false)
147-
148-
**Note**: _This occurs locally, and is not part of Contiguity's online verification service._
149-
150-
## Email analytics
151-
152-
If you sent an HTML email, and chose Contiguity to track it, you can fetch an email's status (delivered/read) using:
153-
154-
```py
155-
client.email_analytics.retrieve("email_id")
156-
```
157-
158-
## Quota
159-
160-
If you'd like to retrieve your quota, whether you're on our free tier or Unlimited, you can fetch it using:
161-
162-
```py
163-
client.quota.retrieve()
164-
```
165-
166-
You'll receive an object similar to the `crumbs` the API provides on completion of every request.
115+
See more examples in the [examples](examples/) folder.
167116

168117
## Roadmap 🚦
169118

170119
- Contiguity Identity will be supported
171120
- Adding support for calls
172121
- Adding support for webhooks
173-
- Adding support for online templates
174-
- and way more.
122+
- and much more!
123+
124+
## License ⚖️
175125

176-
### See complete examples in [examples/](https://github.com/use-contiguity/python/tree/main/examples)
126+
[MIT License](LICENSE.txt)

0 commit comments

Comments
 (0)