api-config.json 6.1 KB

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