Skip to main content

Official Python SDK for FitSMS.lk Gateway

Project description

FitSMS Python SDK (v4)

The official Python SDK for the FitSMS.lk gateway, maintained by Global Cloud Media. This package provides a seamless way to integrate SMS capabilities into Python applications, automation scripts, and AI agents using the FitSMS v4 API.


🚀 Features

  • Auto-Formatting: Converts Sri Lankan numbers into 947XXXXXXXX format.
  • v4 Support: Fully compatible with FitSMS v4 REST API.
  • Requests Powered: Uses the industry-standard requests library.
  • DevOps Ready: Lightweight and ideal for VPS alerts, cron jobs, and monitoring systems.

📦 Installation

pip install fitsms

⚡ Quick Start

1. Initialize the Client

from fitsms import FitSMS

api_token = 'YOUR_V4_API_TOKEN'
sender_id = 'YOUR_SENDER_ID'

sms = FitSMS(api_token, sender_id)

2. Send an SMS

try:
    response = sms.send('0761234567', 'Hello from Global Cloud Media!')

    if response.get('status') == 'success':
        print(f"Message Sent! RUID: {response['data']['ruid']}")
    else:
        print(f"Failed: {response.get('message')}")

except Exception as e:
    print(f"Error: {str(e)}")

3. Check Account Balance

balance = sms.get_balance()
print(f"Remaining Units: {balance['data']['sms_unit']}")

📖 API Reference

Method Parameters Description
send() recipient(s), message Send SMS (Single/Bulk)
get_balance() none Get SMS unit balance
get_status() ruid, recipient Check delivery status
get_profile() none Get account details

⚙️ Advanced Usage

Manual Status Reconciliation

import time

time.sleep(10)

status = sms.get_status(
    'fe424939fc3c4b6dbcc876994517d712',
    '0761234567'
)

print(status)

🇱🇰 Sri Lankan Number Formatting

The SDK automatically formats numbers:

0761234567   → 94761234567
761234567    → 94761234567
+94761234567 → 94761234567

🔔 Webhook Integration (Recommended)

FitSMS v4 uses webhooks for real-time delivery updates.

Sample Webhook Payload

{
    "status": "success",
    "data": {
        "to": "94770000000",
        "from": "MyBrand",
        "message": "Test",
        "ruid": "fe424939fc3c4b6dbcc876994517d712",
        "received_at": "2026-03-28T23:24:22+05:30"
    }
}

Example Flask Webhook

from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/sms-webhook', methods=['POST'])
def sms_webhook():
    data = request.json

    print("SMS Status Update:", data)

    # Example DB update
    # update_message_status(data['data']['ruid'], data['data']['status'])

    return jsonify({'status': 'ok'})

🛡 Best Practices

  • Use environment variables:
import os
api_token = os.getenv('FITSMS_API_TOKEN')
  • Store and index ruid in your database
  • Log all API responses
  • Prefer webhooks over polling

📄 License

This project is licensed under the MIT License.


🤝 Contributing

Contributions, issues, and feature requests are welcome!


👨‍💻 Maintainer

Maintained by Global Cloud Media (pvt) Ltd.

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

fitsms-1.0.2.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

fitsms-1.0.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file fitsms-1.0.2.tar.gz.

File metadata

  • Download URL: fitsms-1.0.2.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for fitsms-1.0.2.tar.gz
Algorithm Hash digest
SHA256 a6f1977edc24ec394d63cbeff266cedd86a9048550eb30488efb397c68be2255
MD5 ae8096137696d9e498d5faf531300658
BLAKE2b-256 f39d7f59e9fa85abc34cc1410fc9f5a6c2d837aaf83cc3e48bbe251dedfc3997

See more details on using hashes here.

File details

Details for the file fitsms-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: fitsms-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for fitsms-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bb27ca8aec6915c9eaeb879d45baa3f7a7feffc412f182738ba0b2b461d3da39
MD5 9106a4d937adff60d431b775933e78c7
BLAKE2b-256 d552fcce43c00188ad8a1f6c5f46b5e38569f30d7e4608750bd969209dd4bab5

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