swapzone 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.
- swapzone-0.1.0/.gitignore +46 -0
- swapzone-0.1.0/LICENSE +15 -0
- swapzone-0.1.0/PKG-INFO +198 -0
- swapzone-0.1.0/README.md +186 -0
- swapzone-0.1.0/examples/quickstart.py +24 -0
- swapzone-0.1.0/pyproject.toml +42 -0
- swapzone-0.1.0/src/swapzone/__init__.py +23 -0
- swapzone-0.1.0/src/swapzone/client.py +341 -0
- swapzone-0.1.0/src/swapzone/errors.py +21 -0
- swapzone-0.1.0/src/swapzone/types.py +71 -0
- swapzone-0.1.0/tests/test_client.py +112 -0
- swapzone-0.1.0/tests/test_live.py +20 -0
- swapzone-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
|
swapzone-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.
|
swapzone-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: swapzone
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python client for the Swapzone cryptocurrency exchange and DEX aggregator API
|
|
5
|
+
Project-URL: Repository, https://github.com/TysikGG/api-kit
|
|
6
|
+
Project-URL: Documentation, https://documenter.getpostman.com/view/16362858/UVXokDS6
|
|
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
|
+
# swapzone
|
|
14
|
+
|
|
15
|
+
[](https://pypi.org/project/swapzone/)
|
|
16
|
+
[](LICENSE)
|
|
17
|
+
[](https://pypi.org/project/swapzone/)
|
|
18
|
+
|
|
19
|
+
Modern, fully typed Python client library for the [Swapzone](https://swapzone.io) instant cryptocurrency exchange & DEX cross-chain aggregator REST API.
|
|
20
|
+
|
|
21
|
+
Official API documentation: <https://documenter.getpostman.com/view/16362858/UVXokDS6>
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- 🔄 **15+ Exchange Providers Aggregated** — Compares rates in real time across top instant swap platforms (SimpleSwap, StealthEX, ChangeNOW, Changelly, etc.).
|
|
28
|
+
- 🪙 **1000+ Cryptocurrencies** — Full support for fixed and floating cross-chain swaps.
|
|
29
|
+
- 🐍 **Modern Pythonic Design** — Type annotations, dataclass models (`RateOffer`, `TransactionResult`, `SupportedCurrency`, `TransactionStatus`), context manager support (`with Swapzone(...) as client:`), and custom exceptions.
|
|
30
|
+
- ⚡ **DEX Aggregation** — DEX blockchain routes, token catalogs, and quote comparisons.
|
|
31
|
+
- 🛡️ **Address Validation** — Built-in `validate_address()` helper to verify destination wallet addresses.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install swapzone
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Requires Python 3.10 or higher.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Quick Start (Safe Check)
|
|
46
|
+
|
|
47
|
+
The quick check only inspects supported currencies and compares live provider exchange rates. It does not create orders:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
import os
|
|
51
|
+
from swapzone import Swapzone
|
|
52
|
+
|
|
53
|
+
with Swapzone(api_key=os.environ["SWAPZONE_API_KEY"]) as client:
|
|
54
|
+
# 1. Fetch supported currencies
|
|
55
|
+
currencies = client.get_currencies()
|
|
56
|
+
print(f"Available currencies: {len(currencies)}")
|
|
57
|
+
|
|
58
|
+
# 2. Query best rate offer for 0.1 BTC to ETH
|
|
59
|
+
rate = client.get_rate(
|
|
60
|
+
from_currency="btc",
|
|
61
|
+
to_currency="eth",
|
|
62
|
+
amount=0.1,
|
|
63
|
+
rate_type="all",
|
|
64
|
+
)
|
|
65
|
+
print(f"Best Provider: {rate.best_offer.adapter}")
|
|
66
|
+
print(f"Estimated Receive: {rate.best_offer.amount_to} ETH")
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Usage Guide
|
|
72
|
+
|
|
73
|
+
### 1. Finding the Best Rate and Creating a Swap
|
|
74
|
+
|
|
75
|
+
Full lifecycle: query provider rates, validate destination address, create transaction, and monitor status:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from swapzone import Swapzone, SwapzoneError
|
|
79
|
+
|
|
80
|
+
with Swapzone(api_key="your_api_key") as client:
|
|
81
|
+
# 1. Get rate offers across all providers
|
|
82
|
+
rate = client.get_rate(
|
|
83
|
+
from_currency="btc",
|
|
84
|
+
to_currency="eth",
|
|
85
|
+
amount=0.1,
|
|
86
|
+
rate_type="all",
|
|
87
|
+
)
|
|
88
|
+
best_offer = rate.best_offer
|
|
89
|
+
print(f"Selected Provider: {best_offer.adapter} (Quota: {best_offer.amount_to} ETH)")
|
|
90
|
+
|
|
91
|
+
# 2. Validate destination wallet address
|
|
92
|
+
check = client.validate_address(
|
|
93
|
+
currency="eth",
|
|
94
|
+
address="0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
|
|
95
|
+
)
|
|
96
|
+
if not check.result:
|
|
97
|
+
raise ValueError("Invalid destination wallet address!")
|
|
98
|
+
|
|
99
|
+
# 3. Create transaction with the selected provider
|
|
100
|
+
tx = client.create_transaction(
|
|
101
|
+
from_currency="btc",
|
|
102
|
+
to_currency="eth",
|
|
103
|
+
amount_deposit=0.1,
|
|
104
|
+
address_receive="0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
|
|
105
|
+
quota_id=best_offer.quota_id,
|
|
106
|
+
refund_address="bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh", # optional
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
print(f"Transaction Created! ID: {tx.transaction.id}")
|
|
110
|
+
print(f"Send BTC to Deposit Address: {tx.transaction.address_deposit}")
|
|
111
|
+
print(f"Status: {tx.transaction.status}")
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 2. Tracking Transaction Progress
|
|
115
|
+
|
|
116
|
+
Monitor swap progress from deposit to settlement:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
current = client.get_transaction(tx.transaction.id)
|
|
120
|
+
print(f"Status: {current.status}")
|
|
121
|
+
|
|
122
|
+
if current.status == "finished":
|
|
123
|
+
print(f"Received: {current.amount_receive} ETH")
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 3. Querying DEX Aggregation
|
|
127
|
+
|
|
128
|
+
Inspect supported DEX blockchains and token pairs:
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
# List supported DEX blockchains
|
|
132
|
+
blockchains = client.get_dex_blockchains()
|
|
133
|
+
print("DEX Blockchains:", blockchains)
|
|
134
|
+
|
|
135
|
+
# Check DEX tokens
|
|
136
|
+
dex_tokens = client.get_dex_tokens()
|
|
137
|
+
print(f"DEX Tokens count: {len(dex_tokens)}")
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## API Reference
|
|
143
|
+
|
|
144
|
+
### `Swapzone` Class
|
|
145
|
+
|
|
146
|
+
#### Constructor
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
Swapzone(
|
|
150
|
+
api_key: str,
|
|
151
|
+
base_url: str = "https://api.swapzone.io/v1",
|
|
152
|
+
timeout: float = 30.0,
|
|
153
|
+
)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
| Parameter | Type | Default | Description |
|
|
157
|
+
| :--- | :--- | :--- | :--- |
|
|
158
|
+
| `api_key` | `str` | **Required** | Your Swapzone API key. |
|
|
159
|
+
| `base_url` | `str` | `"https://api.swapzone.io/v1"` | Swapzone API base URL. |
|
|
160
|
+
| `timeout` | `float` | `30.0` | HTTP request timeout in seconds. |
|
|
161
|
+
|
|
162
|
+
#### Methods
|
|
163
|
+
|
|
164
|
+
- **`get_currencies() -> list[SupportedCurrency]`** — Returns all supported cryptocurrencies.
|
|
165
|
+
- **`get_rate(from_currency, to_currency, amount, rate_type="all") -> RateOffer`** — Returns aggregated quotes.
|
|
166
|
+
- **`create_transaction(from_currency, to_currency, amount_deposit, address_receive, quota_id, ...) -> TransactionResult`** — Creates transaction.
|
|
167
|
+
- **`get_transaction(transaction_id: str) -> TransactionStatus`** — Checks swap status and execution details.
|
|
168
|
+
- **`validate_address(currency, address) -> ValidateAddressResult`** — Validates destination wallet address.
|
|
169
|
+
- **`get_markets(rate_type=None) -> list[Any]`** — Retrieves active market pairs.
|
|
170
|
+
- **`get_dex_blockchains() -> list[DEXBlockchain]`** — Lists supported DEX blockchains.
|
|
171
|
+
- **`get_dex_tokens() -> list[Any]`** — Lists tokens supported on DEX routers.
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Error Handling
|
|
176
|
+
|
|
177
|
+
When the API returns an error, `SwapzoneError` is raised:
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
from swapzone import Swapzone, SwapzoneError
|
|
181
|
+
|
|
182
|
+
try:
|
|
183
|
+
with Swapzone(api_key="invalid_key") as client:
|
|
184
|
+
client.get_currencies()
|
|
185
|
+
except SwapzoneError as exc:
|
|
186
|
+
print(f"Swapzone Error: {exc.message} (Status: {exc.status})")
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Common HTTP status codes:
|
|
190
|
+
- `400 Bad Request` — Invalid address or amount out of limits.
|
|
191
|
+
- `401 Unauthorized` — Invalid API key.
|
|
192
|
+
- `404 Not Found` — Transaction ID not found.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
ISC
|
swapzone-0.1.0/README.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# swapzone
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/swapzone/)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://pypi.org/project/swapzone/)
|
|
6
|
+
|
|
7
|
+
Modern, fully typed Python client library for the [Swapzone](https://swapzone.io) instant cryptocurrency exchange & DEX cross-chain aggregator REST API.
|
|
8
|
+
|
|
9
|
+
Official API documentation: <https://documenter.getpostman.com/view/16362858/UVXokDS6>
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- 🔄 **15+ Exchange Providers Aggregated** — Compares rates in real time across top instant swap platforms (SimpleSwap, StealthEX, ChangeNOW, Changelly, etc.).
|
|
16
|
+
- 🪙 **1000+ Cryptocurrencies** — Full support for fixed and floating cross-chain swaps.
|
|
17
|
+
- 🐍 **Modern Pythonic Design** — Type annotations, dataclass models (`RateOffer`, `TransactionResult`, `SupportedCurrency`, `TransactionStatus`), context manager support (`with Swapzone(...) as client:`), and custom exceptions.
|
|
18
|
+
- ⚡ **DEX Aggregation** — DEX blockchain routes, token catalogs, and quote comparisons.
|
|
19
|
+
- 🛡️ **Address Validation** — Built-in `validate_address()` helper to verify destination wallet addresses.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install swapzone
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Requires Python 3.10 or higher.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Quick Start (Safe Check)
|
|
34
|
+
|
|
35
|
+
The quick check only inspects supported currencies and compares live provider exchange rates. It does not create orders:
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
import os
|
|
39
|
+
from swapzone import Swapzone
|
|
40
|
+
|
|
41
|
+
with Swapzone(api_key=os.environ["SWAPZONE_API_KEY"]) as client:
|
|
42
|
+
# 1. Fetch supported currencies
|
|
43
|
+
currencies = client.get_currencies()
|
|
44
|
+
print(f"Available currencies: {len(currencies)}")
|
|
45
|
+
|
|
46
|
+
# 2. Query best rate offer for 0.1 BTC to ETH
|
|
47
|
+
rate = client.get_rate(
|
|
48
|
+
from_currency="btc",
|
|
49
|
+
to_currency="eth",
|
|
50
|
+
amount=0.1,
|
|
51
|
+
rate_type="all",
|
|
52
|
+
)
|
|
53
|
+
print(f"Best Provider: {rate.best_offer.adapter}")
|
|
54
|
+
print(f"Estimated Receive: {rate.best_offer.amount_to} ETH")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Usage Guide
|
|
60
|
+
|
|
61
|
+
### 1. Finding the Best Rate and Creating a Swap
|
|
62
|
+
|
|
63
|
+
Full lifecycle: query provider rates, validate destination address, create transaction, and monitor status:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from swapzone import Swapzone, SwapzoneError
|
|
67
|
+
|
|
68
|
+
with Swapzone(api_key="your_api_key") as client:
|
|
69
|
+
# 1. Get rate offers across all providers
|
|
70
|
+
rate = client.get_rate(
|
|
71
|
+
from_currency="btc",
|
|
72
|
+
to_currency="eth",
|
|
73
|
+
amount=0.1,
|
|
74
|
+
rate_type="all",
|
|
75
|
+
)
|
|
76
|
+
best_offer = rate.best_offer
|
|
77
|
+
print(f"Selected Provider: {best_offer.adapter} (Quota: {best_offer.amount_to} ETH)")
|
|
78
|
+
|
|
79
|
+
# 2. Validate destination wallet address
|
|
80
|
+
check = client.validate_address(
|
|
81
|
+
currency="eth",
|
|
82
|
+
address="0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
|
|
83
|
+
)
|
|
84
|
+
if not check.result:
|
|
85
|
+
raise ValueError("Invalid destination wallet address!")
|
|
86
|
+
|
|
87
|
+
# 3. Create transaction with the selected provider
|
|
88
|
+
tx = client.create_transaction(
|
|
89
|
+
from_currency="btc",
|
|
90
|
+
to_currency="eth",
|
|
91
|
+
amount_deposit=0.1,
|
|
92
|
+
address_receive="0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
|
|
93
|
+
quota_id=best_offer.quota_id,
|
|
94
|
+
refund_address="bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh", # optional
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
print(f"Transaction Created! ID: {tx.transaction.id}")
|
|
98
|
+
print(f"Send BTC to Deposit Address: {tx.transaction.address_deposit}")
|
|
99
|
+
print(f"Status: {tx.transaction.status}")
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 2. Tracking Transaction Progress
|
|
103
|
+
|
|
104
|
+
Monitor swap progress from deposit to settlement:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
current = client.get_transaction(tx.transaction.id)
|
|
108
|
+
print(f"Status: {current.status}")
|
|
109
|
+
|
|
110
|
+
if current.status == "finished":
|
|
111
|
+
print(f"Received: {current.amount_receive} ETH")
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 3. Querying DEX Aggregation
|
|
115
|
+
|
|
116
|
+
Inspect supported DEX blockchains and token pairs:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
# List supported DEX blockchains
|
|
120
|
+
blockchains = client.get_dex_blockchains()
|
|
121
|
+
print("DEX Blockchains:", blockchains)
|
|
122
|
+
|
|
123
|
+
# Check DEX tokens
|
|
124
|
+
dex_tokens = client.get_dex_tokens()
|
|
125
|
+
print(f"DEX Tokens count: {len(dex_tokens)}")
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## API Reference
|
|
131
|
+
|
|
132
|
+
### `Swapzone` Class
|
|
133
|
+
|
|
134
|
+
#### Constructor
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
Swapzone(
|
|
138
|
+
api_key: str,
|
|
139
|
+
base_url: str = "https://api.swapzone.io/v1",
|
|
140
|
+
timeout: float = 30.0,
|
|
141
|
+
)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
| Parameter | Type | Default | Description |
|
|
145
|
+
| :--- | :--- | :--- | :--- |
|
|
146
|
+
| `api_key` | `str` | **Required** | Your Swapzone API key. |
|
|
147
|
+
| `base_url` | `str` | `"https://api.swapzone.io/v1"` | Swapzone API base URL. |
|
|
148
|
+
| `timeout` | `float` | `30.0` | HTTP request timeout in seconds. |
|
|
149
|
+
|
|
150
|
+
#### Methods
|
|
151
|
+
|
|
152
|
+
- **`get_currencies() -> list[SupportedCurrency]`** — Returns all supported cryptocurrencies.
|
|
153
|
+
- **`get_rate(from_currency, to_currency, amount, rate_type="all") -> RateOffer`** — Returns aggregated quotes.
|
|
154
|
+
- **`create_transaction(from_currency, to_currency, amount_deposit, address_receive, quota_id, ...) -> TransactionResult`** — Creates transaction.
|
|
155
|
+
- **`get_transaction(transaction_id: str) -> TransactionStatus`** — Checks swap status and execution details.
|
|
156
|
+
- **`validate_address(currency, address) -> ValidateAddressResult`** — Validates destination wallet address.
|
|
157
|
+
- **`get_markets(rate_type=None) -> list[Any]`** — Retrieves active market pairs.
|
|
158
|
+
- **`get_dex_blockchains() -> list[DEXBlockchain]`** — Lists supported DEX blockchains.
|
|
159
|
+
- **`get_dex_tokens() -> list[Any]`** — Lists tokens supported on DEX routers.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Error Handling
|
|
164
|
+
|
|
165
|
+
When the API returns an error, `SwapzoneError` is raised:
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
from swapzone import Swapzone, SwapzoneError
|
|
169
|
+
|
|
170
|
+
try:
|
|
171
|
+
with Swapzone(api_key="invalid_key") as client:
|
|
172
|
+
client.get_currencies()
|
|
173
|
+
except SwapzoneError as exc:
|
|
174
|
+
print(f"Swapzone Error: {exc.message} (Status: {exc.status})")
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Common HTTP status codes:
|
|
178
|
+
- `400 Bad Request` — Invalid address or amount out of limits.
|
|
179
|
+
- `401 Unauthorized` — Invalid API key.
|
|
180
|
+
- `404 Not Found` — Transaction ID not found.
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
ISC
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
from swapzone import Swapzone
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def main() -> None:
|
|
8
|
+
api_key = os.environ.get("SWAPZONE_API_KEY")
|
|
9
|
+
if not api_key:
|
|
10
|
+
print("Please set SWAPZONE_API_KEY environment variable.", file=sys.stderr)
|
|
11
|
+
sys.exit(1)
|
|
12
|
+
|
|
13
|
+
with Swapzone(api_key=api_key) as client:
|
|
14
|
+
currencies = client.get_currencies()
|
|
15
|
+
print(f"Supported currencies: {len(currencies)}")
|
|
16
|
+
sample = [f"{c['name']} ({c['ticker'].upper()})" for c in currencies[:5]]
|
|
17
|
+
print("Sample:", ", ".join(sample))
|
|
18
|
+
|
|
19
|
+
rate = client.get_rate("btc", "eth", "0.1")
|
|
20
|
+
print(f"\n0.1 BTC -> {rate['amountTo']} ETH via {rate['adapter']}")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
if __name__ == "__main__":
|
|
24
|
+
main()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "swapzone"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python client for the Swapzone cryptocurrency exchange and DEX aggregator 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://documenter.getpostman.com/view/16362858/UVXokDS6"
|
|
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/swapzone"]
|
|
29
|
+
|
|
30
|
+
[tool.pytest.ini_options]
|
|
31
|
+
markers = [
|
|
32
|
+
"live: calls the real Swapzone API and needs SWAPZONE_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,23 @@
|
|
|
1
|
+
"""Swapzone cryptocurrency exchange and DEX aggregator client."""
|
|
2
|
+
|
|
3
|
+
from .client import Swapzone
|
|
4
|
+
from .errors import SwapzoneError
|
|
5
|
+
from .types import (
|
|
6
|
+
DEXBlockchain,
|
|
7
|
+
RateOffer,
|
|
8
|
+
SupportedCurrency,
|
|
9
|
+
TransactionResult,
|
|
10
|
+
TransactionStatus,
|
|
11
|
+
ValidateAddressResult,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"DEXBlockchain",
|
|
16
|
+
"RateOffer",
|
|
17
|
+
"SupportedCurrency",
|
|
18
|
+
"Swapzone",
|
|
19
|
+
"SwapzoneError",
|
|
20
|
+
"TransactionResult",
|
|
21
|
+
"TransactionStatus",
|
|
22
|
+
"ValidateAddressResult",
|
|
23
|
+
]
|