API

Documents

Overview

  1. List documents
  2. Create a document
  3. Get a document
  4. Update a document
  5. Delete a document

List documents

Endpoint

GET https://api.siteleaf.com/v2/sites/:site_id/collections/:path/documents

Query String Params

Name Desc
q Searches by title and path
sort Should be formated as field-asc or field-desc
visibility Can be one of visible, hidden or draft
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": "5697cc7b16d5640c40000005",
    "title": "The Great Gatsby",
    "body": "Lorem ipsum…",
    "filename": "_books/the-great-gatsby.md",
    "path": "the-great-gatsby.md",
    "basename": "the-great-gatsby.md",
    "directory": "_books",
    "tags": [],
    "categories": ["fiction"],
    "defaults": {
      "layout": "books"
    },
    "metadata": {},
    "type": "document",
    "date": null,
    "sha": "4d481d526f0010ed96e43260f0e776acf6da315d",
    "visibility": "visible",
    "permalink": null,
    "url": "/books/the-great-gatsby.html",
    "site_id": "5697cc7b16d5640c40000002",
    "user_id": "5697cc7b16d5640c40000000",
    "created_at": "2016-01-14 20:50:46 +0000",
    "updated_at": "2016-01-14 20:56:40 +0000"
  }
]

Create a document

Endpoint

POST https://api.siteleaf.com/v2/sites/:site_id/collections/:path/documents

Input

Name Type Desc
title String Document title (required)
body String Document body
path String Path of the document relative to its collection
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
tags Array<String> Document tags
categories Array<String> Document categories

Example

{
  "tags": ["required reading"],
  "metadata": {
    "author": "F. Scott Fitzgerald"
  }
}

Response

Status: 201 Created
{
  "id": "5697cc7b16d5640c40000005",
  "title": "The Great Gatsby",
  "body": "Lorem ipsum…",
  "filename": "_books/the-great-gatsby.md",
  "path": "the-great-gatsby.md",
  "basename": "the-great-gatsby.md",
  "directory": "_books",
  "tags": [],
  "categories": ["fiction"],
  "defaults": {
    "layout": "books"
  },
  "metadata": {},
  "type": "document",
  "date": null,
  "sha": "4d481d526f0010ed96e43260f0e776acf6da315d",
  "visibility": "visible",
  "permalink": null,
  "url": "/books/the-great-gatsby.html",
  "site_id": "5697cc7b16d5640c40000002",
  "user_id": "5697cc7b16d5640c40000000",
  "created_at": "2016-01-14 20:50:46 +0000",
  "updated_at": "2016-01-14 20:56:40 +0000"
}

Get a document

Endpoint

GET https://api.siteleaf.com/v2/documents/:document_id

Response

Status: 200 OK
{
  "id": "5697cc7b16d5640c40000005",
  "title": "The Great Gatsby",
  "body": "Lorem ipsum…",
  "filename": "_books/the-great-gatsby.md",
  "path": "the-great-gatsby.md",
  "basename": "the-great-gatsby.md",
  "directory": "_books",
  "tags": [],
  "categories": ["fiction"],
  "defaults": {
    "layout": "books"
  },
  "metadata": {},
  "type": "document",
  "date": null,
  "sha": "4d481d526f0010ed96e43260f0e776acf6da315d",
  "visibility": "visible",
  "permalink": null,
  "url": "/books/the-great-gatsby.html",
  "site_id": "5697cc7b16d5640c40000002",
  "user_id": "5697cc7b16d5640c40000000",
  "created_at": "2016-01-14 20:50:46 +0000",
  "updated_at": "2016-01-14 20:56:40 +0000"
}

Update a document

Endpoint

PUT https://api.siteleaf.com/v2/documents/:document_id

Input

Name Type Desc
title String Document title
body String Document body
path String Path of the document relative to its collection
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
tags Array<String> Document tags
categories Array<String> Document categories

Example

{
  "tags": ["required reading"],
  "metadata": {
    "author": "F. Scott Fitzgerald"
  }
}

Response

Status: 200 OK
{
  "id": "5697cc7b16d5640c40000005",
  "title": "The Great Gatsby",
  "body": "Lorem ipsum…",
  "filename": "_books/the-great-gatsby.md",
  "path": "the-great-gatsby.md",
  "basename": "the-great-gatsby.md",
  "directory": "_books",
  "tags": [],
  "categories": ["fiction"],
  "defaults": {
    "layout": "books"
  },
  "metadata": {},
  "type": "document",
  "date": null,
  "sha": "4d481d526f0010ed96e43260f0e776acf6da315d",
  "visibility": "visible",
  "permalink": null,
  "url": "/books/the-great-gatsby.html",
  "site_id": "5697cc7b16d5640c40000002",
  "user_id": "5697cc7b16d5640c40000000",
  "created_at": "2016-01-14 20:50:46 +0000",
  "updated_at": "2016-01-14 20:56:40 +0000"
}

Delete a document

Endpoint

DELETE https://api.siteleaf.com/v2/documents/:document_id

Response

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

Help improve this page