Difference between revisions of "API Page"

From Spiffy Stores Knowledge Base

Line 64: Line 64:
 
Indicates whether the page is published and visible to customers.
 
Indicates whether the page is published and visible to customers.
 
}
 
}
 +
 +
== Endpoints ==
 +
 +
=== <code>GET /api/pages.json</code> ===
 +
 +
Retrieve a list of all pages.
 +
 +
==== Optional Parameters ====
 +
 +
{| class="reference"
 +
!limit
 +
|Number of results returned. The default is 30, with a maximum of 50 in a single request.
 +
|-
 +
!page
 +
|The number of the page to return. The number of results per page is set by the <code>limit</code> parameter. If more results are required, then submit the request again, increasing the page number each time.
 +
|-
 +
!since_id
 +
|Limit the results to only include objects which have an id greater than the given value.
 +
|-
 +
!title
 +
|Limit the results to only include pages with the given title.
 +
|-
 +
!handle
 +
|Limit the results to only include pages with the given handle.
 +
|-
 +
!published
 +
|Limit the results to only include pages with the given published status.
 +
|-
 +
!created_at_min
 +
|Return only the pages created after the given date and time. Use the format "2014-12-31 12:00".
 +
|-
 +
!created_at_max
 +
|Return only the pages created before the given date and time. Use the format "2014-12-31 12:00".
 +
|-
 +
!updated_at_min
 +
|Return only the pages updated after the given date and time. Use the format "2014-12-31 12:00".
 +
|-
 +
!updated_at_max
 +
|Return only the pages updated before the given date and time. Use the format "2014-12-31 12:00".
 +
|-
 +
!fields
 +
|A comma-separated list of fields to return in the response.
 +
|}
 +
 +
==== Example Request and Response ====
 +
 +
<pre>
 +
GET /api/pages.json
 +
 +
HTTP/1.1 200 OK
 +
 +
{
 +
  "pages": [
 +
    {
 +
      "id": 123456789,
 +
      "title": "How to make money",
 +
      "handle": "how-to-make-money",
 +
      "body": "This is a *sample* page.",
 +
      "body_html": "<p>This is a <b>sample<b> page.",
 +
      "created_at": "2015-02-19T06:02:51Z",
 +
      "updated_at": "2015-02-19T06:02:51Z",
 +
      "published": true
 +
    }, ...
 +
  ]
 +
}
 +
 +
Examples using filters
 +
 +
GET /api/metafields.json?fields=id,namespace,key,value
 +
 +
GET /api/metafields.json?namespace=inventory
 +
 +
</pre>
 +
 +
=== <code>GET /api/metafields/count.json<br/>GET /api/products/PRODUCT_ID/metafields/count.json<br/>GET /api/variations/VARIATION_ID/metafields/count.json<br/>GET /api/pages/PAGE_ID/metafields/count.json<br/>GET /api/blogs/BLOG_ID/metafields/count.json<br/>GET /api/standard_collections/STANDARD_COLLECTION_ID/metafields/count.json<br/>GET /api/super_collections/SUPER_COLLECTION_ID/metafields/count.json<br/>GET /api/customers/CUSTOMER_ID/metafields/count.json<br/>GET /api/orders/ORDER_ID/metafields/count.json</code> ===
 +
 +
Return a count of metafields that belong to the store, product, variation, page, blog, standard collection, super collection, customer or order.
 +
 +
==== Optional Parameters ====
 +
 +
{| class="reference"
 +
!since_id
 +
|Limit the results to only include objects which have an id greater than the given value.
 +
|-
 +
!namespace
 +
|Limit the results to only include metafields with the given namespace.
 +
|-
 +
!key
 +
|Limit the results to only include metafields with the given key.
 +
|-
 +
!value_type
 +
|Limit the results to only include metafields with the given value_type.
 +
|-
 +
!created_at_min
 +
|Return only the metafields created after the given date and time. Use the format "2014-12-31 12:00".
 +
|-
 +
!created_at_max
 +
|Return only the metafields created before the given date and time. Use the format "2014-12-31 12:00".
 +
|-
 +
!updated_at_min
 +
|Return only the metafields updated after the given date and time. Use the format "2014-12-31 12:00".
 +
|-
 +
!updated_at_max
 +
|Return only the metafields updated before the given date and time. Use the format "2014-12-31 12:00".
 +
|}
 +
 +
