# templateMessage.getTemplateLibraryList
Call this API at the server side. For more information, see Server API.
This API supports Cloud Calls. The WeChat DevTools version must be
1.02.1904090or later (download the latest stable version here), and thewx-server-sdkversion must be0.4.0or later.
Obtains the title list from the template library of a Mini Program.
Calling methods:
# HTTPS Call
# Request Address
POST https://api.weixin.qq.com/cgi-bin/wxopen/template/library/list?access_token=ACCESS_TOKEN
# Request Parameters
| Attribute | Type | Default | Required | Description |
|---|---|---|---|---|
| access_token | string | Yes | Credentials to call API | |
| offset | number | Yes | Used for paging. It indicates that each page starts from "offset". Pages are counted from "0". | |
| count | number | Yes | Used for paging. It indicates "count" records are fetched. Its maximum value is "20". |
# Return Value
# Object
JSON data package that is returned
| Attribute | Type | Description |
|---|---|---|
| errcode | number | Error code |
| errmsg | string | Error message |
| id | string | The ID of the template title. It is required when the keyword library under the template title is to be obtained. |
| title | string | The content of the template title. |
| total_count | number | The quantity of titles in the template library. |
# Request Data Example
{
"offset": 0,
"count": 5
}
# Return Data Example
{
"errcode":0,
"errmsg":"ok",
"list":[
{"id":"AT0002","title":"Purchase success notification"},
{"id":"AT0003","title":"Purchase failure notification"},
{"id":"AT0004","title":"Transaction reminder"},
{"id":"AT0005","title":"Payment success notification"},
{"id":"AT0006","title":"Payment failure notification"}
],
"total_count":599
}
# Cloud Call
Cloud call is a capability provided by Mini Program·Cloud Base that allows you to call WeChat APIs in a cloud function. It must be used via
wx-server-sdkin the cloud function.
# API Calling Method
openapi.templateMessage.getTemplateLibraryList
You need to configure the permissions for the
templateMessage.getTemplateLibraryListAPI viaconfig.json. Details
# Request Parameters
| Attribute | Type | Default | Required | Description |
|---|---|---|---|---|
| offset | number | Yes | Used for paging. It indicates that each page starts from "offset". Pages are counted from "0". | |
| count | number | Yes | Used for paging. It indicates "count" records are fetched. Its maximum value is "20". |
# Return Value
# Object
JSON data package that is returned
| Attribute | Type | Description |
|---|---|---|
| errCode | number | Error code |
| errMsg | string | Error message |
| id | string | The ID of the template title. It is required when the keyword library under the template title is to be obtained. |
| title | string | The content of the template title. |
| totalCount | number | The quantity of titles in the template library. |
# Exceptions
# Object
Thrown Exceptions
| Property | Type | Description |
|---|---|---|
| errCode | number | Error code |
| errMsg | string | Error message |
Valid values of errCode
| Value | Description | Minimum Version |
|---|
# Request Data Example
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.templateMessage.getTemplateLibraryList({
offset: 0,
count: 5
})
console.log(result)
return result
} catch (err) {
console.log(err)
return err
}
}
# Return Data Example
{
"errCode": 0,
"errMsg": "openapi.templateMessage.getTemplateLibraryList:ok",
"list": [
{
"id": "AT0002",
"title": "Purchase success notification"
},
{
"id": "AT0003",
"title": "Purchase failure notification"
},
{
"id": "AT0004",
"title": "Transaction reminder"
},
{
"id": "AT0005",
"title": "Payment success notification"
},
{
"id": "AT0006",
"title": "Payment failure notification"
}
],
"totalCount": 599
}