blacksms 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- blacksms-1.0.0/PKG-INFO +71 -0
- blacksms-1.0.0/README.md +58 -0
- blacksms-1.0.0/blacksms/__init__.py +3 -0
- blacksms-1.0.0/blacksms/client.py +123 -0
- blacksms-1.0.0/blacksms.egg-info/PKG-INFO +71 -0
- blacksms-1.0.0/blacksms.egg-info/SOURCES.txt +9 -0
- blacksms-1.0.0/blacksms.egg-info/dependency_links.txt +1 -0
- blacksms-1.0.0/blacksms.egg-info/requires.txt +1 -0
- blacksms-1.0.0/blacksms.egg-info/top_level.txt +1 -0
- blacksms-1.0.0/pyproject.toml +20 -0
- blacksms-1.0.0/setup.cfg +4 -0
blacksms-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: blacksms
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official Python SDK for BlackSMS API (SMS OTP, WhatsApp OTP, Quick SMS, Bulk SMS)
|
|
5
|
+
Author: BlackSMS
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://blacksms.in
|
|
8
|
+
Project-URL: Documentation, https://docs.blacksms.in
|
|
9
|
+
Keywords: blacksms,sms,otp,whatsapp,bulk-sms,django,fastapi
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: requests>=2.25.0
|
|
13
|
+
|
|
14
|
+
# BlackSMS Python SDK (`blacksms`)
|
|
15
|
+
|
|
16
|
+
Official Python client library for the [BlackSMS API Platform](https://docs.blacksms.in/).
|
|
17
|
+
|
|
18
|
+
Easily send **SMS OTPs**, **WhatsApp OTPs**, **Quick SMS**, and manage **Bulk SMS Campaigns** in Python, Django, FastAPI, and Flask.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install blacksms
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from blacksms import BlackSMS, BlackSMSAPIError
|
|
34
|
+
|
|
35
|
+
# Initialize client with your API key
|
|
36
|
+
client = BlackSMS(api_key="YOUR_BLACKSMS_API_KEY")
|
|
37
|
+
|
|
38
|
+
# 1. Send SMS OTP
|
|
39
|
+
try:
|
|
40
|
+
response = client.send_sms(
|
|
41
|
+
sender_id=1, # Your numeric Sender ID (e.g. 1, 2, 10)
|
|
42
|
+
code="123456", # OTP code
|
|
43
|
+
numbers="9876543210", # Recipient number
|
|
44
|
+
route=1
|
|
45
|
+
)
|
|
46
|
+
print("SMS OTP Sent:", response)
|
|
47
|
+
except BlackSMSAPIError as e:
|
|
48
|
+
print("API Error:", e)
|
|
49
|
+
|
|
50
|
+
# 2. Send WhatsApp OTP
|
|
51
|
+
response = client.send_whatsapp(
|
|
52
|
+
sender_id=1,
|
|
53
|
+
code="123456",
|
|
54
|
+
numbers="9876543210"
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# 3. Send Quick SMS
|
|
58
|
+
response = client.send_quick_sms(
|
|
59
|
+
sender_id=1,
|
|
60
|
+
message="Welcome to BlackSMS!",
|
|
61
|
+
numbers="9876543210"
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# 4. Create Bulk SMS Campaign
|
|
65
|
+
campaign = client.create_bulk_sms_campaign(
|
|
66
|
+
title="Promo Sale",
|
|
67
|
+
message="Check out our special offers!",
|
|
68
|
+
contacts=["9876543210", "9123456789"]
|
|
69
|
+
)
|
|
70
|
+
print("Campaign Created:", campaign)
|
|
71
|
+
```
|
blacksms-1.0.0/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# BlackSMS Python SDK (`blacksms`)
|
|
2
|
+
|
|
3
|
+
Official Python client library for the [BlackSMS API Platform](https://docs.blacksms.in/).
|
|
4
|
+
|
|
5
|
+
Easily send **SMS OTPs**, **WhatsApp OTPs**, **Quick SMS**, and manage **Bulk SMS Campaigns** in Python, Django, FastAPI, and Flask.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install blacksms
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from blacksms import BlackSMS, BlackSMSAPIError
|
|
21
|
+
|
|
22
|
+
# Initialize client with your API key
|
|
23
|
+
client = BlackSMS(api_key="YOUR_BLACKSMS_API_KEY")
|
|
24
|
+
|
|
25
|
+
# 1. Send SMS OTP
|
|
26
|
+
try:
|
|
27
|
+
response = client.send_sms(
|
|
28
|
+
sender_id=1, # Your numeric Sender ID (e.g. 1, 2, 10)
|
|
29
|
+
code="123456", # OTP code
|
|
30
|
+
numbers="9876543210", # Recipient number
|
|
31
|
+
route=1
|
|
32
|
+
)
|
|
33
|
+
print("SMS OTP Sent:", response)
|
|
34
|
+
except BlackSMSAPIError as e:
|
|
35
|
+
print("API Error:", e)
|
|
36
|
+
|
|
37
|
+
# 2. Send WhatsApp OTP
|
|
38
|
+
response = client.send_whatsapp(
|
|
39
|
+
sender_id=1,
|
|
40
|
+
code="123456",
|
|
41
|
+
numbers="9876543210"
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
# 3. Send Quick SMS
|
|
45
|
+
response = client.send_quick_sms(
|
|
46
|
+
sender_id=1,
|
|
47
|
+
message="Welcome to BlackSMS!",
|
|
48
|
+
numbers="9876543210"
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# 4. Create Bulk SMS Campaign
|
|
52
|
+
campaign = client.create_bulk_sms_campaign(
|
|
53
|
+
title="Promo Sale",
|
|
54
|
+
message="Check out our special offers!",
|
|
55
|
+
contacts=["9876543210", "9123456789"]
|
|
56
|
+
)
|
|
57
|
+
print("Campaign Created:", campaign)
|
|
58
|
+
```
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import requests
|
|
3
|
+
from typing import Union, List, Dict, Any, Optional
|
|
4
|
+
|
|
5
|
+
class BlackSMSError(Exception):
|
|
6
|
+
"""Base exception for BlackSMS SDK."""
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
class BlackSMSAPIError(BlackSMSError):
|
|
10
|
+
"""Exception raised when API returns an error response."""
|
|
11
|
+
def __init__(self, message: str, status_code: Optional[int] = None, response: Optional[Dict[str, Any]] = None):
|
|
12
|
+
super().__init__(message)
|
|
13
|
+
self.status_code = status_code
|
|
14
|
+
self.response = response
|
|
15
|
+
|
|
16
|
+
class BlackSMS:
|
|
17
|
+
"""Official Python Client for BlackSMS API."""
|
|
18
|
+
def __init__(self, api_key: str, base_url: str = "https://blacksms.in", timeout: int = 15):
|
|
19
|
+
if not api_key:
|
|
20
|
+
raise BlackSMSError("BlackSMS api_key cannot be empty.")
|
|
21
|
+
self.api_key = api_key.strip()
|
|
22
|
+
self.base_url = base_url.rstrip("/")
|
|
23
|
+
self.timeout = timeout
|
|
24
|
+
|
|
25
|
+
def _post(self, path: str, payload: Dict[str, Any]) -> Dict[str, Any]:
|
|
26
|
+
url = f"{self.base_url}/{path.lstrip('/')}"
|
|
27
|
+
headers = {
|
|
28
|
+
"Authorization": self.api_key,
|
|
29
|
+
"Content-Type": "application/json",
|
|
30
|
+
"Accept": "application/json"
|
|
31
|
+
}
|
|
32
|
+
try:
|
|
33
|
+
res = requests.post(url, headers=headers, json=payload, timeout=self.timeout)
|
|
34
|
+
try:
|
|
35
|
+
data = res.json()
|
|
36
|
+
except ValueError:
|
|
37
|
+
data = {"raw": res.text}
|
|
38
|
+
|
|
39
|
+
if not res.ok:
|
|
40
|
+
msg = data.get("message", f"HTTP status {res.status_code}")
|
|
41
|
+
raise BlackSMSAPIError(msg, status_code=res.status_code, response=data)
|
|
42
|
+
|
|
43
|
+
if isinstance(data, dict):
|
|
44
|
+
if data.get("status") == 0 or data.get("success") is False:
|
|
45
|
+
msg = data.get("message", "API Request Failed")
|
|
46
|
+
raise BlackSMSAPIError(msg, status_code=res.status_code, response=data)
|
|
47
|
+
|
|
48
|
+
return data
|
|
49
|
+
except requests.RequestException as e:
|
|
50
|
+
raise BlackSMSError(f"Network error: {str(e)}")
|
|
51
|
+
|
|
52
|
+
def send_sms(
|
|
53
|
+
self,
|
|
54
|
+
numbers: Union[str, List[str]],
|
|
55
|
+
code: Optional[str] = None,
|
|
56
|
+
variables_values: Optional[str] = None,
|
|
57
|
+
sender_id: Optional[Union[str, int]] = None,
|
|
58
|
+
route: int = 1
|
|
59
|
+
) -> Dict[str, Any]:
|
|
60
|
+
"""Send SMS OTP."""
|
|
61
|
+
num_str = ",".join(numbers) if isinstance(numbers, list) else str(numbers)
|
|
62
|
+
val = variables_values or code or ""
|
|
63
|
+
payload = {
|
|
64
|
+
"numbers": num_str,
|
|
65
|
+
"variables_values": val,
|
|
66
|
+
"route": route
|
|
67
|
+
}
|
|
68
|
+
if sender_id:
|
|
69
|
+
payload["sender_id"] = sender_id
|
|
70
|
+
return self._post("/sms", payload)
|
|
71
|
+
|
|
72
|
+
def send_whatsapp(
|
|
73
|
+
self,
|
|
74
|
+
numbers: Union[str, List[str]],
|
|
75
|
+
code: Optional[str] = None,
|
|
76
|
+
variables_values: Optional[str] = None,
|
|
77
|
+
sender_id: Optional[str] = None,
|
|
78
|
+
route: int = 1
|
|
79
|
+
) -> Dict[str, Any]:
|
|
80
|
+
"""Send WhatsApp OTP."""
|
|
81
|
+
num_str = ",".join(numbers) if isinstance(numbers, list) else str(numbers)
|
|
82
|
+
val = variables_values or code or ""
|
|
83
|
+
payload = {
|
|
84
|
+
"numbers": num_str,
|
|
85
|
+
"variables_values": val,
|
|
86
|
+
"route": route
|
|
87
|
+
}
|
|
88
|
+
if sender_id:
|
|
89
|
+
payload["sender_id"] = sender_id
|
|
90
|
+
return self._post("/wasms", payload)
|
|
91
|
+
|
|
92
|
+
def send_quick_sms(
|
|
93
|
+
self,
|
|
94
|
+
numbers: Union[str, List[str]],
|
|
95
|
+
message: str,
|
|
96
|
+
sender_id: Optional[str] = None,
|
|
97
|
+
route: Optional[int] = None
|
|
98
|
+
) -> Dict[str, Any]:
|
|
99
|
+
"""Send Quick SMS."""
|
|
100
|
+
num_str = ",".join(numbers) if isinstance(numbers, list) else str(numbers)
|
|
101
|
+
payload = {
|
|
102
|
+
"numbers": num_str,
|
|
103
|
+
"message": message
|
|
104
|
+
}
|
|
105
|
+
if sender_id:
|
|
106
|
+
payload["sender_id"] = sender_id
|
|
107
|
+
if route is not None:
|
|
108
|
+
payload["route"] = route
|
|
109
|
+
return self._post("/quick-sms", payload)
|
|
110
|
+
|
|
111
|
+
def create_bulk_sms_campaign(
|
|
112
|
+
self,
|
|
113
|
+
title: str,
|
|
114
|
+
message: str,
|
|
115
|
+
contacts: List[str]
|
|
116
|
+
) -> Dict[str, Any]:
|
|
117
|
+
"""Create Bulk SMS Campaign."""
|
|
118
|
+
payload = {
|
|
119
|
+
"title": title,
|
|
120
|
+
"message": message,
|
|
121
|
+
"contacts": contacts if isinstance(contacts, list) else [contacts]
|
|
122
|
+
}
|
|
123
|
+
return self._post("/endpoints/v1/bulk-sms", payload)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: blacksms
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official Python SDK for BlackSMS API (SMS OTP, WhatsApp OTP, Quick SMS, Bulk SMS)
|
|
5
|
+
Author: BlackSMS
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://blacksms.in
|
|
8
|
+
Project-URL: Documentation, https://docs.blacksms.in
|
|
9
|
+
Keywords: blacksms,sms,otp,whatsapp,bulk-sms,django,fastapi
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: requests>=2.25.0
|
|
13
|
+
|
|
14
|
+
# BlackSMS Python SDK (`blacksms`)
|
|
15
|
+
|
|
16
|
+
Official Python client library for the [BlackSMS API Platform](https://docs.blacksms.in/).
|
|
17
|
+
|
|
18
|
+
Easily send **SMS OTPs**, **WhatsApp OTPs**, **Quick SMS**, and manage **Bulk SMS Campaigns** in Python, Django, FastAPI, and Flask.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install blacksms
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from blacksms import BlackSMS, BlackSMSAPIError
|
|
34
|
+
|
|
35
|
+
# Initialize client with your API key
|
|
36
|
+
client = BlackSMS(api_key="YOUR_BLACKSMS_API_KEY")
|
|
37
|
+
|
|
38
|
+
# 1. Send SMS OTP
|
|
39
|
+
try:
|
|
40
|
+
response = client.send_sms(
|
|
41
|
+
sender_id=1, # Your numeric Sender ID (e.g. 1, 2, 10)
|
|
42
|
+
code="123456", # OTP code
|
|
43
|
+
numbers="9876543210", # Recipient number
|
|
44
|
+
route=1
|
|
45
|
+
)
|
|
46
|
+
print("SMS OTP Sent:", response)
|
|
47
|
+
except BlackSMSAPIError as e:
|
|
48
|
+
print("API Error:", e)
|
|
49
|
+
|
|
50
|
+
# 2. Send WhatsApp OTP
|
|
51
|
+
response = client.send_whatsapp(
|
|
52
|
+
sender_id=1,
|
|
53
|
+
code="123456",
|
|
54
|
+
numbers="9876543210"
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# 3. Send Quick SMS
|
|
58
|
+
response = client.send_quick_sms(
|
|
59
|
+
sender_id=1,
|
|
60
|
+
message="Welcome to BlackSMS!",
|
|
61
|
+
numbers="9876543210"
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# 4. Create Bulk SMS Campaign
|
|
65
|
+
campaign = client.create_bulk_sms_campaign(
|
|
66
|
+
title="Promo Sale",
|
|
67
|
+
message="Check out our special offers!",
|
|
68
|
+
contacts=["9876543210", "9123456789"]
|
|
69
|
+
)
|
|
70
|
+
print("Campaign Created:", campaign)
|
|
71
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests>=2.25.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
blacksms
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "blacksms"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Official Python SDK for BlackSMS API (SMS OTP, WhatsApp OTP, Quick SMS, Bulk SMS)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [{ name = "BlackSMS" }]
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
requires-python = ">=3.8"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"requests>=2.25.0"
|
|
15
|
+
]
|
|
16
|
+
keywords = ["blacksms", "sms", "otp", "whatsapp", "bulk-sms", "django", "fastapi"]
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Homepage = "https://blacksms.in"
|
|
20
|
+
Documentation = "https://docs.blacksms.in"
|
blacksms-1.0.0/setup.cfg
ADDED