开放 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
Metafields
Metafield
Metafield 用于拓展数据对象,参考拓展字段的介绍。
Metafield 相关API
Metafield 属性
- id
Number 类型,Metafield 的唯一整型标识。{ "id" : 2 }
- name
String 类型,Metafield 的唯一字符串标识。{ "name" : "inventory" }
仅支持小写字母、数字、中横和下划线,最多 200 个字符。
- owner_id
Number 类型,附属对象的整型标识。{ "owner_id" : 0 }
- owner_resource
String 类型,附属对象的字符串标识。{ "owner_resource" : "shop" }
- fields
Object 类型,Metafield 的字段,Key-Value 结构对象。{ "fields" : {"key":"value"} }
- description
String 类型,Metafield 的说明,最多 2000 个字符。{ "description" : "用途说明" }
- created_at
Datetime 类型,创建时间。{ "created_at" : "2015-03-12T15:35:12.242+08:00" }
- updated_at
Datetime 类型,上次更新时间。{ "updated_at" : "2015-03-12T16:18:21.602+08:00" }
GET /metas
获取店铺中所有的 Metafield
- limit
- 可选,返回结果条数
默认 10,最大 50
- page
- 可选,显示的页码
默认 1
- since_id
- 可选,返回大于指定 ID 的结果
- name
- 可选,获取名称的结果
- fields
- 可选,只返回指定的字段
多个字段用,
间隔
- ids
- 以
,
拼接要显示的id
范围
- created_at_min
- 缺省筛选创建时间在指定日期时间之后的Metafield(格式2014-09-01T01:00:01)
- created_at_max
- 缺省筛选创建时间在指定日期时间之前的Metafield(格式2014-09-01T01:00:01)
- updated_at_min
- 缺省筛选更新时间在指定日期时间之后的Metafield(格式2014-09-01T01:00:01)
- updated_at_max
- 缺省筛选更新时间在指定日期时间之前的Metafield(格式2014-09-01T01:00:01)
- 获取店铺中的 Metafield 列表
- GET /metas
{ "metas": [ { "created_at": "2015-03-14T01:56:38.718+08:00", "id": 5, "name": "inventory", "owner_id": 0, "fields": {}, "owner_resource": "shop", "updated_at": "2015-03-15T21:09:49.467+08:00" } ] }
- 获取大于指定 ID 的 Metafield 列表
- GET /metas?since_id=5
{ "metas": [ { "created_at": "2015-03-16T15:40:23.139+08:00", "description": "test", "id": 6, "name": "Inventory", "owner_id": 0, "fields": {}, "owner_resource": "shop", "updated_at": "2015-03-16T15:40:23.139+08:00" } ] }
GET /metas/count
获取店铺中 Metafield 总数
- 获取店铺中的 Metafield 总数
- GET /metas/count
{ "count": 1 }
GET /metas/#{id}
获取店铺中指定 ID 的 Metafield
- 获取 ID 为 7 的 Metafield
- GET /metas/7
{ "meta": { "id": 7, "name": "extend", "description": "店铺积分拓展字段", "owner_id": 0, "fields": {}, "owner_resource": "shop", "created_at": "2015-04-13T21:27:15.822+08:00", "updated_at": "2015-04-13T21:27:15.822+08:00" } }
POST /metas
创建一个新的 Metafield
- 为店铺创建一个新的 Metafield
- POST /metas
{ "meta" : { "name":"shop_score", "owner_id":"0", "owner_resource":"shop", "fields": { "key1": "value1", "key2": "value2" }, "description":"店铺积分拓展字段" } }
{ "meta": { "id": 8, "name": "shop_score", "description": "店铺积分拓展字段", "owner_id": 0, "owner_resource": "shop", "fields": { "key1": "value1", "key2": "value2" }, "created_at": "2015-04-13T21:44:51.069+08:00", "updated_at": "2015-04-13T21:44:51.069+08:00" } }
- 创建同名的 Metafield,会报错
- POST /metas
{ "meta" : { "name":"shop_score", "owner_id":"0", "owner_resource":"shop", "description":"店铺积分拓展字段" } }
{ "code": 422, "errors": [ "名称:shop_score 已存在" ] }
PUT /metas/#{id}
修改指定 ID 的 Metafield 基本数据
- 修改 ID 为 7 的 Metafield
- put /metas/7
{ "meta" : { "name":"extend_new", "owner_id":"0", "owner_resource":"shop", "fields": { "key1": "new value1", "key2": "new value2" }, "description":"修改后的店铺积分拓展字段" } }
{ "meta": { "id": 7, "name": "extend_new", "description": "修改后的店铺积分拓展字段", "owner_id": 0, "fields": { "key1": "new value1", "key2": "new value2" }, "owner_resource": "shop", "created_at": "2015-04-13T21:27:15.822+08:00", "updated_at": "2015-04-14T05:22:16.602+08:00" } }
DELETE /metas/#{id}
删除指定 ID 的 Metafield
- 删除ID为7的 Metafield
- delete /metas/7
{}
POST /metas/#{id}/fields
给指定 ID 的 Metafield 设置字段
- 为 ID 为 8 的 Metafield 设置字段,当指定 Key 不存在时新增,存在时会更新 Value
- post /metas/8/fields
{ "fields" : { "key1":"value1", "key2":"value2" } }
{ "fields": { "key1": "value1", "key2": "value2" } }
GET /metas/#{id}/fields
获取指定 ID 的 Metafield 所有字段
- 获取 ID 为 7 的 Metafield 中 Key-Value 结构数据
- get /metas/7/fields
{ "fields": { "key1": "value1", "key2": "value2" } }
DELETE /metas/#{id}/fields
删除指定 ID 的 Metafield 字段
- 删除 ID 为 8 的 Metafield 中指定 Key 的字段
- delete /metas/7
{ "fields" : ["key1"] }
{}