API

Pages

Overview

  1. List pages
  2. Create a page
  3. Get a page
  4. Update a page
  5. Delete a page

List pages

Endpoint

GET https://api.siteleaf.com/v2/sites/:site_id/pages

Query String Params

Name Desc
q Searches by title and path
sort Should be formated as field-asc or field-desc
visibility Can be either visible or hidden
extensions A comma separated list of file extensions, or markdown which is equivalent to markdown,md,mkdown,mkdn,mkd

Response

Status: 200 OK
Link: <https://api.siteleaf.com/v2/:path?page=2>; rel="next",
      <https://api.siteleaf.com/v2/:path?page=9>; rel="last"
[
  {
    "id": "5697cc7b16d5640c40000003",
    "title": "My page",
    "body": "Hello world",
    "filename": "example/page.markdown",
    "path": "example/page.markdown",
    "basename": "page.markdown",
    "directory": "example",
    "defaults": {},
    "metadata": {
      "layout": "page"
    },
    "type": "page",
    "date": "2015-10-31T23:50:00+00:00",
    "sha": "3a974494793ed1daf4c94ce54d69fda71480e050",
    "visibility": "visible",
    "permalink": null,
    "url": "/example/page/",
    "site_id": "5697cc7b16d5640c40000002",
    "user_id": "5697cc7b16d5640c40000000",
    "created_at": "2015-12-18 17:00:23 +0000",
    "updated_at": "2016-01-14 05:37:58 +0000"
  }
]

Create a page

Endpoint

POST https://api.siteleaf.com/v2/sites/:site_id/pages

Input

Name Type Desc
title String Page title (required)
body String Page body
path String Path of the page, essentially the filename
permalink String Custom permalink, overrides the generated url
date String ISO8601 formated date
visibility String Valid options are visible and hidden, defaults to visible
metadata Hash<String, *> Arbitrary key/value pairs

Example

{
  "title": "Foo Bar",
  "body": "Lorem ipsum …",
  "metadata": {
    "FizzBuzz": [1, 2, "fizz"]
  }
}

Response

Status: 201 Created
{
  "id": "5697cc7b16d5640c40000003",
  "title": "My page",
  "body": "Hello world",
  "filename": "example/page.markdown",
  "path": "example/page.markdown",
  "basename": "page.markdown",
  "directory": "example",
  "defaults": {},
  "metadata": {
    "layout": "page"
  },
  "type": "page",
  "date": "2015-10-31T23:50:00+00:00",
  "sha": "3a974494793ed1daf4c94ce54d69fda71480e050",
  "visibility": "visible",
  "permalink": null,
  "url": "/example/page/",
  "site_id": "5697cc7b16d5640c40000002",
  "user_id": "5697cc7b16d5640c40000000",
  "created_at": "2015-12-18 17:00:23 +0000",
  "updated_at": "2016-01-14 05:37:58 +0000"
}

Get a page

Endpoint

GET https://api.siteleaf.com/v2/pages/:page_id

Response

Status: 200 OK
{
  "id": "5697cc7b16d5640c40000003",
  "title": "My page",
  "body": "Hello world",
  "filename": "example/page.markdown",
  "path": "example/page.markdown",
  "basename": "page.markdown",
  "directory": "example",
  "defaults": {},
  "metadata": {
    "layout": "page"
  },
  "type": "page",
  "date": "2015-10-31T23:50:00+00:00",
  "sha": "3a974494793ed1daf4c94ce54d69fda71480e050",
  "visibility": "visible",
  "permalink": null,
  "url": "/example/page/",
  "site_id": "5697cc7b16d5640c40000002",
  "user_id": "5697cc7b16d5640c40000000",
  "created_at": "2015-12-18 17:00:23 +0000",
  "updated_at": "2016-01-14 05:37:58 +0000"
}

Update a page

Endpoint

PUT https://api.siteleaf.com/v2/pages/:page_id

Input

Name Type Desc
title String Page title
body String Page body
path String Path of the page, essentially the filename
permalink String Custom permalink, overrides the generated url
date String ISO8601 formated date
visibility String Valid options are visible and hidden, defaults to visible
metadata Hash<String, *> Arbitrary key/value pairs

Example

{
  "title": "Foo Bar",
  "body": "Lorem ipsum …",
  "metadata": {
    "FizzBuzz": [1, 2, "fizz"]
  }
}

Response

Status: 200 OK
{
  "id": "5697cc7b16d5640c40000003",
  "title": "My page",
  "body": "Hello world",
  "filename": "example/page.markdown",
  "path": "example/page.markdown",
  "basename": "page.markdown",
  "directory": "example",
  "defaults": {},
  "metadata": {
    "layout": "page"
  },
  "type": "page",
  "date": "2015-10-31T23:50:00+00:00",
  "sha": "3a974494793ed1daf4c94ce54d69fda71480e050",
  "visibility": "visible",
  "permalink": null,
  "url": "/example/page/",
  "site_id": "5697cc7b16d5640c40000002",
  "user_id": "5697cc7b16d5640c40000000",
  "created_at": "2015-12-18 17:00:23 +0000",
  "updated_at": "2016-01-14 05:37:58 +0000"
}

Delete a page

Endpoint

DELETE https://api.siteleaf.com/v2/pages/:page_id

Response

Status: 200 OK
{
  "id": "5697cc7b16d5640c40000003",
  "deleted": true
}

Help improve this page