polymarket-cli 0.2.0__tar.gz → 0.2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polymarket-cli
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Production-oriented read-only CLI wrapper around Polymarket public Gamma + CLOB APIs
5
5
  Author: ra1nty
6
6
  License-Expression: MIT
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Classifier: Programming Language :: Python :: 3.13
15
15
  Classifier: Topic :: Utilities
16
+ Requires-Dist: certifi>=2024.0.0
16
17
  Requires-Python: >=3.11
17
18
  Project-URL: Homepage, https://github.com/ra1nty/polymarket-cli
18
19
  Project-URL: Repository, https://github.com/ra1nty/polymarket-cli
@@ -42,6 +43,8 @@ uv tool install polymarket-cli
42
43
  polymarket-cli --help
43
44
  ```
44
45
 
46
+ The published package pins a bundled CA root store via `certifi`, so HTTPS works consistently in environments where `uv` or Homebrew Python points at an incomplete local OpenSSL trust store. If you already manage trust with `SSL_CERT_FILE` or `SSL_CERT_DIR`, the CLI respects those overrides.
47
+
45
48
  For one-off execution:
46
49
 
47
50
  ```bash
@@ -21,6 +21,8 @@ uv tool install polymarket-cli
21
21
  polymarket-cli --help
22
22
  ```
23
23
 
24
+ The published package pins a bundled CA root store via `certifi`, so HTTPS works consistently in environments where `uv` or Homebrew Python points at an incomplete local OpenSSL trust store. If you already manage trust with `SSL_CERT_FILE` or `SSL_CERT_DIR`, the CLI respects those overrides.
25
+
24
26
  For one-off execution:
25
27
 
26
28
  ```bash
@@ -1,2 +1,2 @@
1
1
  __all__ = ["__version__"]
2
- __version__ = "0.2.0"
2
+ __version__ = "0.2.1"
@@ -1,12 +1,16 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import json
4
+ import os
5
+ import ssl
4
6
  import urllib.parse
5
7
  import urllib.request
6
8
  from dataclasses import dataclass
7
9
  from datetime import datetime
8
10
  from typing import Any, Iterable
9
11
 
12
+ import certifi
13
+
10
14
  from .formatting import coerce_float, parse_datetime
11
15
 
12
16
  DEFAULT_HEADERS = {
@@ -14,7 +18,7 @@ DEFAULT_HEADERS = {
14
18
  "Accept": "application/json",
15
19
  }
16
20
 
17
- GAMMA_ORDER_MAP = {
21
+ MARKET_ORDER_MAP = {
18
22
  "volume24hr": "volume_24hr",
19
23
  "volume_24hr": "volume_24hr",
20
24
  "volume": "volume",
@@ -27,6 +31,15 @@ GAMMA_ORDER_MAP = {
27
31
  "closedTime": "closed_time",
28
32
  "closed_time": "closed_time",
29
33
  }
34
+ GAMMA_ORDER_PARAM_MAP = {
35
+ "volume_24hr": "volume24hr",
36
+ "volume": "volume",
37
+ "liquidity": "liquidity",
38
+ "start_date": "startDate",
39
+ "end_date": "endDate",
40
+ "competitive": "competitive",
41
+ "closed_time": "closedTime",
42
+ }
30
43
 
31
44
  HISTORY_INTERVALS = {"max", "all", "1m", "1h", "6h", "1d", "1w"}
32
45
  RANK_FIELD_ALIASES = {
@@ -50,16 +63,27 @@ class ApiError(RuntimeError):
50
63
  pass
51
64
 
52
65
 
66
+ def create_ssl_context() -> ssl.SSLContext:
67
+ # Respect explicit user overrides. Otherwise, use certifi's CA bundle so
68
+ # uv/Homebrew-installed Python builds do not depend on broken local defaults.
69
+ if os.environ.get("SSL_CERT_FILE") or os.environ.get("SSL_CERT_DIR"):
70
+ return ssl.create_default_context()
71
+ return ssl.create_default_context(cafile=certifi.where())
72
+
73
+
53
74
  @dataclass
54
75
  class HttpClient:
55
76
  timeout: float = 20.0
56
77
  headers: dict[str, str] | None = None
78
+ ssl_context: ssl.SSLContext | None = None
57
79
 
58
80
  def __post_init__(self) -> None:
59
81
  merged = dict(DEFAULT_HEADERS)
60
82
  if self.headers:
61
83
  merged.update(self.headers)
62
84
  self.headers = merged
85
+ if self.ssl_context is None:
86
+ self.ssl_context = create_ssl_context()
63
87
 
64
88
  def _iter_param_pairs(self, params: dict[str, Any]) -> Iterable[tuple[str, str]]:
65
89
  for key, value in params.items():
@@ -84,7 +108,7 @@ class HttpClient:
84
108
  url = f"{url}{sep}{query}"
85
109
  req = urllib.request.Request(url, headers=self.headers)
86
110
  try:
87
- with urllib.request.urlopen(req, timeout=self.timeout) as resp:
111
+ with urllib.request.urlopen(req, timeout=self.timeout, context=self.ssl_context) as resp:
88
112
  return json.load(resp)
89
113
  except Exception as exc: # pragma: no cover - exercised through tests with stubs
90
114
  raise ApiError(f"GET {url} failed: {exc}") from exc
@@ -129,7 +153,7 @@ class PolymarketClient:
129
153
  "active": active,
130
154
  "closed": closed,
131
155
  "archived": archived,
132
- "order": gamma_order,
156
+ "order": GAMMA_ORDER_PARAM_MAP[gamma_order],
133
157
  "ascending": ascending,
134
158
  }
135
159
  if search:
@@ -461,9 +485,9 @@ class PolymarketClient:
461
485
 
462
486
  def _normalize_market_order(self, order: str) -> str:
463
487
  try:
464
- return GAMMA_ORDER_MAP[order]
488
+ return MARKET_ORDER_MAP[order]
465
489
  except KeyError as exc:
466
- valid = ", ".join(sorted(GAMMA_ORDER_MAP))
490
+ valid = ", ".join(sorted(MARKET_ORDER_MAP))
467
491
  raise ValueError(f"Unsupported market sort field: {order}. Choose from: {valid}") from exc
468
492
 
469
493
  def _filter_markets(
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "polymarket-cli"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "Production-oriented read-only CLI wrapper around Polymarket public Gamma + CLOB APIs"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -21,7 +21,7 @@ classifiers = [
21
21
  "Programming Language :: Python :: 3.13",
22
22
  "Topic :: Utilities",
23
23
  ]
24
- dependencies = []
24
+ dependencies = ["certifi>=2024.0.0"]
25
25
 
26
26
  [project.urls]
27
27
  Homepage = "https://github.com/ra1nty/polymarket-cli"
File without changes