==== Example Request and Response ====
 +
 +
<pre>
 +
GET /api/metafields/count.json
 +
 +
HTTP/1.1 200 OK
 +
 +
{
 +
  "count": 578
 +
}
 +
 +
Examples using filters
 +
 +
GET /api/metafields/count.json?namespace=inventory
 +
 +
</pre>
 +
 +
=== <code>GET /api/metafields/METAFIELD_ID.json<br/>GET /api/products/PRODUCT_ID/metafields/METAFIELD_ID.json<br/>GET /api/variations/VARIATION_ID/metafields/METAFIELD_ID.json<br/>GET /api/pages/PAGE_ID/metafields/METAFIELD_ID.json<br/>GET /api/blogs/BLOG_ID/metafields/METAFIELD_ID.json<br/>GET /api/standard_collections/STANDARD_COLLECTION_ID/metafields/METAFIELD_ID.json<br/>GET /api/super_collections/SUPER_COLLECTION_ID/metafields/METAFIELD_ID.json<br/>GET /api/customers/CUSTOMER_ID/metafields/METAFIELD_ID.json<br/>GET /api/orders/ORDER_ID/metafields/METAFIELD_ID.json</code> ===
 +
 +
Return a single metafield that belongs to the store, product, variation, page, blog, standard collection, super collection, customer or order.
 +
 +
==== Optional Parameters ====
 +
 +
{| class="reference"
 +
!fields
 +
|A comma-separated list of fields to return in the response.
 +
|}
 +
 +
==== Example Request and Response ====
 +
 +
<pre>
 +
GET /api/metafields/123456789.json
 +
 +
HTTP/1.1 200 OK
 +
 +
{
 +
  "metafield": {
 +
    "id": 123456789,
 +
    "namespace": "inventory",
 +
    "key": "stock_location",
 +
    "value": "Sydney",
 +
    "value_type": "string",
 +
    "description": "Physical location of stock items",
 +
    "owner_id": 36903842,
 +
    "owner_resource": "Store",
 +
    "created_at": "2015-02-19T06:02:51Z",
 +
    "updated_at": "2015-02-19T06:02:51Z"
 +
  }
 +
}
 +
</pre>
 +
 +
=== <code>POST /api/metafields.json<br/>POST /api/products/PRODUCT_ID/metafields.json<br/>POST /api/variations/VARIATION_ID/metafields.json<br/>POST /api/pages/PAGE_ID/metafields.json<br/>POST /api/blogs/BLOG_ID/metafields.json<br/>POST /api/standard_collections/STANDARD_COLLECTION_ID/metafields.json<br/>POST /api/super_collections/SUPER_COLLECTION_ID/metafields.json<br/>POST /api/customers/CUSTOMER_ID/metafields.json<br/>POST /api/orders/ORDER_ID/metafields.json</code> ===
 +
 +
Create a new metafield that belongs to the store, product, variation, page, blog, standard collection, super collection, customer or order.
 +
 +
==== Example Request and Response ====
 +
 +
<pre>
 +
POST /api/metafields.json
 +
 +
{
 +
  "metafield": {
 +
    "namespace": "inventory",
 +
    "key": "stock_location",
 +
    "value": "Sydney",
 +
    "value_type": "string",
 +
    "description": "Physical location of stock items"
 +
  }
 +
}
 +
 +
HTTP/1.1 201 Created
 +
</pre>
 +
 +
