fixedfloat-client 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,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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 TysikGG
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,218 @@
1
+ Metadata-Version: 2.5
2
+ Name: fixedfloat-client
3
+ Version: 0.1.0
4
+ Summary: Python client for the FixedFloat cryptocurrency exchange API v2
5
+ Project-URL: Repository, https://github.com/TysikGG/api-kit
6
+ Project-URL: Documentation, https://fixedfloat.com/api
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Requires-Python: >=3.10
10
+ Requires-Dist: httpx>=0.27
11
+ Description-Content-Type: text/markdown
12
+
13
+ # fixedfloat-client
14
+
15
+ [![PyPI version](https://img.shields.io/pypi/v/fixedfloat-client.svg)](https://pypi.org/project/fixedfloat-client/)
16
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
17
+ [![Python Version](https://img.shields.io/pypi/pyversions/fixedfloat-client.svg)](https://pypi.org/project/fixedfloat-client/)
18
+
19
+ Modern, fully typed Python client library for the [FixedFloat](https://fixedfloat.com/api) cryptocurrency exchange REST API v2.
20
+
21
+ Official API documentation: <https://fixedfloat.com/api>
22
+
23
+ ---
24
+
25
+ ## Features
26
+
27
+ - ⚡ **Fixed & Float Exchange Rates** — Choose between guaranteed fixed rates (1% fee) and floating market rates (0.5% fee).
28
+ - 🔐 **Automatic Request Signing** — Cryptographic HMAC-SHA256 signature generation (`X-API-KEY` & `X-API-SIGN`) built-in.
29
+ - 🪙 **Multi-Currency Support** — Trade Bitcoin, Ethereum, USDT, Solana, Monero, and dozens of other coins across multiple blockchains.
30
+ - 🐍 **Modern Pythonic Design** — Type annotations, dataclass models (`Order`, `PriceResult`, `Currency`), context manager support (`with FixedFloat(...) as client:`), and custom exceptions.
31
+ - 🚨 **Emergency Handling** — Support for emergency resolution actions (`EXCHANGE` or `REFUND`) on interrupted orders.
32
+
33
+ ---
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ pip install fixedfloat-client
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 price quotes. It does not create orders or spend funds:
48
+
49
+ ```python
50
+ import os
51
+ from fixedfloat import FixedFloat
52
+
53
+ with FixedFloat(
54
+ api_key=os.environ.get("FIXEDFLOAT_API_KEY"),
55
+ api_secret=os.environ.get("FIXEDFLOAT_API_SECRET"),
56
+ ) as client:
57
+ # 1. Fetch available currencies
58
+ currencies = client.get_currencies()
59
+ print(f"Available currencies: {len(currencies)}")
60
+
61
+ # 2. Query price calculation for 0.1 BTC to ETH
62
+ price = client.get_price(
63
+ from_ccy="BTC",
64
+ to_ccy="ETH",
65
+ amount=0.1,
66
+ direction="from",
67
+ order_type="float",
68
+ )
69
+ print(f"0.1 BTC -> {price.to_side.amount} ETH (Rate: {price.to_side.rate})")
70
+ ```
71
+
72
+ ---
73
+
74
+ ## Usage Guide
75
+
76
+ ### 1. Creating a Floating Rate Order
77
+
78
+ Create an exchange order with a floating rate, deposit instructions, and receive destination address:
79
+
80
+ ```python
81
+ from fixedfloat import FixedFloat, FixedFloatError
82
+
83
+ with FixedFloat(
84
+ api_key="your_api_key",
85
+ api_secret="your_api_secret",
86
+ ) as client:
87
+ # Create float order
88
+ order = client.create_order(
89
+ from_ccy="BTC",
90
+ to_ccy="ETH",
91
+ amount=0.1,
92
+ direction="from",
93
+ order_type="float",
94
+ to_address="0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
95
+ refund_address="bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh", # optional
96
+ )
97
+
98
+ print(f"Order Created! ID: {order.id}")
99
+ print(f"Security Token: {order.token}")
100
+ print(f"Send BTC to: {order.from_side.address}")
101
+ print(f"Order Status: {order.status}")
102
+ ```
103
+
104
+ ### 2. Creating a Fixed Rate Order
105
+
106
+ Lock in a guaranteed rate for 10 minutes:
107
+
108
+ ```python
109
+ fixed_order = client.create_order(
110
+ from_ccy="ETH",
111
+ to_ccy="BTC",
112
+ amount=2.5,
113
+ direction="from",
114
+ order_type="fixed",
115
+ to_address="bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
116
+ )
117
+
118
+ print(f"Fixed Order ID: {fixed_order.id}")
119
+ print(f"Expected Payout: {fixed_order.to_side.amount} BTC")
120
+ print(f"Send ETH to: {fixed_order.from_side.address}")
121
+ ```
122
+
123
+ ### 3. Tracking Order Status & QR Codes
124
+
125
+ Check order execution, transaction confirmations, and fetch QR codes:
126
+
127
+ ```python
128
+ # Query status using order ID and secret token
129
+ current = client.get_order(order.id, order.token)
130
+ print(f"Status: {current.status}")
131
+
132
+ if current.from_side.tx:
133
+ print(f"Deposit confirmations: {current.from_side.tx.confirmations}")
134
+
135
+ # Fetch QR code for deposit address
136
+ qr = client.get_qr(order.id, order.token)
137
+ print(f"Deposit QR code: {qr.src}")
138
+
139
+ # Attach email address for status notifications
140
+ client.set_email(order.id, order.token, "user@example.com")
141
+ ```
142
+
143
+ ### 4. Setting Emergency Action Choice
144
+
145
+ If an order requires user decision (e.g. rate shifted or deposit was delayed):
146
+
147
+ ```python
148
+ # Choose to execute exchange at current market rate or refund
149
+ client.set_emergency(
150
+ id=order.id,
151
+ token=order.token,
152
+ choice="REFUND",
153
+ address="bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
154
+ )
155
+ print("Emergency action submitted.")
156
+ ```
157
+
158
+ ---
159
+
160
+ ## API Reference
161
+
162
+ ### `FixedFloat` Class
163
+
164
+ #### Constructor
165
+
166
+ ```python
167
+ FixedFloat(
168
+ api_key: Optional[str] = None,
169
+ api_secret: Optional[str] = None,
170
+ base_url: str = "https://ff.io/api/v2",
171
+ timeout: float = 15.0,
172
+ )
173
+ ```
174
+
175
+ | Parameter | Type | Default | Description |
176
+ | :--- | :--- | :--- | :--- |
177
+ | `api_key` | `str` | `None` | Your FixedFloat API key. |
178
+ | `api_secret` | `str` | `None` | Your FixedFloat API secret for HMAC signatures. |
179
+ | `base_url` | `str` | `"https://ff.io/api/v2"` | FixedFloat API v2 base URL. |
180
+ | `timeout` | `float` | `15.0` | HTTP request timeout in seconds. |
181
+
182
+ #### Methods
183
+
184
+ - **`get_currencies() -> list[Currency]`** — Retrieves all supported cryptocurrencies and networks.
185
+ - **`get_price(from_ccy, to_ccy, amount, direction="from", order_type="float", ...) -> PriceResult`** — Price estimates, rates, limits.
186
+ - **`create_order(from_ccy, to_ccy, amount, to_address, direction="from", order_type="float", ...) -> Order`** — Creates a new order.
187
+ - **`get_order(id: str, token: str) -> Order`** — Retrieves order status and transaction info.
188
+ - **`set_emergency(id, token, choice, address=None, extra_id=None) -> Any`** — Sets emergency choice (`EXCHANGE` or `REFUND`).
189
+ - **`set_email(id, token, email) -> Any`** — Sets email address for order notifications.
190
+ - **`get_qr(id, token) -> QrResult`** — Retrieves deposit address QR code.
191
+
192
+ ---
193
+
194
+ ## Error Handling
195
+
196
+ When the FixedFloat API returns an error or non-zero status code, a `FixedFloatError` is raised:
197
+
198
+ ```python
199
+ from fixedfloat import FixedFloat, FixedFloatError
200
+
201
+ try:
202
+ with FixedFloat() as client:
203
+ client.get_order("INVALID_ID", "INVALID_TOKEN")
204
+ except FixedFloatError as exc:
205
+ print(f"FixedFloat Error: {exc.message} (Code: {exc.code})")
206
+ ```
207
+
208
+ Common error codes:
209
+ - `101` — Invalid currency pair or amount out of limits.
210
+ - `102` — Missing required parameter.
211
+ - `103` — Invalid destination wallet address.
212
+ - `401` — Unauthorized: invalid API key or signature.
213
+
214
+ ---
215
+
216
+ ## License
217
+
218
+ MIT
@@ -0,0 +1,206 @@
1
+ # fixedfloat-client
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/fixedfloat-client.svg)](https://pypi.org/project/fixedfloat-client/)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
5
+ [![Python Version](https://img.shields.io/pypi/pyversions/fixedfloat-client.svg)](https://pypi.org/project/fixedfloat-client/)
6
+
7
+ Modern, fully typed Python client library for the [FixedFloat](https://fixedfloat.com/api) cryptocurrency exchange REST API v2.
8
+
9
+ Official API documentation: <https://fixedfloat.com/api>
10
+
11
+ ---
12
+
13
+ ## Features
14
+
15
+ - ⚡ **Fixed & Float Exchange Rates** — Choose between guaranteed fixed rates (1% fee) and floating market rates (0.5% fee).
16
+ - 🔐 **Automatic Request Signing** — Cryptographic HMAC-SHA256 signature generation (`X-API-KEY` & `X-API-SIGN`) built-in.
17
+ - 🪙 **Multi-Currency Support** — Trade Bitcoin, Ethereum, USDT, Solana, Monero, and dozens of other coins across multiple blockchains.
18
+ - 🐍 **Modern Pythonic Design** — Type annotations, dataclass models (`Order`, `PriceResult`, `Currency`), context manager support (`with FixedFloat(...) as client:`), and custom exceptions.
19
+ - 🚨 **Emergency Handling** — Support for emergency resolution actions (`EXCHANGE` or `REFUND`) on interrupted orders.
20
+
21
+ ---
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ pip install fixedfloat-client
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 price quotes. It does not create orders or spend funds:
36
+
37
+ ```python
38
+ import os
39
+ from fixedfloat import FixedFloat
40
+
41
+ with FixedFloat(
42
+ api_key=os.environ.get("FIXEDFLOAT_API_KEY"),
43
+ api_secret=os.environ.get("FIXEDFLOAT_API_SECRET"),
44
+ ) as client:
45
+ # 1. Fetch available currencies
46
+ currencies = client.get_currencies()
47
+ print(f"Available currencies: {len(currencies)}")
48
+
49
+ # 2. Query price calculation for 0.1 BTC to ETH
50
+ price = client.get_price(
51
+ from_ccy="BTC",
52
+ to_ccy="ETH",
53
+ amount=0.1,
54
+ direction="from",
55
+ order_type="float",
56
+ )
57
+ print(f"0.1 BTC -> {price.to_side.amount} ETH (Rate: {price.to_side.rate})")
58
+ ```
59
+
60
+ ---
61
+
62
+ ## Usage Guide
63
+
64
+ ### 1. Creating a Floating Rate Order
65
+
66
+ Create an exchange order with a floating rate, deposit instructions, and receive destination address:
67
+
68
+ ```python
69
+ from fixedfloat import FixedFloat, FixedFloatError
70
+
71
+ with FixedFloat(
72
+ api_key="your_api_key",
73
+ api_secret="your_api_secret",
74
+ ) as client:
75
+ # Create float order
76
+ order = client.create_order(
77
+ from_ccy="BTC",
78
+ to_ccy="ETH",
79
+ amount=0.1,
80
+ direction="from",
81
+ order_type="float",
82
+ to_address="0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
83
+ refund_address="bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh", # optional
84
+ )
85
+
86
+ print(f"Order Created! ID: {order.id}")
87
+ print(f"Security Token: {order.token}")
88
+ print(f"Send BTC to: {order.from_side.address}")
89
+ print(f"Order Status: {order.status}")
90
+ ```
91
+
92
+ ### 2. Creating a Fixed Rate Order
93
+
94
+ Lock in a guaranteed rate for 10 minutes:
95
+
96
+ ```python
97
+ fixed_order = client.create_order(
98
+ from_ccy="ETH",
99
+ to_ccy="BTC",
100
+ amount=2.5,
101
+ direction="from",
102
+ order_type="fixed",
103
+ to_address="bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
104
+ )
105
+
106
+ print(f"Fixed Order ID: {fixed_order.id}")
107
+ print(f"Expected Payout: {fixed_order.to_side.amount} BTC")
108
+ print(f"Send ETH to: {fixed_order.from_side.address}")
109
+ ```
110
+
111
+ ### 3. Tracking Order Status & QR Codes
112
+
113
+ Check order execution, transaction confirmations, and fetch QR codes:
114
+
115
+ ```python
116
+ # Query status using order ID and secret token
117
+ current = client.get_order(order.id, order.token)
118
+ print(f"Status: {current.status}")
119
+
120
+ if current.from_side.tx:
121
+ print(f"Deposit confirmations: {current.from_side.tx.confirmations}")
122
+
123
+ # Fetch QR code for deposit address
124
+ qr = client.get_qr(order.id, order.token)
125
+ print(f"Deposit QR code: {qr.src}")
126
+
127
+ # Attach email address for status notifications
128
+ client.set_email(order.id, order.token, "user@example.com")
129
+ ```
130
+
131
+ ### 4. Setting Emergency Action Choice
132
+
133
+ If an order requires user decision (e.g. rate shifted or deposit was delayed):
134
+
135
+ ```python
136
+ # Choose to execute exchange at current market rate or refund
137
+ client.set_emergency(
138
+ id=order.id,
139
+ token=order.token,
140
+ choice="REFUND",
141
+ address="bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
142
+ )
143
+ print("Emergency action submitted.")
144
+ ```
145
+
146
+ ---
147
+
148
+ ## API Reference
149
+
150
+ ### `FixedFloat` Class
151
+
152
+ #### Constructor
153
+
154
+ ```python
155
+ FixedFloat(
156
+ api_key: Optional[str] = None,
157
+ api_secret: Optional[str] = None,
158
+ base_url: str = "https://ff.io/api/v2",
159
+ timeout: float = 15.0,
160
+ )
161
+ ```
162
+
163
+ | Parameter | Type | Default | Description |
164
+ | :--- | :--- | :--- | :--- |
165
+ | `api_key` | `str` | `None` | Your FixedFloat API key. |
166
+ | `api_secret` | `str` | `None` | Your FixedFloat API secret for HMAC signatures. |
167
+ | `base_url` | `str` | `"https://ff.io/api/v2"` | FixedFloat API v2 base URL. |
168
+ | `timeout` | `float` | `15.0` | HTTP request timeout in seconds. |
169
+
170
+ #### Methods
171
+
172
+ - **`get_currencies() -> list[Currency]`** — Retrieves all supported cryptocurrencies and networks.
173
+ - **`get_price(from_ccy, to_ccy, amount, direction="from", order_type="float", ...) -> PriceResult`** — Price estimates, rates, limits.
174
+ - **`create_order(from_ccy, to_ccy, amount, to_address, direction="from", order_type="float", ...) -> Order`** — Creates a new order.
175
+ - **`get_order(id: str, token: str) -> Order`** — Retrieves order status and transaction info.
176
+ - **`set_emergency(id, token, choice, address=None, extra_id=None) -> Any`** — Sets emergency choice (`EXCHANGE` or `REFUND`).
177
+ - **`set_email(id, token, email) -> Any`** — Sets email address for order notifications.
178
+ - **`get_qr(id, token) -> QrResult`** — Retrieves deposit address QR code.
179
+
180
+ ---
181
+
182
+ ## Error Handling
183
+
184
+ When the FixedFloat API returns an error or non-zero status code, a `FixedFloatError` is raised:
185
+
186
+ ```python
187
+ from fixedfloat import FixedFloat, FixedFloatError
188
+
189
+ try:
190
+ with FixedFloat() as client:
191
+ client.get_order("INVALID_ID", "INVALID_TOKEN")
192
+ except FixedFloatError as exc:
193
+ print(f"FixedFloat Error: {exc.message} (Code: {exc.code})")
194
+ ```
195
+
196
+ Common error codes:
197
+ - `101` — Invalid currency pair or amount out of limits.
198
+ - `102` — Missing required parameter.
199
+ - `103` — Invalid destination wallet address.
200
+ - `401` — Unauthorized: invalid API key or signature.
201
+
202
+ ---
203
+
204
+ ## License
205
+
206
+ MIT
@@ -0,0 +1,35 @@
1
+ """Example checking FixedFloat currencies and price without spending balance."""
2
+
3
+ import os
4
+
5
+ from fixedfloat import FixedFloat
6
+
7
+
8
+ def main() -> None:
9
+ api_key = os.getenv("FIXEDFLOAT_API_KEY")
10
+ api_secret = os.getenv("FIXEDFLOAT_API_SECRET")
11
+
12
+ with FixedFloat(api_key=api_key, api_secret=api_secret) as client:
13
+ print("Fetching currencies from FixedFloat...")
14
+ currencies = client.get_currencies()
15
+ print(f"Success! Found {len(currencies)} currencies.")
16
+
17
+ btc = next((c for c in currencies if c.code == "BTC"), None)
18
+ eth = next((c for c in currencies if c.code == "ETH"), None)
19
+ if btc and eth:
20
+ print(f"BTC: {btc.name} (network: {btc.network})")
21
+ print(f"ETH: {eth.name} (network: {eth.network})")
22
+
23
+ print("\nChecking exchange rate for BTC to ETH...")
24
+ price = client.get_price(
25
+ from_ccy="BTC",
26
+ to_ccy="ETH",
27
+ amount=0.1,
28
+ direction="from",
29
+ order_type="float",
30
+ )
31
+ print(f"0.1 BTC -> {price.to_side.amount} ETH (Rate: {price.to_side.rate})")
32
+
33
+
34
+ if __name__ == "__main__":
35
+ main()
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "fixedfloat-client"
7
+ version = "0.1.0"
8
+ description = "Python client for the FixedFloat cryptocurrency exchange API v2"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ dependencies = [
13
+ "httpx>=0.27",
14
+ ]
15
+
16
+ [project.urls]
17
+ Repository = "https://github.com/TysikGG/api-kit"
18
+ Documentation = "https://fixedfloat.com/api"
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/fixedfloat"]
29
+
30
+ [tool.pytest.ini_options]
31
+ markers = [
32
+ "live: calls the real FixedFloat API",
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,34 @@
1
+ """FixedFloat API v2 client library."""
2
+
3
+ from .client import DEFAULT_REFCODE, FixedFloat
4
+ from .errors import FixedFloatError
5
+ from .types import (
6
+ Currency,
7
+ EmergencyChoice,
8
+ ExchangeDirection,
9
+ Order,
10
+ OrderSide,
11
+ OrderTime,
12
+ OrderTx,
13
+ OrderType,
14
+ PriceResult,
15
+ PriceSide,
16
+ QrResult,
17
+ )
18
+
19
+ __all__ = [
20
+ "DEFAULT_REFCODE",
21
+ "Currency",
22
+ "EmergencyChoice",
23
+ "ExchangeDirection",
24
+ "FixedFloat",
25
+ "FixedFloatError",
26
+ "Order",
27
+ "OrderSide",
28
+ "OrderTime",
29
+ "OrderTx",
30
+ "OrderType",
31
+ "PriceResult",
32
+ "PriceSide",
33
+ "QrResult",
34
+ ]