pax-api 2.4.0__tar.gz → 2.5.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.
- {pax_api-2.4.0/src/pax_api.egg-info → pax_api-2.5.0}/PKG-INFO +5 -5
- {pax_api-2.4.0 → pax_api-2.5.0}/README.md +3 -3
- {pax_api-2.4.0 → pax_api-2.5.0}/pyproject.toml +2 -2
- {pax_api-2.4.0 → pax_api-2.5.0}/src/pax_api/auth.py +12 -12
- {pax_api-2.4.0 → pax_api-2.5.0}/src/pax_api/client.py +1 -1
- {pax_api-2.4.0 → pax_api-2.5.0/src/pax_api.egg-info}/PKG-INFO +5 -5
- {pax_api-2.4.0 → pax_api-2.5.0}/tests/test_auth.py +8 -8
- {pax_api-2.4.0 → pax_api-2.5.0}/tests/test_client.py +4 -4
- {pax_api-2.4.0 → pax_api-2.5.0}/LICENSE +0 -0
- {pax_api-2.4.0 → pax_api-2.5.0}/setup.cfg +0 -0
- {pax_api-2.4.0 → pax_api-2.5.0}/src/pax_api/__init__.py +0 -0
- {pax_api-2.4.0 → pax_api-2.5.0}/src/pax_api/errors.py +0 -0
- {pax_api-2.4.0 → pax_api-2.5.0}/src/pax_api/py.typed +0 -0
- {pax_api-2.4.0 → pax_api-2.5.0}/src/pax_api/retry.py +0 -0
- {pax_api-2.4.0 → pax_api-2.5.0}/src/pax_api/ws_client.py +0 -0
- {pax_api-2.4.0 → pax_api-2.5.0}/src/pax_api.egg-info/SOURCES.txt +0 -0
- {pax_api-2.4.0 → pax_api-2.5.0}/src/pax_api.egg-info/dependency_links.txt +0 -0
- {pax_api-2.4.0 → pax_api-2.5.0}/src/pax_api.egg-info/requires.txt +0 -0
- {pax_api-2.4.0 → pax_api-2.5.0}/src/pax_api.egg-info/top_level.txt +0 -0
- {pax_api-2.4.0 → pax_api-2.5.0}/tests/test_errors.py +0 -0
- {pax_api-2.4.0 → pax_api-2.5.0}/tests/test_retry.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pax-api
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.0
|
|
4
4
|
Summary: Official Python SDK for the PredictAsiaX Trader Track API — Web3-native prediction markets
|
|
5
5
|
Author-email: PredictAsiaX <support@predictasiax.com>
|
|
6
6
|
License: MIT
|
|
@@ -9,7 +9,7 @@ Project-URL: Documentation, https://docs.predictasiax.com
|
|
|
9
9
|
Project-URL: Repository, https://github.com/predictasiax/pax-python-sdk
|
|
10
10
|
Project-URL: Issues, https://github.com/predictasiax/pax-python-sdk/issues
|
|
11
11
|
Project-URL: Changelog, https://docs.predictasiax.com/changelog
|
|
12
|
-
Keywords: predictasiax,pax,prediction-market,trading-api,web3,hmac
|
|
12
|
+
Keywords: predictasiax,pax,prediction-market,trading-api,web3,hmac
|
|
13
13
|
Classifier: Development Status :: 4 - Beta
|
|
14
14
|
Classifier: Intended Audience :: Developers
|
|
15
15
|
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
@@ -40,9 +40,9 @@ Dynamic: license-file
|
|
|
40
40
|
|
|
41
41
|
# pax-api — Official Python SDK for PredictAsiaX
|
|
42
42
|
|
|
43
|
-
Web3-native prediction market REST + WebSocket API client.
|
|
43
|
+
Web3-native prediction market REST + WebSocket API client. HMAC-SHA256 signed-request auth for high-security trading bots.
|
|
44
44
|
|
|
45
|
-
**Version 2.
|
|
45
|
+
**Version 2.5.0** · MIT license · Python 3.8+
|
|
46
46
|
|
|
47
47
|
- **Docs**: https://docs.predictasiax.com
|
|
48
48
|
- **Verify**: https://docs.predictasiax.com/verify — public Merkle verifier over the operational ledger
|
|
@@ -85,7 +85,7 @@ Same production host either way (`api.predictasiax.com/v1`). Sandbox tier is enf
|
|
|
85
85
|
|
|
86
86
|
## Production trading (HMAC-signed)
|
|
87
87
|
|
|
88
|
-
Machine-to-machine bots use HMAC signing (
|
|
88
|
+
Machine-to-machine bots use HMAC-SHA256 signing (4 PAX_* headers per request):
|
|
89
89
|
|
|
90
90
|
```python
|
|
91
91
|
from pax_api import PaxClient
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# pax-api — Official Python SDK for PredictAsiaX
|
|
2
2
|
|
|
3
|
-
Web3-native prediction market REST + WebSocket API client.
|
|
3
|
+
Web3-native prediction market REST + WebSocket API client. HMAC-SHA256 signed-request auth for high-security trading bots.
|
|
4
4
|
|
|
5
|
-
**Version 2.
|
|
5
|
+
**Version 2.5.0** · MIT license · Python 3.8+
|
|
6
6
|
|
|
7
7
|
- **Docs**: https://docs.predictasiax.com
|
|
8
8
|
- **Verify**: https://docs.predictasiax.com/verify — public Merkle verifier over the operational ledger
|
|
@@ -45,7 +45,7 @@ Same production host either way (`api.predictasiax.com/v1`). Sandbox tier is enf
|
|
|
45
45
|
|
|
46
46
|
## Production trading (HMAC-signed)
|
|
47
47
|
|
|
48
|
-
Machine-to-machine bots use HMAC signing (
|
|
48
|
+
Machine-to-machine bots use HMAC-SHA256 signing (4 PAX_* headers per request):
|
|
49
49
|
|
|
50
50
|
```python
|
|
51
51
|
from pax_api import PaxClient
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pax-api"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.5.0"
|
|
8
8
|
description = "Official Python SDK for the PredictAsiaX Trader Track API — Web3-native prediction markets"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -12,7 +12,7 @@ license = { text = "MIT" }
|
|
|
12
12
|
authors = [
|
|
13
13
|
{ name = "PredictAsiaX", email = "support@predictasiax.com" },
|
|
14
14
|
]
|
|
15
|
-
keywords = ["predictasiax", "pax", "prediction-market", "trading-api", "web3", "hmac"
|
|
15
|
+
keywords = ["predictasiax", "pax", "prediction-market", "trading-api", "web3", "hmac"]
|
|
16
16
|
classifiers = [
|
|
17
17
|
"Development Status :: 4 - Beta",
|
|
18
18
|
"Intended Audience :: Developers",
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"""HMAC signing helpers —
|
|
1
|
+
"""HMAC signing helpers — PAX canonical 5-header signed-request protocol.
|
|
2
2
|
|
|
3
3
|
Signature construction:
|
|
4
4
|
message = timestamp_ms + method_upper + path + body
|
|
5
5
|
signature = base64(HMAC-SHA256(secret, message))
|
|
6
6
|
|
|
7
|
-
Headers sent:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
Headers sent (canonical PAX_* form):
|
|
8
|
+
PAX_ACCESS_KEY: <key_id>
|
|
9
|
+
PAX_TIMESTAMP: <ms epoch>
|
|
10
|
+
PAX_PASSPHRASE: <passphrase>
|
|
11
|
+
PAX_SIGNATURE: <base64 sig>
|
|
12
12
|
|
|
13
13
|
Server rejects with 401 INVALID_SIGNATURE if timestamp is more than
|
|
14
14
|
±30 seconds from server clock. Sync your machine via NTP.
|
|
@@ -32,7 +32,7 @@ def sign_request(
|
|
|
32
32
|
passphrase: str,
|
|
33
33
|
timestamp_ms: Optional[int] = None,
|
|
34
34
|
) -> Dict[str, str]:
|
|
35
|
-
"""Build the
|
|
35
|
+
"""Build the 4 PAX_* headers for an HMAC-signed request.
|
|
36
36
|
|
|
37
37
|
Args:
|
|
38
38
|
method: HTTP method (GET/POST/DELETE/etc.). Case-normalized to upper.
|
|
@@ -46,7 +46,7 @@ def sign_request(
|
|
|
46
46
|
timestamp_ms: Override timestamp for testing. Defaults to now.
|
|
47
47
|
|
|
48
48
|
Returns:
|
|
49
|
-
Dict of
|
|
49
|
+
Dict of 4 headers to merge into the request.
|
|
50
50
|
"""
|
|
51
51
|
ts = str(timestamp_ms if timestamp_ms is not None else int(time.time() * 1000))
|
|
52
52
|
method_u = method.upper()
|
|
@@ -54,10 +54,10 @@ def sign_request(
|
|
|
54
54
|
digest = hmac.new(secret.encode("utf-8"), message.encode("utf-8"), hashlib.sha256).digest()
|
|
55
55
|
signature = base64.b64encode(digest).decode("ascii")
|
|
56
56
|
return {
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
57
|
+
"PAX_ACCESS_KEY": key_id,
|
|
58
|
+
"PAX_TIMESTAMP": ts,
|
|
59
|
+
"PAX_PASSPHRASE": passphrase,
|
|
60
|
+
"PAX_SIGNATURE": signature,
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Auth modes (auto-detected):
|
|
4
4
|
1. HMAC — pass ``api_key`` + ``secret`` + ``passphrase``. Every request
|
|
5
|
-
signed with
|
|
5
|
+
signed with 4 PAX_* headers. Use for high-security trading bots.
|
|
6
6
|
2. API Key — pass only ``api_key``. Sent via X-Api-Key header. Simple
|
|
7
7
|
for read-only or low-risk M2M flows.
|
|
8
8
|
3. Bearer — pass ``bearer_token``. Session-based. Browser/mobile only.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pax-api
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.0
|
|
4
4
|
Summary: Official Python SDK for the PredictAsiaX Trader Track API — Web3-native prediction markets
|
|
5
5
|
Author-email: PredictAsiaX <support@predictasiax.com>
|
|
6
6
|
License: MIT
|
|
@@ -9,7 +9,7 @@ Project-URL: Documentation, https://docs.predictasiax.com
|
|
|
9
9
|
Project-URL: Repository, https://github.com/predictasiax/pax-python-sdk
|
|
10
10
|
Project-URL: Issues, https://github.com/predictasiax/pax-python-sdk/issues
|
|
11
11
|
Project-URL: Changelog, https://docs.predictasiax.com/changelog
|
|
12
|
-
Keywords: predictasiax,pax,prediction-market,trading-api,web3,hmac
|
|
12
|
+
Keywords: predictasiax,pax,prediction-market,trading-api,web3,hmac
|
|
13
13
|
Classifier: Development Status :: 4 - Beta
|
|
14
14
|
Classifier: Intended Audience :: Developers
|
|
15
15
|
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
@@ -40,9 +40,9 @@ Dynamic: license-file
|
|
|
40
40
|
|
|
41
41
|
# pax-api — Official Python SDK for PredictAsiaX
|
|
42
42
|
|
|
43
|
-
Web3-native prediction market REST + WebSocket API client.
|
|
43
|
+
Web3-native prediction market REST + WebSocket API client. HMAC-SHA256 signed-request auth for high-security trading bots.
|
|
44
44
|
|
|
45
|
-
**Version 2.
|
|
45
|
+
**Version 2.5.0** · MIT license · Python 3.8+
|
|
46
46
|
|
|
47
47
|
- **Docs**: https://docs.predictasiax.com
|
|
48
48
|
- **Verify**: https://docs.predictasiax.com/verify — public Merkle verifier over the operational ledger
|
|
@@ -85,7 +85,7 @@ Same production host either way (`api.predictasiax.com/v1`). Sandbox tier is enf
|
|
|
85
85
|
|
|
86
86
|
## Production trading (HMAC-signed)
|
|
87
87
|
|
|
88
|
-
Machine-to-machine bots use HMAC signing (
|
|
88
|
+
Machine-to-machine bots use HMAC-SHA256 signing (4 PAX_* headers per request):
|
|
89
89
|
|
|
90
90
|
```python
|
|
91
91
|
from pax_api import PaxClient
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""Unit tests for HMAC signing helpers — verify
|
|
1
|
+
"""Unit tests for HMAC signing helpers — verify PAX canonical 5-header protocol."""
|
|
2
2
|
|
|
3
3
|
import base64
|
|
4
4
|
import hashlib
|
|
@@ -21,28 +21,28 @@ def test_signature_matches_reference() -> None:
|
|
|
21
21
|
hmac.new(secret.encode(), msg.encode(), hashlib.sha256).digest()
|
|
22
22
|
).decode()
|
|
23
23
|
headers = sign_request("GET", "/v1/health", "", "sk_live_ABC", secret, "pass", timestamp_ms=ts)
|
|
24
|
-
assert headers["
|
|
25
|
-
assert headers["
|
|
26
|
-
assert headers["
|
|
27
|
-
assert headers["
|
|
24
|
+
assert headers["PAX_ACCESS_KEY"] == "sk_live_ABC"
|
|
25
|
+
assert headers["PAX_TIMESTAMP"] == str(ts)
|
|
26
|
+
assert headers["PAX_PASSPHRASE"] == "pass"
|
|
27
|
+
assert headers["PAX_SIGNATURE"] == expected
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
def test_signature_differs_when_body_changes() -> None:
|
|
31
31
|
secret = "s" * 32
|
|
32
32
|
h1 = sign_request("POST", "/v1/orders", '{"size":"1"}', "k", secret, "p", timestamp_ms=1)
|
|
33
33
|
h2 = sign_request("POST", "/v1/orders", '{"size":"2"}', "k", secret, "p", timestamp_ms=1)
|
|
34
|
-
assert h1["
|
|
34
|
+
assert h1["PAX_SIGNATURE"] != h2["PAX_SIGNATURE"]
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
def test_signature_differs_when_timestamp_changes() -> None:
|
|
38
38
|
secret = "s" * 32
|
|
39
39
|
h1 = sign_request("GET", "/v1/health", "", "k", secret, "p", timestamp_ms=1)
|
|
40
40
|
h2 = sign_request("GET", "/v1/health", "", "k", secret, "p", timestamp_ms=2)
|
|
41
|
-
assert h1["
|
|
41
|
+
assert h1["PAX_SIGNATURE"] != h2["PAX_SIGNATURE"]
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
def test_method_is_upcased() -> None:
|
|
45
45
|
secret = "s" * 32
|
|
46
46
|
h1 = sign_request("get", "/v1/health", "", "k", secret, "p", timestamp_ms=1)
|
|
47
47
|
h2 = sign_request("GET", "/v1/health", "", "k", secret, "p", timestamp_ms=1)
|
|
48
|
-
assert h1["
|
|
48
|
+
assert h1["PAX_SIGNATURE"] == h2["PAX_SIGNATURE"]
|
|
@@ -43,10 +43,10 @@ def test_hmac_headers_sent_when_secret() -> None:
|
|
|
43
43
|
responses.add(responses.GET, f"{PROD_BASE}/v1/health", json={"ok": True}, status=200)
|
|
44
44
|
c.get_health()
|
|
45
45
|
req = responses.calls[0].request
|
|
46
|
-
assert req.headers.get("
|
|
47
|
-
assert req.headers.get("
|
|
48
|
-
assert req.headers.get("
|
|
49
|
-
assert req.headers.get("
|
|
46
|
+
assert req.headers.get("PAX_ACCESS_KEY") == "sk_live_ABC"
|
|
47
|
+
assert req.headers.get("PAX_PASSPHRASE") == "p"
|
|
48
|
+
assert req.headers.get("PAX_TIMESTAMP")
|
|
49
|
+
assert req.headers.get("PAX_SIGNATURE")
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
@responses.activate
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|