=== <code>PUT /api/metafields/METAFIELD_ID.json<br/>PUT /api/products/PRODUCT_ID/metafields/METAFIELD_ID.json<br/>PUT /api/variations/VARIATION_ID/metafields/METAFIELD_ID.json<br/>PUT /api/pages/PAGE_ID/metafields/METAFIELD_ID.json<br/>PUT /api/blogs/BLOG_ID/metafields/METAFIELD_ID.json<br/>PUT /api/standard_collections/STANDARD_COLLECTION_ID/metafields/METAFIELD_ID.json<br/>PUT /api/super_collections/SUPER_COLLECTION_ID/metafields/METAFIELD_ID.json<br/>PUT /api/customers/CUSTOMER_ID/metafields/METAFIELD_ID.json<br/>PUT /api/orders/ORDER_ID/metafields/METAFIELD_ID.json</code> ===
 +
 +
Update an existing metafield that belongs to the store, product, variation, page, blog, standard collection, super collection, customer or order.
 +
 +
The Namespace and Key of an existing metafield cannot be changed.
 +
 +
==== Example Request and Response ====
 +
 +
<pre>
 +
PUT /api/metafields/123456789.json
 +
 +
{
 +
  "metafield": {
 +
    "id": 123456789,
 +
    "value": "Melbourne",
 +
    "value_type": "string"
 +
  }
 +
}
 +
 +
HTTP/1.1 200 OK
 +
</pre>
 +
 +
=== <code>DELETE /api/metafields/METAFIELD_ID.json<br/>DELETE /api/products/PRODUCT_ID/metafields/METAFIELD_ID.json<br/>DELETE /api/variations/VARIATION_ID/metafields/METAFIELD_ID.json<br/>DELETE /api/pages/PAGE_ID/metafields/METAFIELD_ID.json<br/>DELETE /api/blogs/BLOG_ID/metafields/METAFIELD_ID.json<br/>DELETE /api/standard_collections/STANDARD_COLLECTION_ID/metafields/METAFIELD_ID.json<br/>DELETE /api/super_collections/SUPER_COLLECTION_ID/metafields/METAFIELD_ID.json<br/>DELETE /api/customers/CUSTOMER_ID/metafields/METAFIELD_ID.json<br/>DELETE /api/orders/ORDER_ID/metafields/METAFIELD_ID.json</code> ===
 +
 +
Delete an existing metafield that belongs to the store, product, variation, page, blog, standard collection, super collection, customer or order.
 +
 +
==== Example Request and Response ====
 +
 +
<pre>
 +
DELETE /api/metafields/123456789.json
 +
 +
HTTP/1.1 200 OK
 +
 +
{}
 +
</pre>

Revision as of 18:21, 22 May 2018

Your Spiffy Store comes with a tool for creating basic HTML web pages. Store owners can create any number of pages to hold static content, such as an 'About us' page, a 'Contact us' page, or a page with customer testimonials.

These web pages are represented by the Page resource, and their HTML content is contained in the value of the body_html property. The Page resource lets you retrieve, create, update, and delete web pages for a store.

Pages are used for long-term, static content that rarely changes. Frequently updated content is best created with the Blog resource instead.

Contents

Page Properties

id
{ "id" : 123456789 }

A unique numeric identifier for the page.

title
{ "title" : "How to save Money" }

This is the page title.

handle
{ "handle" : "how-to-save-money" }

A unique, human-friendly string for the page, generated automatically from its title. In online store themes, the Liquid templating language refers to a page by its handle.

body
{ "body" : "This is a *sample* page."}

The text content of the page in Textile markup. This is automatically translated into body_html for display on a browser.

body_html
{ "body_html" : "<p>This is a <b>sample</b> page.</p>"}

The text content of the page, complete with HTML markup.

created_at
{ "created_at": "2008-07-15T20:00:00-04:00" }

