|
通过托管 OAuth 认证访问 WooCommerce REST API。管理产品、订单、客户、优惠券、配送、税费等电商运营所需资源。
bash
https://gateway.maton.ai/woocommerce/{native-api-path}
将 {native-api-path} 替换为实际的 WooCommerce API 端点路径。网关会将请求代理到您的 WooCommerce 商店,并自动处理认证。
所有请求都需要在 Authorization 请求头中携带 Maton API 密钥:
Authorization: Bearer $MATONAPIKEY
环境变量: 将您的 API 密钥设置为 MATONAPIKEY:
bash
export MATONAPIKEY=YOURAPIKEY
在 https://ctrl.maton.ai 管理您的 WooCommerce OAuth 连接。
bash
python <
req = urllib.request.Request(https://ctrl.maton.ai/connections?app=woocommerce&status=ACTIVE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
bash
python <
data = json.dumps({app: woocommerce}).encode()
req = urllib.request.Request(https://ctrl.maton.ai/connections, data=data, method=POST)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Content-Type, application/json)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
bash
python <
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id})
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
响应:
json
{
connection: {
connection_id: 21fd90f9-5935-43cd-b6c8-bde9d915ca80,
status: ACTIVE,
creation_time: 2025-12-08T07:20:53.488460Z,
lastupdatedtime: 2026-01-31T20:03:32.593153Z,
url: https://connect.maton.ai/?session_token=...,
app: woocommerce,
metadata: {}
}
}
在浏览器中打开返回的 url 以完成 OAuth 授权。
bash
python <
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id}, method=DELETE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
如果您有多个 WooCommerce 连接,可以通过 Maton-Connection 请求头指定使用哪一个:
bash
python <
req = urllib.request.Request(https://gateway.maton.ai/woocommerce/wp-json/wc/v3/products)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Maton-Connection, 21fd90f9-5935-43cd-b6c8-bde9d915ca80)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
如果省略,网关将使用默认(最早创建的)活跃连接。
bash
GET /woocommerce/wp-json/wc/v3/products
查询参数:
示例:
bash
curl -s -X GET https://gateway.maton.ai/woocommerce/wp-json/wc/v3/products?perpage=20&status=publish -H Authorization: Bearer $MATONAPI_KEY
响应:
json
[
{
id: 123,
name: Premium T-Shirt,
slug: premium-t-shirt,
type: simple,
status: publish,
sku: TSH-001,
price: 29.99,
regular_price: 34.99,
sale_price: 29.99,
stock_quantity: 50,
stock_status: instock,
categories: [{id: 15, name: Apparel}],
images: [{id: 456, src: https://...}]
}
]
bash
GET /woocommerce/wp-json/wc/v3/products/{id}
示例:
bash
curl -s -X GET https://gateway.maton.ai/woocommerce/wp-json/wc/v3/products/123 -H Authorization: Bearer $MATONAPIKEY
bash
POST /woocommerce/wp-json/wc/v3/products
Content-Type: application/json
{
name: New Product,
type: simple,
regular_price: 49.99,
description: Full product description,
short_description: Brief description,
sku: PROD-001,
manage_stock: true,
stock_quantity: 100,
categories: [{id: 15}],
images: [{src: https://example.com/image.jpg}]
}
示例:
bash
curl -s -X POST https://gateway.maton.ai/woocommerce/wp-json/wc/v3/products -H Content-Type: application/json -H Authorization: Bearer $MATONAPIKEY -d {name: Premium Widget, type: simple, regular_price: 19.99, sku: WDG-001}
bash
PUT /woocommerce/wp-json/wc/v3/products/{id}
示例:
bash
curl -s -X PUT https://gateway.maton.ai/woocommerce/wp-json/wc/v3/products/123 -H Content-Type: application/json -H Authorization: Bearer $MATONAPIKEY -d {regularprice: 24.99, saleprice: 19.99}
bash
DELETE /woocommerce/wp-json/wc/v3/products/{id}
查询参数:
bash
POST /woocommerce/wp-json/wc/v3/products/{id}/duplicate
###
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 woocommerce-1776204913 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 woocommerce-1776204913 技能
skillhub install woocommerce-1776204913
文件大小: 8.43 KB | 发布时间: 2026-4-15 10:38