bitcoinvn 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.
@@ -0,0 +1,45 @@
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
+
38
+ # GitBook / HonKit
39
+ _book/
40
+
41
+ # OS and editors
42
+ .DS_Store
43
+ Thumbs.db
44
+ .idea/
45
+ *.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,173 @@
1
+ Metadata-Version: 2.5
2
+ Name: bitcoinvn
3
+ Version: 0.1.0
4
+ Summary: Python client for the BitcoinVN exchange API
5
+ Project-URL: Repository, https://github.com/TysikGG/api-kit
6
+ Project-URL: Documentation, https://bitcoinvn.io/api/doc.json
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
+ # bitcoinvn
14
+
15
+ [![PyPI version](https://img.shields.io/pypi/v/bitcoinvn.svg)](https://pypi.org/project/bitcoinvn/)
16
+ [![Python versions](https://img.shields.io/pypi/pyversions/bitcoinvn.svg)](https://pypi.org/project/bitcoinvn/)
17
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
18
+
19
+ Modern, typed Python client for the [BitcoinVN Exchange API](https://bitcoinvn.io/api/doc.json) — Vietnam's premier cryptocurrency exchange and instant swap platform. Built on [HTTPX](https://www.python-httpx.org).
20
+
21
+ Official API documentation:
22
+ - OpenAPI specification: <https://bitcoinvn.io/api/doc.json>
23
+ - Exchange website: <https://bitcoinvn.io>
24
+
25
+ ---
26
+
27
+ ## Features
28
+
29
+ - 📊 **Public Market Data** — Tickers, real-time exchange rates, pair metadata, and system status (no API key required).
30
+ - 🔄 **Instant Swaps & Quotes** — Calculate competitive quotes for crypto-to-crypto and crypto-to-fiat trades.
31
+ - 📦 **Order Management** — Create orders with support for crypto wallets, Lightning Network invoices, destination tags, bank wires, and cash pickups.
32
+ - 💰 **Balances & History** — Inspect internal wallet balances, transaction ledgers, and attach deposit transaction IDs.
33
+ - 📈 **Staking Vaults** — Discover staking opportunities, toggle auto-staking, and adjust notification alerts.
34
+ - 🛡️ **Cryptographic Proofs** — Retrieve and verify BitcoinVN cryptographic guarantee letters and public keys.
35
+ - ⚡ **Resilient** — Context manager support (`with BitcoinVn(...) as client:`), type annotations, and rate-limit handling (`retry_after` header).
36
+
37
+ ---
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pip install bitcoinvn
43
+ ```
44
+
45
+ Requires Python 3.10 or higher.
46
+
47
+ ---
48
+
49
+ ## Quick Start (Safe Check)
50
+
51
+ The quick check queries the public market ticker for `BTC/USDT`. It does not require an API key and does not place orders or move funds.
52
+
53
+ ```python
54
+ import os
55
+ from bitcoinvn import BitcoinVn
56
+
57
+ # Anonymous client for public market queries (or pass api_key)
58
+ api_key = os.environ.get("BITCOINVN_API_KEY")
59
+
60
+ with BitcoinVn(api_key) as client:
61
+ ticker = client.get_ticker("BTC", "USDT")
62
+ print(f"Rate: {ticker['rate']}, 24h Volume: {ticker['volume24h']}")
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Usage Guide
68
+
69
+ ### 1. Authentication
70
+
71
+ Public read operations (health, info, pairs, ticker, address validation) work without a key.
72
+
73
+ For account-specific operations (viewing balances, order history, internal balance orders, staking), pass your API key:
74
+
75
+ ```python
76
+ from bitcoinvn import BitcoinVn
77
+
78
+ with BitcoinVn(api_key="your_api_key_here") as client:
79
+ balances = client.get_balances()
80
+ print(balances)
81
+ ```
82
+
83
+ API keys can be generated in your account dashboard on [bitcoinvn.io](https://bitcoinvn.io).
84
+
85
+ ### 2. Market Pairs and Quotes
86
+
87
+ Inspect supported trading pairs and request live price quotes:
88
+
89
+ ```python
90
+ from bitcoinvn import BitcoinVn
91
+
92
+ with BitcoinVn() as client:
93
+ # Fetch trading pair specifications and limits
94
+ pair = client.get_pair("btc", "usdt")
95
+ print(f"Min: {pair['minDeposit']}, Max: {pair['maxDeposit']}")
96
+
97
+ # Request an instant quote
98
+ quote = client.create_quote(
99
+ deposit_method="btc",
100
+ settle_method="usdt",
101
+ deposit_amount=0.05,
102
+ )
103
+ print(f"Expected settle amount: {quote['settleAmount']}")
104
+ ```
105
+
106
+ ### 3. Creating and Managing Orders
107
+
108
+ Create an exchange order with specific settlement details:
109
+
110
+ ```python
111
+ from bitcoinvn import BitcoinVn
112
+
113
+ with BitcoinVn(api_key=os.environ.get("BITCOINVN_API_KEY")) as client:
114
+ # Create an order swapping BTC for USDT
115
+ order = client.create_order(
116
+ deposit_method="btc",
117
+ settle_method="usdt",
118
+ settle_amount=1000,
119
+ settle_data={"address": "0xYourUsdtAddressHere..."},
120
+ )
121
+ print(f"Order created: {order['shortId']}")
122
+ print(f"Send BTC deposit to: {order['depositAddress']}")
123
+
124
+ # Check order status
125
+ status = client.get_order(order["shortId"])
126
+ print(f"Order status: {status['status']}")
127
+ ```
128
+
129
+ ### 4. Account Balances and History
130
+
131
+ Inspect your account's internal wallet balances and ledger transactions:
132
+
133
+ ```python
134
+ with BitcoinVn(api_key=os.environ["BITCOINVN_API_KEY"]) as client:
135
+ # List balances
136
+ balances = client.get_balances()
137
+ print(balances)
138
+
139
+ # List ledger history
140
+ history = client.list_balance_history(limit=10)
141
+ for entry in history:
142
+ print(f"{entry['createdAt']}: {entry['amount']} {entry['asset']}")
143
+ ```
144
+
145
+ ---
146
+
147
+ ## Error Handling
148
+
149
+ When the API returns a `4xx` or `5xx` error, the client raises a `BitcoinVnError` containing HTTP status code, API error message, and rate-limit backoff details:
150
+
151
+ ```python
152
+ from bitcoinvn import BitcoinVn, BitcoinVnError
153
+
154
+ with BitcoinVn() as client:
155
+ try:
156
+ client.get_ticker("INVALID", "PAIR")
157
+ except BitcoinVnError as err:
158
+ print(f"BitcoinVN error [{err.status_code}]: {err.message}")
159
+ if err.status_code == 429 and err.retry_after:
160
+ print(f"Rate limited. Retry after {err.retry_after} seconds.")
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Partner Referrer ID
166
+
167
+ In accordance with BitcoinVN's partner program, outgoing `POST /api/orders` requests automatically include the required referrer identifier in the payload.
168
+
169
+ ---
170
+
171
+ ## License
172
+
173
+ [ISC](LICENSE) © api-kit contributors
@@ -0,0 +1,161 @@
1
+ # bitcoinvn
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/bitcoinvn.svg)](https://pypi.org/project/bitcoinvn/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/bitcoinvn.svg)](https://pypi.org/project/bitcoinvn/)
5
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
6
+
7
+ Modern, typed Python client for the [BitcoinVN Exchange API](https://bitcoinvn.io/api/doc.json) — Vietnam's premier cryptocurrency exchange and instant swap platform. Built on [HTTPX](https://www.python-httpx.org).
8
+
9
+ Official API documentation:
10
+ - OpenAPI specification: <https://bitcoinvn.io/api/doc.json>
11
+ - Exchange website: <https://bitcoinvn.io>
12
+
13
+ ---
14
+
15
+ ## Features
16
+
17
+ - 📊 **Public Market Data** — Tickers, real-time exchange rates, pair metadata, and system status (no API key required).
18
+ - 🔄 **Instant Swaps & Quotes** — Calculate competitive quotes for crypto-to-crypto and crypto-to-fiat trades.
19
+ - 📦 **Order Management** — Create orders with support for crypto wallets, Lightning Network invoices, destination tags, bank wires, and cash pickups.
20
+ - 💰 **Balances & History** — Inspect internal wallet balances, transaction ledgers, and attach deposit transaction IDs.
21
+ - 📈 **Staking Vaults** — Discover staking opportunities, toggle auto-staking, and adjust notification alerts.
22
+ - 🛡️ **Cryptographic Proofs** — Retrieve and verify BitcoinVN cryptographic guarantee letters and public keys.
23
+ - ⚡ **Resilient** — Context manager support (`with BitcoinVn(...) as client:`), type annotations, and rate-limit handling (`retry_after` header).
24
+
25
+ ---
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pip install bitcoinvn
31
+ ```
32
+
33
+ Requires Python 3.10 or higher.
34
+
35
+ ---
36
+
37
+ ## Quick Start (Safe Check)
38
+
39
+ The quick check queries the public market ticker for `BTC/USDT`. It does not require an API key and does not place orders or move funds.
40
+
41
+ ```python
42
+ import os
43
+ from bitcoinvn import BitcoinVn
44
+
45
+ # Anonymous client for public market queries (or pass api_key)
46
+ api_key = os.environ.get("BITCOINVN_API_KEY")
47
+
48
+ with BitcoinVn(api_key) as client:
49
+ ticker = client.get_ticker("BTC", "USDT")
50
+ print(f"Rate: {ticker['rate']}, 24h Volume: {ticker['volume24h']}")
51
+ ```
52
+
53
+ ---
54
+
55
+ ## Usage Guide
56
+
57
+ ### 1. Authentication
58
+
59
+ Public read operations (health, info, pairs, ticker, address validation) work without a key.
60
+
61
+ For account-specific operations (viewing balances, order history, internal balance orders, staking), pass your API key:
62
+
63
+ ```python
64
+ from bitcoinvn import BitcoinVn
65
+
66
+ with BitcoinVn(api_key="your_api_key_here") as client:
67
+ balances = client.get_balances()
68
+ print(balances)
69
+ ```
70
+
71
+ API keys can be generated in your account dashboard on [bitcoinvn.io](https://bitcoinvn.io).
72
+
73
+ ### 2. Market Pairs and Quotes
74
+
75
+ Inspect supported trading pairs and request live price quotes:
76
+
77
+ ```python
78
+ from bitcoinvn import BitcoinVn
79
+
80
+ with BitcoinVn() as client:
81
+ # Fetch trading pair specifications and limits
82
+ pair = client.get_pair("btc", "usdt")
83
+ print(f"Min: {pair['minDeposit']}, Max: {pair['maxDeposit']}")
84
+
85
+ # Request an instant quote
86
+ quote = client.create_quote(
87
+ deposit_method="btc",
88
+ settle_method="usdt",
89
+ deposit_amount=0.05,
90
+ )
91
+ print(f"Expected settle amount: {quote['settleAmount']}")
92
+ ```
93
+
94
+ ### 3. Creating and Managing Orders
95
+
96
+ Create an exchange order with specific settlement details:
97
+
98
+ ```python
99
+ from bitcoinvn import BitcoinVn
100
+
101
+ with BitcoinVn(api_key=os.environ.get("BITCOINVN_API_KEY")) as client:
102
+ # Create an order swapping BTC for USDT
103
+ order = client.create_order(
104
+ deposit_method="btc",
105
+ settle_method="usdt",
106
+ settle_amount=1000,
107
+ settle_data={"address": "0xYourUsdtAddressHere..."},
108
+ )
109
+ print(f"Order created: {order['shortId']}")
110
+ print(f"Send BTC deposit to: {order['depositAddress']}")
111
+
112
+ # Check order status
113
+ status = client.get_order(order["shortId"])
114
+ print(f"Order status: {status['status']}")
115
+ ```
116
+
117
+ ### 4. Account Balances and History
118
+
119
+ Inspect your account's internal wallet balances and ledger transactions:
120
+
121
+ ```python
122
+ with BitcoinVn(api_key=os.environ["BITCOINVN_API_KEY"]) as client:
123
+ # List balances
124
+ balances = client.get_balances()
125
+ print(balances)
126
+
127
+ # List ledger history
128
+ history = client.list_balance_history(limit=10)
129
+ for entry in history:
130
+ print(f"{entry['createdAt']}: {entry['amount']} {entry['asset']}")
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Error Handling
136
+
137
+ When the API returns a `4xx` or `5xx` error, the client raises a `BitcoinVnError` containing HTTP status code, API error message, and rate-limit backoff details:
138
+
139
+ ```python
140
+ from bitcoinvn import BitcoinVn, BitcoinVnError
141
+
142
+ with BitcoinVn() as client:
143
+ try:
144
+ client.get_ticker("INVALID", "PAIR")
145
+ except BitcoinVnError as err:
146
+ print(f"BitcoinVN error [{err.status_code}]: {err.message}")
147
+ if err.status_code == 429 and err.retry_after:
148
+ print(f"Rate limited. Retry after {err.retry_after} seconds.")
149
+ ```
150
+
151
+ ---
152
+
153
+ ## Partner Referrer ID
154
+
155
+ In accordance with BitcoinVN's partner program, outgoing `POST /api/orders` requests automatically include the required referrer identifier in the payload.
156
+
157
+ ---
158
+
159
+ ## License
160
+
161
+ [ISC](LICENSE) © api-kit contributors
@@ -0,0 +1,16 @@
1
+ """Read a public ticker. Does not create an order."""
2
+
3
+ import os
4
+
5
+ from bitcoinvn import BitcoinVn
6
+
7
+
8
+ def main() -> None:
9
+ api_key = os.environ.get("BITCOINVN_API_KEY")
10
+ with BitcoinVn(api_key) as client:
11
+ ticker = client.get_ticker("BTC", "USDT")
12
+ print(ticker["rate"], ticker["volume24h"])
13
+
14
+
15
+ if __name__ == "__main__":
16
+ main()
@@ -0,0 +1,13 @@
1
+ loaders:
2
+ - type: python
3
+ search_path: [src]
4
+ processors:
5
+ - type: filter
6
+ documented_only: true
7
+ skip_empty_modules: true
8
+ - type: smart
9
+ - type: crossref
10
+ renderer:
11
+ type: markdown
12
+ filename: ../../docs/bitcoinvn/python/bitcoinvn.md
13
+ render_module_header: true
@@ -0,0 +1,43 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "bitcoinvn"
7
+ version = "0.1.0"
8
+ description = "Python client for the BitcoinVN exchange 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://bitcoinvn.io/api/doc.json"
19
+
20
+ [dependency-groups]
21
+ dev = [
22
+ "pytest>=8",
23
+ "pytest-httpx>=0.30",
24
+ "ruff>=0.8",
25
+ "pydoc-markdown>=4.8",
26
+ ]
27
+
28
+ [tool.hatch.build.targets.wheel]
29
+ packages = ["src/bitcoinvn"]
30
+
31
+ [tool.pytest.ini_options]
32
+ markers = [
33
+ "live: calls the real BitcoinVN API and needs BITCOINVN_API_KEY",
34
+ ]
35
+ testpaths = ["tests"]
36
+
37
+ [tool.ruff]
38
+ target-version = "py310"
39
+ line-length = 100
40
+ src = ["src", "tests", "examples"]
41
+
42
+ [tool.ruff.lint]
43
+ select = ["E", "F", "I", "UP"]
@@ -0,0 +1,57 @@
1
+ """Python client for the BitcoinVN exchange API.
2
+
3
+ The production base URL is https://bitcoinvn.io. Official OpenAPI:
4
+ https://bitcoinvn.io/api/doc.json
5
+
6
+ Public reads do not need a key. Account calls send ``X-API-KEY`` when
7
+ ``api_key`` is set. Order creation always includes the JSON field ``referrer``.
8
+
9
+ Examples:
10
+ from bitcoinvn import BitcoinVn
11
+
12
+ client = BitcoinVn()
13
+ ticker = client.get_ticker("BTC", "USDT")
14
+ """
15
+
16
+ from bitcoinvn.client import REFERRER, BitcoinVn
17
+ from bitcoinvn.errors import BitcoinVnError
18
+ from bitcoinvn.types import (
19
+ AddressValidation,
20
+ Asset,
21
+ Balances,
22
+ BooleanConfiguration,
23
+ EnsResolution,
24
+ HealthStatus,
25
+ Info,
26
+ LedgerItem,
27
+ Order,
28
+ OrderStatus,
29
+ Pair,
30
+ Quote,
31
+ Ticker,
32
+ TransferMethod,
33
+ Vault,
34
+ )
35
+
36
+ __all__ = [
37
+ "REFERRER",
38
+ "AddressValidation",
39
+ "Asset",
40
+ "Balances",
41
+ "BitcoinVn",
42
+ "BitcoinVnError",
43
+ "BooleanConfiguration",
44
+ "EnsResolution",
45
+ "HealthStatus",
46
+ "Info",
47
+ "LedgerItem",
48
+ "Order",
49
+ "OrderStatus",
50
+ "Pair",
51
+ "Quote",
52
+ "Ticker",
53
+ "TransferMethod",
54
+ "Vault",
55
+ ]
56
+
57
+ __version__ = "0.1.0"