The date and time (ISO 8601 format) when the page was created.

updated_at
{ "updated_at": "2008-07-16T20:00:00-04:00" }

The date and time (ISO 8601 format) when the page was last updated.

published
{ "published" : true }

Indicates whether the page is published and visible to customers. }

Endpoints

GET /api/pages.json

Retrieve a list of all pages.

Optional Parameters

limit Number of results returned. The default is 30, with a maximum of 50 in a single request.
page The number of the page to return. The number of results per page is set by the limit parameter. If more results are required, then submit the request again, increasing the page number each time.
since_id Limit the results to only include objects which have an id greater than the given value.
title Limit the results to only include pages with the given title.
handle Limit the results to only include pages with the given handle.
published Limit the results to only include pages with the given published status.
created_at_min Return only the pages created after the given date and time. Use the format "2014-12-31 12:00".
created_at_max Return only the pages created before the given date and time. Use the format "2014-12-31 12:00".
updated_at_min Return only the pages updated after the given date and time. Use the format "2014-12-31 12:00".
updated_at_max Return only the pages updated before the given date and time. Use the format "2014-12-31 12:00".
fields A comma-separated list of fields to return in the response.

Example Request and Response

GET /api/pages.json

HTTP/1.1 200 OK

{
  "pages": [
    {
      "id": 123456789,
      "title": "How to make money",
      "handle": "how-to-make-money",
      "body": "This is a *sample* page.",
      "body_html": "<p>This is a <b>sample<b> page.",
      "created_at": "2015-02-19T06:02:51Z",
      "updated_at": "2015-02-19T06:02:51Z",
      "published": true
    }, ...
  ]
}

Examples using filters

GET /api/metafields.json?fields=id,namespace,key,value

GET /api/metafields.json?namespace=inventory

GET /api/metafields/count.json
GET /api/products/PRODUCT_ID/metafields/count.json
GET /api/variations/VARIATION_ID/metafields/count.json
GET /api/pages/PAGE_ID/metafields/count.json
GET /api/blogs/BLOG_ID/metafields/count.json
GET /api/standard_collections/STANDARD_COLLECTION_ID/metafields/count.json
GET /api/super_collections/SUPER_COLLECTION_ID/metafields/count.json
GET /api/customers/CUSTOMER_ID/metafields/count.json
GET /api/orders/ORDER_ID/metafields/count.json

Return a count of metafields that belong to the store, product, variation, page, blog, standard collection, super collection, customer or order.

Optional Parameters

since_id Limit the results to only include objects which have an id greater than the given value.
namespace Limit the results to only include metafields with the given namespace.
key Limit the results to only include metafields with the given key.
value_type Limit the results to only include metafields with the given value_type.
created_at_min Return only the metafields created after the given date and time. Use the format "2014-12-31 12:00".
created_at_max Return only the metafields created before the given date and time. Use the format "2014-12-31 12:00".
updated_at_min Return only the metafields updated after the given date and time. Use the format "2014-12-31 12:00".
updated_at_max Return only the metafields updated before the given date and time. Use the format "2014-12-31 12:00".

Example Request and Response

GET /api/metafields/count.json

HTTP/1.1 200 OK

{
  "count": 578
}

Examples using filters

GET /api/metafields/count.json?namespace=inventory

GET /api/metafields/METAFIELD_ID.json
GET /api/products/PRODUCT_ID/metafields/METAFIELD_ID.json
GET /api/variations/VARIATION_ID/metafields/METAFIELD_ID.json
GET /api/pages/PAGE_ID/metafields/METAFIELD_ID.json
GET /api/blogs/BLOG_ID/metafields/METAFIELD_ID.json
GET /api/standard_collections/STANDARD_COLLECTION_ID/metafields/METAFIELD_ID.json
GET /api/super_collections/SUPER_COLLECTION_ID/metafields/METAFIELD_ID.json
GET /api/customers/CUSTOMER_ID/metafields/METAFIELD_ID.json
GET /api/orders/ORDER_ID/metafields/METAFIELD_ID.json

