vaksms-client 0.2.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.
@@ -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
@@ -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.
@@ -0,0 +1,193 @@
1
+ Metadata-Version: 2.5
2
+ Name: vaksms-client
3
+ Version: 0.2.0
4
+ Summary: Python client for the VAK-SMS virtual number and SMS activation API
5
+ Project-URL: Repository, https://github.com/TysikGG/api-kit
6
+ Project-URL: Documentation, https://vak-sms.com/en/api/
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
+ # vaksms-client
14
+
15
+ [![PyPI version](https://img.shields.io/pypi/v/vaksms-client.svg)](https://pypi.org/project/vaksms-client/)
16
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](LICENSE)
17
+ [![Python Version](https://img.shields.io/pypi/pyversions/vaksms-client.svg)](https://pypi.org/project/vaksms-client/)
18
+
19
+ Modern, fully typed Python client library for the [VAK-SMS](https://vak-sms.com/api/) virtual phone numbers and SMS OTP receiving service.
20
+
21
+ Official API documentation: <https://vak-sms.com/api/vak/>
22
+
23
+ Install as `vaksms-client` (`pip install vaksms-client`); import as `vak_sms`.
24
+
25
+ ---
26
+
27
+ ## Features
28
+
29
+ - 📱 **Virtual Phone Numbers** — Disposable phone numbers across dozens of countries for Telegram, WhatsApp, Discord, Google, and 100+ services.
30
+ - 🔁 **Number Prolongation** — Re-rent or prolong previously used numbers for secondary SMS verification.
31
+ - ⏳ **Built-in Auto Polling** — `wait_for_code()` automatically polls until the SMS verification code is received or timeout is reached.
32
+ - 🐍 **Modern Pythonic Design** — Type annotations, dataclass models (`VakNumber`, `CountryOperator`), context manager support (`with VakSmsClient(...) as client:`), and custom exceptions.
33
+
34
+ ---
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install vaksms-client
40
+ ```
41
+
42
+ Requires Python 3.10 or higher.
43
+
44
+ ---
45
+
46
+ ## Quick Start (Safe Check)
47
+
48
+ The quick check only inspects your account balance and supported countries. It does not order numbers or consume funds:
49
+
50
+ ```python
51
+ import os
52
+ from vak_sms import VakSmsClient
53
+
54
+ with VakSmsClient(api_key=os.environ["VAK_SMS_API_KEY"]) as client:
55
+ balance = client.get_balance()
56
+ print(f"Current VAK-SMS balance: {balance:.2f} RUB")
57
+
58
+ countries = client.get_country_list()
59
+ print(f"Supported countries count: {len(countries)}")
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Usage Guide
65
+
66
+ ### 1. Renting a Number and Receiving an SMS Code
67
+
68
+ Full activation lifecycle: order a number, wait for the incoming SMS verification code, and finish the activation:
69
+
70
+ ```python
71
+ from vak_sms import VakSmsClient, VakSmsError
72
+
73
+ with VakSmsClient(api_key="your_api_key") as client:
74
+ # 1. Order a number for Telegram in United States ('us')
75
+ order = client.get_number(service="tg", country="us")
76
+ print(f"Rented Number: +{order.tel} (ID: {order.id_num})")
77
+
78
+ # 2. Poll for the incoming verification code using built-in helper
79
+ try:
80
+ code = client.wait_for_code(order.id_num, timeout_ms=120_000, interval_ms=3_000)
81
+ print(f"Received verification code: {code}")
82
+
83
+ # 3. Mark activation successfully finished ('end')
84
+ client.set_status(order.id_num, "end")
85
+ except VakSmsError as err:
86
+ if err.code == "TIMEOUT":
87
+ print("SMS did not arrive in time. Marking as bad number ('bad')...")
88
+ client.set_status(order.id_num, "bad")
89
+ else:
90
+ raise err
91
+ ```
92
+
93
+ ### 2. Requesting Repeat / Second SMS ('send')
94
+
95
+ If you need a second SMS message on the same rented number:
96
+
97
+ ```python
98
+ # Notify provider that you want to receive another SMS code
99
+ client.set_status(order.id_num, "send")
100
+
101
+ # Wait for the second code
102
+ second_code = client.wait_for_code(order.id_num)
103
+ print(f"Second code: {second_code}")
104
+
105
+ # Finish
106
+ client.set_status(order.id_num, "end")
107
+ ```
108
+
109
+ ### 3. Number Prolongation (Re-using Previous Number)
110
+
111
+ Prolong an existing number for a service if it is still available on the SIM farm:
112
+
113
+ ```python
114
+ prolonged = client.prolong_number("tg", order.id_num)
115
+ print(f"Prolonged number: +{prolonged.tel}")
116
+ ```
117
+
118
+ ### 4. Inspecting Stock Availability
119
+
120
+ Check available numbers for a service:
121
+
122
+ ```python
123
+ # Count available numbers for Telegram in USA
124
+ count = client.get_count_number("tg", "us")
125
+ print(f"Available numbers: {count}")
126
+
127
+ # All service counts in a country
128
+ numbers_list = client.get_count_numbers_list("us")
129
+ print("USA counts by service:", numbers_list)
130
+ ```
131
+
132
+ ---
133
+
134
+ ## API Reference
135
+
136
+ ### `VakSmsClient` Class
137
+
138
+ #### Constructor
139
+
140
+ ```python
141
+ VakSmsClient(
142
+ api_key: str,
143
+ base_url: str = "https://vak-sms.com",
144
+ timeout: float = 30.0,
145
+ )
146
+ ```
147
+
148
+ | Parameter | Type | Default | Description |
149
+ | :--- | :--- | :--- | :--- |
150
+ | `api_key` | `str` | **Required** | Your VAK-SMS API key. |
151
+ | `base_url` | `str` | `"https://vak-sms.com"` | Base URL of VAK-SMS API. |
152
+ | `timeout` | `float` | `30.0` | Request timeout in seconds. |
153
+
154
+ #### Methods
155
+
156
+ - **`get_balance() -> float`** — Returns account balance in RUB.
157
+ - **`get_number(service, country=None, operator=None) -> VakNumber`** — Orders a phone number (`tel`, `id_num`).
158
+ - **`prolong_number(service, id_num, operator=None) -> VakNumber`** — Re-activates a previous number.
159
+ - **`get_sms_code(id_num, all=False) -> str | list[str] | None`** — Checks for incoming SMS code (`None` if waiting).
160
+ - **`wait_for_code(id_num, timeout_ms=120000, interval_ms=3000) -> str`** — Automatically polls until code arrives.
161
+ - **`set_status(id_num: str, status: str) -> str`** — Sets activation state (`'send'`, `'end'`, `'bad'`).
162
+ - **`get_count_number(service, country=None, operator=None) -> int`** — Available numbers for a service.
163
+ - **`get_country_list() -> list[CountryOperator]`** — Lists supported countries and operators.
164
+ - **`get_count_numbers_list(country=None, operator=None) -> dict[str, int]`** — Map of service counts.
165
+
166
+ ---
167
+
168
+ ## Error Handling
169
+
170
+ When the API returns an error response, `VakSmsError` is raised:
171
+
172
+ ```python
173
+ from vak_sms import VakSmsClient, VakSmsError
174
+
175
+ try:
176
+ with VakSmsClient(api_key="invalid_key") as client:
177
+ client.get_balance()
178
+ except VakSmsError as exc:
179
+ print(f"VAK-SMS Error: {exc.message} (Code: {exc.code})")
180
+ ```
181
+
182
+ Common error codes:
183
+ - `noNumber` — No numbers currently available for the service/country.
184
+ - `noMoney` — Insufficient balance on account.
185
+ - `apiKeyNotFound` — Invalid API key.
186
+ - `badStatus` — Invalid status passed.
187
+ - `TIMEOUT` — Polling timeout exceeded in `wait_for_code()`.
188
+
189
+ ---
190
+
191
+ ## License
192
+
193
+ ISC
@@ -0,0 +1,181 @@
1
+ # vaksms-client
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/vaksms-client.svg)](https://pypi.org/project/vaksms-client/)
4
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](LICENSE)
5
+ [![Python Version](https://img.shields.io/pypi/pyversions/vaksms-client.svg)](https://pypi.org/project/vaksms-client/)
6
+
7
+ Modern, fully typed Python client library for the [VAK-SMS](https://vak-sms.com/api/) virtual phone numbers and SMS OTP receiving service.
8
+
9
+ Official API documentation: <https://vak-sms.com/api/vak/>
10
+
11
+ Install as `vaksms-client` (`pip install vaksms-client`); import as `vak_sms`.
12
+
13
+ ---
14
+
15
+ ## Features
16
+
17
+ - 📱 **Virtual Phone Numbers** — Disposable phone numbers across dozens of countries for Telegram, WhatsApp, Discord, Google, and 100+ services.
18
+ - 🔁 **Number Prolongation** — Re-rent or prolong previously used numbers for secondary SMS verification.
19
+ - ⏳ **Built-in Auto Polling** — `wait_for_code()` automatically polls until the SMS verification code is received or timeout is reached.
20
+ - 🐍 **Modern Pythonic Design** — Type annotations, dataclass models (`VakNumber`, `CountryOperator`), context manager support (`with VakSmsClient(...) as client:`), and custom exceptions.
21
+
22
+ ---
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pip install vaksms-client
28
+ ```
29
+
30
+ Requires Python 3.10 or higher.
31
+
32
+ ---
33
+
34
+ ## Quick Start (Safe Check)
35
+
36
+ The quick check only inspects your account balance and supported countries. It does not order numbers or consume funds:
37
+
38
+ ```python
39
+ import os
40
+ from vak_sms import VakSmsClient
41
+
42
+ with VakSmsClient(api_key=os.environ["VAK_SMS_API_KEY"]) as client:
43
+ balance = client.get_balance()
44
+ print(f"Current VAK-SMS balance: {balance:.2f} RUB")
45
+
46
+ countries = client.get_country_list()
47
+ print(f"Supported countries count: {len(countries)}")
48
+ ```
49
+
50
+ ---
51
+
52
+ ## Usage Guide
53
+
54
+ ### 1. Renting a Number and Receiving an SMS Code
55
+
56
+ Full activation lifecycle: order a number, wait for the incoming SMS verification code, and finish the activation:
57
+
58
+ ```python
59
+ from vak_sms import VakSmsClient, VakSmsError
60
+
61
+ with VakSmsClient(api_key="your_api_key") as client:
62
+ # 1. Order a number for Telegram in United States ('us')
63
+ order = client.get_number(service="tg", country="us")
64
+ print(f"Rented Number: +{order.tel} (ID: {order.id_num})")
65
+
66
+ # 2. Poll for the incoming verification code using built-in helper
67
+ try:
68
+ code = client.wait_for_code(order.id_num, timeout_ms=120_000, interval_ms=3_000)
69
+ print(f"Received verification code: {code}")
70
+
71
+ # 3. Mark activation successfully finished ('end')
72
+ client.set_status(order.id_num, "end")
73
+ except VakSmsError as err:
74
+ if err.code == "TIMEOUT":
75
+ print("SMS did not arrive in time. Marking as bad number ('bad')...")
76
+ client.set_status(order.id_num, "bad")
77
+ else:
78
+ raise err
79
+ ```
80
+
81
+ ### 2. Requesting Repeat / Second SMS ('send')
82
+
83
+ If you need a second SMS message on the same rented number:
84
+
85
+ ```python
86
+ # Notify provider that you want to receive another SMS code
87
+ client.set_status(order.id_num, "send")
88
+
89
+ # Wait for the second code
90
+ second_code = client.wait_for_code(order.id_num)
91
+ print(f"Second code: {second_code}")
92
+
93
+ # Finish
94
+ client.set_status(order.id_num, "end")
95
+ ```
96
+
97
+ ### 3. Number Prolongation (Re-using Previous Number)
98
+
99
+ Prolong an existing number for a service if it is still available on the SIM farm:
100
+
101
+ ```python
102
+ prolonged = client.prolong_number("tg", order.id_num)
103
+ print(f"Prolonged number: +{prolonged.tel}")
104
+ ```
105
+
106
+ ### 4. Inspecting Stock Availability
107
+
108
+ Check available numbers for a service:
109
+
110
+ ```python
111
+ # Count available numbers for Telegram in USA
112
+ count = client.get_count_number("tg", "us")
113
+ print(f"Available numbers: {count}")
114
+
115
+ # All service counts in a country
116
+ numbers_list = client.get_count_numbers_list("us")
117
+ print("USA counts by service:", numbers_list)
118
+ ```
119
+
120
+ ---
121
+
122
+ ## API Reference
123
+
124
+ ### `VakSmsClient` Class
125
+
126
+ #### Constructor
127
+
128
+ ```python
129
+ VakSmsClient(
130
+ api_key: str,
131
+ base_url: str = "https://vak-sms.com",
132
+ timeout: float = 30.0,
133
+ )
134
+ ```
135
+
136
+ | Parameter | Type | Default | Description |
137
+ | :--- | :--- | :--- | :--- |
138
+ | `api_key` | `str` | **Required** | Your VAK-SMS API key. |
139
+ | `base_url` | `str` | `"https://vak-sms.com"` | Base URL of VAK-SMS API. |
140
+ | `timeout` | `float` | `30.0` | Request timeout in seconds. |
141
+
142
+ #### Methods
143
+
144
+ - **`get_balance() -> float`** — Returns account balance in RUB.
145
+ - **`get_number(service, country=None, operator=None) -> VakNumber`** — Orders a phone number (`tel`, `id_num`).
146
+ - **`prolong_number(service, id_num, operator=None) -> VakNumber`** — Re-activates a previous number.
147
+ - **`get_sms_code(id_num, all=False) -> str | list[str] | None`** — Checks for incoming SMS code (`None` if waiting).
148
+ - **`wait_for_code(id_num, timeout_ms=120000, interval_ms=3000) -> str`** — Automatically polls until code arrives.
149
+ - **`set_status(id_num: str, status: str) -> str`** — Sets activation state (`'send'`, `'end'`, `'bad'`).
150
+ - **`get_count_number(service, country=None, operator=None) -> int`** — Available numbers for a service.
151
+ - **`get_country_list() -> list[CountryOperator]`** — Lists supported countries and operators.
152
+ - **`get_count_numbers_list(country=None, operator=None) -> dict[str, int]`** — Map of service counts.
153
+
154
+ ---
155
+
156
+ ## Error Handling
157
+
158
+ When the API returns an error response, `VakSmsError` is raised:
159
+
160
+ ```python
161
+ from vak_sms import VakSmsClient, VakSmsError
162
+
163
+ try:
164
+ with VakSmsClient(api_key="invalid_key") as client:
165
+ client.get_balance()
166
+ except VakSmsError as exc:
167
+ print(f"VAK-SMS Error: {exc.message} (Code: {exc.code})")
168
+ ```
169
+
170
+ Common error codes:
171
+ - `noNumber` — No numbers currently available for the service/country.
172
+ - `noMoney` — Insufficient balance on account.
173
+ - `apiKeyNotFound` — Invalid API key.
174
+ - `badStatus` — Invalid status passed.
175
+ - `TIMEOUT` — Polling timeout exceeded in `wait_for_code()`.
176
+
177
+ ---
178
+
179
+ ## License
180
+
181
+ ISC
@@ -0,0 +1,26 @@
1
+ """Quickstart example for the VAK-SMS Python client."""
2
+
3
+ import os
4
+ import sys
5
+
6
+ from vak_sms import VakSmsClient
7
+
8
+
9
+ def main() -> None:
10
+ api_key = os.environ.get("VAK_SMS_API_KEY")
11
+ if not api_key:
12
+ print("Please set the VAK_SMS_API_KEY environment variable", file=sys.stderr)
13
+ sys.exit(1)
14
+
15
+ with VakSmsClient(api_key=api_key) as client:
16
+ balance = client.get_balance()
17
+ print(f"VAK-SMS Balance: {balance:.2f} RUB")
18
+
19
+ countries = client.get_country_list()
20
+ print(f"Supported countries: {len(countries)}")
21
+ if countries:
22
+ print("First country:", countries[0].country_name)
23
+
24
+
25
+ if __name__ == "__main__":
26
+ main()
@@ -0,0 +1,44 @@
1
+ # Publish trigger
2
+ # VAK-SMS API client
3
+ [build-system]
4
+ requires = ["hatchling"]
5
+ build-backend = "hatchling.build"
6
+
7
+ [project]
8
+ name = "vaksms-client"
9
+ version = "0.2.0"
10
+ description = "Python client for the VAK-SMS virtual number and SMS activation API"
11
+ readme = "README.md"
12
+ requires-python = ">=3.10"
13
+ license = "ISC"
14
+ dependencies = [
15
+ "httpx>=0.27",
16
+ ]
17
+
18
+ [project.urls]
19
+ Repository = "https://github.com/TysikGG/api-kit"
20
+ Documentation = "https://vak-sms.com/en/api/"
21
+
22
+ [dependency-groups]
23
+ dev = [
24
+ "pytest>=8",
25
+ "pytest-httpx>=0.30",
26
+ "ruff>=0.8",
27
+ ]
28
+
29
+ [tool.hatch.build.targets.wheel]
30
+ packages = ["src/vak_sms"]
31
+
32
+ [tool.pytest.ini_options]
33
+ markers = [
34
+ "live: calls the real VAK-SMS API and needs VAK_SMS_API_KEY",
35
+ ]
36
+ testpaths = ["tests"]
37
+
38
+ [tool.ruff]
39
+ target-version = "py310"
40
+ line-length = 100
41
+ src = ["src", "tests", "examples"]
42
+
43
+ [tool.ruff.lint]
44
+ select = ["E", "F", "I", "UP"]
@@ -0,0 +1,14 @@
1
+ """VAK-SMS Python Client."""
2
+
3
+ from .client import DEFAULT_SOFT_ID, VakSmsClient
4
+ from .errors import VakSmsError
5
+ from .types import CountNumber, CountryOperator, VakNumber
6
+
7
+ __all__ = [
8
+ "DEFAULT_SOFT_ID",
9
+ "CountNumber",
10
+ "CountryOperator",
11
+ "VakNumber",
12
+ "VakSmsClient",
13
+ "VakSmsError",
14
+ ]