api-config.json 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. {
  2. "name": "asin-sales-volume",
  3. "displayName": "ASIN 销量查询",
  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/AsinSalesVolume",
  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. "DailySales": {
  50. "type": "integer",
  51. "description": "日均销量"
  52. },
  53. "WeeklySales": {
  54. "type": "integer",
  55. "description": "周均销量"
  56. },
  57. "MonthlySales": {
  58. "type": "integer",
  59. "description": "月均销量"
  60. },
  61. "Revenue": {
  62. "type": "number",
  63. "description": "估算收入(美元)"
  64. },
  65. "SalesTrend": {
  66. "type": "array",
  67. "description": "销量趋势数据点"
  68. }
  69. }
  70. },
  71. "usageExamples": [
  72. {
  73. "name": "查询产品销量",
  74. "input": {
  75. "ASIN": "B0CSVRWJ1H",
  76. "domain": 1
  77. },
  78. "description": "查询该产品的日/周/月销量和收入估算"
  79. }
  80. ],
  81. "reportMapping": {
  82. "slides": [
  83. "市场全景(Slide3)",
  84. "品类矩阵(Slide6)"
  85. ],
  86. "dataPoints": [
  87. "周均销量",
  88. "周均销售额",
  89. "销量趋势"
  90. ]
  91. },
  92. "timeout": 60000,
  93. "retry": {
  94. "maxAttempts": 3,
  95. "delay": 1000,
  96. "backoffMultiplier": 2
  97. },
  98. "tokenConfig": {
  99. "type": "bearer",
  100. "configFile": "~/.openclaw/voc-credentials.json",
  101. "tokenField": "vocToken",
  102. "resolutionOrder": [
  103. "configFile"
  104. ],
  105. "apigId": "7HwdQZk55B",
  106. "paymentUrlResolution": {
  107. "description": "动态构建充值URL:在已存在 session token 时查出用户 objectId,拼接到专属充值页面",
  108. "steps": [
  109. "1. 从 voc-credentials.json 获取当前 session token",
  110. "2. 调用 GET https://server.fmode.cn/parse/users/me (Header: X-Parse-Application-Id: ncloudmaster, X-Parse-Session-Token: {token})获取用户 objectId",
  111. "3. 拼接充值URL: https://app.fmode.cn/dev/apig-pay/?user={objectId}&apigid=7HwdQZk55B&fun_id=HOkkX72PMF",
  112. "4. 将该URL展示给用户,引导扫码支付"
  113. ],
  114. "userResolveEndpoint": "https://server.fmode.cn/parse/users/me",
  115. "userResolveHeaders": {
  116. "X-Parse-Application-Id": "ncloudmaster",
  117. "X-Parse-Session-Token": "{vocToken}"
  118. },
  119. "paymentBaseUrl": "https://app.fmode.cn/dev/apig-pay/",
  120. "paymentParams": {
  121. "user": "{resolvedUserId}",
  122. "apigid": "7HwdQZk55B",
  123. "fun_id": "HOkkX72PMF"
  124. },
  125. "balanceCheckEndpoint": "https://server.fmode.cn/api/apig/getApig"
  126. },
  127. "onMissing": {
  128. "action": "showPaymentQR",
  129. "qrCodeUrl": "https://app.fmode.cn/dev/apig-pay/?apigid=7HwdQZk55B&fun_id=HOkkX72PMF",
  130. "title": "扫码开通 VOC-AI 数据服务",
  131. "message": "此 Skill 需要有效的 API Token。请先打开充值页面完成登录和充值;当用户提供 session token 后,请由 OpenClaw 运行 node scripts/tools/set-voc-token.js <session-token> 写入 ~/.openclaw/voc-credentials.json 的 vocToken 字段,再重试当前 Skill。",
  132. "tokenSetupCommandTemplate": "node scripts/tools/set-voc-token.js {sessionToken}",
  133. "tokenSetupInstructions": "当用户完成登录和充值后,如果用户把 session token 发给你,请直接运行 node scripts/tools/set-voc-token.js <session-token> 写入 ~/.openclaw/voc-credentials.json,然后重试当前 Skill。"
  134. },
  135. "onBalanceInsufficient": {
  136. "action": "resolveUserThenShowPayment",
  137. "title": "VOC-AI Token 余额不足,请扫码充值",
  138. "message": "当前 Token 余额不足,我将为你生成专属充值链接,扫码支付后即可继续使用。"
  139. }
  140. },
  141. "errorHandling": {
  142. "balanceInsufficient": {
  143. "conditions": [
  144. {
  145. "responseField": "code",
  146. "operator": "in",
  147. "value": [
  148. -2,
  149. -3,
  150. -10,
  151. 402,
  152. 429
  153. ]
  154. },
  155. {
  156. "responseField": "msg",
  157. "operator": "contains",
  158. "value": [
  159. "余额不足",
  160. "insufficient",
  161. "balance",
  162. "quota",
  163. "没有开通",
  164. "权限或余额"
  165. ]
  166. },
  167. {
  168. "responseField": "mess",
  169. "operator": "contains",
  170. "value": [
  171. "余额不足",
  172. "insufficient",
  173. "balance",
  174. "quota",
  175. "没有开通",
  176. "权限或余额"
  177. ]
  178. },
  179. {
  180. "responseField": "message",
  181. "operator": "contains",
  182. "value": [
  183. "余额不足",
  184. "insufficient",
  185. "balance",
  186. "没有开通",
  187. "权限或余额"
  188. ]
  189. }
  190. ],
  191. "matchMode": "any",
  192. "trigger": "tokenConfig.onBalanceInsufficient"
  193. },
  194. "unauthorized": {
  195. "conditions": [
  196. {
  197. "responseField": "code",
  198. "operator": "in",
  199. "value": [
  200. 401,
  201. 403
  202. ]
  203. },
  204. {
  205. "responseField": "msg",
  206. "operator": "contains",
  207. "value": [
  208. "unauthorized",
  209. "token",
  210. "invalid",
  211. "auth"
  212. ]
  213. }
  214. ],
  215. "matchMode": "any",
  216. "trigger": "tokenConfig.onMissing"
  217. }
  218. }
  219. }