- Learn Siteleaf
- API
Collections
Overview
- List collections
- Create a collection
- Get a collection
- Update a collection
- Delete a collection
- List collection files
- Create a collection file
For interacting with a Collection’s documents refer to the Documents page.
List collections
Endpoint
GET https://api.siteleaf.com/v2/sites/:site_id/collections
Response
[
{
"id": "5697cc7b16d5640c40000004",
"title": "Books",
"directory": ".",
"path": "books",
"output": true,
"permalink": null,
"metadata": {
"foo": "bar"
},
"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 collection
Endpoint
POST https://api.siteleaf.com/v2/sites/:site_id/collections
| Name |
Type |
Desc |
title |
String |
Collection title (required) |
path |
String |
Collection path, defaults to a url safe version of title |
permalink |
String |
The permalink style for documents, see Permalinks for more detail |
output |
Boolean |
Whether the collection’s documents will be rendered, defaults to true |
metadata |
Hash<String, *> |
Arbitrary key/value pairs |
Example
{
"title": "Library",
"output": false
}
Response
{
"id": "5697cc7b16d5640c40000004",
"title": "Books",
"directory": ".",
"path": "books",
"output": true,
"permalink": null,
"metadata": {
"foo": "bar"
},
"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 collection
Endpoint
GET https://api.siteleaf.com/v2/sites/:site_id/collections/:path
Response
{
"id": "5697cc7b16d5640c40000004",
"title": "Books",
"directory": ".",
"path": "books",
"output": true,
"permalink": null,
"metadata": {
"foo": "bar"
},
"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 collection
Endpoint
PUT https://api.siteleaf.com/v2/sites/:site_id/collections/:path
| Name |
Type |
Desc |
title |
String |
Collection title |
path |
String |
Collection path, defaults to a url safe version of title |
permalink |
String |
The permalink style for documents, see Permalinks for more detail |
output |
Boolean |
Whether the collection’s documents will be rendered, defaults to true |
metadata |
Hash<String, *> |
Arbitrary key/value pairs |
Example
{
"title": "Library",
"output": false
}
Response
{
"id": "5697cc7b16d5640c40000004",
"title": "Books",
"directory": ".",
"path": "books",
"output": true,
"permalink": null,
"metadata": {
"foo": "bar"
},
"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 collection
Endpoint
DELETE https://api.siteleaf.com/v2/sites/:site_id/collections/:path
Response
{
"id": "5697cc7b16d5640c40000004",
"deleted": true
}
List collection files
Endpoint
GET https://api.siteleaf.com/v2/sites/:site_id/collections/:path/files
Query String Params
| Name |
Desc |
q |
Searches by filename |
sort |
Should be formated as field-asc or field-desc |
Response
[
{
"filename": "_uploads/IMG_2331.JPG",
"content_type": "image/jpeg",
"directory": "_uploads",
"basename": "IMG_2331.JPG",
"url": "/uploads/IMG_2331.JPG",
"filesize": 1689833,
"sha": "e5ca9010389ac30e387acbc3daac3b1b0c8f8c09",
"download_url": "https://api.siteleaf.com/v2/sites/5697cc7b16d5640c40000002/files/_uploads/IMG_2331.JPG?download",
"site_id": "5697cc7b16d5640c40000002",
"user_id": "5697cc7b16d5640c40000000",
"edited_by_id": null,
"created_at": "2016-01-15 16:22:12 +0000",
"updated_at": "2016-01-15 16:22:12 +0000"
}
]
Create a collection file
Collection files only support static files, that is any file without YAML front matter. This endpoint will return an error if it detects front matter. If you need to upload arbitrary text files use the Files API which parses file uploads and will create either a Document or File.
Endpoint
POST https://api.siteleaf.com/v2/sites/:site_id/collections/:path/files
| Name |
Type |
Desc |
file |
File |
A multipart/form-data file attachment |
Response
{
"filename": "_uploads/IMG_2331.JPG",
"content_type": "image/jpeg",
"directory": "_uploads",
"basename": "IMG_2331.JPG",
"url": "/uploads/IMG_2331.JPG",
"filesize": 1689833,
"sha": "e5ca9010389ac30e387acbc3daac3b1b0c8f8c09",
"download_url": "https://api.siteleaf.com/v2/sites/5697cc7b16d5640c40000002/files/_uploads/IMG_2331.JPG?download",
"site_id": "5697cc7b16d5640c40000002",
"user_id": "5697cc7b16d5640c40000000",
"edited_by_id": null,
"created_at": "2016-01-15 16:22:12 +0000",
"updated_at": "2016-01-15 16:22:12 +0000"
}
Help improve this page