Skip to main content

Official Python SDK for TXTMSG.lk SMS Gateway API v3 — Send bulk SMS, transactional SMS, campaigns, and manage contacts from Python

Project description

TXTMSG.lk Python SDK — Python SMS Gateway Integration for Sri Lanka

Official Python SDK for TXTMSG.lk SMS Gateway API v3. Send bulk SMS, transactional SMS, campaigns, and manage contacts from any Python 3.9+ application. The reliable Python SMS client for Sri Lanka's leading SMS gateway.

Features

  • Send SMS — Deliver single or bulk messages to any country via REST API
  • Campaign Management — Send SMS campaigns using contact lists
  • Contact Groups — Create, update, and manage contact groups
  • Contacts — Import and manage individual contacts within groups
  • Schedule Messages — Set future delivery times for your SMS
  • Balance & Profile — Check remaining SMS units and account details
  • DLT Support — Send DLT-compliant messages with template IDs
  • httpx — Modern HTTP client with sync and async support
  • Type Hints — Full type annotations for IDE autocompletion

Requirements

  • Python 3.9+

Installation

pip install txtmsg-sdk

Quick Start

Send an SMS

from txtmsg import TxtmsgClient

client = TxtmsgClient(api_key="your-api-key-here")

response = client.send_sms(
    recipient="94771234567",
    sender_id="TXTMSG",
    message="Hello from TXTMSG.lk!",
)

print(response)

Check Balance

balance = client.view_balance()
print(balance["data"]["remaining_balance"])

Send a Campaign

client.send_campaign(
    contact_list_id="6415907d0d37a",
    sender_id="TXTMSG",
    message="Campaign message",
    schedule_time="2025-12-20 07:00",
)

API Reference

Client

TxtmsgClient(api_key: str, base_url: str | None = None, http_client: httpx.Client | None = None)

SMS Operations

Method Description
send_sms(recipient, sender_id, message, ...) Send SMS via POST
send_campaign(contact_list_id, sender_id, message, ...) Send campaign to contact list(s)
view_sms(uid) View details of a sent SMS
view_all_messages() List all sent messages
view_campaign(uid) View campaign details

Contact Groups

Method Description
view_all_contact_groups() Retrieve all contact groups
create_contact_group(name) Create a new contact group
view_contact_group(group_id) Get group details
update_contact_group(group_id, name) Update a group
delete_contact_group(group_id) Delete a group

Contacts

Method Description
create_contact(group_id, phone, ...) Add a contact to a group
view_contact(group_id, uid) View contact details
update_contact(group_id, uid, ...) Update a contact
delete_contact(group_id, uid) Delete a contact
view_all_contacts_in_group(group_id) List contacts in a group

Account

Method Description
view_balance() Check remaining SMS units
view_profile() View account profile

Error Handling

from txtmsg import TxtmsgClient, TxtmsgError

client = TxtmsgClient(api_key="your-key")

try:
    client.send_sms(recipient="94771234567", sender_id="TXTMSG", message="Hello")
except TxtmsgError as e:
    print(f"API Error [{e.status_code}]: {e}")

About TXTMSG.lk

TXTMSG.lk is a Sri Lankan SMS gateway provider offering reliable bulk SMS services, transactional SMS APIs, and messaging solutions for businesses. The API v3 provides RESTful endpoints for SMS delivery, contact management, and campaign automation with worldwide coverage.

Documentation

Support

License

MIT

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

txtmsg_sdk-1.0.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

txtmsg_sdk-1.0.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file txtmsg_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: txtmsg_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for txtmsg_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d92b2cfcf2ad59022679355ba717177e3196da028fbf7f74f5ecdb85fca8ed87
MD5 312cde66158bdffed3fa25e626e7107e
BLAKE2b-256 c99a8f806221465986d23d96fd169c509364a1c8bf4cf474818a949abad5be20

See more details on using hashes here.

File details

Details for the file txtmsg_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: txtmsg_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for txtmsg_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 503445c8f26596d5e75d60bf98e001891459d08791812c147bf6543ea387d05d
MD5 145bfb4ffaa67f636153077e4f1bbbcf
BLAKE2b-256 fa05a2ad2b1dbc7b152d7aef187011dd9cc491942f2aa181c39e2bc93bbdaaa8

See more details on using hashes here.

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