api-config.json 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. {
  2. "name": "keyword-product-ranking",
  3. "displayName": "关键词产品排名查询",
  4. "description": "查询指定关键词下的产品排名列表,获取该关键词搜索结果中的产品排序。用于竞品在关键词下的位置分析、广告优化。",
  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. "Keyword"
  19. ],
  20. "properties": {
  21. "Keyword": {
  22. "type": "string",
  23. "description": "要查询排名的关键词,如 'reed diffuser'"
  24. },
  25. "domain": {
  26. "type": "integer",
  27. "description": "Amazon 站点 ID: 1=amazon.com",
  28. "default": 1
  29. }
  30. }
  31. },
  32. "requestTransform": {
  33. "template": {
  34. "path": "/api/KeywordProductRanking",
  35. "method": "POST",
  36. "query": {
  37. "domain": "{{domain}}"
  38. },
  39. "body": {
  40. "Keyword": "{{Keyword}}"
  41. }
  42. }
  43. },
  44. "response": {
  45. "type": "array",
  46. "description": "关键词下的产品排名列表",
  47. "items": {
  48. "type": "object",
  49. "properties": {
  50. "Asin": {
  51. "type": "string",
  52. "description": "产品 ASIN"
  53. },
  54. "Title": {
  55. "type": "string",
  56. "description": "产品标题"
  57. },
  58. "Rank": {
  59. "type": "integer",
  60. "description": "在该关键词下的排名"
  61. },
  62. "Price": {
  63. "type": "number",
  64. "description": "售价"
  65. },
  66. "Rating": {
  67. "type": "number",
  68. "description": "评分"
  69. },
  70. "RatingsCount": {
  71. "type": "integer",
  72. "description": "评论数"
  73. },
  74. "IsSponsored": {
  75. "type": "boolean",
  76. "description": "是否为广告产品"
  77. }
  78. }
  79. }
  80. },
  81. "usageExamples": [
  82. {
  83. "name": "查询关键词产品排名",
  84. "input": {
  85. "Keyword": "reed diffuser",
  86. "domain": 1
  87. },
  88. "description": "获取 'reed diffuser' 搜索结果页产品排名"
  89. }
  90. ],
  91. "reportMapping": {
  92. "slides": [
  93. "趋势雷达(Slide12)",
  94. "广告关键词引擎(Slide15)"
  95. ],
  96. "dataPoints": [
  97. "关键词排名",
  98. "竞品在关键词下的位置"
  99. ]
  100. },
  101. "timeout": 60000,
  102. "retry": {
  103. "maxAttempts": 3,
  104. "delay": 1000,
  105. "backoffMultiplier": 2
  106. },
  107. "tokenConfig": {
  108. "type": "bearer",
  109. "configFile": "~/.openclaw/voc-credentials.json",
  110. "tokenField": "vocToken",
  111. "resolutionOrder": [
  112. "configFile"
  113. ],
  114. "apigId": "7HwdQZk55B",
  115. "paymentUrlResolution": {
  116. "description": "动态构建充值URL:在已存在 session token 时查出用户 objectId,拼接到专属充值页面",
  117. "steps": [
  118. "1. 从 voc-credentials.json 获取当前 session token",
  119. "2. 调用 GET https://server.fmode.cn/parse/users/me (Header: X-Parse-Application-Id: ncloudmaster, X-Parse-Session-Token: {token})获取用户 objectId",
  120. "3. 拼接充值URL: https://app.fmode.cn/dev/apig-pay/?user={objectId}&apigid=7HwdQZk55B&fun_id=HOkkX72PMF",
  121. "4. 将该URL展示给用户,引导扫码支付"
  122. ],
  123. "userResolveEndpoint": "https://server.fmode.cn/parse/users/me",
  124. "userResolveHeaders": {
  125. "X-Parse-Application-Id": "ncloudmaster",
  126. "X-Parse-Session-Token": "{vocToken}"
  127. },
  128. "paymentBaseUrl": "https://app.fmode.cn/dev/apig-pay/",
  129. "paymentParams": {
  130. "user": "{resolvedUserId}",
  131. "apigid": "7HwdQZk55B",
  132. "fun_id": "HOkkX72PMF"
  133. },
  134. "balanceCheckEndpoint": "https://server.fmode.cn/api/apig/getApig"
  135. },
  136. "onMissing": {
  137. "action": "showPaymentQR",
  138. "qrCodeUrl": "https://app.fmode.cn/dev/apig-pay/?apigid=7HwdQZk55B&fun_id=HOkkX72PMF",
  139. "title": "扫码开通 VOC-AI 数据服务",
  140. "message": "此 Skill 需要有效的 API Token。请先打开充值页面完成登录和充值;当用户提供 session token 后,请由 OpenClaw 运行 node scripts/tools/set-voc-token.js <session-token> 写入 ~/.openclaw/voc-credentials.json 的 vocToken 字段,再重试当前 Skill。",
  141. "tokenSetupCommandTemplate": "node scripts/tools/set-voc-token.js {sessionToken}",
  142. "tokenSetupInstructions": "当用户完成登录和充值后,如果用户把 session token 发给你,请直接运行 node scripts/tools/set-voc-token.js <session-token> 写入 ~/.openclaw/voc-credentials.json,然后重试当前 Skill。"
  143. },
  144. "onBalanceInsufficient": {
  145. "action": "resolveUserThenShowPayment",
  146. "title": "VOC-AI Token 余额不足,请扫码充值",
  147. "message": "当前 Token 余额不足,我将为你生成专属充值链接,扫码支付后即可继续使用。"
  148. }
  149. },
  150. "errorHandling": {
  151. "balanceInsufficient": {
  152. "conditions": [
  153. {
  154. "responseField": "code",
  155. "operator": "in",
  156. "value": [
  157. -2,
  158. -3,
  159. -10,
  160. 402,
  161. 429
  162. ]
  163. },
  164. {
  165. "responseField": "msg",
  166. "operator": "contains",
  167. "value": [
  168. "余额不足",
  169. "insufficient",
  170. "balance",
  171. "quota",
  172. "没有开通",
  173. "权限或余额"
  174. ]
  175. },
  176. {
  177. "responseField": "mess",
  178. "operator": "contains",
  179. "value": [
  180. "余额不足",
  181. "insufficient",
  182. "balance",
  183. "quota",
  184. "没有开通",
  185. "权限或余额"
  186. ]
  187. },
  188. {
  189. "responseField": "message",
  190. "operator": "contains",
  191. "value": [
  192. "余额不足",
  193. "insufficient",
  194. "balance",
  195. "没有开通",
  196. "权限或余额"
  197. ]
  198. }
  199. ],
  200. "matchMode": "any",
  201. "trigger": "tokenConfig.onBalanceInsufficient"
  202. },
  203. "unauthorized": {
  204. "conditions": [
  205. {
  206. "responseField": "code",
  207. "operator": "in",
  208. "value": [
  209. 401,
  210. 403
  211. ]
  212. },
  213. {
  214. "responseField": "msg",
  215. "operator": "contains",
  216. "value": [
  217. "unauthorized",
  218. "token",
  219. "invalid",
  220. "auth"
  221. ]
  222. }
  223. ],
  224. "matchMode": "any",
  225. "trigger": "tokenConfig.onMissing"
  226. }
  227. }
  228. }