sensortower-st-cli 0.1.2__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.
@@ -0,0 +1,14 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .cursor/
5
+ .DS_Store
6
+ chrome_data/
7
+ .pytest_cache/
8
+ .ruff_cache/
9
+ dist/
10
+ *.egg-info/
11
+ chrome_driver/
12
+ chrome_data/
13
+ doc/
14
+ .idea/
@@ -0,0 +1,164 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
124
+ any Contribution intentionally submitted for inclusion in the Work
125
+ by You to the Licensor shall be under the terms and conditions of
126
+ this License, without any additional terms or conditions.
127
+
128
+ 6. Trademarks. This License does not grant permission to use the trade
129
+ names, trademarks, service marks, or product names of the Licensor,
130
+ except as required for reasonable and customary use in describing the
131
+ origin of the Work and reproducing the content of the NOTICE file.
132
+
133
+ 7. Disclaimer of Warranty. Unless required by applicable law or
134
+ agreed to in writing, Licensor provides the Work (and each
135
+ Contributor provides its Contributions) on an "AS IS" BASIS,
136
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
137
+ implied, including, without limitation, any warranties or conditions
138
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
139
+ PARTICULAR PURPOSE.
140
+
141
+ 8. Limitation of Liability. In no event and under no legal theory,
142
+ whether in tort (including negligence), contract, or otherwise,
143
+ unless required by applicable law (such as deliberate and grossly
144
+ negligent acts) or agreed to in writing, shall any Contributor be
145
+ liable to You for damages, including any direct, indirect, special,
146
+ incidental, or consequential damages of any character arising as a
147
+ result of this License or out of the use or inability to use the
148
+ Work (including but not limited to damages for loss of goodwill,
149
+ work stoppage, computer failure or malfunction, or any and all
150
+ other commercial damages or losses), even if such Contributor
151
+ has been advised of the possibility of such damages.
152
+
153
+ 9. Accepting Warranty or Additional Liability. While redistributing
154
+ the Work or Derivative Works thereof, You may choose to offer,
155
+ and charge a fee for, acceptance of support, warranty, indemnity,
156
+ or other liability obligations and/or rights consistent with this
157
+ License. However, in accepting such obligations, You may act only
158
+ on Your own behalf and on Your sole responsibility, not on behalf
159
+ of any other Contributor, and only if You agree to indemnify,
160
+ defend, and hold each Contributor harmless for any liability
161
+ incurred by, or claims asserted against, such Contributor by reason
162
+ of your accepting any such warranty or additional liability.
163
+
164
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,94 @@
1
+ Metadata-Version: 2.4
2
+ Name: sensortower-st-cli
3
+ Version: 0.1.2
4
+ Summary: Sensor Tower CLI — browser cookies + httpx, JSON envelope for agents
5
+ Project-URL: Homepage, https://github.com/ronaldo123321/st-cli
6
+ Project-URL: Repository, https://github.com/ronaldo123321/st-cli
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Requires-Python: >=3.10
10
+ Requires-Dist: browser-cookie3>=0.19
11
+ Requires-Dist: click>=8.0
12
+ Requires-Dist: httpx>=0.27
13
+ Description-Content-Type: text/markdown
14
+
15
+ # st-cli
16
+
17
+ 源码仓库:<https://github.com/ronaldo123321/st-cli>(`git clone https://github.com/ronaldo123321/st-cli.git`)
18
+
19
+ Sensor Tower 命令行工具:**Cookie 提取**对齐 rdt-cli:`uv run --with browser-cookie3` 子进程读库(避免 SQLite 锁)。**HTTP 头**按 Sensor Tower 网页里对 `/api/*` 的 XHR(带 `Origin`、`Referer`、`X-Requested-With`),与 Reddit 的只读接口头不完全相同。Cookie 写入 `~/.config/st-cli/credential.json`,请求走 **httpx**。
20
+
21
+ ## 依赖
22
+
23
+ - Python 3.10+
24
+ - 本机已用浏览器登录过 [Sensor Tower](https://app.sensortower.com)(Chrome / Firefox / Edge / Brave 之一,供 `st login` 读 Cookie)
25
+
26
+ ## 安装
27
+
28
+ 推荐给他人使用(全局安装,像 rdt-cli 一样直接 `st ...`):
29
+
30
+ PyPI 上的包名是 **`sensortower-st-cli`**(`st-cli` 与已有项目名过于相似,无法占用);安装后命令行仍是 **`st`**。
31
+
32
+ ```bash
33
+ uv tool install sensortower-st-cli
34
+ ```
35
+
36
+ ## 认证
37
+
38
+ 1. 在浏览器中打开并登录 `https://app.sensortower.com`。
39
+ 2. 在同一台机器上执行:
40
+
41
+ ```bash
42
+ st login --json
43
+ ```
44
+
45
+ 会话文件:`~/.config/st-cli/credential.json`(权限 `600`)。过期策略见 `st_cli/auth.py`(默认可尝试从浏览器自动刷新)。
46
+
47
+ 退出登录:
48
+
49
+ ```bash
50
+ st logout
51
+ ```
52
+
53
+ ### 已登录但 `st login` 仍报 403 / `api_ok: false`
54
+
55
+ 1. **先完全退出 Chrome(或你用来登录 ST 的浏览器)再执行 `st login`**,与 rdt-cli 一样用子进程读 Cookie,避免 SQLite 锁导致读到旧/空数据。
56
+ 2. **Chrome 非 Default 配置**:`export ST_CHROME_COOKIES_DB="$HOME/Library/Application Support/Google/Chrome/Profile 1/Cookies"`(路径按本机 Profile 名),再 `uv run st login`。
57
+ 3. 提取到的 Cookie 必须至少包含 `sessionToken`、`sensor_tower_session`、`.ASPXAUTH` 之一(见 `constants.REQUIRED_COOKIES`),否则不会保存。
58
+ 4. 仍 403 时看 `details.body_preview`;若为空,多为边缘/WAF,可换网络或稍后重试。
59
+
60
+ ## 命令
61
+
62
+ | 命令 | 说明 |
63
+ |------|------|
64
+ | `st login` | 从浏览器提取并保存 Cookie,并探测 autocomplete API |
65
+ | `st logout` | 删除已保存的凭据文件 |
66
+ | `st status` | 用当前凭据探测 ST API 是否可用 |
67
+ | `st fetch "<URL 或 应用名>"` | 自动完成 → `internal_entities` → **最近 36 个月** `/api/apps/facets` 收入 |
68
+ | `st batch -f queries.txt` | 对文件中每行执行与 `fetch` 相同的流水线(每行取自动完成第一条) |
69
+
70
+ 多结果时 `fetch` 会返回 `needs_disambiguation` 与 `candidates`,请再执行:
71
+
72
+ ```bash
73
+ st fetch "Duolingo" --pick 1 --json
74
+ ```
75
+
76
+ ## 输出
77
+
78
+ 默认与 `rdt-cli` 类似:非 TTY 输出 YAML;`--json` 输出结构化 envelope:
79
+
80
+ ```json
81
+ { "ok": true, "schema_version": "1", "data": { ... } }
82
+ ```
83
+
84
+ ## 开发
85
+
86
+ ```bash
87
+ uv run pytest
88
+ uv run ruff check st_cli tests
89
+ ```
90
+
91
+ ## 说明
92
+
93
+ - 月度收入来自 ST 的 **`/api/apps/facets`**,按自然月拆分请求(36 次),请勿并发过猛。
94
+ - 若 ST 改版导致字段变化,需调整 `st_cli/st_api.py` 中的解析逻辑。
@@ -0,0 +1,80 @@
1
+ # st-cli
2
+
3
+ 源码仓库:<https://github.com/ronaldo123321/st-cli>(`git clone https://github.com/ronaldo123321/st-cli.git`)
4
+
5
+ Sensor Tower 命令行工具:**Cookie 提取**对齐 rdt-cli:`uv run --with browser-cookie3` 子进程读库(避免 SQLite 锁)。**HTTP 头**按 Sensor Tower 网页里对 `/api/*` 的 XHR(带 `Origin`、`Referer`、`X-Requested-With`),与 Reddit 的只读接口头不完全相同。Cookie 写入 `~/.config/st-cli/credential.json`,请求走 **httpx**。
6
+
7
+ ## 依赖
8
+
9
+ - Python 3.10+
10
+ - 本机已用浏览器登录过 [Sensor Tower](https://app.sensortower.com)(Chrome / Firefox / Edge / Brave 之一,供 `st login` 读 Cookie)
11
+
12
+ ## 安装
13
+
14
+ 推荐给他人使用(全局安装,像 rdt-cli 一样直接 `st ...`):
15
+
16
+ PyPI 上的包名是 **`sensortower-st-cli`**(`st-cli` 与已有项目名过于相似,无法占用);安装后命令行仍是 **`st`**。
17
+
18
+ ```bash
19
+ uv tool install sensortower-st-cli
20
+ ```
21
+
22
+ ## 认证
23
+
24
+ 1. 在浏览器中打开并登录 `https://app.sensortower.com`。
25
+ 2. 在同一台机器上执行:
26
+
27
+ ```bash
28
+ st login --json
29
+ ```
30
+
31
+ 会话文件:`~/.config/st-cli/credential.json`(权限 `600`)。过期策略见 `st_cli/auth.py`(默认可尝试从浏览器自动刷新)。
32
+
33
+ 退出登录:
34
+
35
+ ```bash
36
+ st logout
37
+ ```
38
+
39
+ ### 已登录但 `st login` 仍报 403 / `api_ok: false`
40
+
41
+ 1. **先完全退出 Chrome(或你用来登录 ST 的浏览器)再执行 `st login`**,与 rdt-cli 一样用子进程读 Cookie,避免 SQLite 锁导致读到旧/空数据。
42
+ 2. **Chrome 非 Default 配置**:`export ST_CHROME_COOKIES_DB="$HOME/Library/Application Support/Google/Chrome/Profile 1/Cookies"`(路径按本机 Profile 名),再 `uv run st login`。
43
+ 3. 提取到的 Cookie 必须至少包含 `sessionToken`、`sensor_tower_session`、`.ASPXAUTH` 之一(见 `constants.REQUIRED_COOKIES`),否则不会保存。
44
+ 4. 仍 403 时看 `details.body_preview`;若为空,多为边缘/WAF,可换网络或稍后重试。
45
+
46
+ ## 命令
47
+
48
+ | 命令 | 说明 |
49
+ |------|------|
50
+ | `st login` | 从浏览器提取并保存 Cookie,并探测 autocomplete API |
51
+ | `st logout` | 删除已保存的凭据文件 |
52
+ | `st status` | 用当前凭据探测 ST API 是否可用 |
53
+ | `st fetch "<URL 或 应用名>"` | 自动完成 → `internal_entities` → **最近 36 个月** `/api/apps/facets` 收入 |
54
+ | `st batch -f queries.txt` | 对文件中每行执行与 `fetch` 相同的流水线(每行取自动完成第一条) |
55
+
56
+ 多结果时 `fetch` 会返回 `needs_disambiguation` 与 `candidates`,请再执行:
57
+
58
+ ```bash
59
+ st fetch "Duolingo" --pick 1 --json
60
+ ```
61
+
62
+ ## 输出
63
+
64
+ 默认与 `rdt-cli` 类似:非 TTY 输出 YAML;`--json` 输出结构化 envelope:
65
+
66
+ ```json
67
+ { "ok": true, "schema_version": "1", "data": { ... } }
68
+ ```
69
+
70
+ ## 开发
71
+
72
+ ```bash
73
+ uv run pytest
74
+ uv run ruff check st_cli tests
75
+ ```
76
+
77
+ ## 说明
78
+
79
+ - 月度收入来自 ST 的 **`/api/apps/facets`**,按自然月拆分请求(36 次),请勿并发过猛。
80
+ - 若 ST 改版导致字段变化,需调整 `st_cli/st_api.py` 中的解析逻辑。
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ # PyPI project name (must be unique). CLI command remains `st` via [project.scripts].
7
+ name = "sensortower-st-cli"
8
+ version = "0.1.2"
9
+ description = "Sensor Tower CLI — browser cookies + httpx, JSON envelope for agents"
10
+ readme = "README.md"
11
+ requires-python = ">=3.10"
12
+ license = "Apache-2.0"
13
+ dependencies = [
14
+ "click>=8.0",
15
+ "httpx>=0.27",
16
+ "browser-cookie3>=0.19",
17
+ ]
18
+
19
+ [project.scripts]
20
+ st = "st_cli.cli:cli"
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/ronaldo123321/st-cli"
24
+ Repository = "https://github.com/ronaldo123321/st-cli"
25
+
26
+ [tool.hatch.build.targets.wheel]
27
+ packages = ["st_cli"]
28
+
29
+ [tool.ruff]
30
+ target-version = "py310"
31
+ line-length = 100
32
+
33
+ [tool.pytest.ini_options]
34
+ testpaths = ["tests"]
35
+ python_files = ["test_*.py"]
36
+
37
+ [dependency-groups]
38
+ dev = ["pytest>=8.0", "ruff>=0.4"]
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: st-competitive-landscape
3
+ description: 用 st-cli + rdt-cli-research 输出,生成“市场规模 + 竞品优劣势 + AI 标签 + B2B/B2C”的竞争格局报告。触发词:竞争格局、竞品报告、SensorTower 竞品、landscape report
4
+ ---
5
+
6
+ # st-competitive-landscape
7
+
8
+ ## 你需要提供
9
+
10
+ - 一份 `rdt-cli-research` 产出的 Markdown 报告路径(里面包含 **“二、竞品生态”** 表格)
11
+ - 表头需要包含:`竞品 | 提及次数 | 正面 | 负面 | 核心评价`
12
+
13
+ ## 自动化步骤(由你执行命令)
14
+
15
+ 1) 用 **全球口径** 抓取 Sensor Tower 数据(当前月 as-of,month facets):
16
+
17
+ ```bash
18
+ ST_FACET_REGIONS=global uv run st landscape --rdt-report "<PATH_TO_RDT_REPORT>" --limit 12 --json > /tmp/st_landscape.json
19
+ ```
20
+
21
+ 2) 将 `/tmp/st_landscape.json` 的 `data.competitors` 作为证据集,让模型生成最终报告。
22
+
23
+ 若使用一键 Markdown(`--out report.md`),`st landscape` 会基于 **rdt 核心评价 + ST 评论 sentiment/关键词** 自动生成每条竞品的 **Strengths / Weaknesses** 要点,并在疑似匹配错 app 时输出 `caveat`。
24
+
25
+ ## 输出要求(模型生成报告时必须遵循)
26
+
27
+ - 报告目标:给出 **全球市场规模(Revenue)**,并按收入给竞品排序,逐个产出“优势/劣势/定位”。
28
+ - 时间口径:使用 `data.source.month` + `data.source.as_of`(当前月 as-of)。
29
+ - 每个竞品必须输出:
30
+ - **Revenue(USD)**:`st.revenue_as_of_current_month_usd`
31
+ - **Market share**:`st.market_share_as_of_current_month.share_percent`(如缺失需标注 unavailable)
32
+ - **AI 标签**(必须给):`AI-enabled` / `No AI features` / `AI-unclear`(三选一即可;可扩展更多)
33
+ - **B2B/B2C**(必须给):`B2B` / `B2C` / `Hybrid`
34
+ - **优势/劣势**:基于 ST 评论片段(`st.comments`)的 sentiment/关键词进行总结;当可能存在 app 匹配不一致时,会输出 `App-match uncertainty` 之类的提示而不强行生成要点
35
+ - 任何无法从证据推导的结论,必须标注为“推断”并给出依据字段(不要胡编)。
36
+
37
+ ## 判定指引(AI 标签 + B2B/B2C)
38
+
39
+ ### AI 标签(优先级从高到低)
40
+
41
+ - 看到明确关键词:`AI`, `LLM`, `assistant`, `autopilot`, `智能`, `自动生成`, `自动分类`, `transcribe`, `summarize`, `chat` 等,并且与核心功能直接相关 → `AI-enabled`
42
+ - 如果核心评价/评论中明确表达“不涉及 AI / 只是传统工具” → `No AI features`
43
+ - 否则 → `AI-unclear`
44
+
45
+ ### B2B/B2C
46
+
47
+ - **B2C**:个人用户订阅/个人工具(语言学习、密码管理、记账、健身等),评论多为个人使用场景
48
+ - **B2B**:公司/团队/企业流程(费用报销、发票、会计、审批、权限、合规、团队管理等)
49
+ - **Hybrid**:同时覆盖个人和企业(例如同时有个人版与企业团队版)
50
+
51
+ ## 建议的报告结构(示例)
52
+
53
+ ```markdown
54
+ # Competitive Landscape — {month} Mobile Revenue (Global, as-of {as_of})
55
+
56
+ ## Market size
57
+ - **Total market revenue (proxy)**: ${sum_top_apps} (Top N proxy)
58
+ - **As-of window**: {month} (as-of {as_of})
59
+ - **Regions**: global preset list
60
+
61
+ ## Leaders
62
+ (按 revenue 排序的竞品卡片列表)
63
+
64
+ ### {Competitor}
65
+ - Revenue: $X
66
+ - Share: Y%
67
+ - AI label: ...
68
+ - Segment: B2B/B2C/Hybrid
69
+ - Strengths:
70
+ - ...
71
+ - Weaknesses:
72
+ - ...
73
+ - Notes (evidence):
74
+ - rdt: "{core_review}"
75
+ - st: sample reviews: "..."
76
+ ```
77
+
@@ -0,0 +1,3 @@
1
+ """st-cli: Sensor Tower helper using local Chrome profile + Playwright."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,5 @@
1
+ """python -m st_cli"""
2
+
3
+ from st_cli.cli import cli
4
+
5
+ cli()