@bluevs/ttcli 0.0.4 → 0.0.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluevs/ttcli",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "TikTok CLI - designed for AI Agent and developers",
5
5
  "bin": {
6
6
  "ttcli": "scripts/run.js"
@@ -9,12 +9,12 @@
9
9
  "postinstall": "node -e \"console.log('\\n📦 ttcli installed. To install the openclaw skill, run:\\n bash $(npm root -g)/@bluevs/ttcli/skills/ttcli/scripts/install-skill.sh\\n')\""
10
10
  },
11
11
  "optionalDependencies": {
12
- "@bluevs/ttcli-darwin-arm64": "0.0.4",
13
- "@bluevs/ttcli-darwin-x64": "0.0.4",
14
- "@bluevs/ttcli-linux-arm64": "0.0.4",
15
- "@bluevs/ttcli-linux-x64": "0.0.4",
16
- "@bluevs/ttcli-win32-arm64": "0.0.4",
17
- "@bluevs/ttcli-win32-x64": "0.0.4"
12
+ "@bluevs/ttcli-darwin-arm64": "0.0.5",
13
+ "@bluevs/ttcli-darwin-x64": "0.0.5",
14
+ "@bluevs/ttcli-linux-arm64": "0.0.5",
15
+ "@bluevs/ttcli-linux-x64": "0.0.5",
16
+ "@bluevs/ttcli-win32-arm64": "0.0.5",
17
+ "@bluevs/ttcli-win32-x64": "0.0.5"
18
18
  },