Return a single metafield that belongs to the store, product, variation, page, blog, standard collection, super collection, customer or order.

Optional Parameters

fields A comma-separated list of fields to return in the response.

Example Request and Response

GET /api/metafields/123456789.json

HTTP/1.1 200 OK

{
  "metafield": {
    "id": 123456789,
    "namespace": "inventory",
    "key": "stock_location",
    "value": "Sydney",
    "value_type": "string",
    "description": "Physical location of stock items",
    "owner_id": 36903842,
    "owner_resource": "Store",
    "created_at": "2015-02-19T06:02:51Z",
    "updated_at": "2015-02-19T06:02:51Z"
  }
}

POST /api/metafields.json
POST /api/products/PRODUCT_ID/metafields.json
POST /api/variations/VARIATION_ID/metafields.json
POST /api/pages/PAGE_ID/metafields.json
POST /api/blogs/BLOG_ID/metafields.json
POST /api/standard_collections/STANDARD_COLLECTION_ID/metafields.json
POST /api/super_collections/SUPER_COLLECTION_ID/metafields.json
POST /api/customers/CUSTOMER_ID/metafields.json
POST /api/orders/ORDER_ID/metafields.json

Create a new metafield that belongs to the store, product, variation, page, blog, standard collection, super collection, customer or order.

Example Request and Response

POST /api/metafields.json

{
  "metafield": {
    "namespace": "inventory",
    "key": "stock_location",
    "value": "Sydney",
    "value_type": "string",
    "description": "Physical location of stock items"
  }
}

HTTP/1.1 201 Created

PUT /api/metafields/METAFIELD_ID.json
PUT /api/products/PRODUCT_ID/metafields/METAFIELD_ID.json
PUT /api/variations/VARIATION_ID/metafields/METAFIELD_ID.json
PUT /api/pages/PAGE_ID/metafields/METAFIELD_ID.json
PUT /api/blogs/BLOG_ID/metafields/METAFIELD_ID.json
PUT /api/standard_collections/STANDARD_COLLECTION_ID/metafields/METAFIELD_ID.json
PUT /api/super_collections/SUPER_COLLECTION_ID/metafields/METAFIELD_ID.json
PUT /api/customers/CUSTOMER_ID/metafields/METAFIELD_ID.json
PUT /api/orders/ORDER_ID/metafields/METAFIELD_ID.json

Update an existing metafield that belongs to the store, product, variation, page, blog, standard collection, super collection, customer or order.

The Namespace and Key of an existing metafield cannot be changed.

Example Request and Response

PUT /api/metafields/123456789.json

{
  "metafield": {
    "id": 123456789,
    "value": "Melbourne",
    "value_type": "string"
  }
}

HTTP/1.1 200 OK

DELETE /api/metafields/METAFIELD_ID.json
DELETE /api/products/PRODUCT_ID/metafields/METAFIELD_ID.json
DELETE /api/variations/VARIATION_ID/metafields/METAFIELD_ID.json
DELETE /api/pages/PAGE_ID/metafields/METAFIELD_ID.json
DELETE /api/blogs/BLOG_ID/metafields/METAFIELD_ID.json
DELETE /api/standard_collections/STANDARD_COLLECTION_ID/metafields/METAFIELD_ID.json
DELETE /api/super_collections/SUPER_COLLECTION_ID/metafields/METAFIELD_ID.json
DELETE /api/customers/CUSTOMER_ID/metafields/METAFIELD_ID.json
DELETE /api/orders/ORDER_ID/metafields/METAFIELD_ID.json

Delete an existing metafield that belongs to the store, product, variation, page, blog, standard collection, super collection, customer or order.

Example Request and Response

DELETE /api/metafields/123456789.json

HTTP/1.1 200 OK

{}