Skip to main content

Contiguity's official Python SDK

Project description

@contiguity/python

Contiguity's official Python SDK.

Installation 🏗 & Setup 🛠

You can install the SDK using pip

pip install contiguity

Then, import & initialize it like this:

import contiguity
client = contiguity.login("your_token_here")

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.

email_object = {
    "to": "example@example.com",
    "from": "Contiguity",
    "subject": "My first email!",
    "html": "<b>I sent an email using Contiguity</b>"
}

client.send.email(email_object)

To send an email with a text body, it's very similar. Just switch "html" to "text".

email_object = {
    "to": "example@example.com",
    "from": "Contiguity",
    "subject": "My first email!",
    "text": "I sent an email using Contiguity"
}

client.send.email(email_object)

Optional fields

  • replyTo allows you 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):

template = client.template.local('templates/first_email.html')

email_object = {
    "to": "example@example.com",
    "from": "Contiguity",
    "subject": "My first email!",
    "html": template,
}

client.send.email(email_object)

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.

text_object = {
    "to": "+15555555555",
    "message": "My first text using Contiguity"
}

client.send.text(text_object)

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!

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:

otp_id = client.otp.send({
    'to': "+15555555555",
    'language': "en",
    'name': "Contiguity"
})

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():

verify = client.otp.verify({
    'otp_id': otp_id # you received this when you called client.otp.send(),
    'otp': input # the 6 digits your user inputted.
})

It will return a boolean (true/false). The OTP expires 15 minutes after sending it.

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

resend = client.otp.resend({
    'otp_id': otp_id # you received this when you called client.otp.send(),
})

OTP expiry does not renew.

Verify formatting

Contiguity provides two functions that verify phone number and email formatting, which are:

client.verify.number("number")

and

client.verify.email("example@example.com")

They return a boolean (true/false)

Note: 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:

client.email_analytics.retrieve("email_id")

Quota

If you'd like to retrieve your quota, whether you're on our free tier or Unlimited, you can fetch it using:

client.quota.retrieve()

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.

See complete examples in examples/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

contiguity-3.0.0.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

contiguity-3.0.0-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file contiguity-3.0.0.tar.gz.

File metadata

  • Download URL: contiguity-3.0.0.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for contiguity-3.0.0.tar.gz
Algorithm Hash digest
SHA256 96276c9198f3cf13d5389086650cb20953573952efafc8b791394c8e5e0b7a76
MD5 2ded6624e685051680feeccd7fc913f4
BLAKE2b-256 846f2ad1184e34eb77ef897954f663c1e0d2e31d06fc066dd781f7902ec9a23b

See more details on using hashes here.

Provenance

The following attestation bundles were made for contiguity-3.0.0.tar.gz:

Publisher: ci.yaml on contiguity/python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file contiguity-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: contiguity-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for contiguity-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c1067652c4ad0e07d545795a60dc06df5fdcbfc3ac074400995ce9bc7a316e33
MD5 66b84bfcef7aee33d66e82a6a93d532a
BLAKE2b-256 58db2674ce284a388b123b92b782dde86d1ae4b2069302d53dd3da2397b9836a

See more details on using hashes here.

Provenance

The following attestation bundles were made for contiguity-3.0.0-py3-none-any.whl:

Publisher: ci.yaml on contiguity/python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page