19
19
  "engines": {
20
20
  "node": ">=16"
@@ -1,12 +1,12 @@
1
1
  ---
2
2
  name: ttcli
3
- version: 0.0.4
3
+ version: 0.0.5
4
4
  description: 直接调用 TikTok Marketing API(access token 鉴权,不经 VH 平台/项目层)。当用户提供原生 TikTok access_token + advertiser_id、要直连 TikTok 创建或查询 Smart+ campaign/adgroup/ad、或查 identity/app/region 等元数据时使用。注意:用户走 VH 项目流程(po_xxxx + account_id)的 TikTok 创编应改走 vhcli tiktok。
5
5
  ---
6
6
 
7
7
  # TikTok CLI (`ttcli`)
8
8
 
9
- > **Skill version**: `0.0.4`
9
+ > **Skill version**: `0.0.5`
10
10
  >
11
11
  > 当用户问"ttcli skill 版本是多少 / skill 装好了吗 / 升级生效了没" 时,**直接念出上面的版本号**。
12
12
  > 用户期望更高版本但没看到 → 让他们:(1) 重跑 `npm install -g @bluevs/ttcli && bash $(npm root -g)/@bluevs/ttcli/skills/ttcli/scripts/install-skill.sh` (2) 然后**新开一个会话**(skill 在会话启动时加载,老会话不刷新)。
@@ -102,14 +102,21 @@ Before creating a campaign or adgroup, gather the IDs you'll reference:
102
102
 
103
103
  ```
104
104
  ttcli auth show # confirm credentials loaded + their source
105
+ ttcli bc list # → bc_id (Business Centers; needed for BC_AUTH_TT identities)
105
106
  ttcli app list # → app_id (Android/iOS apps)
106
107
  ttcli minis list # → minis_id (TikTok Minis: MINI_GAME / MINI_SERIES)
107
108
  ttcli identity list # → identity_id (Spark Ads publishing identity)
108
109
  ttcli smart-plus campaign list # → existing campaign_id (or you'll create one)
110
+ ttcli smart-plus adgroup list # → existing adgroup_id (filter by --campaign-ids / --promotion-type)
111
+ ttcli smart-plus ad list # → existing smart_plus_ad_id + creative_list (only explicitly-selected creatives)
109
112
  ttcli tool region \
110
113
  --placements=PLACEMENT_TIKTOK \
111
114
  --objective-type=APP_PROMOTION \
112
115
  --level-range=TO_COUNTRY # → location_id for targeting_spec.location_ids
116
+ ttcli tool targeting search \
117
+ --objective-type=APP_PROMOTION --promotion-type=APP_ANDROID \
118
+ --placements=PLACEMENT_TIKTOK --search-type=FUZZY_SEARCH \
119
+ --keywords=Kentucky # → geo_id by name (location_ids OR zipcode_ids)
113
120
  ```
114
121
 
115
122
  `tool region` accepts `--language=zh-CN` (or any of 78 supported codes) for localized region names — useful when surfacing options to the user.
@@ -366,6 +373,65 @@ Common codes:
366
373
 
367
374
  The CLI does NOT validate enum values, type correctness, or conditional-required fields. It only checks that unconditionally required fields are present. TikTok is the source of truth for everything else — surface its error messages directly.
368
375
 
376
+ ## TikTok user OAuth (Login Kit / Content Posting API) — separate token type
377
+
378
+ ttcli's main job is Marketing API. But it also wraps OAuth-side endpoints under `tt-user` and `business`:
379
+
380
+ ```
381
+ ttcli tt-user token-info \ # inspect a user OAuth token
382
+ --app-id=aw1234abcd5678 \
383
+ --tt-access-token=act.xxxxx
384
+
385
+ ttcli business get \ # account profile + insights
386
+ --business-id=open_id_xxx \ # (= creator_id from tt-user token-info)
387
+ --tt-access-token=act.xxxxx \
388
+ --fields=username,display_name,followers_count,video_views,audience_countries
389
+ ```
390
+
391
+ **These are different token types** from the rest of ttcli. The Marketing API token in `auth show` is for ad management (`/smart_plus/...`, `/report/...`). The token here is a **TikTok user OAuth token** from Login Kit / Content Posting API consumer flow — used for posting videos, reading user profile, etc. They are not interchangeable.
392
+
393
+ | Endpoint | Auth model | Required scopes (some) |
394
+ |---|---|---|
395
+ | `/tt_user/token_info/get/` | access_token in JSON body, no header | n/a (introspection) |
396
+ | `/business/get/` | Access-Token header (with user OAuth token) | `user.info.basic`, `user.info.username`, `user.info.profile`, `user.info.stats`, `user.account.type`, `user.insights` |
397
+
398
+ If the user only has a Marketing API token, both will return `code=40105 access_token invalid` — that's the signal to ask for a Login-Kit-flow token instead.
399
+
400
+ **`business get` defaults**: TikTok defaults `fields=["display_name","profile_image"]` — pass `--fields=...` to get more. Daily metrics have **24-48h delay**; same-day data is unavailable. Audience demographic fields require **≥100 followers**.
401
+
402
+ ## Reporting (async)
403
+
404
+ `ttcli report task create` posts to `/report/task/create/` and returns a `task_id`. The actual report data is NOT in the response — async reports are three steps:
405
+
406
+ 1. **Create task** — `ttcli report task create ...` → `task_id`
407
+ 2. **Poll status** — `ttcli report task check --task-id=...` → `status` (QUEUING / PROCESSING / SUCCESS / FAILED / CANCELED). Poll every ~30s; tasks typically take 30s–a few minutes.
408
+ 3. **Download** — `ttcli report task download --task-id=...`. Behavior depends on what `--output-format` you used at create:
409
+ - **CSV_STRING** (default at create) → returns raw CSV bytes directly to stdout. AI agents: parse CSV from stdout.
410
+ - **CSV_DOWNLOAD / XLSX_DOWNLOAD** → returns JSON with a 1-hour signed `download_url`. Pass `--out=FILE --fetch` to follow the URL and write the file in one shot.
411
+
412
+ **Bad task_id gotcha**: TikTok returns `code=51010 internal system error` for unknown task_ids on `task check` (not a clean 4xx). Treat 51010 as "task not found / not yours" when polling.
413
+
414
+ **Stdout vs JSON**: `task download` is the one ttcli command where `--human`/JSON modes are ignored on the CSV_STRING branch — the body IS the data, so it's written verbatim to stdout. Other commands honor JSON-by-default.
415
+
416
+ **Async filtering is restricted**: only `campaign_ids` / `adgroup_ids` / `ad_ids` / `country_code` (max 20000 IDs total). For other filters, use sync `/report/integrated/get/` (also not yet wrapped).
417
+
418
+ **Lifetime metrics**: pass `--query-lifetime` to get all-time metrics; ignores `--start-date`/`--end-date`. No time/audience/country breakdowns allowed in lifetime mode.
419
+
420
+ **Recommended**: pass `--enable-title-translation=false` for stable header rows (TikTok periodically updates translated headers — raw field names don't change).
421
+
422
+ ```
423
+ ttcli report task create \
424
+ --report-type=BASIC --data-level=AUCTION_AD \
425
+ --dimensions=ad_id,stat_time_day \
426
+ --metrics=spend,impressions,clicks,cpc,ctr \
427
+ --start-date=2026-05-01 --end-date=2026-06-01 \
428
+ --filter-ad-ids=1866239337888050,1866239351340034 \
429
+ --output-format=CSV_DOWNLOAD \
430
+ --enable-title-translation=false
431
+ ```
432
+
433
+ Limits: 1 QPS per app; 500 async tasks/hour per advertiser; 30-day task validity.
434
+
369
435
  ## Credentials
370
436
 
371
437
  Priority: `--flag` > env var > config file (`~/.config/ttcli/credentials.json`, mode 0600).