In addition to an online storefront, Haravan shops come with a web page creation tool, allowing a shop to have one or more pages. Shop owners are encouraged to use pages for information that customers will use often, such as an 'About Us' page, a 'Contact Us' page, a page with customer testimonials etc.
Reminder
Pages are meant to be used for static content. If the shop needs a page for content that is created on a regular basis, we recommend that you use the blog feature instead.
What you can do with Page
The Haravan API lets you do the following with the Page resource. More detailed versions of these general actions may be available:
- GET /web/pages.jsonReceive a list of all Pages
- GET /web/pages/count.jsonReceive a count of all Pages
- GET /web/pages/#{id}.jsonReceive a single Page
- POST /web/pages.jsonCreate a new Page
- PUT /web/pages/#{id}.jsonModify an existing Page
- DELETE /web/pages/#{id}.jsonRemove a Page from the database
Page properties
author |
The name of the person who created the page. |
body_html |
Text content of the page, complete with HTML markup. |
created_at |
The date and time when the page was created. The API returns this value in ISO 8601 format. |
handle |
A human-friendly unique string for the page automatically generated from its title. This is used in shop themes by the Liquid templating language to refer to the page. |
id |
The unique numeric identifier for the page. |
metafield |
Attaches additional information to a shop's resources:
|
published_at |
This can have two different types of values, depending on whether the page has been published (i.e., made visible to the blog's readers).
|
shop_id |
The id of the shop to which the page belongs. |
template_suffix |
The suffix of the liquid template being used. By default, the original template is called page.liquid, without any suffix. Any additional templates will be: page.suffix.liquid. |
title |
The title of the page. |
updated_at |
The date and time when the page was last updated. The API returns this value in ISO 8601 format. |
Endpoints
limit | Amount of results (default: 50) (maximum: 250) |
page | Page to show (default: 1) |
since_id | Restrict results to after the specified ID |
title | Show pages by Title |
handle | Filter by Page handle |
created_at_min | Show pages created after date (format: 2008-12-31) |
created_at_max | Show pages created before date (format: 2008-12-31) |
updated_at_min | Show pages last updated after date (format: 2008-12-31) |
updated_at_max | Show pages last updated before date (format: 2008-12-31) |
published_at_min | Show pages published after date (format: 2014-04-25T16:15:47-04:00) |
published_at_max | Show pages published before date (format: 2014-04-25T16:15:47-04:00) |
fields | comma-separated list of fields to include in the response |
published_status |
|
Get all pages for a shop
GET /web/pages.json
Response:
HTTP/1.1 200 OK { "pages": [ { "id": 322471, "title": "Support", "shop_id": 690933842, "handle": "support", "body_html": "<p>Come in store for support.<\/p>", "author": "Dennis", "created_at": "2009-07-15T20:00:00-04:00", "updated_at": "2009-07-16T20:00:00-04:00", "published_at": null, "template_suffix": null }, { "id": 108828309, "title": "Sample Page", "shop_id": 690933842, "handle": "sample", "body_html": "<p>this is a <strong>sample<\/strong> page.<\/p>", "author": "Dennis", "created_at": "2008-07-15T20:00:00-04:00", "updated_at": "2008-07-16T20:00:00-04:00", "published_at": null, "template_suffix": null }, { "id": 131092082, "title": "Terms of Services", "shop_id": 690933842, "handle": "tos", "body_html": "<p>We make <strong>perfect<\/strong> stuff, we don't need a warranty.<\/p>", "author": "Dennis", "created_at": "2008-07-15T20:00:00-04:00", "updated_at": "2008-07-16T20:00:00-04:00", "published_at": "2008-07-15T20:00:00-04:00", "template_suffix": null }, { "id": 169524623, "title": "Store hours", "shop_id": 690933842, "handle": "store-hours", "body_html": "<p>We never close.<\/p>", "author": "Jobs", "created_at": "2013-12-31T19:00:00-05:00", "updated_at": "2013-12-31T19:00:00-05:00", "published_at": "2014-02-01T19:00:00-05:00", "template_suffix": null } ] }
Get a list of all pages after the specified ID
GET /web/pages.json?since_id=108828309
Response:
HTTP/1.1 200 OK { "pages": [ { "id": 131092082, "title": "Terms of Services", "shop_id": 690933842, "handle": "tos", "body_html": "<p>We make <strong>perfect<\/strong> stuff, we don't need a warranty.<\/p>", "author": "Dennis", "created_at": "2008-07-15T20:00:00-04:00", "updated_at": "2008-07-16T20:00:00-04:00", "published_at": "2008-07-15T20:00:00-04:00", "template_suffix": null }, { "id": 169524623, "title": "Store hours", "shop_id": 690933842, "handle": "store-hours", "body_html": "<p>We never close.<\/p>", "author": "Jobs", "created_at": "2013-12-31T19:00:00-05:00", "updated_at": "2013-12-31T19:00:00-05:00", "published_at": "2014-02-01T19:00:00-05:00", "template_suffix": null } ] }
title | Pages with a given title |
created_at_min | Pages created after date (format: 2008-12-31) |
created_at_max | Pages created before date (format: 2008-12-31) |
updated_at_min | Pages last updated after date (format: 2008-12-31) |
updated_at_max | Pages last updated before date (format: 2008-12-31) |
published_at_min | Show pages published after date (format: 2014-04-25T16:15:47-04:00) |
published_at_max | Show pages published before date (format: 2014-04-25T16:15:47-04:00) |
published_status |
|
Count all pages for a shop
GET /web/pages/count.json
Response:
HTTP/1.1 200 OK { "count": 4 }
fields | comma-separated list of fields to include in the response |
Get a single page
GET /web/pages/#{id}.json
Response:
HTTP/1.1 200 OK { "page": { "id": 131092082, "title": "Terms of Services", "shop_id": 690933842, "handle": "tos", "body_html": "<p>We make <strong>perfect<\/strong> stuff, we don't need a warranty.<\/p>", "author": "Dennis", "created_at": "2008-07-15T20:00:00-04:00", "updated_at": "2008-07-16T20:00:00-04:00", "published_at": "2008-07-15T20:00:00-04:00", "template_suffix": null } }
Create a new, but unpublished page
POST /web/pages.json
{ "page": { "title": "Warranty information", "body_html": "<h1>Warranty<\/h1>\n<p><strong>Forget it<\/strong>, we aint giving you nothing<\/p>", "published": false } }
Response:
HTTP/1.1 201 Created { "page": { "id": 905192171, "title": "Warranty information", "shop_id": 690933842, "handle": "warranty-information", "body_html": "<h1>Warranty<\/h1>\n<p><strong>Forget it<\/strong>, we aint giving you nothing<\/p>", "author": "Shopify API", "created_at": "2017-01-05T15:42:18-05:00", "updated_at": "2017-01-05T15:42:18-05:00", "published_at": null, "template_suffix": null } }
Trying to create a page without a title will return an error
POST /web/pages.json
{ "page": { "body": "foobar" } }
Response:
HTTP/1.1 422 Unprocessable Entity { "errors": { "title": [ "can't be blank" ] } }
Create a page with a metafield
Create a new page with html markup and upload it to the shop
POST /web/pages.json
{ "page": { "title": "Warranty information", "body_html": "<h1>Warranty<\/h1>\n<p><strong>Forget it<\/strong>, we aint giving you nothing<\/p>" } }
Response:
HTTP/1.1 201 Created { "page": { "id": 905192173, "title": "Warranty information", "shop_id": 690933842, "handle": "warranty-information", "body_html": "<h1>Warranty<\/h1>\n<p><strong>Forget it<\/strong>, we aint giving you nothing<\/p>", "author": "Haravan API", "created_at": "2017-01-05T15:42:20-05:00", "updated_at": "2017-01-05T15:42:20-05:00", "published_at": "2017-01-05T15:42:20-05:00", "template_suffix": null } }
Show a hidden page by changing the published attribute to true
PUT /web/pages/#{id}.json
{ "page": { "id": 131092082, "published": true } }
Response:
HTTP/1.1 200 OK { "page": { "shop_id": 690933842, "id": 131092082, "published_at": "2017-01-05T15:42:15-05:00", "title": "Terms of Services", "handle": "tos", "body_html": "<p>We make <strong>perfect<\/strong> stuff, we don't need a warranty.<\/p>", "author": "Dennis", "created_at": "2008-07-15T20:00:00-04:00", "updated_at": "2017-01-05T15:42:15-05:00", "template_suffix": null } }
Update an existing page body_html
PUT /web/pages/#{id}.json
{ "page": { "id": 131092082, "body_html": "<p>Okay, maybe we will give you a warranty.<\/p>" } }
Response:
HTTP/1.1 200 OK { "page": { "shop_id": 690933842, "id": 131092082, "title": "Terms of Services", "handle": "tos", "body_html": "<p>Okay, maybe we will give you a warranty.<\/p>", "author": "Dennis", "created_at": "2008-07-15T20:00:00-04:00", "updated_at": "2017-01-05T15:42:16-05:00", "published_at": "2008-07-15T20:00:00-04:00", "template_suffix": null } }
Hide a published page by changing the published attribute to false
PUT /web/pages/#{id}.json
{ "page": { "id": 131092082, "published": false } }
Response:
HTTP/1.1 200 OK { "page": { "shop_id": 690933842, "id": 131092082, "title": "Terms of Services", "handle": "tos", "body_html": "<p>We make <strong>perfect<\/strong> stuff, we don't need a warranty.<\/p>", "author": "Dennis", "created_at": "2008-07-15T20:00:00-04:00", "updated_at": "2017-01-05T15:42:17-05:00", "published_at": null, "template_suffix": null } }
Add a metafield to an existing page
PUT /web/pages/#{id}.json
{ "page": { "id": 131092082, "metafields": [ { "key": "new", "value": "newvalue", "value_type": "string", "namespace": "global" } ] } }
Response:
Update an existing page completely
PUT /web/pages/#{id}.json
{ "page": { "id": 131092082, "body_html": "<p>Okay, maybe we will give you a warranty.<\/p>", "author": "Your name", "title": "My new Title", "handle": "new-title" } }
Response:
HTTP/1.1 200 OK { "page": { "shop_id": 690933842, "id": 131092082, "title": "My new Title", "handle": "new-title", "body_html": "<p>Okay, maybe we will give you a warranty.<\/p>", "author": "Your name", "created_at": "2008-07-15T20:00:00-04:00", "updated_at": "2017-01-05T15:42:20-05:00", "published_at": "2008-07-15T20:00:00-04:00", "template_suffix": null } }
Remove an existing page from a shop
DELETE /web/pages/#{id}.json
Response:
HTTP/1.1 200 OK {}