Skip to main content

The `termii_sdk` is a Python package that facilitates seamless integration with the Termii API, empowering developers to send SMS, voice, and email messages within their applications.

Project description

Termii SDK Documentation

Welcome to the Termii SDK documentation! This SDK provides a Python interface for integrating with the Termii API, allowing you to send SMS, voice, and email messages easily within your applications.

Table of Contents

  1. Installation
  2. Quick Start
  3. Authentication
  4. Events and Report
  5. Campaigns
  6. Contacts
  7. Messaging
  8. Number
  9. Phonebook
  10. SenderID
  11. Templates
  12. Token
  13. Contributing
  14. License

Installation

You can install the termii_sdk using pip:

pip install termii_sdk

Quick Start

from termii_sdk import TermiiSDK
from termii_sdk.core import Request

# Default sdk termii_enpoint
# TERMII_ENDPOINT = "https://api.ng.termii.com/api"

Request.termii_endpoint = 'your termii endpoint'

# Initialize the SDK with your API key
api_key = "your_api_key_here"
termii = TermiiSDK(api_key)

# Send an SMS message
message = "Hello from Termii SDK!"
phone_number = "+1234567890"
response = termii.send_message(to=phone_number, sms=message)
print("Message ID:", response.get("message_id"))

Authentication

To use the Termii SDK, you need to provide your Termii API key when initializing the SDK. You can obtain your API key from your Termii account dashboard.

from termii_sdk import *

api_key = "your_api_key_here"
termii = TermiiSDK(api_key)

Events and Report

response: Union[Error, BalanceResponse] = termii.balance()

response: Union[Error, SearchResponse] = termii.search()

response: Union[Error, StatusResponse] = termii.status()

response: Union[Error, HistoryResponse] = termii.history()

Campaigns

response: Union[Error, Response] = termii.send_campaign(
        country_code: str,
        sender_id: str,
        message: str,
        channel: Channel,
        message_type: MessageType,
        phonebook_id: str,
        delimiter: str,
        remove_duplicate: str,
        campaign_type: str,
        schedule_time: str = "",
        schedule_sms_status: str = "",
    )

response: Union[Error, FetchCampaignsResponse] = termii.fetch_campaigns()

response: Union[Error, FetchCampaignsHistoryResponse] = termii.fetch_campaign_history(campaign_id: str)

Contacts

response: Union[Error, FetchPhonebooksResponse]: = termii.fetch_contacts(phonebook_id: str)

response: Union[Error, AddContactResponse]: = termii.add_contact(
        phonebook_id: str,
        phone_number: str,
        email_address: str,
        first_name: str,
        last_name: str,
        company: str,
        country_code: str,
    )

response: Union[Error, Response]: = termii.add_contacts(
        phonebook_id: str,
        contact_file: str,
        country_code: str,
    )

response: Union[Error, Response]: = termii.delete_contact_phonebook(contact_id: str)

Messaging

response: Union[Error, BasicResponse]: = termii.send_message(
        to: str,
        from_: str,
        channel: Channel = Channel.GENERIC,
        sms: str = "",
        type: MediaType = MediaType.PLAIN,
        media_url: str = "",
        media_caption: str = "",
    )

response: Union[Error, BasicResponse]: = termii.send_bulk_message(
        to: list[str],
        from_: str,
        channel: Channel = Channel.GENERIC,
        sms: str = "",
    )

Number

response: Union[Error, BasicResponse]: = termii.send_message_number(
        to: str,
        sms: str = "",
    )

Phonebook

response: Union[Error, FetchPhonebooksResponse]: = termii.fetch_phonebooks()

response: Union[Error, Response]: = termii.create_phonebook(
        phonebook_name: str,
        description: str,
    )

response: Union[Error, Response]: = termii.update_phonebook(
        phonebook_id: str,
        phonebook_name: str,
        description: str,
    )

response: Union[Error, Response]: = termii.delete_phonebook(phonebook_id: str)

SenderID

response: Union[Error, FetchSenderIDResponse]: = termii.fetch_id()

response: Union[Error, Response]: = termii.request_id(
        sender_id: str,
        usecase: str,
        company: str,
    )

Templates

response: Union[Error, BasicResponse]: = termii.device_template(
        phone_number: str,
        device_id: str,
        template_id: str,
        data: dict = None,
    )

Token

response: Union[Error, SendTokenResponse]: = termii.send_token(
        message_type: MessageType,
        to: str,
        from_: str,
        channel: Channel,
        pin_attempts: int,
        pin_time_to_live: int,
        pin_length: int,
        pin_placeholder: str,
        message_text: str,
        pin_type: MessageType,
    )

response: Union[Error, VoiceTokenResponse]: = termii.voice_token(
        phone_number: str,
        pin_attempts: str,
        pin_time_to_live: str,
        pin_length: str,
    )

response: Union[Error, VoiceCallResponse]: = termii.voice_call(
        phone_number: str,
        code: int,
    )

response: Union[Error, InAppTokenResponse]: = termii.in_app_token(
        phone_number: str,
        pin_type: MessageType,
        pin_attempts: int,
        pin_time_to_live: int,
        pin_length: int,
    )

response: Union[Error, VerifyTokenResponse]: = termii.verify_token(
        pin_id: str,
        pin: str,
    )

response: Union[Error, EmailTokenResponse]: = termii.email_token(
        email_address: str,
        code: str,
        email_configuration_id: str,
    )

Contributing

Contributions are welcome! If you find a bug or want to add a new feature, please submit a pull request.

License

This SDK is released under the MIT License.


Feel free to customize this documentation according to your SDK's features and your personal writing style. Make sure to update the content with accurate details and examples specific to the functions and methods your SDK provides.

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

termii_sdk-1.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

termii_sdk-1.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file termii_sdk-1.0.tar.gz.

File metadata

  • Download URL: termii_sdk-1.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for termii_sdk-1.0.tar.gz
Algorithm Hash digest
SHA256 2f3133de87e078848335f47aa5ba01736c82c829b21729f485d3b5c5a1ec509f
MD5 660b3cbe63a6b3746d3f10b646afdf97
BLAKE2b-256 aae26ab377a14b7b0196d634958651e3785df4a0bbb04fc35b71142b7ecf869a

See more details on using hashes here.

File details

Details for the file termii_sdk-1.0-py3-none-any.whl.

File metadata

  • Download URL: termii_sdk-1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for termii_sdk-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cabac7518b10afb59ddbdb728b29bce2982e44147b97ade7bfb8bbbd61b7c006
MD5 a318bc57d65340d9dd9ff2b6d21611f6
BLAKE2b-256 66cc6b5e726ab9e345081e3d2866c8e562488d9c36a40c1d7e6b8de3cba0761e

See more details on using hashes here.

Supported by

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