polymarket-apis 0.3.1__py3-none-any.whl → 0.3.2__py3-none-any.whl

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.

Potentially problematic release.


This version of polymarket-apis might be problematic. Click here for more details.

@@ -1,3 +1,4 @@
1
+ # python
1
2
  """
2
3
  Type definitions for Polymarket APIs.
3
4
 
@@ -29,9 +30,7 @@ from .clob_types import (
29
30
  PostOrdersArgs,
30
31
  Price,
31
32
  PriceHistory,
32
- RequestArgs,
33
33
  RewardMarket,
34
- RoundConfig,
35
34
  Spread,
36
35
  TickSize,
37
36
  Token,
@@ -40,7 +39,13 @@ from .clob_types import (
40
39
  TokenValue,
41
40
  TokenValueDict,
42
41
  )
43
- from .common import EmptyString, EthAddress, Keccak256, TimeseriesPoint
42
+ from .common import (
43
+ EmptyString,
44
+ EthAddress,
45
+ FlexibleDatetime,
46
+ Keccak256,
47
+ TimeseriesPoint,
48
+ )
44
49
  from .data_types import (
45
50
  Activity,
46
51
  Holder,
@@ -55,29 +60,19 @@ from .data_types import (
55
60
  from .gamma_types import (
56
61
  ClobReward,
57
62
  Event,
58
- EventList,
59
63
  GammaMarket,
60
64
  Pagination,
61
- QueryEvent,
62
- QueryMarket,
63
65
  Series,
64
66
  Tag,
65
67
  )
66
68
  from .websockets_types import (
67
69
  ActivityOrderMatchEvent,
68
- ActivityTrade,
69
70
  ActivityTradeEvent,
70
- AggOrderBookSummary,
71
- Comment,
72
71
  CommentEvent,
73
- CryptoPriceSubscribe,
74
72
  CryptoPriceSubscribeEvent,
75
- CryptoPriceUpdate,
76
73
  CryptoPriceUpdateEvent,
77
74
  ErrorEvent,
78
- LastTradePrice,
79
75
  LastTradePriceEvent,
80
- LiveDataClobMarket,
81
76
  LiveDataLastTradePriceEvent,
82
77
  LiveDataOrderBookSummaryEvent,
83
78
  LiveDataOrderEvent,
@@ -87,16 +82,10 @@ from .websockets_types import (
87
82
  MarketStatusChangeEvent,
88
83
  OrderBookSummaryEvent,
89
84
  OrderEvent,
90
- PriceChange,
91
85
  PriceChangeEvent,
92
- PriceChanges,
93
- Quote,
94
86
  QuoteEvent,
95
- Reaction,
96
87
  ReactionEvent,
97
- Request,
98
88
  RequestEvent,
99
- TickSizeChange,
100
89
  TickSizeChangeEvent,
101
90
  TradeEvent,
102
91
  )
@@ -104,36 +93,29 @@ from .websockets_types import (
104
93
  __all__ = [
105
94
  "Activity",
106
95
  "ActivityOrderMatchEvent",
107
- "ActivityTrade",
108
96
  "ActivityTradeEvent",
109
- "AggOrderBookSummary",
110
97
  "ApiCreds",
111
98
  "AssetType",
112
99
  "BidAsk",
113
100
  "BookParams",
114
101
  "ClobMarket",
115
102
  "ClobReward",
116
- "Comment",
117
103
  "CommentEvent",
118
104
  "ContractConfig",
119
105
  "CreateOrderOptions",
120
- "CryptoPriceSubscribe",
121
106
  "CryptoPriceSubscribeEvent",
122
- "CryptoPriceUpdate",
123
107
  "CryptoPriceUpdateEvent",
124
108
  "DailyEarnedReward",
125
109
  "EmptyString",
126
110
  "ErrorEvent",
127
111
  "EthAddress",
128
112
  "Event",
129
- "EventList",
113
+ "FlexibleDatetime",
130
114
  "GammaMarket",
131
115
  "Holder",
132
116
  "HolderResponse",
133
117
  "Keccak256",
134
- "LastTradePrice",
135
118
  "LastTradePriceEvent",
136
- "LiveDataClobMarket",
137
119
  "LiveDataLastTradePriceEvent",
138
120
  "LiveDataOrderBookSummaryEvent",
139
121
  "LiveDataOrderEvent",
@@ -159,26 +141,16 @@ __all__ = [
159
141
  "Position",
160
142
  "PostOrdersArgs",
161
143
  "Price",
162
- "PriceChange",
163
144
  "PriceChangeEvent",
164
- "PriceChanges",
165
145
  "PriceHistory",
166
- "QueryEvent",
167
- "QueryMarket",
168
- "Quote",
169
146
  "QuoteEvent",
170
- "Reaction",
171
147
  "ReactionEvent",
172
- "Request",
173
- "RequestArgs",
174
148
  "RequestEvent",
175
149
  "RewardMarket",
176
- "RoundConfig",
177
150
  "Series",
178
151
  "Spread",
179
152
  "Tag",
180
153
  "TickSize",
181
- "TickSizeChange",
182
154
  "TickSizeChangeEvent",
183
155
  "TimeseriesPoint",
184
156
  "Token",
@@ -1,7 +1,8 @@
1
1
  import re
2
- from datetime import datetime
2
+ from datetime import UTC, datetime
3
3
  from typing import Annotated
4
4
 
5
+ from dateutil import parser
5
6
  from pydantic import AfterValidator, BaseModel, BeforeValidator, Field
6
7
 
7
8
 
@@ -12,37 +13,17 @@ def validate_keccak256(v: str) -> str:
12
13
  return v
13
14
 
14
15
 
15
- def parse_timestamp(v: str) -> datetime:
16
- if isinstance(v, datetime):
17
- return v
18
- # Normalize '+00' to '+0000' for timezone
19
- if v.endswith("+00"):
20
- v = v[:-3] + "+0000"
21
-
22
- # Pad fractional seconds to 6 digits if present
23
- if "." in v:
24
- dot_pos = v.find(".")
25
- tz_pos = v.find("+", dot_pos) # Find timezone start after '.'
26
- if tz_pos == -1:
27
- tz_pos = v.find("-", dot_pos)
28
-
29
- if tz_pos != -1:
30
- frac = v[dot_pos + 1 : tz_pos]
31
- if len(frac) < 6:
32
- frac = frac.ljust(6, "0")
33
- v = f"{v[: dot_pos + 1]}{frac}{v[tz_pos:]}"
34
-
35
- # Try parsing with and without microseconds
36
- for fmt in ("%Y-%m-%d %H:%M:%S.%f%z", "%Y-%m-%d %H:%M:%S%z"):
37
- try:
38
- return datetime.strptime(v, fmt) # noqa: DTZ007
39
- except ValueError:
40
- continue
41
- msg = f"Time data '{v}' does not match expected formats."
42
- raise ValueError(msg)
43
-
44
-
45
- TimestampWithTZ = Annotated[datetime, BeforeValidator(parse_timestamp)]
16
+ def parse_flexible_datetime(v: str | datetime) -> datetime:
17
+ """Parse datetime from multiple formats using dateutil."""
18
+ if v in {"NOW*()", "NOW()"}:
19
+ return datetime.fromtimestamp(0, tz=UTC)
20
+
21
+ if isinstance(v, str):
22
+ return parser.parse(v)
23
+ return v
24
+
25
+
26
+ FlexibleDatetime = Annotated[datetime, BeforeValidator(parse_flexible_datetime)]
46
27
  EthAddress = Annotated[str, Field(pattern=r"^0x[A-Fa-f0-9]{40}$")]
47
28
  Keccak256 = Annotated[str, AfterValidator(validate_keccak256)]
48
29
  EmptyString = Annotated[str, Field(pattern=r"^$", description="An empty string")]
@@ -1,5 +1,5 @@
1
1
  from datetime import UTC, datetime
2
- from typing import Literal
2
+ from typing import Literal, Optional
3
3
 
4
4
  from pydantic import BaseModel, Field, field_validator
5
5
 
@@ -162,3 +162,13 @@ class UserMetric(User):
162
162
  class UserRank(User):
163
163
  amount: float
164
164
  rank: int
165
+
166
+
167
+ class MarketValue(BaseModel):
168
+ condition_id: Keccak256 = Field(alias="market")
169
+ value: float
170
+
171
+
172
+ class EventLiveVolume(BaseModel):
173
+ total: Optional[float]
174
+ markets: Optional[list[MarketValue]]