{"id":21380898,"url":"https://github.com/android-sms-gateway/client-py","last_synced_at":"2025-07-13T13:30:56.909Z","repository":{"id":221631448,"uuid":"754579602","full_name":"android-sms-gateway/client-py","owner":"android-sms-gateway","description":"A Python client library for sending and managing SMS messages via the SMS Gateway for Android™ API","archived":false,"fork":false,"pushed_at":"2024-11-15T13:25:29.000Z","size":93,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-15T14:25:57.124Z","etag":null,"topics":["android-sms","api-client","communication","http-client","messaging","python","python-library","python-sdk","rest-api","sms","sms-api","sms-gateway"],"latest_commit_sha":null,"homepage":"https://sms-gate.app","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/android-sms-gateway.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-08T11:02:45.000Z","updated_at":"2024-11-15T13:21:21.000Z","dependencies_parsed_at":"2024-06-18T04:44:15.255Z","dependency_job_id":"20a71020-a083-4480-b3cd-1c89285ee348","html_url":"https://github.com/android-sms-gateway/client-py","commit_stats":null,"previous_names":["capcom6/android-sms-gateway-py"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/android-sms-gateway%2Fclient-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/android-sms-gateway%2Fclient-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/android-sms-gateway%2Fclient-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/android-sms-gateway%2Fclient-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/android-sms-gateway","download_url":"https://codeload.github.com/android-sms-gateway/client-py/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225885790,"owners_count":17539640,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-sms","api-client","communication","http-client","messaging","python","python-library","python-sdk","rest-api","sms","sms-api","sms-gateway"],"created_at":"2024-11-22T10:43:18.672Z","updated_at":"2025-07-13T13:30:56.897Z","avatar_url":"https://github.com/android-sms-gateway.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📱 SMS Gateway for Android™ Python API Client\n\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=for-the-badge)](https://github.com/android-sms-gateway/client-py/blob/master/LICENSE)\n[![PyPI Version](https://img.shields.io/pypi/v/android-sms-gateway.svg?style=for-the-badge)](https://pypi.org/project/android-sms-gateway/)\n[![Python Version](https://img.shields.io/pypi/pyversions/android-sms-gateway.svg?style=for-the-badge)](https://pypi.org/project/android-sms-gateway/)\n[![Downloads](https://img.shields.io/pypi/dm/android-sms-gateway.svg?style=for-the-badge)](https://pypi.org/project/android-sms-gateway/)\n[![GitHub Issues](https://img.shields.io/github/issues/capcom6/android-sms-gateway-py.svg?style=for-the-badge)](https://github.com/android-sms-gateway/client-py/issues)\n[![GitHub Stars](https://img.shields.io/github/stars/capcom6/android-sms-gateway-py.svg?style=for-the-badge)](https://github.com/android-sms-gateway/client-py/stargazers)\n[![GitHub Forks](https://img.shields.io/github/forks/capcom6/android-sms-gateway-py.svg?style=for-the-badge)](https://github.com/android-sms-gateway/client-py/network)\n\nA modern Python client for seamless integration with the [SMS Gateway for Android](https://sms-gate.app) API. Send SMS messages programmatically through your Android devices with this powerful yet simple-to-use library.\n\n## 📖 Table of Contents\n- [📱 SMS Gateway for Android™ Python API Client](#-sms-gateway-for-android-python-api-client)\n  - [📖 Table of Contents](#-table-of-contents)\n  - [✨ Features](#-features)\n  - [⚙️ Requirements](#️-requirements)\n  - [📦 Installation](#-installation)\n  - [🚀 Quickstart](#-quickstart)\n    - [Basic Usage](#basic-usage)\n  - [🤖 Client Guide](#-client-guide)\n    - [Client Configuration](#client-configuration)\n    - [Core Methods](#core-methods)\n    - [Type Definitions](#type-definitions)\n    - [Encryption Setup](#encryption-setup)\n  - [🌐 HTTP Clients](#-http-clients)\n  - [🔒 Security Notes](#-security-notes)\n  - [📚 API Reference](#-api-reference)\n  - [👥 Contributing](#-contributing)\n    - [Development Setup](#development-setup)\n  - [📄 License](#-license)\n\n## ✨ Features\n- **Dual Client Support**: Choose between synchronous (`APIClient`) and asynchronous (`AsyncAPIClient`) interfaces\n- **End-to-End Encryption**: Optional message encryption using AES-CBC-256\n- **Multiple HTTP Backends**: Supports `requests`, `aiohttp`, and `httpx`\n- **Webhook Management**: Create, read, and delete webhooks\n- **Customizable Base URL**: Point to different API endpoints\n- **Type Hinting**: Fully typed for better development experience\n\n## ⚙️ Requirements\n- Python 3.9+\n- Choose one HTTP client:\n  - 🚀 [requests](https://pypi.org/project/requests/) (sync)\n  - ⚡ [aiohttp](https://pypi.org/project/aiohttp/) (async)\n  - 🌈 [httpx](https://pypi.org/project/httpx/) (sync+async)\n\n**Optional**:\n- 🔒 [pycryptodome](https://pypi.org/project/pycryptodome/) - For end-to-end encryption support\n\n## 📦 Installation\n\nInstall the base package:\n```bash\npip install android_sms_gateway\n```\n\nInstall with your preferred HTTP client:\n```bash\n# Choose one:\npip install android_sms_gateway[requests]\npip install android_sms_gateway[aiohttp]\npip install android_sms_gateway[httpx]\n```\n\nFor encrypted messaging:\n```bash\npip install android_sms_gateway[encryption]\n```\n\n## 🚀 Quickstart\n\n### Basic Usage\n```python\nimport asyncio\nimport os\n\nfrom android_sms_gateway import client, domain, Encryptor\n\nlogin = os.getenv(\"ANDROID_SMS_GATEWAY_LOGIN\")\npassword = os.getenv(\"ANDROID_SMS_GATEWAY_PASSWORD\")\n# for end-to-end encryption, see https://docs.sms-gate.app/privacy/encryption/\n# encryptor = Encryptor('passphrase')\n\nmessage = domain.Message(\n    \"Your message text here.\",\n    [\"+1234567890\"],\n)\n\ndef sync_client():\n    with client.APIClient(\n        login, \n        password,\n        # encryptor=encryptor,\n    ) as c:\n        state = c.send(message)\n        print(state)\n\n        state = c.get_state(state.id)\n        print(state)\n\n\nasync def async_client():\n    async with client.AsyncAPIClient(\n        login, \n        password,\n        # encryptor=encryptor,\n    ) as c:\n        state = await c.send(message)\n        print(state)\n\n        state = await c.get_state(state.id)\n        print(state)\n\nprint(\"Sync client\")\nsync_client()\n\nprint(\"\\nAsync client\")\nasyncio.run(async_client())\n```\n\n## 🤖 Client Guide\n\nThere are two client classes: `APIClient` and `AsyncAPIClient`. The\n`APIClient` is synchronous and the `AsyncAPIClient` is asynchronous. Both\nimplement the same interface and can be used as context managers.\n\n### Client Configuration\n\nBoth clients support the following initialization parameters:\n\n| Argument    | Description        | Default                                  |\n| ----------- | ------------------ | ---------------------------------------- |\n| `login`     | Username           | **Required**                             |\n| `password`  | Password           | **Required**                             |\n| `base_url`  | API base URL       | `\"https://api.sms-gate.app/3rdparty/v1\"` |\n| `encryptor` | Encryptor instance | `None`                                   |\n| `http`      | Custom HTTP client | Auto-detected                            |\n\n### Core Methods\n\n| Method                                          | Description          | Returns                |\n| ----------------------------------------------- | -------------------- | ---------------------- |\n| `send(self, message: domain.Message)`           | Send a message       | `domain.MessageState`  |\n| `get_state(self, _id: str)`                     | Get message state    | `domain.MessageState`  |\n| `create_webhook(self, webhook: domain.Webhook)` | Create a new webhook | `domain.Webhook`       |\n| `get_webhooks(self)`                            | Get all webhooks     | `List[domain.Webhook]` |\n| `delete_webhook(self, _id: str)`                | Delete a webhook     | `None`                 |\n\n\n### Type Definitions\n\n```python\nclass Message:\n    message: str\n    phone_numbers: t.List[str]\n    with_delivery_report: bool = True\n    is_encrypted: bool = False\n\n    id: t.Optional[str] = None\n    ttl: t.Optional[int] = None\n    sim_number: t.Optional[int] = None\n\n\nclass MessageState:\n    id: str\n    state: ProcessState\n    recipients: t.List[RecipientState]\n    is_hashed: bool\n    is_encrypted: bool\n\n\nclass Webhook:\n    id: t.Optional[str]\n    url: str\n    event: WebhookEvent\n```\n\nFor more details, see the [`domain.py`](./android_sms_gateway/domain.py).\n\n### Encryption Setup\n```python\nfrom android_sms_gateway import client, Encryptor\n\n# Initialize with your secret passphrase\nencryptor = Encryptor(\"my-secret-passphrase\")\n\n# Use in client initialization\nclient.APIClient(login, password, encryptor=encryptor)\n```\n\n## 🌐 HTTP Clients\nThe library automatically detects installed HTTP clients. Here's the priority:\n\n| Client   | Sync | Async |\n| -------- | ---- | ----- |\n| aiohttp  | ❌    | 1️⃣     |\n| requests | 1️⃣    | ❌     |\n| httpx    | 2️⃣    | 2️⃣     |\n\nTo use a specific client:\n```python\n# Force httpx sync client\nclient.APIClient(..., http=http.HttpxHttpClient())\n```\n\nYou can also implement your own HTTP client that conforms to the `http.HttpClient` or `ahttp.HttpClient` protocol.\n\n## 🔒 Security Notes\n\n⚠️ **Important Security Practices**\n- Always store credentials in environment variables\n- Never expose credentials in client-side code\n- Use HTTPS for all production communications\n\n## 📚 API Reference\nFor complete API documentation including all available methods, request/response schemas, and error codes, visit:\n[📘 Official API Documentation](https://docs.sms-gate.app/integration/api/)\n\n## 👥 Contributing\nWe welcome contributions! Here's how to help:\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n### Development Setup\n```bash\ngit clone https://github.com/android-sms-gateway/client-py.git\ncd client-py\npipenv install --dev --categories encryption,requests\npipenv shell\n```\n\n## 📄 License\nDistributed under the Apache 2.0 License. See [LICENSE](LICENSE) for more information.\n\n---\n\n**Note**: Android is a trademark of Google LLC. This project is not affiliated with or endorsed by Google.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandroid-sms-gateway%2Fclient-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandroid-sms-gateway%2Fclient-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandroid-sms-gateway%2Fclient-py/lists"}