Skip to main content

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

Metadata

Release files for txtmsg-sdk 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for txtmsg-sdk 1.0.0
File Size Uploaded
txtmsg_sdk-1.0.0.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for txtmsg-sdk 1.0.0
File Interpreter ABI Platform
txtmsg_sdk-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / txtmsg_sdk-1.0.0.tar.gz

Download URL txtmsg_sdk-1.0.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d92b2cfcf2ad59022679355ba717177e3196da028fbf7f74f5ecdb85fca8ed87
BLAKE2b-256 checksum
How to use checksums
c99a8f806221465986d23d96fd169c509364a1c8bf4cf474818a949abad5be20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / txtmsg_sdk-1.0.0-py3-none-any.whl

Download URL txtmsg_sdk-1.0.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
503445c8f26596d5e75d60bf98e001891459d08791812c147bf6543ea387d05d
BLAKE2b-256 checksum
How to use checksums
fa05a2ad2b1dbc7b152d7aef187011dd9cc491942f2aa181c39e2bc93bbdaaa8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page