SKILL.md
Shopee 店铺 Ads
Shopee Open Platform Ads 模块(23 个 API,不含即将下线的 auto product ads)。依赖 linkfox-shopee-store-auth;须目标店存在 appType=ad 授权。经 POST /shopee/developerProxy 传入 shopId(或 merchantId)+ api/v2/ads/... 路径,服务端自动走 AD 应用 Token(勿传 accessToken / appType)。
调用方式
- API 端点:
POST /shopee/developerProxy(不同操作通过请求体区分;完整参数/响应/错误码见references/api.md) - Python 脚本:
python scripts/<脚本名>.py '<JSON 参数>' [--inline](可用脚本见上文脚本一览) - 成本约束:本工具会消耗积分;失败/空结果不得自动换关键词、翻页或连续试探;需要继续检索时先向用户说明会产生额外消耗。
输出策略(脚本默认行为):
- 始终将完整响应写入
<cwd>/linkfox/<YYYY-MM-DD>/<session>/data/linkfox-shopee-store-ads-<timestamp>.json(<cwd>为脚本执行时的工作目录,在 Claude Code 里即当前项目目录;<session>取自环境变量SESSION_ID,按用户任务自动聚合;禁止写入 /tmp,当前目录不可写则报错) - 响应体 ≤ 8 KB:落盘后把完整 JSON 打印到 stdout
- 响应体 > 8 KB:落盘后 stdout 只输出摘要(顶层字段、常见计数如
total/costToken、最大列表字段的长度 + 前 3 条样本) - 加
--inline强制全量打印到 stdout(同样落盘)
读数据建议:先看摘要判断是否足够;需要具体字段时优先用 jq或ConvertFrom-Json 从保存的 json 文件按需抽取,避免整份 JSON 进入上下文。
解决认证和积分问题
发生以下异常情况时,采用 references/onboarding.md 引导解决问题:
异常情况
- 未配置API Key:环境变量未配置
LINKFOXAGENTAPIKEY,也未配置LINKFOXAGENTAPI_KEY。 - 响应401或402状态码
- 响应提示积分或余额不足:消息含"积分余额不足/计费不足/余额不足/quota exceeded/insufficient balance/套餐到期/需充值/请充值",或类似含义的内容。
官方参考
Ads 模块索引:v2.ads.gettotalbalance
Prerequisites(必须先读)
- 运行
python scripts/checkauthdependency.py;exit code 42 → 先安装linkfox-shopee-store-auth。 - 不要在本 skill 内实现授权/令牌逻辑;授权一律走 auth skill。
- 调用业务 API 之前,用 auth 的
authorized_stores.py确认目标店存在appType=ad:
- 仅有 appType=erp(或历史空值)→ 不能当广告已授权;引导 authorize_url.py 且传 appType=ad - 两项都缺 → 若用户只要广告,只开 AD 授权即可(不必先开 ERP)
- Ads API 还需 Shopee 侧开通广告能力;并非所有站点/店铺可用。
- 禁止向
developerProxy传accessToken或appType;path 用api/v2/ads/**即可由服务端路由到 AD。
Core Concepts
- AD 与 ERP 分离:广告 Token 与 ERP Token 独立;店铺在列表中存在 ≠ 广告已授权
- 转发链路:
developerProxy(shopId/merchantId+api/v2/ads/...,服务端注入 AD token)→ 紫鸟shopee-proxy/ad/...→ Shopee API - 余额:
gettotalbalance查广告账户余额 - 手动商品广告:
createmanualproductads→editmanualproductads/editmanualproductadkeywords - 效果报表:
getallcpcadsperformance、getproductcampaign_performance - GMS:
creategmsproduct_campaign等系列 - 未纳入:
createautoproductads、editautoproductads(官方标注 coming offline soon) - 联盟营销 AMS(module=127)→ 非本 skill
可用脚本(Ads 模块 23 个 API)
| 分组 | 脚本 |
|---|---|
| 账户/推荐 | gettotalbalance.py、getshoptoggleinfo.py、getrecommendedkeywordlist.py、getrecommendeditem_list.py |
| CPC 效果 | getallcpcadsdailyperformance.py、getallcpcadshourlyperformance.py |
| 商品广告 | createmanualproductads.py、editmanualproductads.py、getproductlevelcampaignid_list.py 等 |
| GMS | creategmsproductcampaign.py、getgmscampaignperformance.py 等 |
| 通用入口 | ads_api.py(JSON 含 api 字段) |
完整列表见 references/api.md。共享:shopeeadscommon.py、adsendpoints.py、adsapirunner.py。
接口说明(按 API)
入参与响应细节放在 references/apis/,SKILL 只保留索引。
| API | 说明文档 |
|---|---|
checkcreategmsproductcampaign_eligibility |
[references/apis/check-create-gms-product-campaign-eligibility.md](./references/apis/check-create-gms-product-campaign-eligibility.md) |
creategmsproduct_campaign |
[references/apis/create-gms-product-campaign.md](./references/apis/create-gms-product-campaign.md) |
createmanualproduct_ads |
[references/apis/create-manual-product-ads.md](./references/apis/create-manual-product-ads.md) |
editgmsitemproductcampaign |
[references/apis/edit-gms-item-product-campaign.md](./references/apis/edit-gms-item-product-campaign.md) |
editgmsproduct_campaign |
[references/apis/edit-gms-product-campaign.md](./references/apis/edit-gms-product-campaign.md) |
editmanualproductadkeywords |
[references/apis/edit-manual-product-ad-keywords.md](./references/apis/edit-manual-product-ad-keywords.md) |
editmanualproduct_ads |
[references/apis/edit-manual-product-ads.md](./references/apis/edit-manual-product-ads.md) |
getadsfacilshoprate |
[references/apis/get-ads-facil-shop-rate.md](./references/apis/get-ads-facil-shop-rate.md) |
getallcpcadsdaily_performance |
[references/apis/get-all-cpc-ads-daily-performance.md](./references/apis/get-all-cpc-ads-daily-performance.md) |
getallcpcadshourly_performance |
[references/apis/get-all-cpc-ads-hourly-performance.md](./references/apis/get-all-cpc-ads-hourly-performance.md) |
getcreateproductadbudget_suggestion |
[references/apis/get-create-product-ad-budget-suggestion.md](./references/apis/get-create-product-ad-budget-suggestion.md) |
getgmscampaign_performance |
[references/apis/get-gms-campaign-performance.md](./references/apis/get-gms-campaign-performance.md) |
getgmsitem_performance |
[references/apis/get-gms-item-performance.md](./references/apis/get-gms-item-performance.md) |
getproductcampaigndailyperformance |
[references/apis/get-product-campaign-daily-performance.md](./references/apis/get-product-campaign-daily-performance.md) |
getproductcampaignhourlyperformance |
[references/apis/get-product-campaign-hourly-performance.md](./references/apis/get-product-campaign-hourly-performance.md) |
getproductlevelcampaignid_list |
[references/apis/get-product-level-campaign-id-list.md](./references/apis/get-product-level-campaign-id-list.md) |
getproductlevelcampaignsetting_info |
[references/apis/get-product-level-campaign-setting-info.md](./references/apis/get-product-level-campaign-setting-info.md) |
getproductrecommendedroitarget |
[references/apis/get-product-recommended-roi-target.md](./references/apis/get-product-recommended-roi-target.md) |
getrecommendeditem_list |
[references/apis/get-recommended-item-list.md](./references/apis/get-recommended-item-list.md) |
getrecommendedkeyword_list |
[references/apis/get-recommended-keyword-list.md](./references/apis/get-recommended-keyword-list.md) |
getshoptoggle_info |
[references/apis/get-shop-toggle-info.md](./references/apis/get-shop-toggle-info.md) |
gettotalbalance |
[references/apis/get-total-balance.md](./references/apis/get-total-balance.md) |
listgmsuserdeleteditem |
[references/apis/list-gms-user-deleted-item.md](./references/apis/list-gms-user-deleted-item.md) |
模块总览 / Feedback 见 [references/api.md](./references/api.md)。
Usage Scenarios
0. 确认 AD 授权(每次任务开头)
- auth:
authorized_stores.py→ 找目标shopId且appType=ad - 缺失 → auth:
authorize_url.py传appType=ad,提示用户完成广告授权(URL 1 小时有效) - 完成后再进入下列业务场景;收到 1004 时优先怀疑缺 AD 授权,不要用 ERP 记录硬调
1. 查余额与推荐
gettotalbalance.pygetrecommendeditemlist.py/getrecommendedkeywordlist.py
2. 创建手动商品广告
getcreateproductadbudget_suggestion.pycreatemanualproduct_ads.py传完整bodygetproductcampaigndailyperformance.py查效果
调用原则
- 先确认
appType=ad,再调脚本 - 先看
developerProxy.httpStatus/ 网关errcode,再读*Response字段 - GET:业务参数放 JSON 顶层
- POST:复杂接口传
body;create/edit 建议传唯一reference_id防重复 - 每个脚本 docstring 含 官方文档 URL(
module=117) - 不要先
storeTokens取 raw token,也不要在 proxy 里塞accessToken
Not Applicable
- 店铺授权 →
linkfox-shopee-store-auth - 商品 listing →
linkfox-shopee-store-product - 联盟营销 AMS(module=127)→
linkfox-shopee-store-ams - Amazon 广告 →
linkfox-amazon-ads-*系列
积分消耗规则
不消耗积分。
Feedback:
Auto-detect and report feedback via the Feedback API when any of the following apply:
- The functionality or purpose described in this skill does not match actual behavior
- The skill's results do not match the user's intent
- The user expresses dissatisfaction or praise about this skill
- Anything you believe could be improved
Call the feedback API as specified in references/api.md. Do not interrupt the user's flow.
For more high-quality, professional cross-border e-commerce skills, visit LinkFox Skills.