api-config.json 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. {
  2. "name": "product-search",
  3. "displayName": "Amazon 关键词搜索产品",
  4. "description": "按关键词搜索 Amazon 产品列表,返回多个产品的标题、价格、评分、销量等信息。用于品类市场全景分析、Top100 产品列表获取。",
  5. "category": "voc",
  6. "version": "1.3.0",
  7. "endpoint": {
  8. "method": "POST",
  9. "url": "https://server.fmode.cn/api/voc-ecom/forward",
  10. "headers": {
  11. "Content-Type": "application/json",
  12. "Authorization": "Bearer {{vocToken}}"
  13. }
  14. },
  15. "parameters": {
  16. "type": "object",
  17. "required": [
  18. "Pattern"
  19. ],
  20. "properties": {
  21. "Pattern": {
  22. "type": "string",
  23. "description": "搜索关键词,如 'reed diffuser'、'aroma diffuser'、'scented candle'"
  24. },
  25. "Page": {
  26. "type": "integer",
  27. "description": "分页页码,从 1 开始",
  28. "default": 1
  29. },
  30. "domain": {
  31. "type": "integer",
  32. "description": "Amazon 站点 ID: 1=amazon.com, 2=amazon.co.uk, 3=amazon.de, 4=amazon.co.jp",
  33. "default": 1
  34. }
  35. }
  36. },
  37. "requestTransform": {
  38. "template": {
  39. "path": "/api/ProductQuery",
  40. "method": "POST",
  41. "query": {
  42. "domain": "{{domain}}"
  43. },
  44. "body": {
  45. "Page": "{{Page}}",
  46. "Query": "1",
  47. "QueryType": "7",
  48. "Pattern": "{{Pattern}}"
  49. }
  50. }
  51. },
  52. "response": {
  53. "type": "array",
  54. "description": "产品列表数组",
  55. "items": {
  56. "type": "object",
  57. "properties": {
  58. "Asin": {
  59. "type": "string",
  60. "description": "产品 ASIN"
  61. },
  62. "Title": {
  63. "type": "string",
  64. "description": "产品标题"
  65. },
  66. "Price": {
  67. "type": "number",
  68. "description": "售价(美元)"
  69. },
  70. "Rating": {
  71. "type": "number",
  72. "description": "平均评分"
  73. },
  74. "RatingsCount": {
  75. "type": "integer",
  76. "description": "评论总数"
  77. },
  78. "MonthlySales": {
  79. "type": "integer",
  80. "description": "月销量估算"
  81. },
  82. "Brand": {
  83. "type": "string",
  84. "description": "品牌"
  85. },
  86. "BSR": {
  87. "type": "integer",
  88. "description": "BSR 排名"
  89. },
  90. "Photo": {
  91. "type": "array",
  92. "description": "图片列表"
  93. }
  94. }
  95. }
  96. },
  97. "notes": "QueryType=7 表示按标题搜索。如果被验证码拦截(code=-10),返回空数组,需回退到批量 ProductRequest。",
  98. "usageExamples": [
  99. {
  100. "name": "搜索香薰扩散器产品",
  101. "input": {
  102. "Pattern": "aroma diffuser",
  103. "Page": 1,
  104. "domain": 1
  105. },
  106. "description": "在美国站搜索 aroma diffuser 关键词的产品列表"
  107. },
  108. {
  109. "name": "搜索蜡烛加热器",
  110. "input": {
  111. "Pattern": "candle warmer",
  112. "Page": 1,
  113. "domain": 1
  114. },
  115. "description": "在美国站搜索 candle warmer 关键词的产品列表"
  116. }
  117. ],
  118. "reportMapping": {
  119. "slides": [
  120. "市场全景(Slide3)"
  121. ],
  122. "dataPoints": [
  123. "品类Top100产品列表",
  124. "周均销量",
  125. "周均销售额",
  126. "品牌数量",
  127. "中国卖家占比"
  128. ]
  129. },
  130. "timeout": 60000,
  131. "retry": {
  132. "maxAttempts": 3,
  133. "delay": 1000,
  134. "backoffMultiplier": 2
  135. },
  136. "tokenConfig": {
  137. "type": "bearer",
  138. "configFile": "~/.openclaw/voc-credentials.json",
  139. "tokenField": "vocToken",
  140. "resolutionOrder": [
  141. "configFile"
  142. ],
  143. "apigId": "7HwdQZk55B",
  144. "paymentUrlResolution": {
  145. "description": "动态构建充值URL:在已存在 session token 时查出用户 objectId,拼接到专属充值页面",
  146. "steps": [
  147. "1. 从 voc-credentials.json 获取当前 session token",
  148. "2. 调用 GET https://server.fmode.cn/parse/users/me (Header: X-Parse-Application-Id: ncloudmaster, X-Parse-Session-Token: {token})获取用户 objectId",
  149. "3. 拼接充值URL: https://app.fmode.cn/dev/apig-pay/?user={objectId}&apigid=7HwdQZk55B&fun_id=HOkkX72PMF",
  150. "4. 将该URL展示给用户,引导扫码支付"
  151. ],
  152. "userResolveEndpoint": "https://server.fmode.cn/parse/users/me",
  153. "userResolveHeaders": {
  154. "X-Parse-Application-Id": "ncloudmaster",
  155. "X-Parse-Session-Token": "{vocToken}"
  156. },
  157. "paymentBaseUrl": "https://app.fmode.cn/dev/apig-pay/",
  158. "paymentParams": {
  159. "user": "{resolvedUserId}",
  160. "apigid": "7HwdQZk55B",
  161. "fun_id": "HOkkX72PMF"
  162. },
  163. "balanceCheckEndpoint": "https://server.fmode.cn/api/apig/getApig"
  164. },
  165. "onMissing": {
  166. "action": "showPaymentQR",
  167. "qrCodeUrl": "https://app.fmode.cn/dev/apig-pay/?apigid=7HwdQZk55B&fun_id=HOkkX72PMF",
  168. "title": "扫码开通 VOC-AI 数据服务",
  169. "message": "此 Skill 需要有效的 API Token。请先打开充值页面完成登录和充值;当用户提供 session token 后,请由 OpenClaw 运行 node scripts/tools/set-voc-token.js <session-token> 写入 ~/.openclaw/voc-credentials.json 的 vocToken 字段,再重试当前 Skill。",
  170. "tokenSetupCommandTemplate": "node scripts/tools/set-voc-token.js {sessionToken}",
  171. "tokenSetupInstructions": "当用户完成登录和充值后,如果用户把 session token 发给你,请直接运行 node scripts/tools/set-voc-token.js <session-token> 写入 ~/.openclaw/voc-credentials.json,然后重试当前 Skill。"
  172. },
  173. "onBalanceInsufficient": {
  174. "action": "resolveUserThenShowPayment",
  175. "title": "VOC-AI Token 余额不足,请扫码充值",
  176. "message": "当前 Token 余额不足,我将为你生成专属充值链接,扫码支付后即可继续使用。"
  177. }
  178. },
  179. "errorHandling": {
  180. "balanceInsufficient": {
  181. "conditions": [
  182. {
  183. "responseField": "code",
  184. "operator": "in",
  185. "value": [
  186. -2,
  187. -3,
  188. -10,
  189. 402,
  190. 429
  191. ]
  192. },
  193. {
  194. "responseField": "msg",
  195. "operator": "contains",
  196. "value": [
  197. "余额不足",
  198. "insufficient",
  199. "balance",
  200. "quota",
  201. "没有开通",
  202. "权限或余额"
  203. ]
  204. },
  205. {
  206. "responseField": "mess",
  207. "operator": "contains",
  208. "value": [
  209. "余额不足",
  210. "insufficient",
  211. "balance",
  212. "quota",
  213. "没有开通",
  214. "权限或余额"
  215. ]
  216. },
  217. {
  218. "responseField": "message",
  219. "operator": "contains",
  220. "value": [
  221. "余额不足",
  222. "insufficient",
  223. "balance",
  224. "没有开通",
  225. "权限或余额"
  226. ]
  227. }
  228. ],
  229. "matchMode": "any",
  230. "trigger": "tokenConfig.onBalanceInsufficient"
  231. },
  232. "unauthorized": {
  233. "conditions": [
  234. {
  235. "responseField": "code",
  236. "operator": "in",
  237. "value": [
  238. 401,
  239. 403
  240. ]
  241. },
  242. {
  243. "responseField": "msg",
  244. "operator": "contains",
  245. "value": [
  246. "unauthorized",
  247. "token",
  248. "invalid",
  249. "auth"
  250. ]
  251. }
  252. ],
  253. "matchMode": "any",
  254. "trigger": "tokenConfig.onMissing"
  255. }
  256. }
  257. }