开放 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
Asset
Asset
Asset 为 Theme 包含的文件,一个 Theme 包含多个 Asset 。
Asset 相关API
Asset 属性
- theme_id
Number 类型,Asset 所属 Theme 的唯一整型标识。{ "theme_id" : 1480 }
- key
String 类型,Asset 的路径,包含五个路径分别为:layout, config, assets, templates, snippets, 在 assets 文件夹中.jpg .jpeg .gif .png .bmp .webp格式的图片是不带后缀的。{ "key" : "assets/favicon.ico" }
- type
String 类型,Asset 读取的位置,system 表示为主题模版文件,custom 表示为自定义文件。{ "type" : "system" }
- trash
Bool 类型,Asset 是否能删除,true 表示可以删除,false 表示不允许删除。{ "trash" : false }
- rename
Bool 类型,Asset 是否能重命名,true 表示可以重命名,false 表示不允许重命名。{ "rename" : false }
- value
String 类型,Asset 的内容,当文件为图片文件的时候为 null,图片只提供访问路径,在 public_url 里面。{ "value" : "12345" }
- public_url
String 类型,Asset 的内容,当文件不是图片时为 null。{ "public_url" : //asset.ibanquan.com/middle/1482/c/122/54fd4a906387e4ead9000776/blogs_banner_img?rand=1427792969 }
- version
String 类型,Asset 的当前版本,当文件变更时,版本号会对应进行变更。{ "version" : "d66407160dc04dc2aa4946c205afabe0" }
GET /themes/#{id}/assets
获取 Theme 所有的 Asset
- fields
- 需要查询的字段
- 获取 Theme 所有的 Asset
- GET /themes/1482/assets
{ "assets": [ { "key": "assets/favicon.ico", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "assets/jquery.slides.min.js", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "assets/logo", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "assets/main.css", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "assets/main.js", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "assets/pro_list_banner_img", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "assets/share_box.js", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "assets/user.css", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "config/settings.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "config/settings_data.json", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "layout/theme.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "snippets/filter.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "snippets/filter_simple.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "snippets/footer.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "snippets/go_top.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "snippets/nav_list.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "snippets/oauth.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false }, { "key": "snippets/page_mod.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "snippets/popup.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "snippets/products_filter.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "snippets/products_grid.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "snippets/products_grid_item.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "snippets/products_list_mod.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "snippets/products_paginate.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "snippets/sample_blogs.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "snippets/sample_products.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "snippets/share_box.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "snippets/sys_mod.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/account/change_password.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/account/create_order.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/account/forget_password.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/account/index.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/account/login.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/account/order.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/account/orders_list.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/account/register.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/account/reset_password.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/account/validate_email.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/blog.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/blogs_list.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/cart.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/discount.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/index.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/page.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/product.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/products_list.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/search.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/system/404.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/system/500.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/system/closing.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/system/protecting.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/type.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null }, { "key": "templates/vendor.html", "theme_id": 1482, "type": "system", "trash": false, "rename": false, "version": null } ] }
GET /themes/#{id}/assets?asset[key]=
获取 Theme 的单个 Asset
- fields
- 需要查询的字段
- 获取 Asset 文本文件内容
- GET /themes/1482/assets?asset[key]=templates/account/change_password.html
{ "asset": { "theme_id": 1482, "key": "templates/account/change_password.html", "type": "system", "value": "{% unless form.posted_successfully? %}\n\n...", "public_url": null, "trash": false, "rename": false, "version": null } }
- 获取 Asset 图片文件内容
- GET /themes/1482/assets?asset[key]=assets/blogs_banner_img
{ "asset": { "theme_id": 1482, "key": "assets/blogs_banner_img", "type": "system", "value": null, "public_url": "//asset.ibanquan.com/middle/1482/c/122/54fd4a906387e4ead9000776/blogs_banner_img?rand=1427792969", "trash": false, "rename": false, "version": null } }
POST /themes/#{id}/assets
创建 Asset
- asset[key]
- 文件名
- asset[value]
- 内容
- 创建 Asset 文本文件
- POST /themes/1482/assets
{ "asset": { "key": "templates/test.html", "value": "987654321" } }
{ "asset": { "theme_id": 1482, "key": "templates/test.html", "type": "custom", "value": "987654321", "public_url": null, "trash": true, "rename": true } }
- 创建 Asset 图片文件
- POST /themes/1482/assets
{ "asset": { "key": "assets/test.gif", "value": "data:image/gif;base64,R0lGODlhAQABAID/AP///wAAACwAAAAAAQABAAACAkQBADs=" } }
{ "asset": { "theme_id": 1482, "key": "assets/test", "type": "custom", "value": null, "public_url": "//asset.ibanquan.com/asset/551a656e6387e4bb1a000001/test?rand=1427794434", "trash": true, "rename": true } }}
PUT /themes/#{id}/assets
更新 Asset
- asset[key]
- 主题访问路径
- asset[value]
- 新内容
- asset[version]
- 文件版本号,非必须,当回传该参数时,表示验证文件版本是否被变更,有变更时返回422错误,没有变更时,直接保存,当不回传该参数时,表示强制保存。
- 更新 Asset 文本文件
- PUT /themes/1482/assets
{ "asset": { "key": "templates/test.html", "value": "987654321", "version": "d66407160dc04dc2aa4946c205afabe0" } }
{ "asset": { "theme_id": 1482, "key": "templates/test.html", "type": "custom", "value": "987654321", "public_url": null, "trash": true, "rename": true } }
- 更新 Asset 图片文件
- PUT /themes/1482/assets
{ "asset": { "key": "assets/test.gif", "value": "data:image/gif;base64,R0lGODlhAQABAID/AP///wAAACwAAAAAAQABAAACAkQBADs=" } }
{ "asset": { "theme_id": 1482, "key": "assets/test", "type": "custom", "value": null, "public_url": "//asset.ibanquan.com/asset/551a656e6387e4bb1a000001/test?rand=1427794434", "trash": true, "rename": true } }
DELETE /themes/#{id}/assets?asset[key]=
删除 Asset
- 删除 Asset
- DELETE /themes/1482/assets?asset[key]=layout/theme.123.html
{}