1322-python 0.1.0__py3-none-any.whl → 0.2.0__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.
@@ -0,0 +1,376 @@
1
+ Metadata-Version: 2.5
2
+ Name: 1322-python
3
+ Version: 0.2.0
4
+ Summary: Async Python client for the real-time feeds of 1322 Monitors (1322.io) for all eight sources: X (Twitter), Truth Social, Instagram, YouTube, TikTok, Binance Square, News and FOMO. Typed events, auto-reconnect and tracked-list REST helpers.
5
+ Project-URL: Homepage, https://1322.io/docs
6
+ Project-URL: Documentation, https://1322.io/docs
7
+ Project-URL: Repository, https://github.com/1322monitors/1322-python
8
+ Project-URL: Source, https://github.com/1322monitors/1322-python
9
+ Project-URL: Issues, https://github.com/1322monitors/1322-python/issues
10
+ Project-URL: Changelog, https://github.com/1322monitors/1322-python/blob/main/CHANGELOG.md
11
+ Author-email: 1322 Monitors <support@1322.io>
12
+ Maintainer-email: 1322 Monitors <support@1322.io>
13
+ License: MIT
14
+ License-File: LICENSE
15
+ Keywords: 1322,async,binance,binance-square,binance-square-api,fomo,instagram,news,realtime,social-media-monitoring,tiktok,truth-social,truth-social-api,twitter,twitter-websocket-api,websocket,x,youtube
16
+ Classifier: Development Status :: 4 - Beta
17
+ Classifier: Framework :: AsyncIO
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: License :: OSI Approved :: MIT License
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3 :: Only
23
+ Classifier: Programming Language :: Python :: 3.10
24
+ Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
26
+ Classifier: Programming Language :: Python :: 3.13
27
+ Classifier: Topic :: Communications :: Chat
28
+ Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
29
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
30
+ Classifier: Typing :: Typed
31
+ Requires-Python: >=3.10
32
+ Requires-Dist: aiohttp>=3.9
33
+ Provides-Extra: dev
34
+ Requires-Dist: build>=1.0; extra == 'dev'
35
+ Requires-Dist: pytest>=8.0; extra == 'dev'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # 1322-python
39
+
40
+ An async Python client for the real-time feeds of 1322 Monitors ([1322.io](https://1322.io)), covering all eight sources: X (Twitter), Truth Social, Instagram, YouTube, TikTok, Binance Square, News and FOMO. Each source has its own WebSocket feed and key, managed in one 1322 dashboard; this package connects to each of them through the same async interface, with typed events, auto-reconnect and tracked-list REST helpers. Install from PyPI with `pip install 1322-python` (the import name is `client1322`). TikTok and FOMO are in version 0.2.0 and later. Maintained by 1322 Monitors.
41
+
42
+ Delivery, clocked to arrival on each source's WebSocket: X 150-250ms from publication on X, measured daily (selected X Ultimate accounts ~100ms average, measured); Truth Social regular lanes 150-250ms, with the @realDonaldTrump and @WhiteHouse priority lanes ~50ms average from the moment a post goes public; Instagram ~350ms median from the moment a post goes public on Instagram; YouTube uploads and Shorts, Binance Square posts, and TikTok uploads, reposts and go-lives sub-second from the moment they go public or live (a YouTube deletion and a TikTok live end follow once confirmed); FOMO events within seconds; News sub-second from the moment the article is publicly available (an outlet's own publish time can be earlier than that moment, so 1322 clocks News from public availability). No X developer account, Meta app, YouTube Data API quota or TikTok developer app is involved.
43
+
44
+ Plans from $79/month (FOMO Lite); X from $250/month for 100 accounts. A one-day evaluation is available on request, reviewed by the team, no card.
45
+
46
+ The client streams over each source's WebSocket, so your plan needs WebSocket delivery on every source you connect. It is included in X, Instagram and FOMO plans. On Truth Social it is a paid add-on (+$150/month), and on YouTube, TikTok, Binance Square and News a paid add-on (+$100/month); a Pack includes it on every source. See [1322.io/pricing](https://1322.io/pricing).
47
+
48
+ ```python
49
+ from client1322 import Client
50
+
51
+ async with Client(platform="x", api_key="YOUR_API_KEY_HERE") as client:
52
+ async for event in client.stream():
53
+ print(event)
54
+ ```
55
+
56
+ ## Distribution name vs. import name
57
+
58
+ The PyPI distribution name is **`1322-python`** (Python package names on
59
+ PyPI may start with a digit; Python *module* names cannot). The importable
60
+ module is **`client1322`**. So you `pip install 1322-python` but
61
+ `import client1322` in code. Every example in this repo uses the real
62
+ import name.
63
+
64
+ ## Install
65
+
66
+ From PyPI:
67
+
68
+ ```bash
69
+ pip install 1322-python
70
+ ```
71
+
72
+ Or straight from GitHub, if you want the unreleased `main`:
73
+
74
+ ```bash
75
+ pip install git+https://github.com/1322monitors/1322-python
76
+ ```
77
+
78
+ Requires Python 3.10+.
79
+
80
+ ## Why a client instead of per-source scripts
81
+
82
+ 1322 documents each source separately: its own REST base URL, WebSocket
83
+ URL, key and event payload shape (see [1322.io/docs](https://1322.io/docs)
84
+ for the authoritative contract). This package keeps that per-source
85
+ reality (it does not invent a common REST API that doesn't exist, and every
86
+ source still connects to its own WebSocket feed with its own key) but gives
87
+ you the same connection lifecycle, reconnect behavior and streaming
88
+ interface for each source it covers:
89
+
90
+ - **One shape**: `async with Client(platform=..., api_key=...) as client:`
91
+ then `async for event in client.stream():`, for every covered source.
92
+ - **Typed events**: every event is a `dataclass` with real field types
93
+ (`TypedDict`-typed nested payloads), not a loosely-typed `dict`. Full
94
+ `py.typed` support for IDEs and type checkers.
95
+ - **Auto-reconnect**: exponential backoff (1s, 2s, 4s, 8s, ... capped at
96
+ 30s), matching 1322's documented reconnection policy, implemented once
97
+ and shared by every source adapter.
98
+ - **Additive tweet merge**: X tweets arrive across up to four progressive
99
+ stages (`tweet.mini.update` -> `tweet.update` -> `tweet.update.expanded`
100
+ -> `tweet.full`); `TweetMerger` implements 1322's documented merge rules
101
+ (longest text, unioned media, deepest reply/quote chain, highest metrics,
102
+ never overwrite a filled field with an empty one) by `tweet.id` so you
103
+ don't have to.
104
+ - **Thin REST helpers**: `track()` / `untrack()` / `list_tracked()` /
105
+ `health()` and friends, matching each source's documented management
106
+ API (YouTube REST is not wrapped yet, see below).
107
+
108
+ ## Source coverage
109
+
110
+ | Source | `platform=` | REST base | WebSocket connection | Docs |
111
+ |---|---|---|---|---|
112
+ | X / Twitter | `"x"` (or `"twitter"`) | `api.1322.io` | fixed URL per stream (`normal` / `ultimate`), key in the `X-API-Key` header | [docs/x](https://1322.io/docs/x) |
113
+ | Truth Social | `"truth"` | `truth.1322.io` | pass `ws_path` + `ws_key` from the API access page | [docs/truth](https://1322.io/docs/truth) |
114
+ | Instagram | `"instagram"` | `1322.io` | `wss://1322.io/IG?key=<api_key>`, the same key as REST | [docs/instagram](https://1322.io/docs/instagram) |
115
+ | YouTube | `"youtube"` | `youtube.1322.io` (not wrapped yet) | pass `ws_url` with `?key=<ws_key>` from `GET /v1/dashboard` | [docs/youtube](https://1322.io/docs/youtube) |
116
+ | Binance Square | `"binance"` | `binance.1322.io` | `ws_path` / `ws_key` fetched from `GET /v1/dashboard` | [docs/binance](https://1322.io/docs/binance) |
117
+ | News | `"news"` | `newsfeed.1322.io` | `ws_path` / `ws_key` fetched from `GET /v1/dashboard` | [docs/news](https://1322.io/docs/news) |
118
+ | TikTok | `"tiktok"` | `tiktok.1322.io` | `ws_path` fetched from `GET /v1/ws/status`; pass `ws_key` (the separate WebSocket key), sent as the `X-WS-Key` header | [docs/tiktok](https://1322.io/docs/tiktok) |
119
+ | FOMO | `"fomo"` | `fomo.1322.io` | `ws_url` / `ws_key` fetched from `GET /v1/dashboard`; one key for REST and the stream | [docs/fomo](https://1322.io/docs/fomo) |
120
+
121
+ **About YouTube:** the client wraps the YouTube WebSocket stream and its
122
+ three event types (`upload`, `upgrade`, `deletion`). It does not wrap
123
+ YouTube REST yet: track, untrack and list (`POST /v1/track`,
124
+ `POST /v1/untrack`, `GET /v1/list`) and `GET /v1/dashboard` are documented
125
+ at [1322.io/docs/youtube](https://1322.io/docs/youtube); call them with
126
+ your own HTTP client for now. The adapter also does not fetch the stream
127
+ URL for you: take `ws_url` and `ws_key` from `GET /v1/dashboard` (or the
128
+ API access page) and pass `ws_url="<ws_url>?key=<ws_key>"`.
129
+
130
+ ## Usage per source
131
+
132
+ Runnable examples for all eight sources live in
133
+ [`examples/`](https://github.com/1322monitors/1322-python/tree/main/examples). Each one reads its key from an environment
134
+ variable and consumes the event stream; all but YouTube also call a REST
135
+ helper first. Quick summaries:
136
+
137
+ ### X / Twitter
138
+
139
+ ```python
140
+ from client1322 import Client, TweetMerger
141
+ from client1322.platforms.x import MiniTweetUpdate, TweetFull, TweetUpdate, TweetUpdateExpanded
142
+
143
+ merger = TweetMerger()
144
+
145
+ async with Client(platform="x", api_key="YOUR_API_KEY_HERE", tier="normal") as client:
146
+ async for event in client.stream():
147
+ if isinstance(event, (MiniTweetUpdate, TweetUpdate, TweetUpdateExpanded, TweetFull)):
148
+ merged = merger.merge(event.tweet) # dedupe + additive merge by tweet.id
149
+ print(merged["author"]["handle"], merged["body"]["text"])
150
+ ```
151
+
152
+ `tweet.type` is `TWEET`, `RETWEET`, `QUOTE` or `REPLY`, and
153
+ `tweet.created_at` is Unix milliseconds. Deletions arrive as
154
+ `DeletedTweet` (`tweet.deleted`). On a hybrid plan, run one client per
155
+ stream (`tier="normal"` and `tier="ultimate"`), each with its own key, and
156
+ feed both into the same `TweetMerger`.
157
+
158
+ Also available: `client.list_tracked()`, `client.add_tracked("exampledesk")`,
159
+ `client.remove_tracked("exampledesk")`, `client.list_keys()`,
160
+ `client.get_tweet(tweet_id, full=True)`, `client.resolve_username("exampledesk")`.
161
+
162
+ ### Truth Social
163
+
164
+ ```python
165
+ async with Client(
166
+ platform="truth", api_key="YOUR_API_KEY_HERE",
167
+ ws_path="YOUR_WS_PATH_HERE", ws_key="YOUR_WS_KEY_HERE",
168
+ ) as client:
169
+ async for post in client.stream():
170
+ kind = "retruth" if post.is_retruth else "quote" if post.is_quote else "post"
171
+ print(kind, post.key, post.username, post.text)
172
+ ```
173
+
174
+ Each frame is one Truth Social post with no `type` field; dedupe on
175
+ `post.key`. On a retruth, `post.username` is the account that retruthed.
176
+
177
+ Also available: `client.track("examplecampaign")`, `client.untrack(...)`,
178
+ `client.list_tracked()`, `client.limits()`, `client.status()`, `client.health()`.
179
+
180
+ ### Instagram
181
+
182
+ ```python
183
+ async with Client(platform="instagram", api_key="YOUR_API_KEY_HERE") as client:
184
+ async for post in client.stream():
185
+ print(post.post_type, post.key, post.username, post.text)
186
+ ```
187
+
188
+ `post.post_type` is `post`, `reel`, `story` or `carousel`; dedupe on
189
+ `post.key`. Fields such as `is_collab`, `collab_with`, `is_pinned`,
190
+ `is_paid_partnership` and `location` are `None` unless the post has that
191
+ context.
192
+
193
+ Also available: `client.track("examplebrand")`, `client.untrack(...)`,
194
+ `client.list_tracked()`, `client.limits()`, `client.health()`.
195
+
196
+ ### YouTube
197
+
198
+ ```python
199
+ from client1322.platforms.youtube import DeletionMessage, UploadMessage, UpgradeMessage
200
+
201
+ async with Client(
202
+ platform="youtube", api_key="YOUR_API_KEY_HERE",
203
+ ws_url="YOUR_WS_URL_HERE?key=YOUR_WS_KEY_HERE",
204
+ ) as client:
205
+ async for event in client.stream():
206
+ if isinstance(event, UploadMessage):
207
+ print(event.subtype, event.video["id"], event.channel["name"], event.video["title"])
208
+ elif isinstance(event, UpgradeMessage):
209
+ print("image upgraded:", event.upgrade["video_id"], event.upgrade["url"])
210
+ elif isinstance(event, DeletionMessage):
211
+ print("deleted:", event.video["id"])
212
+ ```
213
+
214
+ `upload` is the primary event (`subtype` is `video` or `short`); `upgrade`
215
+ is conditional and most videos never produce one; `deletion` is a separate,
216
+ later event. Channel fields and `video["title"]` can be `None`. No YouTube
217
+ REST helpers yet (see "About YouTube" above).
218
+
219
+ ### Binance Square
220
+
221
+ ```python
222
+ from client1322.platforms.binance import BinancePinUpdateEvent, BinancePostEvent
223
+
224
+ async with Client(platform="binance", api_key="YOUR_API_KEY_HERE") as client:
225
+ async for event in client.stream():
226
+ if isinstance(event, BinancePostEvent):
227
+ print(event.post["id"], event.post["username"], event.post.get("tendency"), event.post.get("text"))
228
+ elif isinstance(event, BinancePinUpdateEvent):
229
+ print("pin change:", event.pin["username"])
230
+ ```
231
+
232
+ Every frame is `{type, data}` with `type` `binance.post` or
233
+ `binance.pin.update`; `event.post` / `event.pin` is the `data` object.
234
+
235
+ Also available: `client.track("examplecrypto")`, `client.untrack(...)`, `client.dashboard()`.
236
+
237
+ ### News
238
+
239
+ ```python
240
+ async with Client(platform="news", api_key="YOUR_API_KEY_HERE") as client:
241
+ async for article in client.stream():
242
+ print(article.feed, article.title, article.url)
243
+ ```
244
+
245
+ One message per article from every feed you subscribe to; dedupe on
246
+ `article.guid`. Feed names must match the available feeds list in the docs
247
+ exactly, for example `BBC News`.
248
+
249
+ Also available: `client.dashboard()`, `client.subscribe("BBC News")`,
250
+ `client.unsubscribe(...)`.
251
+
252
+ ### TikTok
253
+
254
+ ```python
255
+ from client1322.platforms.tiktok import TikTokContentEvent, TikTokMediaReadyEvent
256
+
257
+ async with Client(
258
+ platform="tiktok", api_key="YOUR_API_KEY_HERE", ws_key="YOUR_WS_KEY_HERE",
259
+ ) as client:
260
+ async for event in client.stream():
261
+ if isinstance(event, TikTokContentEvent):
262
+ print(event.type, event.account.get("username"), event.object.get("kind"), event.object.get("url"))
263
+ elif isinstance(event, TikTokMediaReadyEvent):
264
+ print("file for", event.event_id, event.object.get("media_url"))
265
+ ```
266
+
267
+ The TikTok stream needs the TikTok WebSocket add-on (+$100/month on a
268
+ TikTok plan, included in a Pack; see [pricing](https://1322.io/pricing)).
269
+ The REST helpers work without it.
270
+
271
+ TikTok uses two separate keys: `api_key` is the REST key and `ws_key` is
272
+ the WebSocket key, both on the API access page. The stream path is read
273
+ from `GET /v1/ws/status` unless you pass `ws_path`, and `ws_key` goes in the
274
+ `X-WS-Key` header (there is no query-string key; the API key on the stream
275
+ returns 401). `event.type` is `tiktok.upload.created`,
276
+ `tiktok.repost.created`, `tiktok.live.started` or `tiktok.live.ended`.
277
+ Uploads, reposts and go-lives arrive sub-second from the moment they go
278
+ public or live; a live end follows once it is confirmed, with the same
279
+ `room_id` as its start. A `TikTokMediaReadyEvent` repeats the `event_id` of
280
+ an upload you already have, with its signed `media_url`; it is not a second
281
+ post. Dedupe on `event_id`.
282
+
283
+ Also available: `client.track("examplecreator")` (or `sec_uid=...`),
284
+ `client.untrack(...)` (username, `sec_uid=` or `track_id=`),
285
+ `client.list_tracked()`, `client.dashboard()`, `client.status()`,
286
+ `client.limits()`, `client.ws_status()`, `client.health()`.
287
+
288
+ ### FOMO
289
+
290
+ ```python
291
+ from client1322.platforms.fomo import FomoThesisEvent, FomoTradeEvent
292
+
293
+ async with Client(platform="fomo", api_key="YOUR_API_KEY_HERE") as client:
294
+ async for event in client.stream():
295
+ if isinstance(event, FomoThesisEvent):
296
+ print(event.author.get("username"), event.coin.get("symbol"), event.thesis.get("text"))
297
+ elif isinstance(event, FomoTradeEvent):
298
+ print(event.user.get("username"), event.side, event.coin.get("symbol"), event.trade.get("usdAmount"))
299
+ ```
300
+
301
+ One key for REST and the stream; `ws_url` and `ws_key` are read from
302
+ `GET /v1/dashboard` unless you pass `ws_url`. The first event after
303
+ connecting is `FomoLiveModeActivated`; after that each event carries the
304
+ envelope's `op`, `id` (dedupe on it) and `ts` (Unix ms). Money and amounts
305
+ are decimal strings. Other events: `FomoTokenVerifiedEvent`,
306
+ `FomoNewAccountEvent`, `FomoSignalEvent` (`multi_user`, `listing`,
307
+ `milestone`) and `FomoProfileUpdateEvent` (off until you add
308
+ `profile_update` to `user_events`). WebSocket delivery is included in every
309
+ FOMO plan. FOMO events arrive within seconds.
310
+ FOMO is an independent social trading app; 1322 is not affiliated with or
311
+ endorsed by FOMO.
312
+
313
+ Also available: `client.track_user("exampletrader")`, `client.untrack_user(...)`,
314
+ `client.track_coin("solana:<address>")`, `client.untrack_coin(...)`,
315
+ `client.set_feeds(["verified_all", "listings"])`,
316
+ `client.set_filters(min_trade_usd=500, trade_sides=["buy"])`,
317
+ `client.list_tracked()`, `client.dashboard()`, `client.ws_status()`.
318
+
319
+ ## Auth and secrets
320
+
321
+ Each source has its own key, shown on the API access page of your 1322
322
+ dashboard. Never hardcode a key in source; read it from the environment
323
+ instead. See [`.env.example`](https://github.com/1322monitors/1322-python/blob/main/.env.example) for the variables each example
324
+ expects. Run the client on your own server, never in browser code: your
325
+ key must stay private, and the REST endpoints are not built for
326
+ cross-origin (CORS) browser requests.
327
+
328
+ ## Reconnection
329
+
330
+ `stream()` reconnects automatically on disconnect using 1322's documented
331
+ policy: exponential backoff starting at 1 second, doubling each attempt, and
332
+ capped at 30 seconds. No events are queued while disconnected -- this
333
+ matches 1322's documented server behavior, so a client that's offline will
334
+ simply miss whatever happened during that window, the same as any other
335
+ 1322 WebSocket client. Server-sent WebSocket pings are answered
336
+ automatically by the underlying `aiohttp` transport; you don't need to
337
+ handle that yourself. Pass `auto_reconnect=False` to `Client(...)` to
338
+ disable reconnection (`stream()` then returns after the first disconnect),
339
+ and `backoff_base=`/`backoff_cap=` to tune the delay curve.
340
+
341
+ ## Development
342
+
343
+ ```bash
344
+ git clone https://github.com/1322monitors/1322-python
345
+ cd 1322-python
346
+ python -m venv .venv && source .venv/bin/activate # or .venv\Scripts\activate on Windows
347
+ pip install -e ".[dev]"
348
+ pytest
349
+ ```
350
+
351
+ The test suite (`tests/`) covers backoff math, additive tweet merging, and
352
+ event parsing for all eight sources against payload shapes taken from
353
+ [1322.io/docs](https://1322.io/docs), plus an end-to-end `Client.stream()`
354
+ reconnect test driven against a fake `aiohttp` session (no real socket, no
355
+ API key needed). Every event-parsing fixture uses illustrative example
356
+ data, not production traffic.
357
+
358
+ ## Releasing
359
+
360
+ Maintainer note: the package is published on PyPI as `1322-python`. To cut a
361
+ release, bump `version` in `pyproject.toml` and `__version__` in
362
+ `src/client1322/__init__.py`, add a [`CHANGELOG.md`](https://github.com/1322monitors/1322-python/blob/main/CHANGELOG.md) entry,
363
+ tag `vX.Y.Z`, then `python -m build && twine upload dist/*` with the
364
+ project's PyPI token.
365
+
366
+ ## Related
367
+
368
+ - [1322-client](https://github.com/1322monitors/1322-client) - the TypeScript/JavaScript client
369
+ - [social-monitor-examples](https://github.com/1322monitors/social-monitor-examples) - minimal per-source consumers
370
+ - [binance-square-realtime](https://github.com/1322monitors/binance-square-realtime) - Binance Square example
371
+ - [truthsocial-stream](https://github.com/1322monitors/truthsocial-stream) - Truth Social example
372
+ - [1322-benchmark](https://github.com/1322monitors/1322-benchmark) - latency measurement CLI
373
+
374
+ ## License
375
+
376
+ MIT, see [LICENSE](https://github.com/1322monitors/1322-python/blob/main/LICENSE).
@@ -0,0 +1,20 @@
1
+ client1322/__init__.py,sha256=rJ6BGSDcrT_W6ELfJ4ppjpgh5y_WDEv_GINz1c5gDzo,1329
2
+ client1322/_backoff.py,sha256=tr7jSxSOrll359UZJwjVq0ViV_pjqzdmNycXuMVeZ-o,2054
3
+ client1322/_merge.py,sha256=2eYd0q--8qPr2eeMd1Qnob8NJpcmuRMiqtFHfh7WznY,8051
4
+ client1322/client.py,sha256=bv00KKncRAJ0jEMK_YVQGavCwwwR4iFxl7WMqEVGK54,5272
5
+ client1322/exceptions.py,sha256=F3BR_M7KXd2BKxXLMIdADy2iolNnPWa4hrYKPOnEfS4,1219
6
+ client1322/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ client1322/platforms/__init__.py,sha256=05_QgIOcXJvtKyd4sCr04pL0w6IAPHujl7G7MPoxfBg,53
8
+ client1322/platforms/_base.py,sha256=3YXHmXu7BSXbU87D8NZpTGuzeOp8RyEx4XUVici5uLw,7257
9
+ client1322/platforms/binance.py,sha256=62caRMxl0iJZdnXdfKBHDnsOYC4JFw3vf2bie6yX1mA,7037
10
+ client1322/platforms/fomo.py,sha256=OUMXsmkbxul6BRoGNKfg3k02Wo2qB5t32SL0q9UazGI,12711
11
+ client1322/platforms/instagram.py,sha256=XMPltAqUXUPcOvihWCRQJCppYL8U3Cmb99FuOMsSeL4,4457
12
+ client1322/platforms/news.py,sha256=_XjEkeRf_qWFiMCCCnY5Ppsny-41jgJmF2dhiCTmRJ4,4726
13
+ client1322/platforms/tiktok.py,sha256=WX7QMZnL3Gi8HO-XMEourJd72rt2V4kYTcrJxRZrHDk,9916
14
+ client1322/platforms/truth.py,sha256=9YZ4OJRxfQ-0-dw3dX8wUcpJ7SnHPgrbs1sTvVw0lU0,5924
15
+ client1322/platforms/x.py,sha256=kQ6Ue-ktfSxuJJCRAn7MIUwOqiYVB2Fg5e6CSv4Z_1M,15224
16
+ client1322/platforms/youtube.py,sha256=lqmK_iFxeW74a5vE1YjHF3EBdvVb-uXmmLs6BxS4ryE,5232
17
+ 1322_python-0.2.0.dist-info/METADATA,sha256=pM4oD8tQLYj4tIqzJie9RfvZ--txQVU7gloECYV1M5k,19164
18
+ 1322_python-0.2.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
19
+ 1322_python-0.2.0.dist-info/licenses/LICENSE,sha256=LSko6PxMYvCjAhZ9fiLi2HSv13PJBO9EMaNkPVj8wyc,1082
20
+ 1322_python-0.2.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.31.0
2
+ Generator: hatchling 1.33.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 SisoSol
3
+ Copyright (c) 2026 1322
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
client1322/__init__.py CHANGED
@@ -4,8 +4,9 @@ monitoring API.
4
4
  Distributed on PyPI as ``1322-python``; imported as ``client1322`` because
5
5
  Python module names cannot start with a digit. See the README for details.
6
6
 
7
- Covers all six 1322 platforms (X/Twitter, Truth Social, Instagram, News,
8
- YouTube, Binance Square) behind one consistent async shape:
7
+ Covers all eight 1322 sources (X/Twitter, Truth Social, Instagram, News,
8
+ YouTube, TikTok, Binance Square, FOMO) behind one consistent async shape.
9
+ Each source has its own WebSocket feed and key.
9
10
 
10
11
  .. code-block:: python
11
12
 
@@ -31,7 +32,7 @@ from .exceptions import (
31
32
  UnknownEventError,
32
33
  )
33
34
 
34
- __version__ = "0.1.0"
35
+ __version__ = "0.2.0"
35
36
 
36
37
  __all__ = [
37
38
  "Client",
client1322/_merge.py CHANGED
@@ -29,6 +29,22 @@ _PROXIED_ARRAY_KEYS = ("images", "thumbnails")
29
29
  _METRIC_KEYS = ("likes", "quotes", "replies", "retweets")
30
30
 
31
31
 
32
+ def _is_empty(val: Any) -> bool:
33
+ """True for ``None`` and for an empty list, dict or string."""
34
+ return val is None or (isinstance(val, (list, dict, str)) and len(val) == 0)
35
+
36
+
37
+ def _should_take(dst_val: Any, src_val: Any) -> bool:
38
+ """Whether a later stage's ``src_val`` may replace ``dst_val``.
39
+
40
+ Null never replaces anything, and an empty value never replaces a
41
+ populated one ("a later stage may lack data an earlier stage had").
42
+ """
43
+ if src_val is None:
44
+ return False
45
+ return not (_is_empty(src_val) and not _is_empty(dst_val))
46
+
47
+
32
48
  def _union_preserve_order(a: list[Any], b: list[Any]) -> list[Any]:
33
49
  seen: set[Any] = set()
34
50
  out: list[Any] = []
@@ -50,9 +66,9 @@ def _merge_body(dst: dict[str, Any], src: dict[str, Any]) -> None:
50
66
  dst["text"] = src_text
51
67
  # Other body fields (urls, mentions, components) are not called out with
52
68
  # a specific merge rule in the docs; apply the general "later stage
53
- # enriches, never overwrite with null" rule.
69
+ # enriches, never overwrite with null/empty" rule.
54
70
  for key, val in src.items():
55
- if key == "text" or val is None:
71
+ if key == "text" or not _should_take(dst.get(key), val):
56
72
  continue
57
73
  dst[key] = val
58
74
 
@@ -137,10 +153,10 @@ def _merge_tweet_dicts(dst: dict[str, Any], src: dict[str, Any]) -> None:
137
153
  _merge_metrics(dst["metrics"], src_val)
138
154
  elif key == "subtweet":
139
155
  dst["subtweet"] = _merge_subtweet(dst.get("subtweet"), src_val)
140
- elif src_val is not None:
156
+ elif _should_take(dst.get(key), src_val):
141
157
  dst[key] = src_val
142
- # src_val is None and key already absent/None in dst: nothing to do.
143
- # src_val is None and dst has a populated value: never overwrite.
158
+ # Otherwise src_val is None, or it is empty while dst already holds a
159
+ # populated value: never overwrite.
144
160
 
145
161
 
146
162
  def merge_tweet(base: dict[str, Any] | None, incoming: dict[str, Any]) -> dict[str, Any]:
client1322/client.py CHANGED
@@ -1,4 +1,4 @@
1
- """The unified ``Client`` facade covering all six 1322 platforms.
1
+ """The unified ``Client`` facade for all eight 1322 sources.
2
2
 
3
3
  .. code-block:: python
4
4
 
@@ -26,13 +26,15 @@ from typing import Any, AsyncIterator, Literal
26
26
  from .exceptions import ConfigurationError
27
27
  from .platforms._base import BaseAdapter
28
28
  from .platforms.binance import BinanceAdapter
29
+ from .platforms.fomo import FomoAdapter
29
30
  from .platforms.instagram import InstagramAdapter
30
31
  from .platforms.news import NewsAdapter
32
+ from .platforms.tiktok import TikTokAdapter
31
33
  from .platforms.truth import TruthAdapter
32
34
  from .platforms.x import XAdapter
33
35
  from .platforms.youtube import YouTubeAdapter
34
36
 
35
- Platform = Literal["x", "twitter", "truth", "instagram", "news", "youtube", "binance"]
37
+ Platform = Literal["x", "twitter", "truth", "instagram", "news", "youtube", "tiktok", "binance", "fomo"]
36
38
 
37
39
  _ADAPTERS: dict[str, type[BaseAdapter]] = {
38
40
  "x": XAdapter,
@@ -41,7 +43,9 @@ _ADAPTERS: dict[str, type[BaseAdapter]] = {
41
43
  "instagram": InstagramAdapter,
42
44
  "news": NewsAdapter,
43
45
  "youtube": YouTubeAdapter,
46
+ "tiktok": TikTokAdapter,
44
47
  "binance": BinanceAdapter,
48
+ "fomo": FomoAdapter,
45
49
  }
46
50
 
47
51
 
@@ -49,7 +53,8 @@ class Client:
49
53
  """Unified async client for the 1322 real-time monitoring API.
50
54
 
51
55
  :param platform: one of ``"x"`` (alias ``"twitter"``), ``"truth"``,
52
- ``"instagram"``, ``"news"``, ``"youtube"``, ``"binance"``.
56
+ ``"instagram"``, ``"news"``, ``"youtube"``, ``"tiktok"``,
57
+ ``"binance"``, ``"fomo"``.
53
58
  :param api_key: the API key for that platform (from your 1322 dashboard).
54
59
  :param kwargs: forwarded to the platform's adapter constructor. Common
55
60
  ones: ``session`` (an existing ``aiohttp.ClientSession`` to reuse),
@@ -59,8 +64,13 @@ class Client:
59
64
  takes ``ws_path``/``ws_key`` (or ``ws_url``). News and Binance Square
60
65
  take optional ``ws_path``/``ws_key``/``ws_url`` -- if omitted, they
61
66
  are fetched automatically from that platform's ``/v1/dashboard``.
62
- YouTube requires ``ws_url`` explicitly (see
63
- :mod:`client1322.platforms.youtube`).
67
+ YouTube requires ``ws_url`` explicitly: the ``ws_url`` from
68
+ YouTube's ``GET /v1/dashboard`` with ``?key=<ws_key>`` appended (see
69
+ :mod:`client1322.platforms.youtube`). TikTok requires ``ws_key``, the
70
+ separate WebSocket key (``api_key`` is its REST key), and takes an
71
+ optional ``ws_path`` (read from ``GET /v1/ws/status`` if omitted).
72
+ FOMO uses one key for REST and the stream and takes an optional
73
+ ``ws_url`` (read from ``GET /v1/dashboard`` if omitted).
64
74
  """
65
75
 
66
76
  def __init__(self, platform: Platform | str, api_key: str, **kwargs: Any) -> None:
@@ -69,7 +79,7 @@ class Client:
69
79
  if adapter_cls is None:
70
80
  raise ConfigurationError(
71
81
  f"Unknown platform {platform!r}. Choose one of: "
72
- "x (or twitter), truth, instagram, news, youtube, binance."
82
+ "x (or twitter), truth, instagram, news, youtube, tiktok, binance, fomo."
73
83
  )
74
84
  self.platform: str = "x" if key == "twitter" else key
75
85
  self._adapter: BaseAdapter = adapter_cls(api_key, **kwargs)
@@ -27,44 +27,85 @@ Tendency = Literal["bullish", "bearish", ""]
27
27
 
28
28
 
29
29
  class MediaItem(TypedDict, total=False):
30
+ kind: str # "image" | "video" | "gif" | other
30
31
  url: str
31
- type: str
32
+ preview: str # poster / thumbnail
33
+ mime_type: str
32
34
  width: int
33
35
  height: int
36
+ duration_s: float
37
+ scope: Literal["post", "quote", "quote_nested", "reply_to"]
34
38
 
35
39
 
36
40
  class PostPollOption(TypedDict, total=False):
37
41
  label: str
42
+ value: str
38
43
  votes: int
44
+ ratio: float
39
45
 
40
46
 
41
47
  class PostPoll(TypedDict, total=False):
42
- options: list[PostPollOption]
48
+ question: str
49
+ total_votes: int
43
50
  ends_at: str
51
+ closed: bool
52
+ options: list[PostPollOption]
44
53
 
45
54
 
46
- class PostQuote(TypedDict, total=False):
47
- id: str
48
- username: str
49
- text: str
55
+ class PostLink(TypedDict, total=False):
50
56
  url: str
57
+ kind: str
58
+ domain: str
59
+ label: str
51
60
 
52
61
 
53
62
  class PostTranslation(TypedDict, total=False):
54
- language: str
63
+ body: str
64
+ source_language: str
65
+ target_language: str
66
+ need_translate: bool
67
+
68
+
69
+ class PostQuote(TypedDict, total=False):
70
+ """The quoted or replied-to post (``quote``, ``reply_to``, ``nested``)."""
71
+
72
+ id: str
73
+ username: str
74
+ display_name: str
75
+ avatar_url: str
55
76
  text: str
77
+ link: str
78
+ published_at: str
79
+ tendency: str
80
+ bullish_ratio: float
81
+ bearish_ratio: float
82
+ coin_pairs: list[str]
83
+ hashtags: list[str]
84
+ mentions: list[str]
85
+ links: list[PostLink]
86
+ media: list[MediaItem]
87
+ poll: PostPoll
88
+ nested: "PostQuote"
89
+ translation: PostTranslation
56
90
 
57
91
 
58
92
  class SpaceLiveReplay(TypedDict, total=False):
59
- url: str
60
- duration_seconds: int
93
+ title: str
94
+ duration_s: float
95
+ replay_url: str
96
+ status: int
97
+ live_type: int
98
+ live_status: int
99
+ view_count: int
100
+ audio_web_url: str
101
+ content_type: str
61
102
 
62
103
 
63
104
  class PostResolvedLink(TypedDict, total=False):
105
+ kind: str
106
+ label: str
64
107
  url: str
65
- title: str
66
- description: str
67
- image: str
108
+ raw: str
68
109
 
69
110
 
70
111
  class BinancePost(TypedDict, total=False):