Shopify API – Asset
top
Receive a single Asset
There are different buckets which hold different kinds of assets, each corresponding to one of the folders within a theme's zip file: layout , templates , and assets . The full key of an asset always starts with the bucket name, and the path separator is a forward slash, like layout/theme.liquid or assets/bg-body.gif .
GET /admin/assets.xml?asset[key]=templates/index.liquid
Get a liquid template
Response
HTTP/1.1 200 OK
< asset >< key > templates/index.liquid</ key >< created_at > 2009-10-20 07:25:08 -0400</ created_at >< updated_at > 2009-10-20 07:25:08 -0400</ updated_at >< value > < !-- LIST 3 PER ROW -->
<h2> Featured Products</h2>
< table id=" products" cellspacing=" 0" cellpadding=" 0">
{% tablerow product in collections.frontpage.products cols:3 %}
< a href=" {{product.url}}"> {{ product.featured_image | product_img_url: 'small' | img_tag }}</a>
<h3>< a href=" {{product.url}}"> {{product.title}}</a></h3>
< ul class=" attributes">
<li>< span class=" money"> {{product.price_min | money}}< /span>< /li>
</ul>
{% endtablerow %}
< /table>
< !-- /LIST 3 PER ROW -->
< div id=" articles">
{% assign article = pages.frontpage %}
< div class=" article">
{% if article.content != "" %}
<h3> {{ article.title }}</h3>
< div class=" article-body textile">
{{ article.content }}
</div>
{% else %}
< div class=" article-body textile">
In <em> Admin &gt; Blogs &amp; Pages</em> , create a page with the handle < strong>< code> frontpage< /code>< /strong> and it will show up here.< br />
{{ " Learn more about handles" | link_to " http://wiki.shopify.com/Handle" }}
</div>
{% endif %}
</div>
</div>
</ value ></ asset >
GET /admin/assets.xml?asset[key]=assets/bg-body.gif
Get a theme image
Response
HTTP/1.1 200 OK
< asset >< key > assets/bg-body.gif</ key >< created_at > 2009-10-20 07:25:09 -0400</ created_at >< updated_at > 2009-10-20 07:25:09 -0400</ updated_at >< attachment > R0lGODlhBgCTAPcAAIzH6Xu423y53IO/4pXP8CAgIJPN75HM7X263YvG6Hq3
2nq325XP8X+835LM7pDL7YTA45TO8I3I6pLN7oG+4IfD5ZPO75DK7I7J64K+
4YC94IbC5ITA4onF54rF54C834jD5o/K7JDL7JHM7nq424XB45TP8JXQ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Qi7I0Yc0HvArgNE
IzLtPTDkgGHCBx4QfsD4wRARiocwliwC8gXIlSNZuhxCRIgLny+IBh06BBUq
SEIg6XTj9A0kr0NgeH0Dg+3ZbGyzCWQ7EBssGLBgWSNBjx4sEpKvIZ68uQQ/
fs7IgSPnzCAA1gFo1w5nu3dA25/+POEE6EkCAGrMJ0igXs16L+7Xy0CDxgsa
GV4S4Pcgo7+H/x5s0oEHA3aQA4E55NDBggumkKAKOahQiQqMpKDChSmAoEKG
IICQQoYpTAFCBU2QOEWJTYAgYolTVPBFBYpUIOMXVVRRQRV4bPCFE058gYcT
G2zAYxVBFrkBE0gmUQITJSTBRBJ00FHCD01WCUEJmFwyJQQ/QOAllxBwwCUH
dtjxg5hhQmAFB2wWksiaHFgxgJwD1PnGACwMcGedA4DCgiZvsJAnnhmwkEGh
GVBwqBF8ZGDEoRnwQYERlFLgCAUUZPEJphpkgSkFGtyRRRYaaIBCqafegQIK
H5z6gQb+HwiyaqwfNNBArR/UaqutRzTgAiG2uiDsHMI+ckQox86B7LGhNOts
KFFAK+0YoXARyhjU/gFGKGAgwAUYYHCBQBR/iIvAuecSsQQRRCCAQx44LIED
ETicK4C8eaSBgAD03rvIvWmkIcDABGvhhgBaDKyEGwEkrIQWSkjBsBJkkBGA
FEoEsMceAQRgsRQkSBEACR13TPICWwSwxckoK9DxAguQEDPKMC/gCQkKLNBF
zgq00UcXXfisgAI470xJz0MrUMDSTM/g9NM6RC21DVRX3cPVWPug9dY8dO31
DmCHHcPYZAth9tlBpK02DGy3zTTTNMQtNxB0113D3Xi/oPcD3gEBADs=
</ attachment ></ asset >
top
Creating or Modifying an Asset
PUT takes care of both creating new assets and updating existing ones
PUT /admin/assets.xml
Change an existing liquid template's value
Request
<? xml version =" 1.0 " encoding =" UTF-8 "?>
< asset >
< value > < img src='backsoon-postit.png'>< p> We are busy updating the store for you and will be back within the hour.</p> </ value >
< key > templates/index.liquid</ key >
</ asset >
Response
HTTP/1.1 200 OK
PUT /admin/assets.xml
Copy an asset by providing a source key
Request
<? xml version =" 1.0 " encoding =" UTF-8 "?>
< asset >
< key > layout/alternate.liquid</ key >
< source-key > layout/theme.liquid</ source-key >
</ asset >
Response
HTTP/1.1 200 OK
PUT /admin/assets.xml
Create a new image by providing a base64-encoded attachment
Request
<? xml version =" 1.0 " encoding =" UTF-8 "?>
< asset >
< attachment > R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==
</ attachment >
< key > assets/empty.gif</ key >
</ asset >
Response
HTTP/1.1 200 OK
PUT /admin/assets.xml
Update an image by providing a source URL from which to fetch the value
Request
<? xml version =" 1.0 " encoding =" UTF-8 "?>
< asset >
< src > http://apple.com/new_bg.gif</ src >
< key > assets/bg-body.gif</ key >
</ asset >
Response
HTTP/1.1 200 OK
top
Remove a Asset from the database
Remove assets from your shop
DELETE /admin/assets.xml?asset[key]=assets/bg-body.gif
Delete an image from your theme
Response
HTTP/1.1 200 OK
DELETE /admin/assets.xml?asset[key]=layout/theme.liquid
There are some files you cannot delete
Response
HTTP/1.1 403 Forbidden
Last updated at Oct 2009 Oct:10 AM.