give-sms 0.1.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.
- give_sms-0.1.0/.gitignore +46 -0
- give_sms-0.1.0/LICENSE +15 -0
- give_sms-0.1.0/PKG-INFO +191 -0
- give_sms-0.1.0/README.md +179 -0
- give_sms-0.1.0/examples/check.py +21 -0
- give_sms-0.1.0/pyproject.toml +42 -0
- give_sms-0.1.0/src/give_sms/__init__.py +12 -0
- give_sms-0.1.0/src/give_sms/client.py +463 -0
- give_sms-0.1.0/src/give_sms/errors.py +20 -0
- give_sms-0.1.0/src/give_sms/types.py +43 -0
- give_sms-0.1.0/tests/test_client.py +149 -0
- give_sms-0.1.0/tests/test_live.py +17 -0
- give_sms-0.1.0/uv.lock +295 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
.pnp.*
|
|
4
|
+
.yarn/
|
|
5
|
+
.pnpm-store/
|
|
6
|
+
|
|
7
|
+
# Build
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
*.tsbuildinfo
|
|
11
|
+
*.egg-info/
|
|
12
|
+
.eggs/
|
|
13
|
+
wheels/
|
|
14
|
+
|
|
15
|
+
# Tests and coverage
|
|
16
|
+
coverage/
|
|
17
|
+
.nyc_output/
|
|
18
|
+
.pytest_cache/
|
|
19
|
+
.mypy_cache/
|
|
20
|
+
.ruff_cache/
|
|
21
|
+
htmlcov/
|
|
22
|
+
.coverage
|
|
23
|
+
.coverage.*
|
|
24
|
+
|
|
25
|
+
# Python
|
|
26
|
+
__pycache__/
|
|
27
|
+
*.py[cod]
|
|
28
|
+
*$py.class
|
|
29
|
+
.venv/
|
|
30
|
+
venv/
|
|
31
|
+
env/
|
|
32
|
+
|
|
33
|
+
# Secrets
|
|
34
|
+
.env
|
|
35
|
+
.env.*
|
|
36
|
+
!.env.example
|
|
37
|
+
AGENTS.md
|
|
38
|
+
|
|
39
|
+
# GitBook / HonKit
|
|
40
|
+
_book/
|
|
41
|
+
|
|
42
|
+
# OS and editors
|
|
43
|
+
.DS_Store
|
|
44
|
+
Thumbs.db
|
|
45
|
+
.idea/
|
|
46
|
+
*.swp
|
give_sms-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 api-kit contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
give_sms-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: give-sms
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python client for the Give-SMS virtual number and SMS activation API
|
|
5
|
+
Project-URL: Repository, https://github.com/TysikGG/api-kit
|
|
6
|
+
Project-URL: Documentation, https://give-sms.com/api.html
|
|
7
|
+
License-Expression: ISC
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Requires-Dist: httpx>=0.27
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# give-sms
|
|
14
|
+
|
|
15
|
+
[](https://pypi.org/project/give-sms/)
|
|
16
|
+
[](LICENSE)
|
|
17
|
+
[](https://pypi.org/project/give-sms/)
|
|
18
|
+
|
|
19
|
+
Modern, fully typed Python client library for the [Give-SMS](https://give-sms.com/api.html) virtual phone numbers and SMS OTP verification service.
|
|
20
|
+
|
|
21
|
+
Official API documentation: <https://give-sms.com/api.html>
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- 📱 **Dual Protocol Support** — Support for both the native JSON REST API (`/api/v1/`) and the SMS-Activate compatible handler protocol (`/stubs/handler_api.php`).
|
|
28
|
+
- 🌍 **Worldwide Numbers** — Rent disposable virtual numbers across multiple countries for Telegram, WhatsApp, Google, and 100+ other services.
|
|
29
|
+
- 🐍 **Modern Pythonic Design** — Type annotations, dataclass models, context manager support (`with GiveSms(...) as client:`), and custom exceptions.
|
|
30
|
+
- 🔄 **Full Activation Lifecycle** — Order numbers, fetch codes, request repeated SMS, cancel, or report dead numbers.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install give-sms
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Requires Python 3.10 or higher.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Quick Start (Safe Check)
|
|
45
|
+
|
|
46
|
+
The quick check only inspects your account balance. It does not order numbers or consume funds.
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import os
|
|
50
|
+
from give_sms import GiveSms
|
|
51
|
+
|
|
52
|
+
with GiveSms(api_key=os.environ["GIVE_SMS_KEY"]) as client:
|
|
53
|
+
balance = client.get_balance()
|
|
54
|
+
print(f"Current balance: ${balance:.2f} USD")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Usage Guide
|
|
60
|
+
|
|
61
|
+
### 1. Renting a Number and Receiving an SMS Code (REST API)
|
|
62
|
+
|
|
63
|
+
Full activation workflow using the `/api/v1/` native JSON API:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
import time
|
|
67
|
+
from give_sms import GiveSms
|
|
68
|
+
|
|
69
|
+
with GiveSms(api_key="your_api_key") as client:
|
|
70
|
+
# 1. Order a number for Telegram in USA
|
|
71
|
+
order = client.get_number(service="tg", country=0)
|
|
72
|
+
print(f"Received number: +{order.number} (Order ID: {order.id})")
|
|
73
|
+
|
|
74
|
+
# 2. Poll for incoming verification code
|
|
75
|
+
code = None
|
|
76
|
+
for _ in range(30):
|
|
77
|
+
time.sleep(3)
|
|
78
|
+
res = client.get_code(order.id)
|
|
79
|
+
if res.status == "SUCCESS" and res.code:
|
|
80
|
+
code = res.code
|
|
81
|
+
break
|
|
82
|
+
|
|
83
|
+
if code:
|
|
84
|
+
print(f"Verification code: {code}")
|
|
85
|
+
else:
|
|
86
|
+
print("Timeout reached. Cancelling number to refund balance...")
|
|
87
|
+
client.cancel_number(order.id)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 2. Querying Available Number Stock & Prices
|
|
91
|
+
|
|
92
|
+
Check available number counts before placing an order:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
counts = client.get_count(service="tg", country=0)
|
|
96
|
+
print("Available numbers:", counts)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 3. Using the SMS-Activate Protocol (`handler_api.php`)
|
|
100
|
+
|
|
101
|
+
If your existing infrastructure is built around `handler_api.php`:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
# 1. Check balance
|
|
105
|
+
balance = client.handler_get_balance()
|
|
106
|
+
print(f"Handler balance: {balance}")
|
|
107
|
+
|
|
108
|
+
# 2. Order number
|
|
109
|
+
activation = client.handler_get_number(service="tg", country=0)
|
|
110
|
+
print(f"Order ID: {activation.id}, Phone: {activation.number}")
|
|
111
|
+
|
|
112
|
+
# 3. Mark ready (status 1)
|
|
113
|
+
client.handler_set_status(activation.id, 1)
|
|
114
|
+
|
|
115
|
+
# 4. Check status
|
|
116
|
+
status = client.handler_get_status(activation.id)
|
|
117
|
+
print(f"Status: {status.status}, Code: {status.code}")
|
|
118
|
+
|
|
119
|
+
# 5. Mark finished (status 6) or cancel (status 8)
|
|
120
|
+
client.handler_set_status(activation.id, 6)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## API Reference
|
|
126
|
+
|
|
127
|
+
### `GiveSms` Class
|
|
128
|
+
|
|
129
|
+
#### Constructor
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
GiveSms(
|
|
133
|
+
api_key: str,
|
|
134
|
+
base_url: str = "https://give-sms.com",
|
|
135
|
+
timeout: float = 30.0,
|
|
136
|
+
)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
| Parameter | Type | Default | Description |
|
|
140
|
+
| :--- | :--- | :--- | :--- |
|
|
141
|
+
| `api_key` | `str` | **Required** | Your Give-SMS API key. |
|
|
142
|
+
| `base_url` | `str` | `"https://give-sms.com"` | Base URL of Give-SMS API. |
|
|
143
|
+
| `timeout` | `float` | `30.0` | Request timeout in seconds. |
|
|
144
|
+
|
|
145
|
+
#### Native REST API Methods (`/api/v1/`)
|
|
146
|
+
|
|
147
|
+
- **`get_balance() -> float`** — Returns current account balance.
|
|
148
|
+
- **`get_count(service=None, country=None) -> dict`** — Retrieves number stock.
|
|
149
|
+
- **`get_number(service, country=None) -> ActivationNumber`** — Orders a phone number.
|
|
150
|
+
- **`get_code(order_id: str | int) -> CodeResult`** — Checks for incoming SMS code.
|
|
151
|
+
- **`repeat_code(order_id: str | int) -> bool`** — Requests an additional SMS on the same number.
|
|
152
|
+
- **`cancel_number(order_id: str | int) -> bool`** — Cancels activation and refunds balance.
|
|
153
|
+
- **`ban_number(order_id: str | int) -> bool`** — Reports number as dead / blocked.
|
|
154
|
+
- **`reactivate(order_id: str | int) -> Any`** — Reactivates a previously used number.
|
|
155
|
+
|
|
156
|
+
#### Handler API Methods (`/stubs/handler_api.php`)
|
|
157
|
+
|
|
158
|
+
- **`handler_get_balance() -> float`** — Returns balance via handler API.
|
|
159
|
+
- **`handler_get_number(service, country=None) -> HandlerNumberResult`** — Orders number (`ACCESS_NUMBER`).
|
|
160
|
+
- **`handler_get_status(order_id: str | int) -> HandlerStatusResult`** — Retrieves status and code.
|
|
161
|
+
- **`handler_set_status(order_id: str | int, status: int) -> str`** — Updates activation status (1 = ready, 6 = complete, 8 = cancel).
|
|
162
|
+
- **`handler_get_prices(service=None, country=None) -> dict`** — Retrieves pricing catalog.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Error Handling
|
|
167
|
+
|
|
168
|
+
When an API request fails, `GiveSmsError` is raised:
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
from give_sms import GiveSms, GiveSmsError
|
|
172
|
+
|
|
173
|
+
try:
|
|
174
|
+
with GiveSms(api_key="invalid_key") as client:
|
|
175
|
+
client.get_balance()
|
|
176
|
+
except GiveSmsError as exc:
|
|
177
|
+
print(f"Give-SMS Error: {exc.message} (Code: {exc.code})")
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Common error codes:
|
|
181
|
+
- `NO_NUMBERS` — No available phone numbers for selected service/country.
|
|
182
|
+
- `NO_BALANCE` — Insufficient funds on account.
|
|
183
|
+
- `BAD_KEY` — Invalid API key.
|
|
184
|
+
- `BAD_ACTION` — Invalid action parameter.
|
|
185
|
+
- `WRONG_ACTIVATION_ID` — Activation ID not found or expired.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
ISC
|
give_sms-0.1.0/README.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# give-sms
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/give-sms/)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://pypi.org/project/give-sms/)
|
|
6
|
+
|
|
7
|
+
Modern, fully typed Python client library for the [Give-SMS](https://give-sms.com/api.html) virtual phone numbers and SMS OTP verification service.
|
|
8
|
+
|
|
9
|
+
Official API documentation: <https://give-sms.com/api.html>
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- 📱 **Dual Protocol Support** — Support for both the native JSON REST API (`/api/v1/`) and the SMS-Activate compatible handler protocol (`/stubs/handler_api.php`).
|
|
16
|
+
- 🌍 **Worldwide Numbers** — Rent disposable virtual numbers across multiple countries for Telegram, WhatsApp, Google, and 100+ other services.
|
|
17
|
+
- 🐍 **Modern Pythonic Design** — Type annotations, dataclass models, context manager support (`with GiveSms(...) as client:`), and custom exceptions.
|
|
18
|
+
- 🔄 **Full Activation Lifecycle** — Order numbers, fetch codes, request repeated SMS, cancel, or report dead numbers.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install give-sms
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Requires Python 3.10 or higher.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Quick Start (Safe Check)
|
|
33
|
+
|
|
34
|
+
The quick check only inspects your account balance. It does not order numbers or consume funds.
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import os
|
|
38
|
+
from give_sms import GiveSms
|
|
39
|
+
|
|
40
|
+
with GiveSms(api_key=os.environ["GIVE_SMS_KEY"]) as client:
|
|
41
|
+
balance = client.get_balance()
|
|
42
|
+
print(f"Current balance: ${balance:.2f} USD")
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Usage Guide
|
|
48
|
+
|
|
49
|
+
### 1. Renting a Number and Receiving an SMS Code (REST API)
|
|
50
|
+
|
|
51
|
+
Full activation workflow using the `/api/v1/` native JSON API:
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
import time
|
|
55
|
+
from give_sms import GiveSms
|
|
56
|
+
|
|
57
|
+
with GiveSms(api_key="your_api_key") as client:
|
|
58
|
+
# 1. Order a number for Telegram in USA
|
|
59
|
+
order = client.get_number(service="tg", country=0)
|
|
60
|
+
print(f"Received number: +{order.number} (Order ID: {order.id})")
|
|
61
|
+
|
|
62
|
+
# 2. Poll for incoming verification code
|
|
63
|
+
code = None
|
|
64
|
+
for _ in range(30):
|
|
65
|
+
time.sleep(3)
|
|
66
|
+
res = client.get_code(order.id)
|
|
67
|
+
if res.status == "SUCCESS" and res.code:
|
|
68
|
+
code = res.code
|
|
69
|
+
break
|
|
70
|
+
|
|
71
|
+
if code:
|
|
72
|
+
print(f"Verification code: {code}")
|
|
73
|
+
else:
|
|
74
|
+
print("Timeout reached. Cancelling number to refund balance...")
|
|
75
|
+
client.cancel_number(order.id)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 2. Querying Available Number Stock & Prices
|
|
79
|
+
|
|
80
|
+
Check available number counts before placing an order:
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
counts = client.get_count(service="tg", country=0)
|
|
84
|
+
print("Available numbers:", counts)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 3. Using the SMS-Activate Protocol (`handler_api.php`)
|
|
88
|
+
|
|
89
|
+
If your existing infrastructure is built around `handler_api.php`:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
# 1. Check balance
|
|
93
|
+
balance = client.handler_get_balance()
|
|
94
|
+
print(f"Handler balance: {balance}")
|
|
95
|
+
|
|
96
|
+
# 2. Order number
|
|
97
|
+
activation = client.handler_get_number(service="tg", country=0)
|
|
98
|
+
print(f"Order ID: {activation.id}, Phone: {activation.number}")
|
|
99
|
+
|
|
100
|
+
# 3. Mark ready (status 1)
|
|
101
|
+
client.handler_set_status(activation.id, 1)
|
|
102
|
+
|
|
103
|
+
# 4. Check status
|
|
104
|
+
status = client.handler_get_status(activation.id)
|
|
105
|
+
print(f"Status: {status.status}, Code: {status.code}")
|
|
106
|
+
|
|
107
|
+
# 5. Mark finished (status 6) or cancel (status 8)
|
|
108
|
+
client.handler_set_status(activation.id, 6)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## API Reference
|
|
114
|
+
|
|
115
|
+
### `GiveSms` Class
|
|
116
|
+
|
|
117
|
+
#### Constructor
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
GiveSms(
|
|
121
|
+
api_key: str,
|
|
122
|
+
base_url: str = "https://give-sms.com",
|
|
123
|
+
timeout: float = 30.0,
|
|
124
|
+
)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
| Parameter | Type | Default | Description |
|
|
128
|
+
| :--- | :--- | :--- | :--- |
|
|
129
|
+
| `api_key` | `str` | **Required** | Your Give-SMS API key. |
|
|
130
|
+
| `base_url` | `str` | `"https://give-sms.com"` | Base URL of Give-SMS API. |
|
|
131
|
+
| `timeout` | `float` | `30.0` | Request timeout in seconds. |
|
|
132
|
+
|
|
133
|
+
#### Native REST API Methods (`/api/v1/`)
|
|
134
|
+
|
|
135
|
+
- **`get_balance() -> float`** — Returns current account balance.
|
|
136
|
+
- **`get_count(service=None, country=None) -> dict`** — Retrieves number stock.
|
|
137
|
+
- **`get_number(service, country=None) -> ActivationNumber`** — Orders a phone number.
|
|
138
|
+
- **`get_code(order_id: str | int) -> CodeResult`** — Checks for incoming SMS code.
|
|
139
|
+
- **`repeat_code(order_id: str | int) -> bool`** — Requests an additional SMS on the same number.
|
|
140
|
+
- **`cancel_number(order_id: str | int) -> bool`** — Cancels activation and refunds balance.
|
|
141
|
+
- **`ban_number(order_id: str | int) -> bool`** — Reports number as dead / blocked.
|
|
142
|
+
- **`reactivate(order_id: str | int) -> Any`** — Reactivates a previously used number.
|
|
143
|
+
|
|
144
|
+
#### Handler API Methods (`/stubs/handler_api.php`)
|
|
145
|
+
|
|
146
|
+
- **`handler_get_balance() -> float`** — Returns balance via handler API.
|
|
147
|
+
- **`handler_get_number(service, country=None) -> HandlerNumberResult`** — Orders number (`ACCESS_NUMBER`).
|
|
148
|
+
- **`handler_get_status(order_id: str | int) -> HandlerStatusResult`** — Retrieves status and code.
|
|
149
|
+
- **`handler_set_status(order_id: str | int, status: int) -> str`** — Updates activation status (1 = ready, 6 = complete, 8 = cancel).
|
|
150
|
+
- **`handler_get_prices(service=None, country=None) -> dict`** — Retrieves pricing catalog.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Error Handling
|
|
155
|
+
|
|
156
|
+
When an API request fails, `GiveSmsError` is raised:
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
from give_sms import GiveSms, GiveSmsError
|
|
160
|
+
|
|
161
|
+
try:
|
|
162
|
+
with GiveSms(api_key="invalid_key") as client:
|
|
163
|
+
client.get_balance()
|
|
164
|
+
except GiveSmsError as exc:
|
|
165
|
+
print(f"Give-SMS Error: {exc.message} (Code: {exc.code})")
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Common error codes:
|
|
169
|
+
- `NO_NUMBERS` — No available phone numbers for selected service/country.
|
|
170
|
+
- `NO_BALANCE` — Insufficient funds on account.
|
|
171
|
+
- `BAD_KEY` — Invalid API key.
|
|
172
|
+
- `BAD_ACTION` — Invalid action parameter.
|
|
173
|
+
- `WRONG_ACTIVATION_ID` — Activation ID not found or expired.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## License
|
|
178
|
+
|
|
179
|
+
ISC
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from give_sms import GiveSms
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def main() -> None:
|
|
7
|
+
api_key = os.getenv("GIVE_SMS_API_KEY", "demo_key")
|
|
8
|
+
with GiveSms(api_key=api_key) as client:
|
|
9
|
+
print("Checking Give-SMS balance...")
|
|
10
|
+
try:
|
|
11
|
+
balance = client.get_balance()
|
|
12
|
+
print(f"Balance: {balance}")
|
|
13
|
+
|
|
14
|
+
counts = client.get_count(country="kazakhstan")
|
|
15
|
+
print(f"Available services: {len(counts)}")
|
|
16
|
+
except Exception as exc:
|
|
17
|
+
print(f"Error checking Give-SMS: {exc}")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
if __name__ == "__main__":
|
|
21
|
+
main()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "give-sms"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python client for the Give-SMS virtual number and SMS activation API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "ISC"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"httpx>=0.27",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[project.urls]
|
|
17
|
+
Repository = "https://github.com/TysikGG/api-kit"
|
|
18
|
+
Documentation = "https://give-sms.com/api.html"
|
|
19
|
+
|
|
20
|
+
[dependency-groups]
|
|
21
|
+
dev = [
|
|
22
|
+
"pytest>=8",
|
|
23
|
+
"pytest-httpx>=0.30",
|
|
24
|
+
"ruff>=0.8",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[tool.hatch.build.targets.wheel]
|
|
28
|
+
packages = ["src/give_sms"]
|
|
29
|
+
|
|
30
|
+
[tool.pytest.ini_options]
|
|
31
|
+
markers = [
|
|
32
|
+
"live: calls the real Give-SMS API and needs GIVE_SMS_API_KEY",
|
|
33
|
+
]
|
|
34
|
+
testpaths = ["tests"]
|
|
35
|
+
|
|
36
|
+
[tool.ruff]
|
|
37
|
+
target-version = "py310"
|
|
38
|
+
line-length = 100
|
|
39
|
+
src = ["src", "tests", "examples"]
|
|
40
|
+
|
|
41
|
+
[tool.ruff.lint]
|
|
42
|
+
select = ["E", "F", "I", "UP"]
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from give_sms.client import PARTNER_KEY, GiveSms
|
|
2
|
+
from give_sms.errors import GiveSmsError
|
|
3
|
+
from give_sms.types import ActivationNumber, CodeResult, HandlerStatusResult
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"GiveSms",
|
|
7
|
+
"PARTNER_KEY",
|
|
8
|
+
"GiveSmsError",
|
|
9
|
+
"ActivationNumber",
|
|
10
|
+
"CodeResult",
|
|
11
|
+
"HandlerStatusResult",
|
|
12
|
+
]
|