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>&lt;!-- LIST 3 PER ROW --&gt;
&lt;h2&gt;Featured Products&lt;/h2&gt;
&lt;table id=&quot;products&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;
{% tablerow product in collections.frontpage.products cols:3  %}
   &lt;a href=&quot;{{product.url}}&quot;&gt;{{ product.featured_image | product_img_url: 'small' | img_tag }}&lt;/a&gt;
   &lt;h3&gt;&lt;a href=&quot;{{product.url}}&quot;&gt;{{product.title}}&lt;/a&gt;&lt;/h3&gt;
   &lt;ul class=&quot;attributes&quot;&gt;
     &lt;li&gt;&lt;span class=&quot;money&quot;&gt;{{product.price_min | money}}&lt;/span&gt;&lt;/li&gt;
   &lt;/ul&gt;
{% endtablerow %}
&lt;/table&gt;
&lt;!-- /LIST 3 PER ROW  --&gt;

  &lt;div id=&quot;articles&quot;&gt;
  	{% assign article = pages.frontpage %}

    &lt;div class=&quot;article&quot;&gt;
    {% if article.content != &quot;&quot; %}
		  &lt;h3&gt;{{ article.title }}&lt;/h3&gt;
      &lt;div class=&quot;article-body textile&quot;&gt;
  		  {{ article.content }}
  		&lt;/div&gt;
  	{% else %}
      &lt;div class=&quot;article-body textile&quot;&gt;
  	  In &lt;em&gt;Admin &amp;gt; Blogs &amp;amp; Pages&lt;/em&gt;, create a page with the handle &lt;strong&gt;&lt;code&gt;frontpage&lt;/code&gt;&lt;/strong&gt; and it will show up here.&lt;br /&gt;
  	  {{ &quot;Learn more about handles&quot; | link_to &quot;http://wiki.shopify.com/Handle&quot; }}
      &lt;/div&gt;
  	{% endif %}
    &lt;/div&gt;
    
  &lt;/div&gt;

</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/K7JDL7JHM7nq424XB45TP8JXQ8YC9
34jE5onE5pTO74K/4ZbQ8n+73u7u7iQkJDU1NYrF6FpaWsvLy+Xl5VNTU47K
63y63YnE51dXVzw8PEJCQk5OTkhISITB49TU1CkpKS8vL5HL7X263JXQ8IG+
4X+83o/J64XB5Hy43Hy63IbB5IfD5obC5YvH6ZPN7n673Xu43IjD5Y/K64fC
5IPA4pbR8o3J6oG94Hu53Hu323273Xq42orG6IfC5X663ZfQ8pLN73663nu5
25fQ8ZPO8IzI6ovF6Hy53YvH6I7I6o7J6nm32ny524O/4Y3H6pbR8YzI6X+7
34XC45fR8oPA44G934fD5H253Y3I63y424K+4Hm42o3I6X273ozG6Y7I64C8
4IzH6oC734O/45bQ8JLO7pHL7oS/4obD5X253InF5pTP8YK94H6735XO8JDK
7ZTN8JbP8Hm324jE54/L7IXA44TB5JLM7YO+4YnG54zG6I7J7Hu32oK94YK/
4n673pbQ8QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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xAguQEDPKMC/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>&lt;img src='backsoon-postit.png'&gt;&lt;p&gt;We are busy updating the store for you and will be back within the hour.&lt;/p&gt;</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.