@contiguity/python
Contiguity’s official Python SDK.
⚠️ Out of date documentation - it is recommended to get documentation by product ⚠️
This is documentation that is out of date. It is a direct copy of the package’s README available on GitHub. It is not always up to date.
We’re in the process of updating this page to match the new documentation style and document new features. Expect this to be updated by Q1 2025.
Installation 🏗 & Setup 🛠
You can install the SDK using pip:
Then, import & initialize it like this:
You can also initialize it with the optional ‘debug’ flag:
You can get your token from the Contiguity dashboard.
Sending your first email 📤
As long as you provided Contiguity a valid token, and provide valid inputs, sending emails will be a breeze!
To begin sending an email with an HTML body, you can define a JSON object with all the required fields.
To send an email with a text body, it’s very similar. Just switch “html” to “text”.
Optional fields
replyTo
allows you to set a reply-to email address.cc
allows you to CC an email address.
You can also fetch a local email template using client.template.local(file)
:
Sending your first text message 💬
As long as you provided Contiguity a valid token, and will provide valid inputs, sending texts will be a breeze!
To begin sending a text message, you can define a JSON object with all the required fields.
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!
Sending your first OTP 🔑
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).
To send your first OTP, first create one:
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)
.
The name
parameter is optional, it customizes the message to say “Your [name] code is …”
To verify an OTP a user has inputted, simply call client.otp.verify()
:
It will return a boolean (true/false). The OTP expires 15 minutes after sending it.
Want to resend an OTP? Use client.otp.resend()
:
OTP expiry does not renew.
Verify formatting
Contiguity provides two functions that verify phone number and email formatting, which are:
and
They return a boolean (true/false).
This occurs locally, and is not part of Contiguity’s online verification service.
Email analytics
If you sent an HTML email, and chose Contiguity to track it, you can fetch an email’s status (delivered/read) using:
Quota
If you’d like to retrieve your quota, whether you’re on our free tier or Unlimited, you can fetch it using:
You’ll receive an object similar to the crumbs
the API provides on completion of every request.
Roadmap 🚦
- Contiguity Identity will be supported
- Adding support for calls
- Adding support for webhooks
- Adding support for online templates
- and way more.