SGC Python SDK
Python client for the SGC (SMS Gateway Center) API. Send SMS, manage account, sender IDs, schedules, contacts, groups, and more. Works with Unify SMS Gateway Center.
Requirements: Python 3.7+, requests>=2.28.0
Prerequisites: Get Your API Credentials
You must have a registered account and API credentials from Unify SMS Gateway Center before using this SDK.
- Register or log in at https://unify.smsgateway.center.
- After login, get your API credentials from your account/settings (username, password, and API key).
- Create or use an existing Sender ID for sending SMS (required for the send API).
Without valid credentials from Unify, all API calls will return authentication errors (e.g. invalid credentials).
Installation
From PyPI
pip install sgc-python-sdk
From GitHub
pip install git+https://github.com/smsgatewaycenter/sgc_python_sdk.git
Local / development
cd /path/to/parent-of-sgc_python_sdk
pip install -r sgc_python_sdk/requirements.txt
To use the package from your code, set PYTHONPATH to the parent directory of sgc_python_sdk:
export PYTHONPATH=/path/to/parent-of-sgc_python_sdk
python -c "from sgc_python_sdk import sgc_auth, sgc_account; print('OK')"
Configuration
Set these environment variables with your Unify credentials:
| Variable | Required | Description |
|---|---|---|
SGC_API_BASE |
No | API base URL. Default: https://unify.smsgateway.center |
SGC_USER |
Yes | Your Unify username |
SGC_PASS |
Yes | Your Unify password |
SGC_APIKEY |
Yes | Your API key from Unify |
Optional (for sending SMS and debugging):
| Variable | Description |
|---|---|
SGC_SMS_PHONE |
Recipient number for the test script (e.g. 919876543210) |
SGC_SMS_SENDER |
Your Sender ID for the test script (e.g. SMSGAT) |
SGC_SMS_TEXT |
Message text (default: Test from SGC Python SDK) |
SGC_SMS_TEST |
Set to true for test mode (no real delivery when supported) |
SGC_DEBUG |
Set to 1 to print full request URL and parameters (sensitive values masked) |
SGC_USE_INDEX_PHP |
Set to 1 if Send SMS returns 404 (uses index.php?url=... style URL) |
How to Test
After installing and setting your credentials, run the included test script to verify account, profile, sender IDs, schedule, and (optionally) send SMS.
-
Set your Unify credentials and API base:
export SGC_API_BASE="https://unify.smsgateway.center" export SGC_USER="your_unify_username" export SGC_PASS="your_unify_password" export SGC_APIKEY="your_api_key_from_unify"
-
Run the test script:
- If you installed via pip (PyPI or GitHub):
python -m sgc_python_sdk.test_sdk
Or from the repo root:python sgc_python_sdk/test_sdk.py - If using locally with PYTHONPATH:
export PYTHONPATH=/path/to/parent-of-sgc_python_sdk python sgc_python_sdk/test_sdk.py
- If you installed via pip (PyPI or GitHub):
-
What the test does:
- 1) Account ReadAccountStatus – checks your account status.
- 2) Account ReadProfile – fetches your profile.
- 3) SenderId Read – lists your sender IDs.
- 4) Schedule Read – lists scheduled messages.
- 5) Send SMS (batch) – only runs if you set
SGC_SMS_PHONEandSGC_SMS_SENDER(see below).
-
To test sending an SMS, set the recipient and a valid Sender ID from your account:
export SGC_SMS_PHONE="919876543210" export SGC_SMS_SENDER="YourSenderId" python sgc_python_sdk/test_sdk.py
Use
SGC_SMS_TEST=truefor test mode (no real delivery when the API supports it). UseSGC_DEBUG=1to see the full request URL and parameters.
If you see invalid credentials (216), double-check your username, password, and API key from Unify SMS Gateway Center.
Quick Start: Use in Your Code
from sgc_python_sdk import sgc_auth, sgc_user, sgc_account, sgc_senderid, sgc_sms, sgc_sms_send
# Use your Unify credentials
auth = sgc_auth()
auth.setUsername("your_unify_username")
auth.setPassword("your_unify_password")
auth.setApiKey("your_api_key_from_unify")
# Account status
user = sgc_user("json")
acc = sgc_account(auth, user)
print(acc.ReadAccountStatus())
# Send SMS (batch)
sms = sgc_sms("json")
sms.setSenderId("YourSenderId") # Must exist in your Unify account
sms.setText("Hello from SDK")
sms.setPhone("919876543210")
sms.setMsgType("text")
sms.setTestMessage("false") # "true" for test mode
sms.setDuplicateCheck("true")
sender = sgc_sms_send(auth, sms)
print(sender.batch())
You can also use environment variables and leave credentials out of code:
import os
from sgc_python_sdk import sgc_auth, sgc_user, sgc_account
auth = sgc_auth()
auth.setUsername(os.environ.get("SGC_USER", ""))
auth.setPassword(os.environ.get("SGC_PASS", ""))
auth.setApiKey(os.environ.get("SGC_APIKEY", ""))
user = sgc_user("json")
acc = sgc_account(auth, user)
print(acc.ReadAccountStatus())
API Overview
| Area | Class / module | Main actions |
|---|---|---|
| Account | sgc_account |
ReadAccountStatus, ReadProfile, etc. |
| Sender ID | sgc_senderid |
Read, Create, Update, Delete |
| Schedule | sgc_schedule |
Read, Update, Delete |
| Send SMS | sgc_sms_send |
batch(), phonebook(), file() |
| API Key | sgc_apikey |
Create, Read, Update, Delete |
| Contact | sgc_contact |
CRUD |
| Group | sgc_group |
CRUD |
| Password | sgc_password |
Change |
| Reseller | sgc_reseller_user_api, sgc_credit_management |
User and credit management |
Boolean parameters such as testMessage and duplicateCheck must be "true" or "false"; the SDK normalizes them for you.
Troubleshooting
-
Invalid credentials (216)
Ensure you are using the correct username, password, and API key from https://unify.smsgateway.center. -
Send SMS returns 404
SetSGC_USE_INDEX_PHP=1so the client uses theindex.php?url=...style URL. -
Parameter testMessage / duplicateCheck error (147)
The SDK sends"true"or"false"automatically; ensure you are on a recent SDK version. -
See exact request URL and parameters
SetSGC_DEBUG=1and run your script again; the full URL and body params will be printed (sensitive values masked).
Metadata
Release files for sgc-python-sdk 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sgc_python_sdk-1.0.1.tar.gz | 20.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sgc_python_sdk-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 52.5 kB
Release files / sgc_python_sdk-1.0.1.tar.gz
| Download URL | sgc_python_sdk-1.0.1.tar.gz |
|---|---|
| Size | 20.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d57a79a78cb12053d26bceb36ca86111f4db58e069f6033b6a4c6045e171f234
|
|
BLAKE2b-256 checksum How to use checksums |
49387e7959d90cc8205cb5ad12710497218ad0fefec8247f72d8d37d823dcb59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.1
|
Release files / sgc_python_sdk-1.0.1-py3-none-any.whl
| Download URL | sgc_python_sdk-1.0.1-py3-none-any.whl |
|---|---|
| Size | 32.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ec44ad7e432cebced078762d1884d649de5a93fb2219095c5d1b612878ddb333
|
|
BLAKE2b-256 checksum How to use checksums |
300d889bbd1ad33bac2b3d20ac678a2395d1a1948f8bec313dbe93752a03e791
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.1
|
Security for sgc-python-sdk 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.