Difference between revisions of "API Page"
From Spiffy Stores Knowledge Base
m |
|||
(21 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
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. | 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. | ||
Line 41: | Line 17: | ||
|- | |- | ||
!handle | !handle | ||
− | |<pre></pre> | + | |<pre>{ "handle" : "how-to-save-money" }</pre> |
+ | 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 | ||
− | |<pre></pre> | + | |<pre>{ "body" : "This is a *sample* page."}</pre> |
+ | 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 | ||
− | |<pre></pre> | + | |<pre>{ "body_html" : "<p>This is a <b>sample</b> page.</p>"}</pre> |
+ | The text content of the page, complete with HTML markup. | ||
|- | |- | ||
!created_at | !created_at | ||
− | |<pre></pre> | + | |<pre>{ "created_at": "2008-07-15T20:00:00-04:00" }</pre> |
+ | The date and time (ISO 8601 format) when the page was created. | ||
|- | |- | ||
!updated_at | !updated_at | ||
− | |<pre></pre> | + | |<pre>{ "updated_at": "2008-07-16T20:00:00-04:00" }</pre> |
+ | The date and time (ISO 8601 format) when the page was last updated. | ||
|- | |- | ||
!published | !published | ||
− | |<pre></pre> | + | |<pre>{ "published" : true }</pre> |
+ | 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_status | ||
+ | |Limit the results to only include pages with the given published status ('published' or 'unpublished'). | ||
+ | |- | ||
+ | !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/pages.json?fields=id,handle,body | ||
+ | |||
+ | GET /api/pages.json?handle=how-to-make-money | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | === <code>GET /api/pages/count.json</code> === | ||
+ | |||
+ | Return a page count. | ||
+ | |||
+ | ==== Optional Parameters ==== | ||
+ | |||
+ | {| class="reference" | ||
+ | !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_status | ||
+ | |Limit the results to only include pages with the given published status ('published' or 'unpublished'). | ||
+ | |- | ||
+ | !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". | ||
+ | |} | ||
+ | |||
+ | ==== Example Request and Response ==== | ||
+ | |||
+ | <pre> | ||
+ | GET /api/pages/count.json | ||
+ | |||
+ | HTTP/1.1 200 OK | ||
+ | |||
+ | { | ||
+ | "count": 578 | ||
+ | } | ||
+ | |||
+ | Examples using filters | ||
+ | |||
+ | GET /api/pages/count.json?handle=how-to-make-money | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | === <code>GET /api/pages/PAGE_ID.json</code> === | ||
+ | |||
+ | Retrieves a single page by its ID. | ||
+ | |||
+ | ==== Optional Parameters ==== | ||
+ | |||
+ | {| class="reference" | ||
+ | !fields | ||
+ | |A comma-separated list of fields to return in the response. | ||
+ | |} | ||
+ | |||
+ | ==== Example Request and Response ==== | ||
+ | |||
+ | <pre> | ||
+ | GET /api/pages/123456789.json | ||
+ | |||
+ | HTTP/1.1 200 OK | ||
+ | |||
+ | { | ||
+ | "page": { | ||
+ | "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 | ||
+ | } | ||
+ | } | ||
+ | </pre> | ||
+ | |||
+ | === <code>POST /api/pages.json</code> === | ||
+ | |||
+ | Creates a page. | ||
+ | |||
+ | ==== Example Request and Response ==== | ||
+ | |||
+ | <pre> | ||
+ | POST /api/pages.json | ||
+ | |||
+ | { | ||
+ | "page": { | ||
+ | "title": "How to make more money", | ||
+ | "body": "This is a *sample* page.", | ||
+ | "published": true | ||
+ | } | ||
+ | } | ||
+ | |||
+ | HTTP/1.1 201 Created | ||
+ | </pre> | ||
+ | |||
+ | === <code>PUT /api/pages/PAGE_ID.json</code> === | ||
+ | |||
+ | Updates a page. | ||
+ | |||
+ | ==== Example Request and Response ==== | ||
+ | |||
+ | <pre> | ||
+ | PUT /api/pages/123456789.json | ||
+ | |||
+ | { | ||
+ | "page": { | ||
+ | "id": 123456789, | ||
+ | "title": "Untold Wealth" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | HTTP/1.1 200 OK | ||
+ | </pre> | ||
+ | |||
+ | === <code>DELETE /api/pages/PAGE_ID.json</code> === | ||
+ | |||
+ | Deletes a page. | ||
+ | |||
+ | ==== Example Request and Response ==== | ||
+ | |||
+ | <pre> | ||
+ | DELETE /api/pages/123456789.json | ||
+ | |||
+ | HTTP/1.1 200 OK | ||
+ | |||
+ | {} | ||
+ | </pre> | ||
+ | |||
+ | == Further Reference == | ||
+ | |||
+ | * [[An Introduction to the Spiffy Stores API]] | ||
+ | * [[Creating Private API Keys]] | ||
+ | * [[Using the API]] | ||
+ | * [[API Reference]] |
Latest revision as of 11:40, 24 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_status | Limit the results to only include pages with the given published status ('published' or 'unpublished'). |
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/pages.json?fields=id,handle,body GET /api/pages.json?handle=how-to-make-money
GET /api/pages/count.json
Return a page count.
Optional Parameters
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_status | Limit the results to only include pages with the given published status ('published' or 'unpublished'). |
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". |
Example Request and Response
GET /api/pages/count.json HTTP/1.1 200 OK { "count": 578 } Examples using filters GET /api/pages/count.json?handle=how-to-make-money
GET /api/pages/PAGE_ID.json
Retrieves a single page by its ID.
Optional Parameters
fields | A comma-separated list of fields to return in the response. |
---|
Example Request and Response
GET /api/pages/123456789.json HTTP/1.1 200 OK { "page": { "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 } }
POST /api/pages.json
Creates a page.
Example Request and Response
POST /api/pages.json { "page": { "title": "How to make more money", "body": "This is a *sample* page.", "published": true } } HTTP/1.1 201 Created
PUT /api/pages/PAGE_ID.json
Updates a page.
Example Request and Response
PUT /api/pages/123456789.json { "page": { "id": 123456789, "title": "Untold Wealth" } } HTTP/1.1 200 OK
DELETE /api/pages/PAGE_ID.json
Deletes a page.
Example Request and Response
DELETE /api/pages/123456789.json HTTP/1.1 200 OK {}