exir-py-lib 1.0.1__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.
- exir_py_lib-1.0.1/LICENSE +21 -0
- exir_py_lib-1.0.1/MANIFEST.in +6 -0
- exir_py_lib-1.0.1/PKG-INFO +108 -0
- exir_py_lib-1.0.1/README.md +73 -0
- exir_py_lib-1.0.1/example/balance.py +48 -0
- exir_py_lib-1.0.1/example/order.py +42 -0
- exir_py_lib-1.0.1/example/public.py +40 -0
- exir_py_lib-1.0.1/example/ws.py +65 -0
- exir_py_lib-1.0.1/exir_py_lib.egg-info/PKG-INFO +108 -0
- exir_py_lib-1.0.1/exir_py_lib.egg-info/SOURCES.txt +14 -0
- exir_py_lib-1.0.1/exir_py_lib.egg-info/dependency_links.txt +1 -0
- exir_py_lib-1.0.1/exir_py_lib.egg-info/requires.txt +9 -0
- exir_py_lib-1.0.1/exir_py_lib.egg-info/top_level.txt +1 -0
- exir_py_lib-1.0.1/pyproject.toml +66 -0
- exir_py_lib-1.0.1/requirements.txt +2 -0
- exir_py_lib-1.0.1/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 EXIR Team
|
|
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,108 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: exir-py-lib
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Python client library for EXIR cryptocurrency exchange API
|
|
5
|
+
Author-email: EXIR Team <support@exir.io>
|
|
6
|
+
Maintainer-email: EXIR Team <support@exir.io>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://gitlab.com/exirorg/exir-py-lib
|
|
9
|
+
Project-URL: Documentation, https://gitlab.com/exirorg/exir-py-lib#readme
|
|
10
|
+
Project-URL: Repository, https://gitlab.com/exirorg/exir-py-lib.git
|
|
11
|
+
Keywords: cryptocurrency,trading,exchange,api,websocket,exir
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.8
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: requests<3,>=2.28
|
|
27
|
+
Requires-Dist: websocket-client<2,>=1.6
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
31
|
+
Requires-Dist: black; extra == "dev"
|
|
32
|
+
Requires-Dist: flake8; extra == "dev"
|
|
33
|
+
Requires-Dist: mypy; extra == "dev"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
## EXIR Python Client - Examples
|
|
37
|
+
|
|
38
|
+
This repository contains a lightweight Python client in `index.py` and runnable examples under `example/` for:
|
|
39
|
+
- **Public**: Fetching market data (e.g., ticker)
|
|
40
|
+
- **Private**: Authenticated calls (user, balance, place orders)
|
|
41
|
+
- **WebSocket**: Streaming market data (orderbook)
|
|
42
|
+
|
|
43
|
+
### Requirements
|
|
44
|
+
- Python 3.8+
|
|
45
|
+
- Install dependencies:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
python3 -m pip install -r requirements.txt
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Project layout
|
|
52
|
+
- `index.py`: EXIR client (public, private, and WebSocket helpers)
|
|
53
|
+
- `utils.py`: HTTP and auth utilities
|
|
54
|
+
- `example/public.py`: Public ticker example
|
|
55
|
+
- `example/balance.py`: Private user + balance example
|
|
56
|
+
- `example/order.py`: Private create order example
|
|
57
|
+
- `example/websocket.py`: WebSocket orderbook subscription example
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Public usage
|
|
62
|
+
|
|
63
|
+
Fetch the ticker for `btc-usdt`:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
python3 example/public.py
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Example:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
python3 example/public.py
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Private usage (user, balance)
|
|
78
|
+
|
|
79
|
+
Set your api keys:
|
|
80
|
+
```bash
|
|
81
|
+
EXIR_API_KEY=<your-api-key> \
|
|
82
|
+
EXIR_API_SECRET=<your-api-secret> \
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Notes:
|
|
86
|
+
- Ensure your key has the required permissions (e.g., trading, read balance).
|
|
87
|
+
- If IP whitelisting is enabled on the key, include your current IP.
|
|
88
|
+
- Your system clock must be accurate; auth uses expiring signatures.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Private usage (create order)
|
|
93
|
+
|
|
94
|
+
Places a limit BUY order for 0.001 BTC at 50,000 USDT on `btc-usdt`:
|
|
95
|
+
|
|
96
|
+
If you receive `401 Unauthorized` when creating orders:
|
|
97
|
+
- Check key permissions and IP whitelist
|
|
98
|
+
- Ensure your system clock is in sync
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## WebSocket usage (orderbook)
|
|
103
|
+
|
|
104
|
+
Subscribes to `orderbook:btc-usdt` and logs messages for ~10 seconds:
|
|
105
|
+
|
|
106
|
+
Notes:
|
|
107
|
+
- Public WS channels (e.g., `orderbook`, `trade`) do not require credentials, but the script will include them if provided.
|
|
108
|
+
- The client automatically reconnects by default.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
## EXIR Python Client - Examples
|
|
2
|
+
|
|
3
|
+
This repository contains a lightweight Python client in `index.py` and runnable examples under `example/` for:
|
|
4
|
+
- **Public**: Fetching market data (e.g., ticker)
|
|
5
|
+
- **Private**: Authenticated calls (user, balance, place orders)
|
|
6
|
+
- **WebSocket**: Streaming market data (orderbook)
|
|
7
|
+
|
|
8
|
+
### Requirements
|
|
9
|
+
- Python 3.8+
|
|
10
|
+
- Install dependencies:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
python3 -m pip install -r requirements.txt
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Project layout
|
|
17
|
+
- `index.py`: EXIR client (public, private, and WebSocket helpers)
|
|
18
|
+
- `utils.py`: HTTP and auth utilities
|
|
19
|
+
- `example/public.py`: Public ticker example
|
|
20
|
+
- `example/balance.py`: Private user + balance example
|
|
21
|
+
- `example/order.py`: Private create order example
|
|
22
|
+
- `example/websocket.py`: WebSocket orderbook subscription example
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Public usage
|
|
27
|
+
|
|
28
|
+
Fetch the ticker for `btc-usdt`:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
python3 example/public.py
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Example:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
python3 example/public.py
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Private usage (user, balance)
|
|
43
|
+
|
|
44
|
+
Set your api keys:
|
|
45
|
+
```bash
|
|
46
|
+
EXIR_API_KEY=<your-api-key> \
|
|
47
|
+
EXIR_API_SECRET=<your-api-secret> \
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Notes:
|
|
51
|
+
- Ensure your key has the required permissions (e.g., trading, read balance).
|
|
52
|
+
- If IP whitelisting is enabled on the key, include your current IP.
|
|
53
|
+
- Your system clock must be accurate; auth uses expiring signatures.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Private usage (create order)
|
|
58
|
+
|
|
59
|
+
Places a limit BUY order for 0.001 BTC at 50,000 USDT on `btc-usdt`:
|
|
60
|
+
|
|
61
|
+
If you receive `401 Unauthorized` when creating orders:
|
|
62
|
+
- Check key permissions and IP whitelist
|
|
63
|
+
- Ensure your system clock is in sync
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## WebSocket usage (orderbook)
|
|
68
|
+
|
|
69
|
+
Subscribes to `orderbook:btc-usdt` and logs messages for ~10 seconds:
|
|
70
|
+
|
|
71
|
+
Notes:
|
|
72
|
+
- Public WS channels (e.g., `orderbook`, `trade`) do not require credentials, but the script will include them if provided.
|
|
73
|
+
- The client automatically reconnects by default.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
import types
|
|
6
|
+
import importlib
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _prepare_local_package():
|
|
10
|
+
repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
11
|
+
package_name = "exir"
|
|
12
|
+
|
|
13
|
+
if package_name not in sys.modules:
|
|
14
|
+
pkg = types.ModuleType(package_name)
|
|
15
|
+
pkg.__path__ = [repo_root]
|
|
16
|
+
sys.modules[package_name] = pkg
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def main():
|
|
20
|
+
_prepare_local_package()
|
|
21
|
+
|
|
22
|
+
EXIR = importlib.import_module("exir.index").EXIR # type: ignore[attr-defined]
|
|
23
|
+
|
|
24
|
+
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
|
|
25
|
+
|
|
26
|
+
# Initialize with API credentials (replace with yours or env vars)
|
|
27
|
+
api_key = os.getenv("EXIR_API_KEY", "<your-api-key>")
|
|
28
|
+
api_secret = os.getenv("EXIR_API_SECRET", "<your-api-secret>")
|
|
29
|
+
|
|
30
|
+
client = EXIR(api_url=api_url, api_key=api_key, api_secret=api_secret)
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
user = client.get_user()
|
|
34
|
+
logging.info("User response:\n%s", json.dumps(user, indent=2))
|
|
35
|
+
except Exception as exc:
|
|
36
|
+
logging.exception("Failed to fetch user: %s", exc)
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
balance = client.get_balance()
|
|
40
|
+
logging.info("Balance response:\n%s", json.dumps(balance, indent=2))
|
|
41
|
+
except Exception as exc:
|
|
42
|
+
logging.exception("Failed to fetch balance: %s", exc)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if __name__ == "__main__":
|
|
46
|
+
main()
|
|
47
|
+
|
|
48
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
import types
|
|
6
|
+
import importlib
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _prepare_local_package():
|
|
10
|
+
repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
11
|
+
package_name = "exir"
|
|
12
|
+
|
|
13
|
+
if package_name not in sys.modules:
|
|
14
|
+
pkg = types.ModuleType(package_name)
|
|
15
|
+
pkg.__path__ = [repo_root]
|
|
16
|
+
sys.modules[package_name] = pkg
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def main():
|
|
20
|
+
_prepare_local_package()
|
|
21
|
+
|
|
22
|
+
EXIR = importlib.import_module("exir.index").EXIR # type: ignore[attr-defined]
|
|
23
|
+
|
|
24
|
+
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
|
|
25
|
+
|
|
26
|
+
api_key = os.getenv("EXIR_API_KEY", "<your-api-key>")
|
|
27
|
+
api_secret = os.getenv("EXIR_API_SECRET", "<your-api-secret>")
|
|
28
|
+
|
|
29
|
+
client = EXIR(api_url=api_url, api_key=api_key, api_secret=api_secret)
|
|
30
|
+
|
|
31
|
+
symbol = "btc-usdt"
|
|
32
|
+
try:
|
|
33
|
+
order = client.create_order(symbol=symbol, side="buy", size=0.001, type="limit", price=50000)
|
|
34
|
+
logging.info("Create order response:\n%s", json.dumps(order, indent=2))
|
|
35
|
+
except Exception as exc:
|
|
36
|
+
logging.exception("Failed to create order: %s", exc)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
if __name__ == "__main__":
|
|
40
|
+
main()
|
|
41
|
+
|
|
42
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
import types
|
|
6
|
+
import importlib
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _prepare_local_package():
|
|
10
|
+
repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
11
|
+
package_name = "exir"
|
|
12
|
+
|
|
13
|
+
if package_name not in sys.modules:
|
|
14
|
+
pkg = types.ModuleType(package_name)
|
|
15
|
+
pkg.__path__ = [repo_root]
|
|
16
|
+
sys.modules[package_name] = pkg
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def main():
|
|
20
|
+
_prepare_local_package()
|
|
21
|
+
|
|
22
|
+
# Import from the local package so relative imports inside index.py work
|
|
23
|
+
EXIR = importlib.import_module("exir.index").EXIR # type: ignore[attr-defined]
|
|
24
|
+
|
|
25
|
+
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
|
|
26
|
+
|
|
27
|
+
client = EXIR()
|
|
28
|
+
|
|
29
|
+
symbol = "btc-irt"
|
|
30
|
+
logging.info("Requesting ticker for symbol=%s", symbol)
|
|
31
|
+
try:
|
|
32
|
+
ticker = client.get_ticker(symbol=symbol)
|
|
33
|
+
logging.info("Ticker response:\n%s", json.dumps(ticker, indent=2))
|
|
34
|
+
except Exception as exc:
|
|
35
|
+
logging.exception("Failed to fetch ticker: %s", exc)
|
|
36
|
+
|
|
37
|
+
if __name__ == "__main__":
|
|
38
|
+
main()
|
|
39
|
+
|
|
40
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
import types
|
|
6
|
+
import importlib
|
|
7
|
+
import time
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _prepare_local_package():
|
|
11
|
+
repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
12
|
+
package_name = "exir"
|
|
13
|
+
|
|
14
|
+
if package_name not in sys.modules:
|
|
15
|
+
pkg = types.ModuleType(package_name)
|
|
16
|
+
pkg.__path__ = [repo_root]
|
|
17
|
+
sys.modules[package_name] = pkg
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def main():
|
|
21
|
+
_prepare_local_package()
|
|
22
|
+
|
|
23
|
+
EXIR = importlib.import_module("exir.index").EXIR # type: ignore[attr-defined]
|
|
24
|
+
|
|
25
|
+
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
|
|
26
|
+
|
|
27
|
+
api_key = os.getenv("EXIR_API_KEY", "<your-api-key>")
|
|
28
|
+
api_secret = os.getenv("EXIR_API_SECRET", "<your-api-secret>")
|
|
29
|
+
|
|
30
|
+
client = EXIR(api_url=api_url, api_key=api_key, api_secret=api_secret, ws_url=ws_url)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
symbol = "btc-usdt"
|
|
34
|
+
|
|
35
|
+
def on_message(message: str):
|
|
36
|
+
try:
|
|
37
|
+
payload = json.loads(message)
|
|
38
|
+
except Exception:
|
|
39
|
+
payload = message
|
|
40
|
+
logging.info("WS message: %s", payload if isinstance(payload, dict) else str(payload)[:500])
|
|
41
|
+
|
|
42
|
+
def on_error(error):
|
|
43
|
+
logging.error("WS error: %s", error)
|
|
44
|
+
|
|
45
|
+
def on_close(status_code, msg):
|
|
46
|
+
logging.info("WS closed: code=%s msg=%s", status_code, msg)
|
|
47
|
+
|
|
48
|
+
try:
|
|
49
|
+
logging.info("Connecting WebSocket and subscribing to orderbook:%s", symbol)
|
|
50
|
+
client.connect(events=[f"order"], on_message=on_message, on_error=on_error, on_close=on_close)
|
|
51
|
+
logging.info("Listening for orderbook updates for 10 seconds...")
|
|
52
|
+
time.sleep(10)
|
|
53
|
+
except Exception as exc:
|
|
54
|
+
logging.exception("WebSocket error: %s", exc)
|
|
55
|
+
finally:
|
|
56
|
+
try:
|
|
57
|
+
client.disconnect()
|
|
58
|
+
except Exception:
|
|
59
|
+
pass
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
if __name__ == "__main__":
|
|
63
|
+
main()
|
|
64
|
+
|
|
65
|
+
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: exir-py-lib
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Python client library for EXIR cryptocurrency exchange API
|
|
5
|
+
Author-email: EXIR Team <support@exir.io>
|
|
6
|
+
Maintainer-email: EXIR Team <support@exir.io>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://gitlab.com/exirorg/exir-py-lib
|
|
9
|
+
Project-URL: Documentation, https://gitlab.com/exirorg/exir-py-lib#readme
|
|
10
|
+
Project-URL: Repository, https://gitlab.com/exirorg/exir-py-lib.git
|
|
11
|
+
Keywords: cryptocurrency,trading,exchange,api,websocket,exir
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.8
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: requests<3,>=2.28
|
|
27
|
+
Requires-Dist: websocket-client<2,>=1.6
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
31
|
+
Requires-Dist: black; extra == "dev"
|
|
32
|
+
Requires-Dist: flake8; extra == "dev"
|
|
33
|
+
Requires-Dist: mypy; extra == "dev"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
## EXIR Python Client - Examples
|
|
37
|
+
|
|
38
|
+
This repository contains a lightweight Python client in `index.py` and runnable examples under `example/` for:
|
|
39
|
+
- **Public**: Fetching market data (e.g., ticker)
|
|
40
|
+
- **Private**: Authenticated calls (user, balance, place orders)
|
|
41
|
+
- **WebSocket**: Streaming market data (orderbook)
|
|
42
|
+
|
|
43
|
+
### Requirements
|
|
44
|
+
- Python 3.8+
|
|
45
|
+
- Install dependencies:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
python3 -m pip install -r requirements.txt
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Project layout
|
|
52
|
+
- `index.py`: EXIR client (public, private, and WebSocket helpers)
|
|
53
|
+
- `utils.py`: HTTP and auth utilities
|
|
54
|
+
- `example/public.py`: Public ticker example
|
|
55
|
+
- `example/balance.py`: Private user + balance example
|
|
56
|
+
- `example/order.py`: Private create order example
|
|
57
|
+
- `example/websocket.py`: WebSocket orderbook subscription example
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Public usage
|
|
62
|
+
|
|
63
|
+
Fetch the ticker for `btc-usdt`:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
python3 example/public.py
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Example:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
python3 example/public.py
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Private usage (user, balance)
|
|
78
|
+
|
|
79
|
+
Set your api keys:
|
|
80
|
+
```bash
|
|
81
|
+
EXIR_API_KEY=<your-api-key> \
|
|
82
|
+
EXIR_API_SECRET=<your-api-secret> \
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Notes:
|
|
86
|
+
- Ensure your key has the required permissions (e.g., trading, read balance).
|
|
87
|
+
- If IP whitelisting is enabled on the key, include your current IP.
|
|
88
|
+
- Your system clock must be accurate; auth uses expiring signatures.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Private usage (create order)
|
|
93
|
+
|
|
94
|
+
Places a limit BUY order for 0.001 BTC at 50,000 USDT on `btc-usdt`:
|
|
95
|
+
|
|
96
|
+
If you receive `401 Unauthorized` when creating orders:
|
|
97
|
+
- Check key permissions and IP whitelist
|
|
98
|
+
- Ensure your system clock is in sync
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## WebSocket usage (orderbook)
|
|
103
|
+
|
|
104
|
+
Subscribes to `orderbook:btc-usdt` and logs messages for ~10 seconds:
|
|
105
|
+
|
|
106
|
+
Notes:
|
|
107
|
+
- Public WS channels (e.g., `orderbook`, `trade`) do not require credentials, but the script will include them if provided.
|
|
108
|
+
- The client automatically reconnects by default.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
requirements.txt
|
|
6
|
+
example/balance.py
|
|
7
|
+
example/order.py
|
|
8
|
+
example/public.py
|
|
9
|
+
example/ws.py
|
|
10
|
+
exir_py_lib.egg-info/PKG-INFO
|
|
11
|
+
exir_py_lib.egg-info/SOURCES.txt
|
|
12
|
+
exir_py_lib.egg-info/dependency_links.txt
|
|
13
|
+
exir_py_lib.egg-info/requires.txt
|
|
14
|
+
exir_py_lib.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "exir-py-lib"
|
|
7
|
+
version = "1.0.1"
|
|
8
|
+
description = "Python client library for EXIR cryptocurrency exchange API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "EXIR Team", email = "support@exir.io"}
|
|
13
|
+
]
|
|
14
|
+
maintainers = [
|
|
15
|
+
{name = "EXIR Team", email = "support@exir.io"}
|
|
16
|
+
]
|
|
17
|
+
keywords = ["cryptocurrency", "trading", "exchange", "api", "websocket", "exir"]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 4 - Beta",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.8",
|
|
24
|
+
"Programming Language :: Python :: 3.9",
|
|
25
|
+
"Programming Language :: Python :: 3.10",
|
|
26
|
+
"Programming Language :: Python :: 3.11",
|
|
27
|
+
"Programming Language :: Python :: 3.12",
|
|
28
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
29
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
30
|
+
]
|
|
31
|
+
requires-python = ">=3.8"
|
|
32
|
+
dependencies = [
|
|
33
|
+
"requests>=2.28,<3",
|
|
34
|
+
"websocket-client>=1.6,<2",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Homepage = "https://gitlab.com/exirorg/exir-py-lib"
|
|
39
|
+
Documentation = "https://gitlab.com/exirorg/exir-py-lib#readme"
|
|
40
|
+
Repository = "https://gitlab.com/exirorg/exir-py-lib.git"
|
|
41
|
+
|
|
42
|
+
[project.optional-dependencies]
|
|
43
|
+
dev = [
|
|
44
|
+
"pytest>=7.0",
|
|
45
|
+
"pytest-cov",
|
|
46
|
+
"black",
|
|
47
|
+
"flake8",
|
|
48
|
+
"mypy",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
[tool.setuptools.packages.find]
|
|
52
|
+
where = ["."]
|
|
53
|
+
include = ["exir*"]
|
|
54
|
+
|
|
55
|
+
[tool.setuptools.package-data]
|
|
56
|
+
"*" = ["*.py", "*.md", "*.txt"]
|
|
57
|
+
|
|
58
|
+
[tool.black]
|
|
59
|
+
line-length = 88
|
|
60
|
+
target-version = ['py38']
|
|
61
|
+
|
|
62
|
+
[tool.pytest.ini_options]
|
|
63
|
+
testpaths = ["tests"]
|
|
64
|
+
python_files = ["test_*.py"]
|
|
65
|
+
python_classes = ["Test*"]
|
|
66
|
+
python_functions = ["test_*"]
|