开放 API
使用说明
获取授权
全部 API
- Shop
- Metafields
- Customer
- CustomerAddress
- Account
- Product
- ProductVariant
- ProductImage
- Theme
- Asset
- Country
- Province
- City
- District
- ScriptTag
- Order
- Shipment
- ShipmentSupplier
- Payment
- PaymentMethod
- Redirect
- Page
- Webhook
- Blog
- BlogAuthor
- CustomerLevel
- StoreFile
- Promotion
- Coupon
- Post
- AfterSale
Webhook
Webhook
参考智能通知介绍。
Webhook 属性
- address
Webhook 接收通知的地址。{"address": "http://www.example.com/create_product" }
- created_at
Webhook 的创建时间。API返回的日期格式为ISO 8601。{ "created_at" : "2014-09-01T00:00:01.987+08:0" }
- id
Webhook 的唯一整型标识,在整个友好速搭系统中,不会有两个相同ID的 Webhook。{ "id" : 2 }
- topic
查看 Webhook 事件列表{ "topic" : "products/create" }
- updated_at
Webhook 的最近一次修改时间。API返回的日期格式为ISO 8601。{ "updated_at": "2015-01-25T22:31:06.155+08:00" }
- content_type
Webhook 的通知数据类型。默认使用的是 http post 的方式,建议更改为 application/json 进行解析{ "content_type": "application/json" }
Webhook 相关API
GET /webhooks
获取店铺中所有 Webhook
- limit
- 可选,返回结果条数
默认10,最大50
- page
- 可选,显示的页码
默认1
- since_id
- 可选,返回大于指定ID的结果
- topic
- 可选,Webhook主题
- 获取店铺中所有 Webhook 列表
- GET /webhooks
{ "webhooks": [ { "address": "http://www.lavandachen.com/test/private_app_create_product_1", "created_at": "2015-07-09T19:55:52.106+08:00", "id": 6, "topic": "products/create", "updated_at": "2015-07-09T19:56:26.040+08:00", "content_type": "application/json" }, { "address": "http://www.lavandachen.com/test/private_app_update_product", "created_at": "2015-07-09T19:56:17.382+08:00", "id": 7, "topic": "products/update", "updated_at": "2015-07-09T19:56:17.382+08:00", "content_type": "application/json" } ] }
- 获取指定ID的 Webhook
- GET /webhooks?ids=6,,7
{ "webhooks": [ { "address": "http://www.lavandachen.com/test/private_app_create_product_1", "created_at": "2015-07-09T19:55:52.106+08:00", "id": 6, "topic": "products/create", "updated_at": "2015-07-09T19:56:26.040+08:00", "content_type": "application/json" }, { "address": "http://www.lavandachen.com/test/private_app_update_product", "created_at": "2015-07-09T19:56:17.382+08:00", "id": 7, "topic": "products/update", "updated_at": "2015-07-09T19:56:17.382+08:00", "content_type": "application/json" } ] }
GET /webhooks/count
获取店铺中 Webhook 总数
- 获取应用创建 Webhook 总数
- GET /webhooks/count
{ "count": 2 }
GET /webhooks/#{id}
获取指定ID的 Webhook
- 获取ID为6的 Webhook
- GET /webhooks/6
{ "webhook": { "address": "http://www.example.com/create_product", "created_at": "2015-07-09T19:55:52.106+08:00", "id": 6, "topic": "products/create", "updated_at": "2015-07-27T14:12:12.894+08:00", "content_type": "application/json" } }
POST /webhooks
创建新的 Webhook
- address
- 接收通知的地址
- topic
- 指定事件主题
- 创建 Webhook
- POST /webhooks
{ "webhook": { "address": "http://www.example.com/create_product", "topic": "products/create", "content_type": "application/json" } }
{ "webhook": { "address": "http://www.example.com/create_product", "created_at": "2015-07-09T19:55:52.106+08:00", "id": 6, "topic": "products/create", "updated_at": "2015-07-27T14:12:12.894+08:00", "content_type": "application/json" } }
- 缺少
topic
参数,创建 Webhook 时会返回错误信息 - POST /webhooks
{ "webhook": { "address": "http://www.example.com/create_product" } }
{ "code": 422, "errors": { "topic": [ "不可为空" ] } }
- 缺少
PUT /webhooks/#{id}
修改指定ID的 Webhook
- address
- 接收通知的地址
- topic
- 指定事件主题
- 修改
id=6
对应 Webhook 的address
- PUT /webhooks/6
{ "webhook": { "address": "http://www.example.com/create_product_1" } }
{ "webhook": { "address": "http://www.example.com/create_product_1", "created_at": "2015-07-09T19:55:52.106+08:00", "id": 6, "topic": "products/create", "updated_at": "2015-07-27T14:23:59.729+08:00", "content_type": "application/json" } }
- 修改
DELETE /webhooks/#{id}
删除指定ID的 Webhook。
- 删除ID为6的 Webhook
- DELETE /webhooks/6
{}