Template Api

Last Updated: 2023-10-28 04:05:45
The blog plugin comes with several template API endpoints.  The template API grants you access to  categories, articles lists and tags collections. The API URL will always begin with /api/blog
The plugin comes with APIs to retrieve the blog categories defined in your administrative portal. The API call has inline variables allowing you to select page, number of rows and sort order. The definition examples use the same formatting as the HTTP API. Lets look at the definitions and remember inline variable name placement/order is important.  

/category/list
The first call is without any variables and returned a list defaulting to the first page, 10 records and in ascending order. For example, { api /api/blog/category/list as categories }

/category/list/{ page:[ digits ] }
The first variable represents which page of categories to retrieve. It has a restriction and is defined as a numeric value. For example, { api /api/blog/category/list/1 as categories }

/category/list/{ page:[ digits ] }/{ rows:[ digits ] }
The second variable represents the number of records a collection will contain. It too has a restriction and is defined with a numeric value. For example, { api /api/blog/category/list1/10 as categories }

Changing the number of records returned also affects the number of pages.  For example, if you have 20 categories and retrieve page 2 with 10 rows but then decide to set rows to 20 records.  The second page will be empty.

/category/list/{ page:[ digits ] }/{ rows:[ digits ] }/{ sort:[ asc|desc ] }
The last variable represents what sort order the categories are returned in. It has a restriction and is defined as either asc or desc. For example, { api /api/blog/category/list/1/desc as categories }

Note: Maple syntax is not dynamic meaning you will not be able to use a variable to represent an inline variable.
The plugin comes with APIs to retrieve the blog tags defined in your administrative portal. The API call has inline variables allowing you to select page, number of rows and sort order. The definitions are the same as with categories with the exception of the endpoint URL.  The examples will be simplified.

/tag/list
For example, { api /api/blog/tag/list as tags }

/tag/list/{ page: [ digits ] }
For example, { api /api/blog/tag/list/1 as tags }

/tag/list/{ page: [ digits ]}/{ rows: [ digits ] }
For example, { api /api/blog/tag/list/1/10 as tags }

/tag/list/{ page: [ digits ] }/{ rows: [ digits ] }/{ sort: [ asc|desc ] }
For example, { api /api/blog/tag/list/1/10/desc as tags }

The plugin comes with APIs to retrieve statistical lists of blog posts based on visitor interaction. There are two lists that can be retrieved, popular and latest posts.  One inline variable is available for both allowing you to control the number of records returned.

Retrieve a list of the most popular blog posts on your website.  The inline variable represents now large
the list will be, defaulting to 5.  It has a restriction and is defined as a numeric value.

/article/popular
For example, { api /api/blog/article/popular as popular }

/article/popular/{ rows:[ digits ] }
For example, { api /api/blog/article/popular/5 as popular }

Retrieve a list of the newest blog posts on your website.  The inline variable represents now large the list will be, defaulting to 5.  It has a restriction and is defined as a numeric value.

/article/latest
For example, { api /api/blog/article/latest as latest }

/article/latest/{ rows: [ digits ] }
For example, { api /api/blog/article/latest/5 as latest }
Was this page helpful?