1322-python 0.1.0__tar.gz → 0.2.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.
- 1322_python-0.2.0/.env.example +38 -0
- 1322_python-0.2.0/CHANGELOG.md +87 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/LICENSE +1 -1
- 1322_python-0.2.0/PKG-INFO +376 -0
- 1322_python-0.2.0/README.md +339 -0
- 1322_python-0.2.0/examples/fomo_example.py +44 -0
- 1322_python-0.2.0/examples/tiktok_example.py +53 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/examples/x_example.py +10 -3
- {1322_python-0.1.0 → 1322_python-0.2.0}/examples/youtube_example.py +11 -5
- {1322_python-0.1.0 → 1322_python-0.2.0}/pyproject.toml +16 -6
- {1322_python-0.1.0 → 1322_python-0.2.0}/src/client1322/__init__.py +4 -3
- {1322_python-0.1.0 → 1322_python-0.2.0}/src/client1322/_merge.py +21 -5
- {1322_python-0.1.0 → 1322_python-0.2.0}/src/client1322/client.py +16 -6
- {1322_python-0.1.0 → 1322_python-0.2.0}/src/client1322/platforms/binance.py +53 -12
- 1322_python-0.2.0/src/client1322/platforms/fomo.py +405 -0
- 1322_python-0.2.0/src/client1322/platforms/tiktok.py +290 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/src/client1322/platforms/youtube.py +42 -26
- 1322_python-0.2.0/tests/test_client_stream.py +315 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/tests/test_merge_x.py +27 -1
- {1322_python-0.1.0 → 1322_python-0.2.0}/tests/test_parse_binance.py +6 -6
- 1322_python-0.2.0/tests/test_parse_fomo.py +130 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/tests/test_parse_instagram.py +2 -2
- 1322_python-0.2.0/tests/test_parse_tiktok.py +112 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/tests/test_parse_truth.py +6 -6
- {1322_python-0.1.0 → 1322_python-0.2.0}/tests/test_parse_x.py +5 -5
- {1322_python-0.1.0 → 1322_python-0.2.0}/tests/test_parse_youtube.py +18 -4
- 1322_python-0.1.0/.env.example +0 -26
- 1322_python-0.1.0/PKG-INFO +0 -273
- 1322_python-0.1.0/README.md +0 -239
- 1322_python-0.1.0/tests/test_client_stream.py +0 -182
- {1322_python-0.1.0 → 1322_python-0.2.0}/.gitignore +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/examples/binance_example.py +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/examples/instagram_example.py +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/examples/news_example.py +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/examples/truth_example.py +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/scripts/smoke_test.py +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/src/client1322/_backoff.py +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/src/client1322/exceptions.py +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/src/client1322/platforms/__init__.py +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/src/client1322/platforms/_base.py +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/src/client1322/platforms/instagram.py +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/src/client1322/platforms/news.py +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/src/client1322/platforms/truth.py +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/src/client1322/platforms/x.py +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/src/client1322/py.typed +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/tests/_fakes.py +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/tests/test_backoff.py +0 -0
- {1322_python-0.1.0 → 1322_python-0.2.0}/tests/test_parse_news.py +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Copy this file to .env and fill in real values. Never commit .env.
|
|
2
|
+
#
|
|
3
|
+
# Each 1322 source has its own WebSocket feed and key, shown on the API
|
|
4
|
+
# access page of your 1322 dashboard. You only need the keys for the
|
|
5
|
+
# source(s) you use. Per-source docs: https://1322.io/docs/<source>
|
|
6
|
+
|
|
7
|
+
# X / Twitter (Normal or Ultimate tier key)
|
|
8
|
+
X_API_KEY=YOUR_API_KEY_HERE
|
|
9
|
+
|
|
10
|
+
# Truth Social — REST key, plus the WS path/key shown in your dashboard config
|
|
11
|
+
TRUTH_API_KEY=YOUR_API_KEY_HERE
|
|
12
|
+
TRUTH_WS_PATH=YOUR_WS_PATH_HERE
|
|
13
|
+
TRUTH_WS_KEY=YOUR_WS_KEY_HERE
|
|
14
|
+
|
|
15
|
+
# Instagram (REST + WebSocket share the same key)
|
|
16
|
+
INSTAGRAM_API_KEY=YOUR_API_KEY_HERE
|
|
17
|
+
|
|
18
|
+
# News — REST key; ws_path/ws_key are fetched automatically from /v1/dashboard
|
|
19
|
+
NEWS_API_KEY=YOUR_API_KEY_HERE
|
|
20
|
+
|
|
21
|
+
# Binance Square — REST key; ws_path/ws_key are fetched automatically from /v1/dashboard
|
|
22
|
+
BINANCE_API_KEY=YOUR_API_KEY_HERE
|
|
23
|
+
|
|
24
|
+
# YouTube — API key, plus ws_url and ws_key from GET /v1/dashboard (also on
|
|
25
|
+
# the API access page). The example connects to YOUTUBE_WS_URL?key=YOUTUBE_WS_KEY.
|
|
26
|
+
YOUTUBE_API_KEY=YOUR_API_KEY_HERE
|
|
27
|
+
YOUTUBE_WS_URL=YOUR_WS_URL_HERE
|
|
28
|
+
YOUTUBE_WS_KEY=YOUR_WS_KEY_HERE
|
|
29
|
+
|
|
30
|
+
# TikTok — the stream needs the TikTok WebSocket add-on (https://1322.io/pricing).
|
|
31
|
+
# Two separate keys: the API key (REST) and the WebSocket key (the
|
|
32
|
+
# stream, sent as the X-WS-Key header). The stream path is fetched from
|
|
33
|
+
# GET /v1/ws/status.
|
|
34
|
+
TIKTOK_API_KEY=YOUR_API_KEY_HERE
|
|
35
|
+
TIKTOK_WS_KEY=YOUR_WS_KEY_HERE
|
|
36
|
+
|
|
37
|
+
# FOMO — one key for REST and the WebSocket; ws_url is fetched from /v1/dashboard
|
|
38
|
+
FOMO_API_KEY=YOUR_API_KEY_HERE
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `1322-python` (import name `client1322`).
|
|
4
|
+
|
|
5
|
+
## 0.2.0 - 2026-12-05
|
|
6
|
+
|
|
7
|
+
The client now covers all eight 1322 sources. No changes to the six
|
|
8
|
+
existing adapters.
|
|
9
|
+
|
|
10
|
+
- TikTok (`platform="tiktok"`): `TikTokContentEvent` (upload, repost, LIVE
|
|
11
|
+
start, LIVE end; schema `1322.tiktok.event.v1`) and
|
|
12
|
+
`TikTokMediaReadyEvent` (schema `1322.tiktok.media.v1`), with TypedDicts
|
|
13
|
+
for the account, object, music and original author. `ws_key` (the
|
|
14
|
+
separate WebSocket key) is required and sent as the `X-WS-Key` header; a
|
|
15
|
+
`ws_key` equal to `api_key` is refused. The stream path is read from
|
|
16
|
+
`GET /v1/ws/status` unless `ws_path` or `ws_url` is passed. REST helpers:
|
|
17
|
+
`track`, `untrack` (username, `sec_uid` or `track_id`), `list_tracked`,
|
|
18
|
+
`dashboard`, `status`, `limits`, `ws_status`, `health`.
|
|
19
|
+
- FOMO (`platform="fomo"`): `FomoLiveModeActivated` for the first frame,
|
|
20
|
+
then `FomoThesisEvent`, `FomoTradeEvent`, `FomoTokenVerifiedEvent`,
|
|
21
|
+
`FomoNewAccountEvent`, `FomoSignalEvent` (`multi_user`, `listing`,
|
|
22
|
+
`milestone`) and `FomoProfileUpdateEvent`. `ws_url` and `ws_key` are
|
|
23
|
+
read from `GET /v1/dashboard` unless `ws_url` is passed. REST helpers:
|
|
24
|
+
`track_user`, `untrack_user`, `track_coin`, `untrack_coin`, `set_feeds`,
|
|
25
|
+
`set_filters`, `list_tracked` (`GET /v1/tracked`), `dashboard`,
|
|
26
|
+
`ws_status`.
|
|
27
|
+
- Examples: `examples/tiktok_example.py`, `examples/fomo_example.py`.
|
|
28
|
+
`.env.example` adds the TikTok and FOMO keys.
|
|
29
|
+
- README: all eight sources. It says which plans include WebSocket
|
|
30
|
+
delivery (X, Instagram, FOMO) and which need the paid add-on (Truth
|
|
31
|
+
Social, YouTube, TikTok, Binance Square, News), with a link to
|
|
32
|
+
https://1322.io/pricing. News delivery is described as sub-second from
|
|
33
|
+
the moment the article is publicly available; an outlet's own publish
|
|
34
|
+
time can be earlier than that moment, so 1322 clocks News from public
|
|
35
|
+
availability.
|
|
36
|
+
|
|
37
|
+
## 0.1.2 - 2026-11-22
|
|
38
|
+
|
|
39
|
+
No API changes. One merge fix; the rest is metadata, docs, type hints and
|
|
40
|
+
examples.
|
|
41
|
+
|
|
42
|
+
- Fixed: `TweetMerger` / `merge_tweet` no longer let a later stage's empty
|
|
43
|
+
value (`[]`, `{}`, `""`) overwrite a filled one, for example `body.urls`,
|
|
44
|
+
`body.mentions` or `card`. This is the documented "never overwrite a
|
|
45
|
+
populated field with null/empty" rule; before, only `null` was skipped.
|
|
46
|
+
- Type hints corrected to the documented frames (no runtime effect):
|
|
47
|
+
YouTube channel fields are all `str | None` and include `avatar`; video
|
|
48
|
+
adds `description`, `published_at`, `updated_at` and the optional
|
|
49
|
+
`view_count`, `duration_display` and open `metadata`; images add
|
|
50
|
+
`thumbnail_small`. Binance Square `MediaItem` uses `kind` (not `type`)
|
|
51
|
+
plus `preview`, `mime_type`, `duration_s` and `scope`; `PostQuote` uses
|
|
52
|
+
`link` (not `url`) with the documented author, sentiment, media and
|
|
53
|
+
`nested` fields; `PostPoll`, `PostTranslation`, `SpaceLiveReplay` and
|
|
54
|
+
`PostResolvedLink` match the docs, and `PostLink` is added.
|
|
55
|
+
- X example and README: the merge loop also handles
|
|
56
|
+
`tweet.update.expanded`, the stage that carries the full text.
|
|
57
|
+
- Package metadata: author and maintainer are "1322 Monitors"
|
|
58
|
+
<support@1322.io>; the homepage is https://1322.io/docs; repository,
|
|
59
|
+
source, issue and changelog links point at
|
|
60
|
+
https://github.com/1322monitors/1322-python (README links moved to the
|
|
61
|
+
1322monitors organization too). New summary and keywords.
|
|
62
|
+
- `client1322.__version__` now matches the package version (0.1.1 still
|
|
63
|
+
reported `0.1.0`).
|
|
64
|
+
- README: the client covers six of 1322's eight sources (X, Truth Social,
|
|
65
|
+
Instagram, YouTube, Binance Square, News); TikTok and FOMO are not in this
|
|
66
|
+
client yet. Each source has its own WebSocket feed and key. Added the
|
|
67
|
+
plan price line and the evaluation note, per-source docs links and the
|
|
68
|
+
documented dedupe field per source. Examples and test fixtures use
|
|
69
|
+
fictional accounts. Links to repo files are absolute, so they also work
|
|
70
|
+
on the PyPI page.
|
|
71
|
+
- YouTube: docs corrected. YouTube REST (track, untrack, list, dashboard)
|
|
72
|
+
is documented at https://1322.io/docs/youtube but not wrapped by this
|
|
73
|
+
client yet; the stream URL is the dashboard `ws_url` with `?key=<ws_key>`
|
|
74
|
+
appended. Docstrings, the missing-`ws_url` error message,
|
|
75
|
+
`examples/youtube_example.py` and `.env.example` updated to match.
|
|
76
|
+
|
|
77
|
+
## 0.1.1 - 2026-09-15
|
|
78
|
+
|
|
79
|
+
Tagged on GitHub; not published to PyPI.
|
|
80
|
+
|
|
81
|
+
- README: PyPI is the install path, related repositories added.
|
|
82
|
+
|
|
83
|
+
## 0.1.0 - 2026-07-28
|
|
84
|
+
|
|
85
|
+
- First release: async client for X, Truth Social, Instagram, YouTube,
|
|
86
|
+
Binance Square and News with typed events, auto-reconnect with capped
|
|
87
|
+
exponential backoff, additive X tweet merge and per-source REST helpers.
|
|
@@ -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).
|